utilidades promocion

This commit is contained in:
Felipe
2023-07-26 18:30:28 -05:00
parent 190be28228
commit 25914187f5
2 changed files with 128 additions and 54 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ use Livewire\Component;
class ShowUtilidades extends Component
{
public $promocion;
public $promocion =1;
public $servicio_id;
@@ -17,7 +17,6 @@
<input type="checkbox" name="promocion" id="promocion" wire:model="promocion">
</div>
</div>
<div class="grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 my-6 mx-6">
<div>
<label for="servicios" class="text-gray-600 text-sm font-semibold block">Filtrar por
@@ -82,66 +81,141 @@
<div class="mt-2">
<h1 class="text-center text-lg sm:mb-4">Utilidades</h1>
<div class="py-2">
<table wire:loading.class="opacity-50 cursor-wait" class="text-center rounded-lg shadow-lg m-auto mt-4 mb-4 bg-white md:w-10/12">
<thead class="font-normal bg-[#000029] text-white h-9 pr-4 sm:pr-2">
<tr class="text-left">
<th class="rounded-l-lg font-normal w-1/12 pr-[1rem] md:pl-[2rem]">Fecha inicio</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Servicio</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Pantallas</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">valor</th>
<th class="rounded-r-lg font-normal w-1/12 pr-[1rem] md:pl-[2rem]">Utilidad</th>
</tr>
</thead>
@php
$totalUtilidades = 0;
@endphp
<tbody class="text-gray-500 select-none pr-4 sm:pr-2">
@foreach ($historiales as $historial)
<tr
class="border-gray-200 text-left w-full sm:pl-4 hover:bg-gray-200 hover:ring-gray-500">
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->fecha_inicio }}
@if ($promocion)
<table wire:loading.class="opacity-50 cursor-wait"
class="text-center rounded-lg shadow-lg m-auto mt-4 mb-4 bg-white md:w-10/12">
<thead class="font-normal bg-[#000029] text-white h-9 pr-4 sm:pr-2">
<tr class="text-left">
<th class="rounded-l-lg font-normal w-1/12 pr-[1rem] md:pl-[2rem]">Fecha inicio</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Servicio</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Pantallas</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">valor</th>
<th class="rounded-r-lg font-normal w-1/12 pr-[1rem] md:pl-[2rem]">Utilidad</th>
</tr>
</thead>
@php
$totalUtilidades = 0;
@endphp
<tbody class="text-gray-500 select-none pr-4 sm:pr-2">
@foreach ($historiales as $historial)
<tr
class="border-gray-200 text-left w-full sm:pl-4 hover:bg-gray-200 hover:ring-gray-500">
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->fecha_inicio }}
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
@foreach ($historial->promocion->tarifas as $tarifa)
<p> {{ $tarifa->servicio->nombre }}</p>
@endforeach
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
@foreach ($historial->promocion->tarifas as $tarifa)
<p>{{ $tarifa->pantallas }}</p>
@endforeach
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
@foreach ($historial->promocion->tarifas as $tarifa)
<p>${{ number_format($tarifa->servicio->precio ?? 0, 2, ',', '.') }}</p>
@endforeach
</td>
<td class="md:pl-[2rem] md:pr-[2rem] text-right">
@foreach ($historial->promocion->tarifas as $tarifa)
<p>${{ number_format($tarifa->servicio->precio / $tarifa->pantallas ?? 0, 2, ',', '.') }}</p>
@endforeach
</td>
</tr>
@foreach ($historial->promocion->tarifas as $tarifa)
@php
$totalUtilidades += $tarifa->servicio->precio / $tarifa->pantallas;
@endphp
@endforeach
@endforeach
<tr>
<td class="border-t border-b">
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->tarifa->servicio->nombre }}
<td class="border-t border-b">
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->tarifa->pantallas }}
<td class="border-t border-b">
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
${{ $historial->tarifa->servicio->precio }}
</td>
<td class="md:pl-[2rem] md:pr-[2rem] text-right">
${{ number_format($historial->tarifa->servicio->precio / $historial->tarifa->pantallas ?? 0, 2, ',', '.') }}
<th class="border-t border-l border-b">
<p class="flex items-center px-6 py-4 cursor-pointer">
Utilidad Total
</p>
</th>
<td class="border-t border-b">
<p class="flex items-center px-6 py-4 cursor-pointer">
$ {{ number_format($totalUtilidades ?? 0, 2, ',', '.') }}
</p>
</td>
</tr>
@php
$totalUtilidades += $historial->tarifa->servicio->precio / $historial->tarifa->pantallas;
@endphp
@endforeach
<tr>
<td class="border-t border-b">
</tbody>
</table>
@else
<table wire:loading.class="opacity-50 cursor-wait"
class="text-center rounded-lg shadow-lg m-auto mt-4 mb-4 bg-white md:w-10/12">
<thead class="font-normal bg-[#000029] text-white h-9 pr-4 sm:pr-2">
<tr class="text-left">
<th class="rounded-l-lg font-normal w-1/12 pr-[1rem] md:pl-[2rem]">Fecha inicio</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Servicio</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Pantallas</th>
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">valor</th>
<th class="rounded-r-lg font-normal w-1/12 pr-[1rem] md:pl-[2rem]">Utilidad</th>
</tr>
</thead>
@php
$totalUtilidades = 0;
@endphp
<tbody class="text-gray-500 select-none pr-4 sm:pr-2">
@foreach ($historiales as $historial)
<tr
class="border-gray-200 text-left w-full sm:pl-4 hover:bg-gray-200 hover:ring-gray-500">
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->fecha_inicio }}
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->tarifa->servicio->nombre }}
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
{{ $historial->tarifa->pantallas }}
</td>
<td class="md:pl-[2rem] md:pr-[2rem]">
${{ $historial->tarifa->servicio->precio }}
</td>
<td class="md:pl-[2rem] md:pr-[2rem] text-right">
${{ number_format($historial->tarifa->servicio->precio / $historial->tarifa->pantallas ?? 0, 2, ',', '.') }}
</td>
</tr>
@php
$totalUtilidades += $historial->tarifa->servicio->precio / $historial->tarifa->pantallas;
@endphp
@endforeach
<tr>
<td class="border-t border-b">
</td>
<td class="border-t border-b">
</td>
<td class="border-t border-b">
</td>
<td class="border-t border-b">
</td>
<td class="border-t border-b">
</td>
<th class="border-t border-l border-b">
<p class="flex items-center px-6 py-4 cursor-pointer">
Utilidad Total
</p>
</th>
<td class="border-t border-b">
<p class="flex items-center px-6 py-4 cursor-pointer">
$ {{ number_format($totalUtilidades ?? 0, 2, ',', '.') }}
</p>
</td>
</tr>
</tbody>
</table>
</td>
<th class="border-t border-l border-b">
<p class="flex items-center px-6 py-4 cursor-pointer">
Utilidad Total
</p>
</th>
<td class="border-t border-b">
<p class="flex items-center px-6 py-4 cursor-pointer">
$ {{ number_format($totalUtilidades ?? 0, 2, ',', '.') }}
</p>
</td>
</tr>
</tbody>
</table>
@endif
</div>
</div>
</div>