From 653281491220bcb02a209a4d7ba27c490d38ef94 Mon Sep 17 00:00:00 2001 From: Felipe Date: Sat, 9 Mar 2024 13:53:10 -0500 Subject: [PATCH] nota de eliminacion --- app/Http/Livewire/ShowPlanes.php | 92 +++++++++---------- .../views/components/listado-planes.blade.php | 2 +- .../views/livewire/show-planes.blade.php | 39 +++++++- 3 files changed, 84 insertions(+), 49 deletions(-) diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 6ab74da..8a49720 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -110,10 +110,14 @@ class ShowPlanes extends Component public $editarTarifaRol = false; + public $notaEliminarModal = false; + public $notaEliminarVariosModal = false; + public $nota_eliminacion; + public function getListeners() { return [ - 'confirmed', 'siRenovar', 'noRenovar' + 'siRenovar', 'noRenovar' ]; } @@ -215,7 +219,7 @@ class ShowPlanes extends Component } public function saveRenovar() { - if($this->fecha_inicial_renovar_old !== $this->fecha_inicial_renovar || $this->fecha_final_renovar_old !== $this->fecha_final_renovar){ + if ($this->fecha_inicial_renovar_old !== $this->fecha_inicial_renovar || $this->fecha_final_renovar_old !== $this->fecha_final_renovar) { $this->alert('warning', '¿Desea también desvincular todos los usuarios de esta cuenta?', [ 'position' => 'center', 'timer' => '60000', @@ -231,7 +235,7 @@ class ShowPlanes extends Component 'cancelButtonText' => 'No, solo renovar', 'confirmButtonText' => 'Si, liberar cuenta', ]); - }else{ + } else { $cuenta_renovar = Cuentas::find($this->id_cuentaVer); Cuentas::where('id', $this->id_cuentaVer)->update([ @@ -255,7 +259,6 @@ class ShowPlanes extends Component $this->ver = false; } } - public function siRenovar() { $id = $this->id_cuentaVer; @@ -284,7 +287,6 @@ class ShowPlanes extends Component $this->renovar = false; $this->ver = false; } - public function noRenovar() { $id = $this->id_cuentaVer; @@ -311,7 +313,6 @@ class ShowPlanes extends Component $this->renovar = false; $this->ver = false; } - /* ------------- CREAR ------------- */ public function createNewCuenta() { @@ -432,31 +433,53 @@ class ShowPlanes extends Component public function delete_cuenta($id) { $this->delete_cuenta = $id; - $this->alert('warning', '¿Eliminar cuenta?', [ - 'position' => 'center', - 'timer' => '10000', - 'toast' => false, - 'text' => 'Esta seguro', - 'showConfirmButton' => true, - 'onConfirmed' => 'confirmed', - 'showDenyButton' => false, - 'onDenied' => '', - 'showCancelButton' => true, - 'onDismissed' => '', - 'cancelButtonText' => 'Salir', - 'confirmButtonText' => 'Si', - ]); + + $this->notaEliminarModal = true; } - public function confirmed() + public function confirm_delete_cuenta() { - Cuentas::where('id', $this->delete_cuenta)->delete(); + $cuenta = Cuentas::findOrFail($this->delete_cuenta); + + Log_historial::create([ + 'user_id' => Auth::user()->id, + 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo . ' nota de eliminacion: ' . $this->nota_eliminacion + ]); + + $cuenta->delete(); + $this->notaEliminarModal = false; $this->alert('success', 'Cuenta eliminada correctamente!', [ 'position' => 'top' ]); } + public function eliminarCuentas() + { + $this->notaEliminarVariosModal = true; + } + + public function confirm_delete_cuentas() + { + $cuentas = Cuentas::whereIn('id', $this->delete_1)->get(); + if ($cuentas) { + forEach ($cuentas as $cuenta) { + Log_historial::create([ + 'user_id' => Auth::user()->id, + 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo . ' nota de eliminacion: ' . $this->nota_eliminacion + ]); + } + } + $consulta_cuentas = Cuentas::whereIn('id', $this->delete_1)->delete(); + + $this->delete_1 = []; + $this->notaEliminarVariosModal = false; + + $this->alert('success', 'Cuentas eliminadas correctamente!', [ + 'position' => 'top' + ]); + + } /* ------------- ACTUALIZAR ------------- */ public function updateTarifas() { @@ -499,9 +522,7 @@ class ShowPlanes extends Component } } - /* ------------- ELIMINAR ------------- */ - public function eliminarModTarifa($id) { Tarifas::where('id', $id)->delete(); @@ -539,31 +560,8 @@ class ShowPlanes extends Component $this->color_servicio = null; } - public function eliminarCuentas() - { - $cuentas = Cuentas::whereIn('id', $this->delete_1)->get(); - - if ($cuentas) { - forEach ($cuentas as $cuenta) { - Log_historial::create([ - 'user_id' => Auth::user()->id, - 'detalle' => 'El usuario ha eliminado la cuenta ' . $cuenta->correo - ]); - } - } - - $consulta_cuentas = Cuentas::whereIn('id', $this->delete_1)->delete(); - - $this->alert('success', 'Cuentas eliminadas correctamente!', [ - 'position' => 'top' - ]); - - $this->delete_1 = []; - } - public function openAdd() { - $this->addUser = true; } public function saveUser() diff --git a/resources/views/components/listado-planes.blade.php b/resources/views/components/listado-planes.blade.php index fbe6374..62b5c58 100755 --- a/resources/views/components/listado-planes.blade.php +++ b/resources/views/components/listado-planes.blade.php @@ -85,7 +85,7 @@
+ class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg z-20"> + +
+ + + + +
+
+
+ +
+ + +
+ +
+ + +
+
+
+
+ @include('layouts.footer') +