update consulta reportes
This commit is contained in:
@@ -20,9 +20,6 @@ class ShowReportes extends Component
|
|||||||
|
|
||||||
public function render()
|
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;
|
$id_user = $this->usuario;
|
||||||
|
|
||||||
@@ -30,39 +27,36 @@ class ShowReportes extends Component
|
|||||||
$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)) {
|
} elseif (empty($this->usuario)) {
|
||||||
if (auth()->user()->rol->nombre == "super" || auth()->user()->rol->nombre == "administrador") {
|
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);
|
||||||
$distribuidores = Role::where('nombre','distribuidor')->with('usuarios')->first();
|
} else {
|
||||||
|
|
||||||
$historial = Historiale::where('cliente_id', auth()->user()->id)->orderBy('id', 'DESC')->paginate(10);
|
$historial = Historiale::where('cliente_id', auth()->user()->id)->orderBy('id', 'DESC')->paginate(10);
|
||||||
//dd($historial);
|
}
|
||||||
|
|
||||||
return view('livewire.show-reportes', [
|
return view('livewire.show-reportes', [
|
||||||
'suma' => $consulta_suma,
|
'suma' => $consulta_suma,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<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">
|
||||||
@@ -6,7 +7,7 @@
|
|||||||
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>
|
||||||
@@ -67,21 +68,19 @@
|
|||||||
<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]">
|
||||||
<td class="sm:pl-[2rem] hidden sm:table-cell">
|
|
||||||
{{ $historial->fecha_inicio }}
|
{{ $historial->fecha_inicio }}
|
||||||
</td>
|
</td>
|
||||||
<td class="sm:pl-[2rem] hidden sm:table-cell">
|
<td class="sm:pl-[2rem] hidden sm:table-cell">
|
||||||
{{ $historial->valor }}
|
{{ $historial->valor }}
|
||||||
</td>
|
</td>
|
||||||
<td class=" pl-[1rem] sm:pl-[2rem]">
|
<td class=" pl-[1rem] hidden sm:table-cell">
|
||||||
{{ $historial->estado }}
|
{{ $historial->estado }}
|
||||||
</td>
|
</td>
|
||||||
<td class="md:pl-[2rem] md:pr-[2rem]">
|
<td class="md:pl-[2rem] md:pr-[2rem]">
|
||||||
@@ -98,5 +97,4 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{ $historiales->links() }}
|
{{ $historiales->links() }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user