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,
|
||||
|
||||
Reference in New Issue
Block a user