saldo restado
This commit is contained in:
@@ -302,6 +302,68 @@ class ShowUsuarios extends Component
|
||||
$this->modalSaldoDesc = true;
|
||||
}
|
||||
|
||||
public function addSaldoSubvendedor()
|
||||
{
|
||||
if (!$this->valor_recargar) {
|
||||
$this->alert('warning', '¡Coloque un valor!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->valor_recargar = str_replace([',', '.'], '', $this->valor_recargar);
|
||||
$montoRecarga = (int) $this->valor_recargar;
|
||||
|
||||
$miSaldo = Saldo::where('usuario_id', Auth::user()->id)->first();
|
||||
|
||||
if (!$miSaldo || $miSaldo->valor < $montoRecarga) {
|
||||
$this->alert('error', 'No tienes saldo suficiente para hacer esta recarga.', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$miSaldoAnterior = $miSaldo->valor;
|
||||
$miSaldo->update([
|
||||
'valor' => $miSaldo->valor - $montoRecarga,
|
||||
]);
|
||||
|
||||
$recarga = new recarga;
|
||||
$recarga->payment_method_id = 'manual';
|
||||
$recarga->status = 'approved';
|
||||
$recarga->usuario_id = $this->user_saldo;
|
||||
$recarga->saldo_id = $this->consulta_saldo->id;
|
||||
$recarga->monto = $montoRecarga;
|
||||
$recarga->valor_recarga = $montoRecarga;
|
||||
$recarga->save();
|
||||
|
||||
$nuevoSaldoDestino = $this->saldo_actual + $montoRecarga;
|
||||
$this->consulta_saldo->update([
|
||||
'valor' => $nuevoSaldoDestino,
|
||||
]);
|
||||
|
||||
$usuarioDestino = User::find($this->user_saldo);
|
||||
$nombre = $usuarioDestino->name;
|
||||
$email = $usuarioDestino->email;
|
||||
|
||||
$logsGeneral = new Log_general();
|
||||
$logsGeneral->user_id = Auth::user()->id;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email .
|
||||
' ha recargado a ' . $nombre . ' - ' . $email . ' la cantidad de $' . number_format($montoRecarga) .
|
||||
', de su saldo. Su saldo anterior: $' . number_format($miSaldoAnterior) .
|
||||
', saldo actual: $' . number_format($miSaldoAnterior - $montoRecarga) .
|
||||
'. Saldo nuevo de ' . $nombre . ': $' . number_format($nuevoSaldoDestino);
|
||||
$logsGeneral->tipo = 'recarga';
|
||||
$logsGeneral->historial_id = null;
|
||||
$logsGeneral->save();
|
||||
|
||||
$this->alert('success', 'Saldo actualizado con éxito.', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
$this->limpiarSaldo();
|
||||
}
|
||||
|
||||
public function addSaldo()
|
||||
{
|
||||
if (!$this->valor_recargar) {
|
||||
|
||||
@@ -4,10 +4,10 @@ modTarifasPromo : @entangle('modTarifasPromo'),
|
||||
editarTarifa : @entangle('editarTarifa'),
|
||||
editarTarifaPromo: @entangle('editarTarifaPromo'),
|
||||
}" 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="guardarTarifa,guardarTarifaPromo,editarTarifa,editarTarifaPromo,actualizarTarifa,actualizarTarifaPromo,limpiarEditarInputs,limpiarInputs">
|
||||
<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="guardarTarifa,guardarTarifaPromo,editarTarifa,editarTarifaPromo,actualizarTarifa,actualizarTarifaPromo,limpiarEditarInputs,limpiarInputs">
|
||||
<div class="grid h-full place-items-center">
|
||||
<div class="max-w-xs">
|
||||
<img src="./img/loading.gif" alt="" class="w-full text-center">
|
||||
<img src="./img/loading.gif" alt="loading" class="w-full text-center">
|
||||
<p class="text-gray-500 text-center">Cargando</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -20,31 +20,30 @@ editarTarifaPromo: @entangle('editarTarifaPromo'),
|
||||
<x-icon-arrow-right />
|
||||
Tarifas
|
||||
</div>
|
||||
|
||||
@if (auth()->user()->subvendedor)
|
||||
<a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
|
||||
Tarifas servicios
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
|
||||
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
|
||||
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
|
||||
</svg>
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if (auth()->user()->subvendedor)
|
||||
<a x-on:click="modTarifasPromo = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
|
||||
Tarifas promociones
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
|
||||
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
|
||||
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
|
||||
</svg>
|
||||
</a>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-ver-entrada />
|
||||
<div class="flex flex-col md:flex-row items-center justify-center gap-6 md:gap-4">
|
||||
@if (auth()->user()->subvendedor)
|
||||
<a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
|
||||
Tarifas servicios
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
|
||||
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
|
||||
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
|
||||
</svg>
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if (auth()->user()->subvendedor)
|
||||
<a x-on:click="modTarifasPromo = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
|
||||
Tarifas promociones
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
|
||||
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
|
||||
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
|
||||
</svg>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div x-cloak x-show="modTarifas" x-transition:enter="transition duration-350" x-transition:enter-start="opacity-0 scale-100" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="transition duration-350" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-100" class="fixed backdrop-blur-sm bg-black/20 left-0 bottom-0 top-0 right-0 h-full z-20">
|
||||
<div class="grid h-full place-items-center">
|
||||
@@ -331,6 +330,5 @@ editarTarifaPromo: @entangle('editarTarifaPromo'),
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -78,14 +78,8 @@
|
||||
<th class="font-normal">Ventas</th>
|
||||
<th class="font-normal">Saldo</th>
|
||||
<th class="font-normal">Precios personalizados</th>
|
||||
|
||||
@if (auth()->user()->rol->nombre == 'super')
|
||||
<th class="font-normal"></th>
|
||||
<th class="rounded-r-lg font-normal"></th>
|
||||
@elseif (Auth::user()->subvendedor)
|
||||
<th class="rounded-r-lg font-normal"></th>
|
||||
@else
|
||||
@endif
|
||||
<th class="font-normal"></th>
|
||||
<th class="rounded-r-lg font-normal"></th>
|
||||
</tr>
|
||||
</x-slot>
|
||||
<x-slot name="tbody">
|
||||
@@ -95,23 +89,24 @@
|
||||
<td>{{ $usuario->email ?? '' }}</td>
|
||||
<td>{{ $usuario->rol->nombre ?? '' }}</td>
|
||||
<td>{{ $usuario->historiales_venta_count ?? '' }}</td>
|
||||
@if (!empty($usuario->saldo->valor))
|
||||
<td>{{ number_format($usuario->saldo->valor) ?? '' }}</td>
|
||||
@else
|
||||
<td></td>
|
||||
@endif
|
||||
|
||||
<td>{{ number_format($usuario->saldo->valor ?? 0) ?? 0 }}</td>
|
||||
<td>
|
||||
<p>
|
||||
<span>Tarifas: <span class="font-bold">{{ $usuario->countActiveTarifas() ?? 0 }}</span></span>,
|
||||
<span>Promos: <span class="font-bold">{{ $usuario->countActivePromos() ?? 0 }}</span> </span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@if (auth()->user()->rol->nombre == 'super')
|
||||
<button wire:click="saldo({{ $usuario->id }})" class="justify-center text-sm flex px-2 py-1 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-0 md:mb-0">Recargar</button>
|
||||
@else
|
||||
@if (Auth::user()->subvendedor)
|
||||
<button wire:click="saldo({{ $usuario->id }})" class="justify-center text-sm flex px-2 py-1 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-0 md:mb-0">Recargar</button>
|
||||
@endif
|
||||
@endif
|
||||
</td>
|
||||
|
||||
@if (auth()->user()->rol->nombre == 'super')
|
||||
<td>
|
||||
<button wire:click="saldo({{ $usuario->id }})" class="justify-center text-sm flex px-2 py-1 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-0 md:mb-0">Recargar</button>
|
||||
</td>
|
||||
<td>
|
||||
<button x-on:click="openOption=!openOption">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
|
||||
@@ -129,28 +124,28 @@
|
||||
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
|
||||
</div>
|
||||
</td>
|
||||
@elseif (Auth::user()->subvendedor)
|
||||
<td>
|
||||
<button x-on:click="openOption=!openOption">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
|
||||
</svg>
|
||||
</button>
|
||||
@elseif (Auth::user()->subvendedor)
|
||||
<td>
|
||||
<button x-on:click="openOption=!openOption">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg right-10">
|
||||
<button x-on:click="openOption=false" wire:click="editar({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
|
||||
<button x-on:click="openOption=!openOption" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Editar password</button>
|
||||
@if ($usuario->subvendedor)
|
||||
<button x-on:click="openOption=!openOption" wire:click="quitarSubvendedor({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Quitar subvendedor</button>
|
||||
@else
|
||||
<button x-on:click="openOption=!openOption" wire:click="ponerSubvendedor({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Habilitar subvendedor</button>
|
||||
@endif
|
||||
<button x-on:click="openOption=false,gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio servicio</button>
|
||||
<button x-on:click="openOption=false,gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio promocion</button>
|
||||
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
|
||||
</div>
|
||||
</td>
|
||||
@else
|
||||
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg right-10">
|
||||
<button x-on:click="openOption=false" wire:click="editar({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
|
||||
<button x-on:click="openOption=!openOption" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Editar password</button>
|
||||
@if ($usuario->subvendedor)
|
||||
<button x-on:click="openOption=!openOption" wire:click="quitarSubvendedor({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Quitar subvendedor</button>
|
||||
@else
|
||||
<button x-on:click="openOption=!openOption" wire:click="ponerSubvendedor({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Habilitar subvendedor</button>
|
||||
@endif
|
||||
<button x-on:click="openOption=false,gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio servicio</button>
|
||||
<button x-on:click="openOption=false,gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio promocion</button>
|
||||
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
|
||||
</div>
|
||||
</td>
|
||||
@else
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -641,15 +636,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="bg-white px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse sm:justify-evenly gap-5 mt-4">
|
||||
<div class="bg-white px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse sm:justify-evenly gap-5 mt-4">
|
||||
<span>
|
||||
<button wire:click="addSaldo" type="button"
|
||||
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Guardar</button>
|
||||
@if (auth()->user()->rol->nombre === 'administrador' || auth()->user()->rol->nombre === 'super')
|
||||
<button wire:click="addSaldo" type="button" class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Guardar</button>
|
||||
@else
|
||||
@if (Auth::user()->subvendedor)
|
||||
<button wire:click="addSaldoSubvendedor" type="button" class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Guardar</button>
|
||||
@endif
|
||||
@endif
|
||||
</span>
|
||||
<span>
|
||||
<button wire:click="limpiarSaldo" x-on:click="modalSaldo=false" type="button"
|
||||
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 text-white bg-[#585858] hover:bg-[#3a3a3a] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Cerrar</button>
|
||||
<button wire:click="limpiarSaldo" x-on:click="modalSaldo=false" type="button" class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 text-white bg-[#585858] hover:bg-[#3a3a3a] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Cerrar</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user