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