ver el mes pasado

This commit is contained in:
Felipe
2023-08-01 14:28:51 -05:00
parent 4759600e1e
commit f435dd2f12
2 changed files with 127 additions and 101 deletions
+19 -16
View File
@@ -8,27 +8,30 @@ use Livewire\Component;
use Jantinnerezo\LivewireAlert\LivewireAlert;
class ShowTop extends Component
{ public $configuracion;
{
public $configuracion;
public $showLastMonth = false;
use LivewireAlert;
public function render()
{
$this->configuracion = Configuracione::orderby('id','desc')->first();
$consulta_ventas = User::with(['historiales_venta' => function ($query) {
$query->whereMonth('fecha_inicio', date('m'));
{
$this->configuracion = Configuracione::orderby('id', 'desc')->first();
$month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m');
$consulta_ventas = User::with(['historiales_venta' => function ($query) use ($month) {
$query->whereMonth('fecha_inicio', $month);
}])
->withCount(['historiales_venta' => function ($query) {
$query->whereMonth('fecha_inicio', date('m'));
}])
->orderBy('historiales_venta_count', 'desc')
->limit(10)
->get();
->withCount(['historiales_venta' => function ($query) use ($month) {
$query->whereMonth('fecha_inicio', $month);
}])
->orderBy('historiales_venta_count', 'desc')
->limit(10)
->get();
//dd($consulta_ventas);
return view('livewire.show-top',[
return view('livewire.show-top', [
'usuarios' => $consulta_ventas,
]);
}
+108 -85
View File
@@ -1,22 +1,48 @@
<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="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">
<div class="flex text-sm">
<svg class="w-4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve"><g><path d="M15.4,9.88,10.81,5.29a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42L14,11.29a1,1,0,0,1,0,1.42L9.4,17.29a1,1,0,0,0,1.41,1.42l4.59-4.59A3,3,0,0,0,15.4,9.88Z" fill="#b221fd" data-original="#000000"/></g></svg>
<svg class="w-4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" x="0" y="0" viewBox="0 0 24 24"
style="enable-background:new 0 0 512 512" xml:space="preserve">
<path
d="M15.4,9.88,10.81,5.29a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42L14,11.29a1,1,0,0,1,0,1.42L9.4,17.29a1,1,0,0,0,1.41,1.42l4.59-4.59A3,3,0,0,0,15.4,9.88Z"
fill="#b221fd" data-original="#000000" />
</svg>
Distribuidores
</div>
</div>
{{-- tabla --}}
<div class="mx-auto bg-white grid grid-cols-1 lg:grid-cols-1text-center rounded-xl py-4 px-2 ms:px-8 shadow-md xl:mx-10 mb-8 ">
<div
class="mx-auto bg-white grid grid-cols-1 lg:grid-cols-1text-center rounded-xl py-4 px-2 ms:px-8 shadow-md xl:mx-10 mb-8 ">
<p class="text-center font-semibold text-base sm:text-2xl">Mejores distribuidores del mes</p>
<div class=" text-center w-full " >
<img src="{{asset($configuracion->img_top)}}" alt="" class="object-cover h-24 sm:h-48 w-full rounded-lg shadow my-3">
<p class=" text-sm sm:text-base my-2 ">{{$configuracion->mensaje_top}}</p>
<div class="text-center w-full">
<img src="{{ asset($configuracion->img_top) }}" alt=""
class="object-cover h-24 sm:h-48 w-full rounded-lg shadow my-3">
<p class=" text-sm sm:text-base my-2 ">{{ $configuracion->mensaje_top }}</p>
</div>
<table class="sm:text-base text-sm text-center rounded-lg shadow-lg m-auto sm:mt-4 mb-4 border-separate border-spacing-y-2 ">
<div class="flex items-center">
<label class="inline-flex items-center cursor-pointer">
<input type="checkbox" wire:model="showLastMonth" class="hidden" />
@if ($showLastMonth)
<div class="w-8 h-4 bg-[#d6a5ee] rounded-full shadow-inner flex justify-end">
<div class="w-4 h-4 rounded-full bg-[#b221fd]"></div>
</div>
@else
<div class="w-8 h-4 bg-gray-300 rounded-full shadow-inner flex justify-start">
<div class="w-4 h-4 rounded-full bg-gray-600"></div>
</div>
@endif
<div class="ml-2 text-sm font-medium text-gray-700">Mostrar resultados del mes pasado</div>
</label>
</div>
<table class="sm:text-base text-sm text-center rounded-lg shadow-lg m-auto sm:mt-4 mb-4 border-separate border-spacing-y-2"
wire:loading.class="opacity-50 cursor-wait">
<thead class="font-normal bg-[#000029] text-white h-9">
<tr class="text-left">
<th class="rounded-l-lg font-normal pl-[1rem] sm:pl-[2rem]"></th>
@@ -32,91 +58,88 @@
@endphp
<tbody class="text-gray-500 select-none">
@foreach ($usuarios as $usuario)
@if($usuario->name == 'usuarioEliminado')
@else
@php
$i++;
@endphp
<tr class="border-gray-200 text-left w-full pl-4">
<td class="pl-[1rem] sm:pl-[2rem]">
<img src="{{asset('img/'.$i.'.png')}}" alt="" class="w-12">
</td>
<td class="pl-[1rem] sm:pl-[2rem]">{{ $usuario->name }}</td>
<td class="pl-[1rem] sm:pl-[2rem] hidden">{{ $usuario->email }}</td>
<td class="pl-[1rem] sm:pl-[2rem]">{{ $usuario->historiales_venta_count }}</td>
@if ($usuario->name == 'usuarioEliminado')
@else
@php
$i++;
@endphp
<tr class="border-gray-200 text-left w-full pl-4">
<td class="pl-[1rem] sm:pl-[2rem]">
@if ($i == 1)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_1)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_1}}</span>
</td>
@elseif ($i == 2)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_2)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_2}}</span>
</td>
@elseif ($i == 3)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_3)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_3}}</span>
</td>
<img src="{{ asset('img/' . $i . '.png') }}" alt="" class="w-12">
@elseif ($i == 4)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_4)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_4}}</span>
</td>
@elseif ($i == 5)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_5)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_5}}</span>
</td>
</td>
<td class="pl-[1rem] sm:pl-[2rem]">{{ $usuario->name }}</td>
<td class="pl-[1rem] sm:pl-[2rem] hidden">{{ $usuario->email }}</td>
<td class="pl-[1rem] sm:pl-[2rem]">{{ $usuario->historiales_venta_count }}</td>
@elseif ($i == 6)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_6)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_6}}</span>
</td>
@elseif ($i == 7)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_7)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_7}}</span>
</td>
@elseif ($i == 8)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_8)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_8}}</span>
</td>
@if ($i == 1)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_1) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_1 }}</span>
</td>
@elseif ($i == 2)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_2) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_2 }}</span>
</td>
@elseif ($i == 3)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_3) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_3 }}</span>
</td>
@elseif ($i == 4)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_4) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_4 }}</span>
</td>
@elseif ($i == 5)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_5) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_5 }}</span>
</td>
@elseif ($i == 6)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_6) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_6 }}</span>
</td>
@elseif ($i == 7)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_7) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_7 }}</span>
</td>
@elseif ($i == 8)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_8) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_8 }}</span>
</td>
@elseif ($i == 9)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_9) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_9 }}</span>
</td>
@elseif ($i == 10)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{ asset($configuracion->top_10) }}" alt=""
class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{ $configuracion->premio_10 }}</span>
</td>
@endif
@elseif ($i == 9)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_9)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_9}}</span>
</td>
@elseif ($i == 10)
<td class="pl-[1rem] pr-[1rem] sm:pl-[2rem] flex">
<img src="{{asset($configuracion->top_10)}}" alt="" class="h-4 w-4 sm:h-6 sm:w-6 object-cover">
<span class="pl-1 ms:pl-3">{{$configuracion->premio_10}}</span>
</td>
@endif
</tr>
</tr>
@endif
@endforeach
</tbody>