antes de comenzar la vista tarifas

This commit is contained in:
Juan Felipe Duarte
2025-06-16 16:30:10 -07:00
parent 9425f519cc
commit 6eb6e3bd2f
8 changed files with 113 additions and 95 deletions
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class ShowTarifas extends Component
{
public function render()
{
return view('livewire.show-tarifas');
}
}
+8 -11
View File
@@ -114,25 +114,21 @@ class ShowUsuarios extends Component
->orWhere('email', 'ILIKE', '%' . $this->buscar . '%');
});
if ($this->verPreciosPersonalizados) {
$consulta_usuarios = $consulta_usuarios->havingRaw('active_tarifas > 0 OR active_promos > 0');
}
if (!(Auth::user()->rol->nombre == "super")) {
$consulta_usuarios = $consulta_usuarios->where('subvendedor_id', Auth::user()->id);
}
$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([
'servicio' => function ($query) {
@@ -153,10 +149,10 @@ class ShowUsuarios extends Component
}
if (Auth::user()->rol->nombre == "super") {
$this->roles = Role::get();
} else if (Auth::user()->subvendedor) {
$this->roles = Role::where('subvendedor_id', Auth::user()->id)->get();
} else {
$this->roles = Role::where('nombre', '=', 'distribuidor')->get();
}
@@ -181,6 +177,7 @@ class ShowUsuarios extends Component
$crear->email = $this->email;
$crear->password = Hash::make($this->password);
$crear->rol_id = $this->rol;
$crear->subvendedor_id = Auth::user()->rol->nombre == "super" ? null : Auth::user()->id;
$crear->save();
$saldo = new saldo;
@@ -6,11 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tarifas', function (Blueprint $table) {
@@ -18,11 +13,6 @@ return new class extends Migration
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tarifas', function (Blueprint $table) {
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('tarifas', function (Blueprint $table) {
$table->string('subvendedor_id')->nullable()->after('utilidad');
});
}
public function down()
{
Schema::table('tarifas', function (Blueprint $table) {
$table->dropColumn('subvendedor_id');
});
}
};
+23 -24
View File
@@ -107,33 +107,32 @@
</div>
@if (auth()->user()->rol->nombre == 'super' ||
auth()->user()->rol->nombre == 'administrador' ||
auth()->user()->rol->nombre == 'editor')
@if (auth()->user()->subvendedor || auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador' || auth()->user()->rol->nombre == 'editor')
<ul class="relative shadow-md block w-11/12 mx-auto select-none " x-data="{ selected: null }">
<li class="flex align-center flex-col">
<h4 @click="selected !== 0 ? selected = 0 : selected = null"
class="cursor-pointer px-5 py-3 bg-[#b221fd] text-white text-center inline-block hover:bg-[#7a02b8] hover:shadow rounded-lg">
Admin</h4>
<p class="absolute bg-[#f2f4ff] rounded-md @if (auth()->user()->rol->nombre == 'editor') -top-[400%] @elseif (auth()->user()->rol->nombre == 'administrador') -top-[200%] @else -top-[800%] @endif -right-[20%] sm:-right-[55%]" x-show="selected == 0">
@if (auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador' || auth()->user()->rol->nombre == 'editor')
<a class="block cursor-pointer hover:rounded-t-md rounded-t-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('planes') }}">Gestión Planes</a>
<a class="block cursor-pointer hover:rounded-b-md rounded-b-md text-center hover:bg-[#d1d3e1] w-full px-3 py-1" href="{{ route('import') }}">Importar cuentas</a>
<h4 @click="selected !== 0 ? selected = 0 : selected = null" class="cursor-pointer px-5 py-3 bg-[#b221fd] text-white text-center inline-block hover:bg-[#7a02b8] hover:shadow rounded-lg">
Admin
</h4>
<p class="absolute bg-[#f2f4ff] rounded-md @if (auth()->user()->rol->nombre == 'editor') -top-[400%] @elseif (auth()->user()->rol->nombre == 'administrador') -top-[200%] @elseif (auth()->user()->subvendedor) -top-3 @else -top-[800%] @endif -right-[20%] sm:-right-[55%]" x-show="selected == 0">
@if (auth()->user()->subvendedor)
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('roles') }}">Gestión Roles</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('usuarios') }}">Gestión Usuarios</a>
@if (auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador')
<a class="block cursor-pointer hover:rounded-t-md rounded-t-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('pendientes') }}">Gestión Pendientes</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logGeneral') }}">Log general</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logs') }}">Log cuentas</a>
@if (auth()->user()->rol->nombre == 'super')
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logHistorial') }}">Log historial</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logsRecargas') }}">Log recargas</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('promociones') }}">Gestión Promociones</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('roles') }}">Gestión Roles</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('servicio') }}">Gestión Servicios</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('categoria') }}">Gestión Categorias</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('utilidades') }}">Utilidades</a>
<a class="block cursor-pointer hover:rounded-b-md rounded-b-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('configuracion') }}">Configuración</a>
@if ( auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador' || auth()->user()->rol->nombre == 'editor')
<a class="block cursor-pointer hover:rounded-t-md rounded-t-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('planes') }}">Gestión Planes</a>
<a class="block cursor-pointer hover:rounded-b-md rounded-b-md text-center hover:bg-[#d1d3e1] w-full px-3 py-1" href="{{ route('import') }}">Importar cuentas</a>
@if (auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador')
<a class="block cursor-pointer hover:rounded-t-md rounded-t-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('pendientes') }}">Gestión Pendientes</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logGeneral') }}">Log general</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logs') }}">Log cuentas</a>
@if (auth()->user()->rol->nombre == 'super')
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logHistorial') }}">Log historial</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('logsRecargas') }}">Log recargas</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('promociones') }}">Gestión Promociones</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('servicio') }}">Gestión Servicios</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('categoria') }}">Gestión Categorias</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('utilidades') }}">Utilidades</a>
<a class="block cursor-pointer hover:rounded-b-md rounded-b-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('configuracion') }}">Configuración</a>
@endif
@endif
@endif
@endif
@@ -71,7 +71,7 @@
<div class="grid h-full place-items-center">
<div class="bg-white rounded-lg shadow-md sm:1/2 md:1/3 lg:1/3 xl:w-1/4">
{{-- PHOTO --}}
<div class="w-full text-left text-white px-4 bg-cover py-2 rounded-lg h-64 bg-[url({{asset($this->imagen)}})] ">
<div class="w-full text-left text-white px-4 bg-cover py-2 rounded-lg h-64 bg-[url({{asset($this->imagen)}})]">
</div>
<div class="text-left">
@@ -0,0 +1,3 @@
<div>
<h1>Tarifas</h1>
</div>
@@ -26,9 +26,7 @@
Usuario
</div>
<div class="flex gap-4">
@if (auth()->user()->rol->nombre === 'administrador' ||
auth()->user()->rol->nombre === 'editor' ||
auth()->user()->rol->nombre === 'super')
@if (auth()->user()->subvendedor || auth()->user()->rol->nombre === 'administrador' || auth()->user()->rol->nombre === 'editor' || auth()->user()->rol->nombre === 'super')
<a x-on:click="add = !add"
class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-3 md:mb-0">Añadir
usuario
@@ -64,10 +62,8 @@
<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">
<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>
@@ -85,12 +81,14 @@
<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>
<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>
@elseif (Auth::user()->subvendedor)
<th class="rounded-r-lg font-normal"></th>
@else
@endif
</tr>
</x-slot>
@@ -116,46 +114,43 @@
@if (auth()->user()->rol->nombre == 'super')
<td>
<button wire:click="saldo({{ $usuario->id }})"
class="justify-center text-sm flex px-2 py-1 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-0 md:mb-0">Recargar</button>
<button wire:click="saldo({{ $usuario->id }})" class="justify-center text-sm flex px-2 py-1 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-0 md:mb-0">Recargar</button>
</td>
<td>
<button x-on:click="openOption=!openOption">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round"
d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>
</button>
<td>
<button x-on:click="openOption=!openOption">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>
</button>
<div x-cloak x-show="openOption" @click.away="openOption = false"
class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg right-10">
<button x-on:click="openOption=false" wire:click="editar({{ $usuario->id }})"
class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
<button x-on:click="openOption=!openOption"
wire:click="editarPassword({{ $usuario->id }})"
class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 ">Editar
password</button>
<button x-on:click="openOption=false" wire:click="saldo({{ $usuario->id }})"
class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 ">Agregar
saldo</button>
<button x-on:click="openOption=false" wire:click="saldodesc({{ $usuario->id }})"
class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 ">Descontar
saldo</button>
<button x-on:click="openOption=false,gestion=true"
wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')"
class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 ">Precio
servicio</button>
<button x-on:click="openOption=false,gestionPromo=true"
wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')"
class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 ">Precio
promocion</button>
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})"
class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
</div>
</td>
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg right-10">
<button x-on:click="openOption=false" wire:click="editar({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
<button x-on:click="openOption=!openOption" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Editar password</button>
<button x-on:click="openOption=false" wire:click="saldo({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Agregar saldo</button>
<button x-on:click="openOption=false" wire:click="saldodesc({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Descontar saldo</button>
<button x-on:click="openOption=false,gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio servicio</button>
<button x-on:click="openOption=false,gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio promocion</button>
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
</div>
</td>
@elseif (Auth::user()->subvendedor)
<td>
<button x-on:click="openOption=!openOption">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>
</button>
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg right-10">
<button x-on:click="openOption=false" wire:click="editar({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
<button x-on:click="openOption=!openOption" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Editar password</button>
<button x-on:click="openOption=false,gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio servicio</button>
<button x-on:click="openOption=false,gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio promocion</button>
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
</div>
</td>
@else
@endif
</tr>
@endforeach
</x-slot>
@@ -485,8 +480,7 @@
<div class="mb-4">
<label class="select-none text-gray-700 text-sm font-bold mb-2">Selecciona rol:</label>
<select name="estado_promocion" id="estado_promocion" wire:model="rol"
class="w-full 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">
<select name="estado_promocion" id="estado_promocion" wire:model="rol" class="w-full 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 selected>Rol</option>
@foreach ($roles as $rol)
<option value="{{ $rol->id }}">{{ $rol->nombre }}</option>