log con filtro y solo cuando editen el usuario

This commit is contained in:
Felipe
2024-03-20 10:33:19 -05:00
parent dc129dac8a
commit 2b0d1b48e7
4 changed files with 48 additions and 22 deletions
+5
View File
@@ -14,6 +14,7 @@ class ShowLogHistorial extends Component
public $entradas;
public $buscar;
public $tipo;
public $filtro_fecha;
public $user_id;
@@ -32,6 +33,10 @@ class ShowLogHistorial extends Component
}
if ($this->tipo) {
$query->where('detalle', 'like', '%' . $this->tipo . '%');
}
if ($this->filtro_fecha) {
$query->whereDate('created_at', $this->filtro_fecha);
}
+22 -6
View File
@@ -77,6 +77,7 @@ class ShowPlanes extends Component
public $usuario_renovar;
public $usuario_renovar_old;
public $password_renovar;
public $fecha_inicial_renovar;
public $fecha_inicial_renovar_old;
@@ -211,6 +212,7 @@ class ShowPlanes extends Component
$id = $this->id_cuentaVer;
$renovarCuenta = Cuentas::findOrFail($id);
$this->usuario_renovar_old = $renovarCuenta->correo;
$this->usuario_renovar = $renovarCuenta->correo;
$this->password_renovar = $renovarCuenta->password;
$this->fecha_inicial_renovar_old = $renovarCuenta->inicio;
@@ -250,10 +252,12 @@ class ShowPlanes extends Component
'estado' => $this->estado,
]);
Log_historial::create([
'user_id' => Auth::user()->id,
'detalle' => 'El usuario ha editado la cuenta ' . $cuenta_renovar->correo
]);
if ( $this->usuario_renovar_old !== $this->usuario_renovar) {
Log_historial::create([
'user_id' => Auth::user()->id,
'detalle' => 'El usuario ha editado el usuario de la cuenta ' . $cuenta_renovar->correo
]);
}
$this->alert('success', 'Cuenta actualizada correctamente!', [
'position' => 'top'
@@ -281,7 +285,7 @@ class ShowPlanes extends Component
Log_historial::create([
'user_id' => Auth::user()->id,
'detalle' => 'El usuario ha editado, renovado y liberado la cuenta ' . $cuenta_renovar->correo
'detalle' => 'El usuario ha renovado y liberado la cuenta ' . $cuenta_renovar->correo
]);
$this->alert('success', 'Cuenta renovada y liberada correctamente!', [
@@ -307,7 +311,7 @@ class ShowPlanes extends Component
Log_historial::create([
'user_id' => Auth::user()->id,
'detalle' => 'El usuario ha editado y renovado la cuenta ' . $cuenta_renovar->correo
'detalle' => 'El usuario ha renovado la cuenta ' . $cuenta_renovar->correo
]);
$this->alert('success', 'Cuenta renovada correctamente!', [
@@ -443,6 +447,12 @@ class ShowPlanes extends Component
public function confirm_delete_cuenta()
{
$this->validate([
'nota_eliminacion' => 'required',
],[
'nota_eliminacion.required' => 'La nota es obligatoria',
]);
$cuenta = Cuentas::findOrFail($this->delete_cuenta);
Log_historial::create([
@@ -465,6 +475,12 @@ class ShowPlanes extends Component
public function confirm_delete_cuentas()
{
$this->validate([
'nota_eliminacion' => 'required',
],[
'nota_eliminacion.required' => 'La nota es obligatoria',
]);
$cuentas = Cuentas::whereIn('id', $this->delete_1)->get();
if ($cuentas) {
forEach ($cuentas as $cuenta) {
@@ -1,25 +1,26 @@
<div class="h-full w-full md:my-2">
<div
class="bg-[#f5f5f5] m-auto p-2 md:p-5 w-auto x-auto grid grid-cols-1 lg:grid-cols-1text-center rounded-xl py-4 px-2 ms:px-8 xl:mx-10 mb-8 ">
<div class="bg-[#f5f5f5] m-auto p-2 md:p-5 w-auto x-auto grid grid-cols-1 lg:grid-cols-1text-center rounded-xl py-4 px-2 ms:px-8 xl:mx-10 mb-8 ">
<div class="md:flex justify-center my-2 items-center text-center">
<div class="flex text-sm">
<x-icon-arrow-right/>
Log historial
</div>
<div class="flex relative text-sm mx-auto w-64 md:w-auto my-2">
<input id="buscar" type="search" wire:model.debounce.500ms="buscar" placeholder="Buscar"
class="shadow-md border-2 active:border-neutral-200 focus:ring-0 border-neutral-200 w-64 md:w-auto rounded-lg pr-7 py-1 m-auto focus:border-neutral-300 focus:outline-none focus:shadow-outline">
<svg class="w-5 absolute top-2 right-3" xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" class="w-4 absolute"
x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;"
xml:space="preserve" class="">
<input id="buscar" type="search" wire:model.debounce.500ms="buscar" placeholder="Buscar" class="shadow-md border-2 active:border-neutral-200 focus:ring-0 border-neutral-200 w-64 md:w-auto rounded-lg pr-7 py-1 m-auto focus:border-neutral-300 focus:outline-none focus:shadow-outline">
<svg class="w-5 absolute top-2 right-3" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" class="w-4 absolute" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;" xml:space="preserve" class="">
<g id="Layer_31" data-name="Layer 31">
<path
d="m21.71 20.29-5.4-5.39a7.92 7.92 0 0 0 1.69-4.9 8 8 0 1 0 -8 8 7.92 7.92 0 0 0 4.9-1.69l5.39 5.4a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zm-17.71-10.29a6 6 0 1 1 6 6 6 6 0 0 1 -6-6z"
fill="#b221fd" data-original="#000000" class=""></path>
<path d="m21.71 20.29-5.4-5.39a7.92 7.92 0 0 0 1.69-4.9 8 8 0 1 0 -8 8 7.92 7.92 0 0 0 4.9-1.69l5.39 5.4a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zm-17.71-10.29a6 6 0 1 1 6 6 6 6 0 0 1 -6-6z" fill="#b221fd" data-original="#000000" class=""></path>
</g>
</svg>
</div>
<select name="tipo" id="tipo" wire:model.debounce.500ms="tipo" class="w-40 mx-auto border-2 border-neutral-200 rounded-lg shadow apperance-none ring-0 focus:ring-0 focus:border-neutral-300 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
<option value="" selected>Todos</option>
<option value="creado">Creadas</option>
<option value="eliminado">Eliminadas</option>
<option value="editado">Editadas</option>
<option value="renovado">Renovadas</option>
<option value="liberado">Liberadas</option>
</select>
<select name="user_id" id="user_id" wire:model.debounce.500ms="user_id" class="w-40 mx-auto border-2 border-neutral-200 rounded-lg shadow apperance-none ring-0 focus:ring-0 focus:border-neutral-300 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
<option value="" selected>Todos</option>
@foreach ($users as $user)
@@ -13,7 +13,7 @@
}" class="h-full w-full md:my-2">
<div class=" fixed backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading
wire:target="noRenovar,siRenovar,ver,openRenovar,saveRenovar,createNewCuenta,createServicio,verObservacion,update,verObservacion1,update_observaciones1,eliminarCuentas,updateTarifas">
wire:target="noRenovar,siRenovar,ver,openRenovar,confirm_delete_cuenta,saveRenovar,createNewCuenta,createServicio,verObservacion,update,verObservacion1,update_observaciones1,eliminarCuentas,updateTarifas">
<div class="grid h-full place-items-center">
<div class="max-w-xs">
<img src="./img/loading.gif" alt="" class="w-full text-center">
@@ -1027,9 +1027,10 @@
<div class="mb-4 flex flex-col">
<label for="nota_eliminacion" class="block text-gray-700 text-sm font-bold mb-2">Nota:</label>
<textarea type="text" id="nota_eliminacion" wire:model="nota_eliminacion"
placeholder="Porque quieres eliminar esta cuenta?"
class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:ring-0 focus:border-neutral-300 w-full py-2 px-3 h-40 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"></textarea>
<textarea type="text" id="nota_eliminacion" wire:model="nota_eliminacion" placeholder="Porque quieres eliminar esta cuenta?" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:ring-0 focus:border-neutral-300 w-full py-2 px-3 h-40 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"></textarea>
@error('nota_eliminacion')
<div class="text-red-500">{{ $message }}</div>
@enderror
</div>
<div class="bg-white py-3 sm:flex sm:flex-row-reverse sm:justify-between gap-5 mt-4">
@@ -1053,8 +1054,11 @@
<div class="mb-4 flex flex-col">
<label for="nota_eliminacion" class="block text-gray-700 text-sm font-bold mb-2">Nota:</label>
<textarea type="text" id="nota_eliminacion" wire:model="nota_eliminacion"
placeholder="Porque quieres eliminar esta cuenta?"
placeholder="Porque quieres eliminar estas cuentas?"
class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:ring-0 focus:border-neutral-300 w-full py-2 px-3 h-40 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"></textarea>
@error('nota_eliminacion')
<div class="text-red-500">{{ $message }}</div>
@enderror
</div>
<div class="bg-white py-3 sm:flex sm:flex-row-reverse sm:justify-between gap-5 mt-4">