From 3d3a9cca5e4a0af4a909c90df27638069ce9f04b Mon Sep 17 00:00:00 2001 From: Felipe Date: Sat, 7 Oct 2023 12:58:41 -0500 Subject: [PATCH] clientes --- app/Http/Livewire/ShowClientes.php | 18 +- .../views/components/primary-table.blade.php | 4 +- .../views/components/ver-entrada.blade.php | 10 + .../views/livewire/show-clientes.blade.php | 429 +++++++++--------- .../views/livewire/show-planes.blade.php | 46 +- resources/views/menu/clientes.blade.php | 6 +- 6 files changed, 242 insertions(+), 271 deletions(-) create mode 100644 resources/views/components/ver-entrada.blade.php diff --git a/app/Http/Livewire/ShowClientes.php b/app/Http/Livewire/ShowClientes.php index 5aaf1b6..beeef99 100644 --- a/app/Http/Livewire/ShowClientes.php +++ b/app/Http/Livewire/ShowClientes.php @@ -45,7 +45,7 @@ class ShowClientes extends Component public $configuracion; public $msj; - + public $entradas = 10; public function render() { @@ -53,7 +53,8 @@ class ShowClientes extends Component $this->fechaActual = date('d/m/Y'); $fechaVencimiento = Carbon::now()->subDay(30); - $consulta_clientes = Historiale::where('vendedor_id', Auth()->user()->id)->whereDate('fecha_final', '>', $fechaVencimiento); + // $consulta_clientes = Historiale::where('vendedor_id', Auth()->user()->id)->whereDate('fecha_final', '>', $fechaVencimiento); + $consulta_clientes = Historiale::whereDate('fecha_final', '>', $fechaVencimiento); $this->configuracion = User::where('id', Auth::user()->id)->whereDate('updated_at', '!=', $fechaHoy)->first(); @@ -82,7 +83,7 @@ class ShowClientes extends Component $consulta_clientes = $consulta_clientes->with('tarifa', 'promocion', 'cliente') ->orderBy('id', 'DESC') - ->paginate(15); + ->paginate($this->entradas); @@ -96,12 +97,21 @@ class ShowClientes extends Component public function verCliente($id) { $this->consulta_historial = Historiale::with('promocion', 'tarifa', 'cliente', 'cuentas')->where('id', $id)->first(); - // dd($this->consulta_historial ); $this->verCliente = true; } + public function consultaPassword($id) + { + $historiale = Historiale::with('promocion', 'tarifa', 'cliente', 'cuentas')->where('id', $id)->first(); + if ($historiale && $historiale->cuentas->isNotEmpty()) { + // Assuming 'password' is a property on the Cuentas model + return $historiale->cuentas->first()->password ?? ''; + } else { + return ''; + } + } public function enviarNotificacion($id) { diff --git a/resources/views/components/primary-table.blade.php b/resources/views/components/primary-table.blade.php index dbfbcf2..8785d87 100644 --- a/resources/views/components/primary-table.blade.php +++ b/resources/views/components/primary-table.blade.php @@ -1,5 +1,5 @@ -
- +
+
{{ $thead }} diff --git a/resources/views/components/ver-entrada.blade.php b/resources/views/components/ver-entrada.blade.php new file mode 100644 index 0000000..e4d9482 --- /dev/null +++ b/resources/views/components/ver-entrada.blade.php @@ -0,0 +1,10 @@ +
+

Ver

+ +

entradas

+
\ No newline at end of file diff --git a/resources/views/livewire/show-clientes.blade.php b/resources/views/livewire/show-clientes.blade.php index 01f7866..de0ca34 100644 --- a/resources/views/livewire/show-clientes.blade.php +++ b/resources/views/livewire/show-clientes.blade.php @@ -50,175 +50,148 @@ + + {{-- tabla clientes --}} -
-
- - - - - - - - - - - - - - @foreach ($clientes as $cliente) - + + + + + + + + + + + + + + + + + @foreach ($clientes as $cliente) + + - - + + + + + @if (!empty($cliente->tarifa_id)) + + @endif + + @if (!empty($cliente->promocion_id)) + + @endif + + + + @php + $date1 = new DateTime(strtr(strval($fechaActual), '/', '-')); + $date2 = new DateTime(strtr(strval($cliente->fecha_final), '/', '-')); + @endphp + + @if ($date1 < $date2) + @endif - @if (!empty($cliente->tarifa_id)) - - @endif - - @if (!empty($cliente->promocion_id)) - - @endif - - + @endif - @php - - $date1 = new DateTime(strtr(strval($fechaActual), '/', '-')); - $date2 = new DateTime(strtr(strval($cliente->fecha_final), '/', '-')); - - @endphp + @if ($date1 == $date2) + + @endif - @if ($date1 < $date2) - - @endif - - @if ($date1 > $date2) - - @endif - - @if ($date1 == $date2) - - @endif - - @if (!empty($cliente->tarifa_id)) - - + - @elseif(!empty($cliente->promocion_id)) - - + @elseif(!empty($cliente->promocion_id)) + - @endif - - @endforeach - -
NombreCorreoCompraServicioVenceRestante
NombreUsuarioContraseƱaServicioCompraEstadoRestanteAcciones
{{ $cliente->nombre_cliente ?? $cliente->cliente->name }}{{ $cliente->nombre_cliente ?? $cliente->cliente->name }}{{ $cliente->cliente->email ?? '' }}{{ $cliente->cliente->email ?? '' }}{{ $this->consultaPassword($cliente->id) }}{{ $cliente->tarifa->servicio->nombre }} + + @if ($cliente->tarifa->servicio->nombre != 'Spotify Premium' && $cliente->tarifa->servicio->nombre != 'Youtube Premium') + {{ $cliente->tarifa->pantallas }} Pantallas + @endif + + {{ $cliente->promocion->nombre }} + {{ Carbon\Carbon::parse($cliente->created_at)->locale('co')->Format('d M Y, h:m a') ?? '' }} + {{ $cliente->estado ?? '' }} - {{ Carbon\Carbon::parse($cliente->created_at)->locale('co')->Format('d M Y, h:m a') ?? '' }} + @php + $diff = $date1->diff($date2); + echo $diff->days . ' dias'; + @endphp {{ $cliente->tarifa->servicio->nombre }} - - @if ($cliente->tarifa->servicio->nombre != 'Spotify Premium' && $cliente->tarifa->servicio->nombre != 'Youtube Premium') - {{ $cliente->tarifa->pantallas }} Pantallas - @endif - - {{ $cliente->promocion->nombre }} - {{ Carbon\Carbon::parse($cliente->fecha_final)->format('M j') ?? '' }} + @if ($date1 > $date2) + + @php + echo 'Vencido'; + @endphp + @php + echo 'Vence hoy!!'; + @endphp + - @php - $diff = $date1->diff($date2); - echo $diff->days . ' dias'; - @endphp - - @php - echo 'Vencido'; - @endphp - - @php - echo 'Vence hoy!!'; - @endphp - - - - - + @if (!empty($cliente->tarifa_id)) + +
- + +
+ + + +
+ - @if (!empty($cliente->cuentas->first()->estado)) - @if ($cliente->cuentas->first()->estado == 'pendiente' && $cliente->tarifa->servicio->renovacion == true) - {{-- renovar --}} + @if (!empty($cliente->cuentas->first()->estado)) + @if ($cliente->cuentas->first()->estado == 'pendiente' && $cliente->tarifa->servicio->renovacion == true) + {{-- renovar --}} - @if (Auth::user()->saldo->valor >= $cliente->tarifa->valor) - - @else - - @endif + @if (Auth::user()->saldo->valor >= $cliente->tarifa->valor) + + @else + @endif @endif + @endif - {{-- whatsapp --}} - Notificar - - - - - - - - -
-
- + - - - + + + - {{-- whatsapp --}} - Notificar - - - - - - - - - -
- {{ $clientes->links() }} -
- - + + + + + + +
+ + {{-- whatsapp --}} + Notificar + + + + + + + + +
+ + @endif + + @endforeach + + + {{ $clientes->links() }} + + {{-- Modal ver clientes --}} diff --git a/resources/views/livewire/show-planes.blade.php b/resources/views/livewire/show-planes.blade.php index 0671e9d..046ed2e 100644 --- a/resources/views/livewire/show-planes.blade.php +++ b/resources/views/livewire/show-planes.blade.php @@ -132,21 +132,11 @@ -
-

Ver

- -

entradas

-
+ - id Servicio @@ -197,40 +187,6 @@ {{ $cuentas->links() }} - {{-- tabla --}} -
- - - - - - - - @php - $n = 0; - @endphp - - @foreach ($cuentas as $cuenta) - - @php - $n++; - $historiales=false; - - if(now()->addDay()->gt($cuenta->vencimiento)){ - $historiales = $cuenta->historiales()->where('fecha_final', '>', now()->addDay()->toDateString())->count(); - //var_dump(now()->toDateString(), $historiales); - } - - @endphp - - @include('components/listado-planes') - - - @endforeach - -
- {{ $cuentas->links() }} -
diff --git a/resources/views/menu/clientes.blade.php b/resources/views/menu/clientes.blade.php index bd10670..f71d130 100644 --- a/resources/views/menu/clientes.blade.php +++ b/resources/views/menu/clientes.blade.php @@ -1,3 +1,7 @@ - +
+ +
+ + @include('layouts.footer')
\ No newline at end of file