update precios personalizados

This commit is contained in:
Felipe
2025-01-02 11:13:00 -05:00
parent 31963b64d3
commit 551e017615
2 changed files with 57 additions and 41 deletions
+38 -20
View File
@@ -46,43 +46,61 @@ class User extends Authenticatable
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
]; ];
public function rol(){ public function rol()
return $this ->belongsTo(Role::class); {
return $this->belongsTo(Role::class);
} }
public function saldo(){ public function saldo()
return $this ->hasOne(Saldo::class,'usuario_id'); {
return $this->hasOne(Saldo::class, 'usuario_id');
} }
public function modificaciones(){ public function modificaciones()
return $this ->hasOne(Configuracione::class,'usermodifico_id'); {
return $this->hasOne(Configuracione::class, 'usermodifico_id');
} }
public function permisos(){ public function permisos()
return $this ->hasMany(Permiso::class,'usuario_id'); {
return $this->hasMany(Permiso::class, 'usuario_id');
} }
public function preferenciales(){ public function preferenciales()
return $this ->hasMany(Preferencial::class,'usuario_id'); {
return $this->hasMany(Preferencial::class, 'usuario_id');
} }
public function historiales_venta(){ public function historiales_venta()
return $this ->hasMany(Historiale::class,'vendedor_id'); {
return $this->hasMany(Historiale::class, 'vendedor_id');
} }
public function historiales_compra(){ public function historiales_compra()
return $this ->hasMany(Historiale::class,'cliente_id'); {
return $this->hasMany(Historiale::class, 'cliente_id');
} }
public function recargas(){ public function recargas()
return $this ->hasMany(recarga::class,'usuario_id'); {
return $this->hasMany(recarga::class, 'usuario_id');
} }
public function usuario_tarifas(){ public function usuario_tarifas()
return $this ->hasMany(Usuario_tarifa::class,'usuario_id'); {
return $this->hasMany(Usuario_tarifa::class, 'usuario_id');
} }
public function usuario_promos(){ public function usuario_promos()
return $this ->hasMany(Usuario_promo::class,'usuario_id'); {
return $this->hasMany(Usuario_promo::class, 'usuario_id');
} }
public function countActiveTarifas()
{
return $this->usuario_tarifas()->where('visible', 'true')->count();
}
public function countActivePromos()
{
return $this->usuario_promos()->where('visible', 'true')->count();
}
} }
@@ -43,33 +43,21 @@
@endif @endif
@if (auth()->user()->rol->nombre === 'super') @if (auth()->user()->rol->nombre === 'super')
<a x-on:click="modTarifas = true" <a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Mod.
class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Mod.
tarifas promos. tarifas promos.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" <polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve"> <path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff"
data-original="#000000" />
<path
d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z"
fill="#ffffff" data-original="#000000" />
</svg> </svg>
</a> </a>
@endif @endif
</div> </div>
<div class="flex relative text-sm mx-auto w-64 md:w-auto my-2"> <div class="flex relative text-sm mx-auto w-64 md:w-auto my-2">
<input id="buscar" type="search" wire:model="buscar" placeholder="Buscar" <input id="buscar" type="search" wire:model="buscar" placeholder="Buscar" class=" shadow-sm border-2 active:border-neutral-200 focus:ring-0 border-neutral-200 w-64 md:w-auto rounded-md pr-7 py-1 m-auto focus:border-neutral-300 focus:outline-none focus:shadow-outline">
class=" shadow-sm border-2 active:border-neutral-200 focus:ring-0 border-neutral-200 w-64 md:w-auto rounded-md pr-7 py-1 m-auto focus:border-neutral-300 focus:outline-none focus:shadow-outline"> <svg class="w-5 absolute top-2 right-3" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" class="w-4 absolute" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;" xml:space="preserve" class="">
<svg class="w-5 absolute top-2 right-3" xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" class="w-4 absolute"
x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;"
xml:space="preserve" class="">
<g id="Layer_31" data-name="Layer 31"> <g id="Layer_31" data-name="Layer 31">
<path <path d="m21.71 20.29-5.4-5.39a7.92 7.92 0 0 0 1.69-4.9 8 8 0 1 0 -8 8 7.92 7.92 0 0 0 4.9-1.69l5.39 5.4a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zm-17.71-10.29a6 6 0 1 1 6 6 6 6 0 0 1 -6-6z" fill="#b221fd" data-original="#000000" class=""></path>
d="m21.71 20.29-5.4-5.39a7.92 7.92 0 0 0 1.69-4.9 8 8 0 1 0 -8 8 7.92 7.92 0 0 0 4.9-1.69l5.39 5.4a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zm-17.71-10.29a6 6 0 1 1 6 6 6 6 0 0 1 -6-6z"
fill="#b221fd" data-original="#000000" class=""></path>
</g> </g>
</svg> </svg>
</div> </div>
@@ -86,6 +74,9 @@
<th class="font-normal">Rol</th> <th class="font-normal">Rol</th>
<th class="font-normal">Ventas</th> <th class="font-normal">Ventas</th>
<th class="font-normal">Saldo</th> <th class="font-normal">Saldo</th>
<th class="font-normal">
Precios personalizados
</th>
@if (auth()->user()->rol->nombre == 'super') @if (auth()->user()->rol->nombre == 'super')
<th class="font-normal"></th> <th class="font-normal"></th>
<th class="rounded-r-lg font-normal"></th> <th class="rounded-r-lg font-normal"></th>
@@ -105,6 +96,13 @@
<td></td> <td></td>
@endif @endif
<td>
<p>
<span>Tarifas: <span class="font-bold">{{ $usuario->countActiveTarifas() ?? 0 }}</span></span>,
<span>Promos: <span class="font-bold">{{ $usuario->countActivePromos() ?? 0 }}</span> </span>
</p>
</td>
@if (auth()->user()->rol->nombre == 'super') @if (auth()->user()->rol->nombre == 'super')
<td> <td>
<button wire:click="saldo({{ $usuario->id }})" <button wire:click="saldo({{ $usuario->id }})"