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',
];
public function rol(){
return $this ->belongsTo(Role::class);
public function rol()
{
return $this->belongsTo(Role::class);
}
public function saldo(){
return $this ->hasOne(Saldo::class,'usuario_id');
public function saldo()
{
return $this->hasOne(Saldo::class, 'usuario_id');
}
public function modificaciones(){
return $this ->hasOne(Configuracione::class,'usermodifico_id');
public function modificaciones()
{
return $this->hasOne(Configuracione::class, 'usermodifico_id');
}
public function permisos(){
return $this ->hasMany(Permiso::class,'usuario_id');
public function permisos()
{
return $this->hasMany(Permiso::class, 'usuario_id');
}
public function preferenciales(){
return $this ->hasMany(Preferencial::class,'usuario_id');
public function preferenciales()
{
return $this->hasMany(Preferencial::class, 'usuario_id');
}
public function historiales_venta(){
return $this ->hasMany(Historiale::class,'vendedor_id');
public function historiales_venta()
{
return $this->hasMany(Historiale::class, 'vendedor_id');
}
public function historiales_compra(){
return $this ->hasMany(Historiale::class,'cliente_id');
public function historiales_compra()
{
return $this->hasMany(Historiale::class, 'cliente_id');
}
public function recargas(){
return $this ->hasMany(recarga::class,'usuario_id');
public function recargas()
{
return $this->hasMany(recarga::class, 'usuario_id');
}
public function usuario_tarifas(){
return $this ->hasMany(Usuario_tarifa::class,'usuario_id');
public function usuario_tarifas()
{
return $this->hasMany(Usuario_tarifa::class, 'usuario_id');
}
public function usuario_promos(){
return $this ->hasMany(Usuario_promo::class,'usuario_id');
public function usuario_promos()
{
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
@if (auth()->user()->rol->nombre === 'super')
<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.
<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.
tarifas promos.
<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">
<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 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">
<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>
</a>
@endif
</div>
<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"
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="">
<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">
<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">
<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>
<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>
</svg>
</div>
@@ -86,6 +74,9 @@
<th class="font-normal">Rol</th>
<th class="font-normal">Ventas</th>
<th class="font-normal">Saldo</th>
<th class="font-normal">
Precios personalizados
</th>
@if (auth()->user()->rol->nombre == 'super')
<th class="font-normal"></th>
<th class="rounded-r-lg font-normal"></th>
@@ -100,11 +91,18 @@
<td>{{ $usuario->rol->nombre ?? '' }}</td>
<td>{{ $usuario->historiales_venta_count ?? '' }}</td>
@if (!empty($usuario->saldo->valor))
<td>{{ number_format($usuario->saldo->valor) ?? '' }}</td>
<td>{{ number_format($usuario->saldo->valor) ?? '' }}</td>
@else
<td></td>
<td></td>
@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')
<td>
<button wire:click="saldo({{ $usuario->id }})"