update consulta reportes
This commit is contained in:
@@ -17,54 +17,48 @@ class ShowReportes extends Component
|
||||
public $fecha;
|
||||
public $mes;
|
||||
public $usuario;
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
// $this->fechaActual = Carbon::now();
|
||||
// $this->fechaActual = Carbon::parse($this->fechaActual);
|
||||
if(!empty($this->usuario)){
|
||||
if (!empty($this->usuario)) {
|
||||
$id_user = $this->usuario;
|
||||
|
||||
$consulta_suma = Historiale::where('vendedor_id', $id_user)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', $id_user)->count();
|
||||
|
||||
if (!empty($this->mes)) {
|
||||
|
||||
$consulta_suma = Historiale::where('vendedor_id', $id_user)->whereMonth('created_at',$this->mes)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', $id_user)->whereMonth('created_at',$this->mes)->count();
|
||||
$consulta_suma = Historiale::where('vendedor_id', $id_user)->whereMonth('created_at', $this->mes)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', $id_user)->whereMonth('created_at', $this->mes)->count();
|
||||
}
|
||||
|
||||
|
||||
}elseif(empty($this->usuario)){
|
||||
if(auth()->user()->rol->nombre == "super" || auth()->user()->rol->nombre == "administrador"){
|
||||
} elseif (empty($this->usuario)) {
|
||||
if (auth()->user()->rol->nombre == "super" || auth()->user()->rol->nombre == "administrador") {
|
||||
$consulta_suma = Historiale::sum('valor');
|
||||
$consulta_cantidad = Historiale::count();
|
||||
}else{
|
||||
|
||||
$consulta_suma = Historiale::where('vendedor_id', auth()->user()->id)->whereMonth('created_at',$this->mes)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', auth()->user()->id)->whereMonth('created_at',$this->mes)->count();
|
||||
|
||||
} else {
|
||||
$consulta_suma = Historiale::where('vendedor_id', auth()->user()->id)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', auth()->user()->id)->count();
|
||||
}
|
||||
|
||||
|
||||
if (!empty($this->mes)) {
|
||||
|
||||
$consulta_suma = Historiale::where('vendedor_id', auth()->user()->id)->whereMonth('created_at',$this->mes)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', auth()->user()->id)->whereMonth('created_at',$this->mes)->count();
|
||||
$consulta_suma = Historiale::where('vendedor_id', auth()->user()->id)->whereMonth('created_at', $this->mes)->sum('valor');
|
||||
$consulta_cantidad = Historiale::where('vendedor_id', auth()->user()->id)->whereMonth('created_at', $this->mes)->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$distribuidores = Role::where('nombre', 'distribuidor')->orWhere('nombre', 'mayorista')
|
||||
->with(['usuarios' => function ($query) {
|
||||
$query->orderBy('name', 'asc');
|
||||
}])->first();
|
||||
|
||||
$distribuidores = Role::where('nombre','distribuidor')->with('usuarios')->first();
|
||||
if (!empty($this->usuario)) {
|
||||
$id_user = $this->usuario;
|
||||
|
||||
$historial = Historiale::where('cliente_id', auth()->user()->id)->orderBy('id','DESC')->paginate(10);
|
||||
//dd($historial);
|
||||
$historial = Historiale::where('cliente_id', $id_user)->orderBy('id', 'DESC')->paginate(10);
|
||||
} else {
|
||||
$historial = Historiale::where('cliente_id', auth()->user()->id)->orderBy('id', 'DESC')->paginate(10);
|
||||
}
|
||||
|
||||
return view('livewire.show-reportes',[
|
||||
return view('livewire.show-reportes', [
|
||||
'suma' => $consulta_suma,
|
||||
'cantidad' => $consulta_cantidad,
|
||||
'roles' => $distribuidores,
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
<div class="bg-white overflow-y-auto md:w-[95%] m-auto p-2 md:p-5 rounded-[1.2rem] border-b border-gray-200 shadow-md relative h-[95%] ">
|
||||
<div
|
||||
class="bg-white overflow-y-auto md:w-[95%] m-auto p-2 md:p-5 rounded-[1.2rem] border-b border-gray-200 shadow-md relative h-[95%] ">
|
||||
<div class="flex justify-between my-2 items-center mb-4">
|
||||
<div class="flex items-center md:gap-4">
|
||||
<div class="flex text-sm">
|
||||
<x-icon-arrow-right/>
|
||||
<x-icon-arrow-right />
|
||||
Reportes
|
||||
</div>
|
||||
</div>
|
||||
@if (auth()->user()->rol->nombre == "super" || auth()->user()->rol->nombre == "administrador")
|
||||
<select wire:model="usuario" name="usr" id="usr"
|
||||
class="lg:w-1/6 border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none ring-0 focus:ring-0 focus:border-neutral-300 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="">Total</option>
|
||||
@foreach($roles->usuarios as $usuario)
|
||||
<option value="{{$usuario->id}}">{{$usuario->name}}</option>
|
||||
@endforeach
|
||||
@if (auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador')
|
||||
<select wire:model="usuario" name="usr" id="usr"
|
||||
class="lg:w-1/6 border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none ring-0 focus:ring-0 focus:border-neutral-300 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="">Total</option>
|
||||
@foreach ($roles->usuarios as $usuario)
|
||||
<option value="{{ $usuario->id }}">{{ $usuario->name }}</option>
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</select>
|
||||
|
||||
@endif
|
||||
<select wire:model="mes" name="mes" id="mes"
|
||||
@@ -41,19 +42,19 @@
|
||||
<div class="bg-white rounded-lg lg:w-[30rem] mx-auto">
|
||||
<div class="flex text-center text-4xl">
|
||||
<p class="w-1/2 border-r border-r-gray-300/30 self-center py-8">
|
||||
{{ $cantidad }}
|
||||
{{ $cantidad }}
|
||||
</p>
|
||||
<p class="w-1/2 text-xl self-center py-8">
|
||||
${{ number_format($suma) }}
|
||||
${{ number_format($suma) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex text-center text-white bg-[#000029] rounded-lg">
|
||||
<p class="w-1/2 border-r border-r-gray-300/30 py-2 self-center">
|
||||
Compras Realizadas
|
||||
</p>
|
||||
<p class="w-1/2 py-2 self-center">
|
||||
Valor
|
||||
</p>
|
||||
<p class="w-1/2 border-r border-r-gray-300/30 py-2 self-center">
|
||||
Compras Realizadas
|
||||
</p>
|
||||
<p class="w-1/2 py-2 self-center">
|
||||
Valor
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,41 +63,38 @@
|
||||
Transacciones Paquetes
|
||||
</div>
|
||||
<table class="text-center rounded-lg shadow-lg m-auto mt-4 mb-4 bg-white ">
|
||||
<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 pl-[1rem] md:pl-[2rem]">Fecha</th>
|
||||
<th class="font-normal sm:pl-[2rem] hidden sm:table-cell">Valor</th>
|
||||
<th class="font-normal sm:pl-[2rem] hidden sm:table-cell">Estado</th>
|
||||
|
||||
<th class="rounded-r-lg font-normal pr-[1rem] pl-[1rem] sm:pr-[2rem] sm:pl-[2rem] ">Detalle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<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 " x-data="{openOption:false}">
|
||||
|
||||
<td class="sm:pl-[2rem] hidden sm:table-cell">
|
||||
{{$historial->fecha_inicio}}
|
||||
</td>
|
||||
<td class="sm:pl-[2rem] hidden sm:table-cell">
|
||||
{{$historial->valor}}
|
||||
</td>
|
||||
<td class=" pl-[1rem] sm:pl-[2rem]">
|
||||
{{$historial->estado}}
|
||||
</td>
|
||||
<td class="md:pl-[2rem] md:pr-[2rem]">
|
||||
@if(!empty($historial->tarifa_id))
|
||||
{{$historial->tarifa->pantallas ?? ''}} {{ $historial->tarifa->servicio->nombre ?? ''}}
|
||||
@endif
|
||||
|
||||
@if(!empty($historial->promocion_id))
|
||||
{{ $historial->promocion->nombre ?? ''}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{{ $historiales->links() }}
|
||||
<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 pl-[1rem] md:pl-[2rem]">Fecha</th>
|
||||
<th class="font-normal sm:pl-[2rem] hidden sm:table-cell">Valor</th>
|
||||
<th class="font-normal sm:pl-[2rem] hidden sm:table-cell">Estado</th>
|
||||
<th class="rounded-r-lg font-normal pr-[1rem] pl-[1rem] sm:pr-[2rem] sm:pl-[2rem] ">Detalle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<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 " x-data="{ openOption: false }">
|
||||
<td class="sm:pl-[2rem]">
|
||||
{{ $historial->fecha_inicio }}
|
||||
</td>
|
||||
<td class="sm:pl-[2rem] hidden sm:table-cell">
|
||||
{{ $historial->valor }}
|
||||
</td>
|
||||
<td class=" pl-[1rem] hidden sm:table-cell">
|
||||
{{ $historial->estado }}
|
||||
</td>
|
||||
<td class="md:pl-[2rem] md:pr-[2rem]">
|
||||
@if (!empty($historial->tarifa_id))
|
||||
{{ $historial->tarifa->pantallas ?? '' }} {{ $historial->tarifa->servicio->nombre ?? '' }}
|
||||
@endif
|
||||
|
||||
@if (!empty($historial->promocion_id))
|
||||
{{ $historial->promocion->nombre ?? '' }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{{ $historiales->links() }}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user