filtro por rol
This commit is contained in:
@@ -3,15 +3,17 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Historiale;
|
||||
use App\Models\Role;
|
||||
use App\Models\Servicio;
|
||||
use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
|
||||
class ShowUtilidades extends Component
|
||||
{
|
||||
public $promocion =1;
|
||||
public $promocion = 1;
|
||||
|
||||
public $servicio_id;
|
||||
public $rol_id;
|
||||
|
||||
public $selectedYear = null;
|
||||
public $selectedMonth = null;
|
||||
@@ -53,11 +55,18 @@ class ShowUtilidades extends Component
|
||||
$query = $query->whereNotNull('tarifa_id');
|
||||
}
|
||||
|
||||
if ($this->rol_id) {
|
||||
$query = $query->whereHas('vendedor', function ($q) {
|
||||
$q->where('rol_id', $this->rol_id);
|
||||
});
|
||||
}
|
||||
|
||||
$query = $query->where('estado', 'activo')->orderByDesc('created_at')->get();
|
||||
|
||||
return view('livewire.show-utilidades', [
|
||||
'historiales' => $query,
|
||||
'servicios' => Servicio::where('estado', 'activo')->get(),
|
||||
'roles' => Role::get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<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 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>
|
||||
@@ -29,6 +29,18 @@
|
||||
@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"
|
||||
@@ -115,12 +127,14 @@
|
||||
</td>
|
||||
<td class="md:pl-[2rem] md:pr-[2rem]">
|
||||
@foreach ($historial->promocion->tarifas as $tarifa)
|
||||
<p>${{ number_format($tarifa->servicio->precio ?? 0, 2, ',', '.') }}</p>
|
||||
<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>
|
||||
<p>${{ number_format($tarifa->servicio->precio / $tarifa->pantallas ?? 0, 2, ',', '.') }}
|
||||
</p>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
@@ -158,7 +172,8 @@
|
||||
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="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>
|
||||
|
||||
Reference in New Issue
Block a user