update: filtro por precios personalizados

This commit is contained in:
Felipe
2025-01-02 15:24:13 -05:00
parent 5275bfced7
commit 33859c8777
3 changed files with 46 additions and 5 deletions
+2 -2
View File
@@ -81,7 +81,7 @@ class ShowTop extends Component
$notificacion = new Notificacion();
$notificacion->remitente_id = Auth::user()->id;
// $notificacion->destinatario_id = 410;
// $notificacion->destinatario_id = 410;`
$notificacion->destinatario_id = $vendedor->id;
$notificacion->titulo = 'Felicidades ' . $vendedor->name ?? '' . ' 🎊';
$notificacion->descripcion = 'Quedaste ' . $rangos[$index] . ' en el #Top10MejoresDistribuidores del mes de ' . date('M', strtotime('last month'));
@@ -98,7 +98,7 @@ class ShowTop extends Component
PremioEntregado::create([
'user_id' => Auth::user()->id,
'fecha' => $year,
'fecha' => $month . '-' . $year,
'entregado' => 1
]);
+33 -3
View File
@@ -89,6 +89,8 @@ class ShowUsuarios extends Component
public $entradas = false;
public $verPreciosPersonalizados = false;
protected $rules = [
'nombre' => 'required',
'email' => 'required',
@@ -101,7 +103,35 @@ class ShowUsuarios extends Component
$consulta_tarifas = TarifaPromo::take(1);
$consulta_usuarios = User::where('name', 'LIKE', '%' . $this->buscar . '%')->orWhere('email', 'LIKE', '%' . $this->buscar . '%')->with('rol', 'saldo')->orderBy('id', 'DESC')->withCount('historiales_venta')->paginate($this->entradas);
$consulta_usuarios = User::withCount(['usuario_tarifas as active_tarifas' => function ($query) {
$query->where('visible', 'true');
}])
->withCount(['usuario_promos as active_promos' => function ($query) {
$query->where('visible', 'true');
}])
->where(function ($query) {
$query->where('name', 'LIKE', '%' . $this->buscar . '%')
->orWhere('email', 'LIKE', '%' . $this->buscar . '%');
});
if ($this->verPreciosPersonalizados) {
$consulta_usuarios = $consulta_usuarios->havingRaw('active_tarifas > 0 OR active_promos > 0');
}
$consulta_usuarios = $consulta_usuarios
->with('rol', 'saldo')
->orderBy('id', 'DESC')
->withCount('historiales_venta')
->paginate($this->entradas);
if (!empty($this->buscar_servicio)) {
$this->consulta_tarifas = Tarifas::where('rol_id', $this->rol_usuario)->with([
@@ -125,7 +155,7 @@ class ShowUsuarios extends Component
if (Auth::user()->rol->nombre == "super") {
$this->roles = Role::get();
}else{
} else {
$this->roles = Role::where('nombre', '=', 'distribuidor')->get();
}
@@ -235,7 +265,7 @@ class ShowUsuarios extends Component
//Log de recarga de saldo s
$logsGeneral = new Log_general();
$logsGeneral->user_id = Auth::user()->id;
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha recargado a ' . $nombre. ' - ' . $email . ' la cantidad de $' . $this->valor_recargar.', Saldo anterior: $'.$this->saldo_actual.', Nuevo saldo disponible: $'.$nuevo_saldo;
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha recargado a ' . $nombre . ' - ' . $email . ' la cantidad de $' . $this->valor_recargar . ', Saldo anterior: $' . $this->saldo_actual . ', Nuevo saldo disponible: $' . $nuevo_saldo;
$logsGeneral->save();
$this->alert('success', 'Saldo actualizado con exito!', [
@@ -61,6 +61,17 @@
</g>
</svg>
</div>
<div>
<div class="flex items-center">
<input id="verPreciosPersonalizados" type="checkbox" wire:model="verPreciosPersonalizados"
class="h-4 w-4 text-[#B221FD] border-gray-300 rounded">
<label for="verPreciosPersonalizados" class="ml-2 block
text-sm text-gray-900">
Precios personalizados
</label>
</div>
</div>
</div>
<x-ver-entrada />