Files
sirpremiumv2/resources/views/livewire/show-utilidades.blade.php
T
2024-03-04 11:32:45 -05:00

230 lines
14 KiB
PHP
Executable File

<div class="h-full w-full md:my-2">
<div class="bg-[#f5f5f5] md:w-[100%] m-auto p-2 md:p-5 rounded-[1.2rem] relative mb-2">
<div class="flex justify-start my-2 items-center mb-4 gap-8">
<div class="flex text-sm">
<x-icon-arrow-right/>
Utilidades
</div>
<div class="my-1 md:my-0">
<label for="promocion">Promociones</label>
<input type="checkbox" name="promocion" id="promocion" wire:model="promocion">
</div>
</div>
<div class="grid gap-4 grid-cols-1 sm:grid-cols-3 lg:grid-cols-5 my-6 mx-6">
<div>
<label for="servicios" class="text-gray-600 text-sm font-semibold block">Filtrar por
servicio:</label>
<select name="servicios" id="servicios" wire:model.debounce.500ms="servicio_id"
class="select-css px-3 py-2 border border-gray-200 rounded-lg shadow focus:border-gray-400 focus:shadow-md focus:ring-0 w-full">
<option value="" selected>Servicios</option>
@foreach ($servicios as $servicio)
<option value="{{ $servicio->id }}">{{ $servicio->nombre ?? '' }}</option>
@endforeach
</select>
</div>
<div>
<label for="rol" class="text-gray-600 text-sm font-semibold block">Filtrar por rol:</label>
<select name="rol" id="rol" wire:model.debounce.500ms="rol_id"
class="select-css px-3 py-2 border border-gray-200 rounded-lg shadow focus:border-gray-400 focus:shadow-md focus:ring-0 w-full">
<option value="" selected>Roles</option>
@foreach ($roles as $rol)
<option value="{{ $rol->id }}">{{ $rol->nombre ?? '' }}</option>
@endforeach
</select>
</div>
<div>
<label for="filter-year" class="text-gray-600 text-sm font-semibold block">Filtrar por año:</label>
<select wire:model="selectedYear" id="filter-year"
class="select-css px-3 py-2 border border-gray-200 rounded-lg shadow focus:border-gray-400 focus:shadow-md focus:ring-0 w-full">
<option value="">Todos</option>
@php
$currentYear = date('Y');
$startYear = $currentYear - 10;
$endYear = $currentYear + 10;
@endphp
@for ($year = $startYear; $year <= $endYear; $year++)
<option value="{{ $year }}" @if ($selectedYear == $year) selected @endif>
{{ $year }}</option>
@endfor
</select>
</div>
<div>
<label for="filter-month" class="text-gray-600 text-sm font-semibold block">Filtrar por mes:</label>
<select wire:model="selectedMonth" id="filter-month"
class="select-css px-3 py-2 border border-gray-200 rounded-lg shadow focus:border-gray-400 focus:shadow-md focus:ring-0 w-full">
<option value="">Todos</option>
<option value="01">ENERO</option>
<option value="02">FEBRERO</option>
<option value="03">MARZO</option>
<option value="04">ABRIL</option>
<option value="05">MAYO</option>
<option value="06">JUNIO</option>
<option value="07">JULIO</option>
<option value="08">AGOSTO</option>
<option value="09">SEPTIEMBRE</option>
<option value="10">OCTUBRE</option>
<option value="11">NOVIEMBRE</option>
<option value="12">DICIEMBRE</option>
</select>
</div>
<div>
<label for="filter-day" class="text-gray-600 text-sm font-semibold block">Filtrar por día:</label>
<select wire:model="selectedDay" id="filter-day"
class="select-css px-3 py-2 border border-gray-200 rounded-lg shadow focus:border-gray-400 focus:shadow-md focus:ring-0 w-full">
<option value="">Todos</option>
@for ($day = 1; $day <= 31; $day++)
<option value="{{ str_pad($day, 2, '0', STR_PAD_LEFT) }}">{{ $day }}</option>
@endfor
</select>
</div>
</div>
<div class="mt-2">
<h1 class="text-center text-lg sm:mb-4">Utilidades</h1>
<div class="py-2">
@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, 0, ',', '.') }}</p>
@endforeach
</td>
<td class="md:pl-[2rem] md:pr-[2rem] text-right">
${{$historial->utilidad ?? ''}}
{{-- @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="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>
@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:p-r[2rem] text-right">
${{ $historial->utilidad ?? ''}}
{{-- ${{ 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>
<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, 0, ',', '.') }}
</p>
</td>
</tr>
</tbody>
</table>
@endif
</div>
</div>
</div>
</div>