Tarifas y promos por usuario (falta el editar en la vista de tarifas)
Introduces the subvendedor_id field to the tarifa_promos table and updates the TarifaPromo model accordingly. Refactors tarifas and promociones management in ShowTarifas and ShowUsuarios Livewire components, including utility calculation, validation, and UI improvements for managing both regular and promo tarifas.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Livewire;
|
||||
use App\Models\Promociones;
|
||||
use App\Models\Role;
|
||||
use App\Models\Servicio;
|
||||
use App\Models\TarifaPromo;
|
||||
use App\Models\Tarifas;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
@@ -16,23 +17,37 @@ class ShowTarifas extends Component
|
||||
use LivewireAlert;
|
||||
use WithPagination;
|
||||
|
||||
// Modales
|
||||
public $modTarifas = false;
|
||||
public $modTarifasPromo = false;
|
||||
|
||||
public $tarifas;
|
||||
public $planes;
|
||||
public $promociones;
|
||||
|
||||
// Tarifa datos
|
||||
public $pantallas;
|
||||
public $dias = 30;
|
||||
public $rol_id;
|
||||
public $precio;
|
||||
public $utilidad;
|
||||
public $estado;
|
||||
public $estado = true;
|
||||
public $valorBase;
|
||||
|
||||
// Tarifa datos
|
||||
public $servicio_id;
|
||||
public $plan_id;
|
||||
public $rol_id;
|
||||
|
||||
// Promo datos
|
||||
public $promocion_id;
|
||||
public $promo_id;
|
||||
|
||||
|
||||
// Todo: QUE PRIMERO vea si el usuario tiene alguna promo en usuario_tarifas pues esta tiene prioridad
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->tarifas = Tarifas::where('servicio_id', $this->servicio_id)->where('rol_id', Auth::user()->rol->id)->where('estado', 'activo')->get();
|
||||
$this->planes = Tarifas::where('servicio_id', $this->servicio_id)->where('rol_id', Auth::user()->rol->id)->where('estado', 'activo')->get();
|
||||
$this->planes = Tarifas::where('servicio_id', $this->servicio_id)->where('rol_id', Auth::user()->rol->id)->where('estado', 'activo')->get();
|
||||
// $this->tarifas = Tarifas::where('servicio_id', $this->servicio_id)->where('rol_id', Auth::user()->rol->id)->where('estado', 'activo')->get();
|
||||
// $this->tarifas = TarifaPromo::where('promocion_id', $this->promocion_id)->where('rol_id', Auth::user()->rol->id)->where('visible', 'activo')->get();
|
||||
$this->promociones = TarifaPromo::where('promocion_id', $this->promocion_id)->where('rol_id', Auth::user()->rol->id)->where('visible', 'activo')->get();
|
||||
|
||||
return view('livewire.show-tarifas', [
|
||||
'roles' => Role::where('subvendedor_id', auth()->user()->id)->get(),
|
||||
@@ -41,39 +56,167 @@ class ShowTarifas extends Component
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatedPlanId($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$planSeleccionado = collect($this->planes)->firstWhere('id', $value);
|
||||
|
||||
if ($planSeleccionado) {
|
||||
$this->valorBase = $planSeleccionado['valor'];
|
||||
$this->precio = $planSeleccionado['valor'];
|
||||
$this->calcularUtilidad();
|
||||
}
|
||||
} else {
|
||||
$this->valorBase = null;
|
||||
$this->precio = null;
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
public function updatedPromoId($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$promocionSeleccionada = collect($this->promociones)->firstWhere('id', $value);
|
||||
|
||||
if ($promocionSeleccionada) {
|
||||
$this->valorBase = $promocionSeleccionada['precio'];
|
||||
$this->precio = $promocionSeleccionada['precio'];
|
||||
$this->calcularUtilidad();
|
||||
}
|
||||
} else {
|
||||
$this->valorBase = null;
|
||||
$this->precio = null;
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedPrecio($value)
|
||||
{
|
||||
$this->calcularUtilidad();
|
||||
}
|
||||
|
||||
private function calcularUtilidad()
|
||||
{
|
||||
if (!is_null($this->precio) && !is_null($this->valorBase)) {
|
||||
$this->utilidad = $this->precio - $this->valorBase;
|
||||
} else {
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function guardarTarifa()
|
||||
{
|
||||
$this->validate([
|
||||
'pantallas' => 'required',
|
||||
'dias' => 'required',
|
||||
'precio' => 'required',
|
||||
'utilidad' => 'required',
|
||||
'estado' => 'required',
|
||||
'servicio_id' => 'required',
|
||||
'rol_id' => 'required',
|
||||
], [
|
||||
'pantallas.required' => 'El campo pantallas es obligatorio',
|
||||
'dias.required' => 'El campo días es obligatorio',
|
||||
'precio.required' => 'El campo precio es obligatorio',
|
||||
'utilidad.required' => 'El campo utilidad es obligatorio',
|
||||
'estado.required' => 'El campo estado es obligatorio',
|
||||
'servicio_id.required' => 'El campo servicio es obligatorio',
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
$planSeleccionado = collect($this->planes)->firstWhere('id', $this->plan_id);
|
||||
|
||||
Tarifas::create([
|
||||
'pantallas' => $this->pantallas,
|
||||
'dias' => $this->dias,
|
||||
'valor' => $this->precio,
|
||||
'utilidad' => $this->utilidad,
|
||||
'estado' => $this->estado ? 'activo' : 'inactivo',
|
||||
'servicio_id' => $this->servicio_id,
|
||||
'rol_id' => $this->rol_id,
|
||||
'subvendedor_id' => Auth::user()->id,
|
||||
]);
|
||||
if ($planSeleccionado) {
|
||||
|
||||
$this->alert('success', '¡Tarifas creada correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
$this->validate([
|
||||
'precio' => 'required|numeric',
|
||||
'utilidad' => 'required',
|
||||
'estado' => 'required',
|
||||
'servicio_id' => 'required',
|
||||
'rol_id' => 'required',
|
||||
], [
|
||||
'precio.required' => 'El campo precio es obligatorio',
|
||||
'utilidad.required' => 'El campo utilidad es obligatorio',
|
||||
'estado.required' => 'El campo estado es obligatorio',
|
||||
'servicio_id.required' => 'El campo servicio es obligatorio',
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
|
||||
if ($this->precio < $this->valorBase) {
|
||||
$this->alert('error', 'El precio no puede ser menor al costo del plan', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
Tarifas::create([
|
||||
'pantallas' => $planSeleccionado['pantallas'],
|
||||
'dias' => $planSeleccionado['dias'],
|
||||
'valor' => $this->precio,
|
||||
'utilidad' => $this->utilidad,
|
||||
'estado' => $this->estado ? 'activo' : 'inactivo',
|
||||
'servicio_id' => $this->servicio_id,
|
||||
'rol_id' => $this->rol_id,
|
||||
'subvendedor_id' => Auth::user()->id,
|
||||
]);
|
||||
|
||||
$this->limpiarInputs();
|
||||
|
||||
$this->alert('success', '¡Tarifas creada correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
} else {
|
||||
$this->alert('error', 'Error inesperado', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function guardarTarifaPromo()
|
||||
{
|
||||
$promocionSeleccionada = collect($this->promociones)->firstWhere('id', $this->promo_id);
|
||||
|
||||
if ($promocionSeleccionada) {
|
||||
|
||||
$this->validate([
|
||||
'precio' => 'required|numeric',
|
||||
'utilidad' => 'required',
|
||||
'estado' => 'required',
|
||||
'promocion_id' => 'required',
|
||||
'rol_id' => 'required',
|
||||
], [
|
||||
'precio.required' => 'El campo precio es obligatorio',
|
||||
'utilidad.required' => 'El campo utilidad es obligatorio',
|
||||
'estado.required' => 'El campo estado es obligatorio',
|
||||
'promocion_id.required' => 'El campo servicio es obligatorio',
|
||||
'rol_id.required' => 'El campo rol es obligatorio',
|
||||
]);
|
||||
|
||||
if ($this->precio < $this->valorBase) {
|
||||
$this->alert('error', 'El precio no puede ser menor al costo del plan', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
TarifaPromo::create([
|
||||
'utilidad' => $this->utilidad,
|
||||
'promocion_id' => $this->promocion_id,
|
||||
'precio' => $this->precio,
|
||||
'visible' => $this->estado ? 'activo' : 'inactivo',
|
||||
'rol_id' => $this->rol_id,
|
||||
'subvendedor_id' => Auth::user()->id,
|
||||
]);
|
||||
|
||||
$this->limpiarInputs();
|
||||
|
||||
$this->alert('success', '¡Tarifas creada correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
} else {
|
||||
$this->alert('error', 'Error inesperado', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function limpiarInputs(){
|
||||
$this->modTarifas = false;
|
||||
|
||||
$this->servicio_id = null;
|
||||
$this->promocion_id = null;
|
||||
$this->precio = null;
|
||||
$this->utilidad = null;
|
||||
$this->estado = true;
|
||||
$this->plan_id = null;
|
||||
$this->rol_id = null;
|
||||
$this->valorBase = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ class ShowUsuarios extends Component
|
||||
$consulta_tarifas = TarifaPromo::take(1);
|
||||
|
||||
$consulta_usuarios = User::withCount(['usuario_tarifas as active_tarifas' => function ($query) {
|
||||
$query->where('visible', 'true');
|
||||
}])
|
||||
$query->where('visible', 'true');
|
||||
}])
|
||||
->withCount(['usuario_promos as active_promos' => function ($query) {
|
||||
$query->where('visible', 'true');
|
||||
}])
|
||||
@@ -118,9 +118,9 @@ class ShowUsuarios extends Component
|
||||
$query->whereHas('usuario_tarifas', function ($q) {
|
||||
$q->where('visible', true);
|
||||
})
|
||||
->orWhereHas('usuario_promos', function ($q) {
|
||||
$q->where('visible', true);
|
||||
});
|
||||
->orWhereHas('usuario_promos', function ($q) {
|
||||
$q->where('visible', true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,6 +168,71 @@ class ShowUsuarios extends Component
|
||||
]);
|
||||
}
|
||||
|
||||
public $valorBase;
|
||||
|
||||
public function updatedTarifasGestion($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$planSeleccionado = collect($this->consulta_tarifas)->firstWhere('id', $value);
|
||||
|
||||
if ($planSeleccionado) {
|
||||
$this->valorBase = $planSeleccionado['valor'];
|
||||
$this->precioTarifasGestion = $planSeleccionado['valor'];
|
||||
$this->calcularUtilidadTarifasGestion();
|
||||
}
|
||||
} else {
|
||||
$this->valorBase = null;
|
||||
$this->precioTarifasGestion = null;
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedPrecioTarifasGestion($value)
|
||||
{
|
||||
$this->calcularUtilidadTarifasGestion();
|
||||
}
|
||||
|
||||
private function calcularUtilidadTarifasGestion()
|
||||
{
|
||||
if (!is_null($this->precioTarifasGestion) && !is_null($this->valorBase)) {
|
||||
$this->utilidad = $this->precioTarifasGestion - $this->valorBase;
|
||||
} else {
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updatedPromoGestion($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$planSeleccionado = collect($this->consulta_promo)->firstWhere('id', $value);
|
||||
|
||||
if ($planSeleccionado) {
|
||||
$this->valorBase = $planSeleccionado['precio'];
|
||||
$this->precioPromoGestion = $planSeleccionado['precio'];
|
||||
$this->calcularUtilidadPromoGestion();
|
||||
}
|
||||
} else {
|
||||
$this->valorBase = null;
|
||||
$this->precioPromoGestion = null;
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedPrecioPromoGestion($value)
|
||||
{
|
||||
$this->calcularUtilidadPromoGestion();
|
||||
}
|
||||
|
||||
private function calcularUtilidadPromoGestion()
|
||||
{
|
||||
if (!is_null($this->precioPromoGestion) && !is_null($this->valorBase)) {
|
||||
$this->utilidad = $this->precioPromoGestion - $this->valorBase;
|
||||
} else {
|
||||
$this->utilidad = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Crear usuario ///
|
||||
public function crear()
|
||||
{
|
||||
@@ -421,6 +486,7 @@ class ShowUsuarios extends Component
|
||||
|
||||
public function gestionar($id, $rid, $usuNom)
|
||||
{
|
||||
$this->utilidad = 0;
|
||||
|
||||
$this->usuarioGestion_id = $id;
|
||||
$this->rol_usuario = $rid;
|
||||
@@ -440,6 +506,14 @@ class ShowUsuarios extends Component
|
||||
->where('usuario_id', $this->usuarioGestion_id)
|
||||
->exists();
|
||||
|
||||
|
||||
if ($this->precio < $this->valorBase) {
|
||||
$this->alert('error', 'El precio no puede ser menor al costo del plan', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($consulta_existe) {
|
||||
$this->alert('warning', '¡Este usuario ya tiene esta tarifa!', [
|
||||
'position' => 'top'
|
||||
@@ -486,6 +560,8 @@ class ShowUsuarios extends Component
|
||||
|
||||
public function gestionarPromociones($id, $usuNom)
|
||||
{
|
||||
$this->utilidad = 0;
|
||||
|
||||
$this->usuarioGestion_id = $id;
|
||||
$this->usuario_nombre = $usuNom;
|
||||
|
||||
|
||||
@@ -15,13 +15,16 @@ class TarifaPromo extends Model
|
||||
'rol_id',
|
||||
'precio',
|
||||
'visible',
|
||||
'subvendedor_id',
|
||||
];
|
||||
|
||||
public function rol(){
|
||||
return $this ->belongsTo(Role::class,'rol_id');
|
||||
public function rol()
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'rol_id');
|
||||
}
|
||||
|
||||
public function promocion(){
|
||||
return $this ->belongsTo(Promociones::class,'promocion_id');
|
||||
public function promocion()
|
||||
{
|
||||
return $this->belongsTo(Promociones::class, 'promocion_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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('tarifa_promos', function (Blueprint $table) {
|
||||
$table->string('subvendedor_id')->nullable()->after('utilidad');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('tarifa_promos', function (Blueprint $table) {
|
||||
$table->dropColumn('subvendedor_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,8 @@
|
||||
<div x-data="{
|
||||
modTarifas: @entangle('modTarifas'),
|
||||
modTarifas : @entangle('modTarifas'),
|
||||
modTarifasPromo: @entangle('modTarifasPromo'),
|
||||
}" class="h-full w-full md:my-2">
|
||||
<div class=" fixed backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading wire:target="">
|
||||
<div class=" fixed backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading wire:target="guardarTarifa,limpiarInputs">
|
||||
<div class="grid h-full place-items-center">
|
||||
<div class="max-w-xs">
|
||||
<img src="./img/loading.gif" alt="" class="w-full text-center">
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
@if (auth()->user()->subvendedor)
|
||||
<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]">
|
||||
Modificar tarifas
|
||||
Tarifas servicios
|
||||
<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" />
|
||||
@@ -29,8 +30,8 @@
|
||||
@endif
|
||||
|
||||
@if (auth()->user()->subvendedor)
|
||||
<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.
|
||||
<a x-on:click="modTarifasPromo = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
|
||||
Tarifas promociones
|
||||
<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" />
|
||||
@@ -45,10 +46,9 @@
|
||||
|
||||
<div x-cloak x-show="modTarifas" x-transition:enter="transition duration-350" x-transition:enter-start="opacity-0 scale-100" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="transition duration-350" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-100" class="fixed backdrop-blur-sm bg-black/20 left-0 bottom-0 top-0 right-0 h-full z-20">
|
||||
<div class="grid h-full place-items-center">
|
||||
|
||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-2xl shadow-md">
|
||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-2xl shadow-md max-w-7xl mx-4">
|
||||
<div class="mb-4">
|
||||
<select name="servicio" id="servicio_id" name="servicio_id" wire:model="servicio_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-[72%] sm:w-60 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<select name="servicio_id" id="servicio_id" name="servicio_id" wire:model="servicio_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-[72%] sm:w-60 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="" selected>Servicios</option>
|
||||
@foreach ($servicios as $servicio)
|
||||
<option value="{{ $servicio->id }}">{{ $servicio->nombre ?? '' }}</option>
|
||||
@@ -73,18 +73,19 @@
|
||||
<select id="plan_id" name="plan_id" wire:model="plan_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="" selected>Planes</option>
|
||||
@foreach ($planes as $plan)
|
||||
<option value="{{ $plan->id }}">{{ $plan->pantallas ?? 0 }} pantallas - {{ $plan->dias ?? 0 }} dias</option>
|
||||
<option value="{{ $plan->id }}">
|
||||
{{ $plan->pantallas ?? 0 }} {{ Str::plural('pantalla', $plan->pantallas ?? 0) }} - {{ $plan->dias ?? 0 }} días </option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="precio" class="text-gray-500 text-sm">Precio</label>
|
||||
<input type="number" id="precio" name="precio" wire:model="precio" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<input type="number" id="precio" name="precio" wire:model.debounce.300ms="precio" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div>
|
||||
<label for="utilidad" class="text-gray-500 text-sm">Utilidad</label>
|
||||
<input type="number" id="utilidad" name="utilidad" wire:model="utilidad" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<input disabled type="number" id="utilidad" name="utilidad" wire:model="utilidad" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div class="flex m-auto items-center">
|
||||
<label for="estado" class="text-gray-500 text-sm mr-2">Activa</label>
|
||||
@@ -127,8 +128,7 @@
|
||||
<td class="pl-[1rem]">{{ $tarifa->dias ?? '' }}</td>
|
||||
<td class="pl-[1rem]">{{ number_format($tarifa->utilidad ?? 0) }}</td>
|
||||
<td class="pl-[1rem]">
|
||||
<button wire:click="editar({{ $tarifa }})"
|
||||
class="justify-center flex px-3 py-2 rounded-lg text-xs cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Editar</button>
|
||||
{{-- <button wire:click="editarTarifa({{ $tarifa }})" class="justify-center flex px-3 py-2 rounded-lg text-xs cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Editar</button> --}}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -139,12 +139,112 @@
|
||||
|
||||
<div class="bg-white px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse sm:justify-evenly gap-5 mt-4">
|
||||
<span>
|
||||
<button x-on:click="modTarifas=false" wire:click="" type="button"
|
||||
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 text-white bg-[#585858] hover:bg-[#3a3a3a] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Cerrar</button>
|
||||
<button x-on:click="modTarifas=false" wire:click="guardarTarifa" type="button" class="justify-center w-full md:w-auto rounded-md border border-transparent px-4 py-1 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5 flex items-center">Cerrar</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div x-cloak x-show="modTarifasPromo" x-transition:enter="transition duration-350" x-transition:enter-start="opacity-0 scale-100" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="transition duration-350" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-100" class="fixed backdrop-blur-sm bg-black/20 left-0 bottom-0 top-0 right-0 h-full z-20">
|
||||
<div class="grid h-full place-items-center">
|
||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-2xl shadow-md max-w-7xl mx-4">
|
||||
|
||||
<div class="mb-4">
|
||||
<select name="promocion_id" id="promocion_id" name="promocion_id" wire:model="promocion_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-[72%] sm:w-60 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="" selected>Promociones</option>
|
||||
@foreach ($promo as $promo)
|
||||
<option value="{{ $promo->id }}">{{ $promo->nombre ?? '' }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">Pantallas:</label>
|
||||
|
||||
<div class="grid grid-cols-6 gap-2 text-left mb-4">
|
||||
<div>
|
||||
<label for="rol_id" class="text-gray-500 text-sm">Rol</label>
|
||||
<select id="rol_id" name="rol_id" wire:model="rol_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="" selected>Roles</option>
|
||||
@foreach ($roles as $rol)
|
||||
<option value="{{ $rol->id }}">{{ $rol->nombre ?? '' }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label id="promo_id" class="text-gray-500 text-sm">Plan</label>
|
||||
<select id="promo_id" name="promo_id" wire:model="promo_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option value="" selected>Planes</option>
|
||||
@foreach ($promociones as $promocion)
|
||||
<option value="{{ $promocion->id }}">{{ $promocion?->promocion?->descripcion ?? '' }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="precio" class="text-gray-500 text-sm">Precio</label>
|
||||
<input type="number" id="precio" name="precio" wire:model.debounce.300ms="precio" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div>
|
||||
<label for="utilidad" class="text-gray-500 text-sm">Utilidad</label>
|
||||
<input disabled type="number" id="utilidad" name="utilidad" wire:model="utilidad" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div class="flex m-auto items-center">
|
||||
<label for="estado" class="text-gray-500 text-sm mr-2">Activa</label>
|
||||
<input type="checkbox" id="estado" name="estado" wire:model="estado" checked class="border-2 border-neutral-200 focus:ring-0 shadow apperance-none focus:border-neutral-300 text-[#B221FD] leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div class="mb-3 mt-3 flex justify-end">
|
||||
<button wire:click="guardarTarifaPromo" type="button" class="inline-flex justify-center w-full md:w-auto rounded-md border border-transparent px-4 py-1 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Añadir</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="overflow-y-auto max-h-48">
|
||||
<table class="w-full sm-w-[20rem] text-center mt-4 border-separate border-spacing-y-2 mb-4">
|
||||
<thead class="font-normal bg-[#000029] text-white h-9">
|
||||
<tr class="text-left">
|
||||
<th class="rounded-l-lg font-normal pl-[1rem]">Estado</th>
|
||||
<th class="font-normal pl-[1rem]">Rol</th>
|
||||
<th class="font-normal pl-[1rem]">Valor</th>
|
||||
<th class="font-normal pl-[1rem]">Utilidad</th>
|
||||
<th class="font-normal pl-[1rem]"></th>
|
||||
<th class="rounded-r-lg font-normal w-[1rem]"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-gray-500 select-none">
|
||||
@if (!empty($tarifas))
|
||||
@foreach ($tarifas as $tarifa)
|
||||
<tr class="border-gray-200 text-left w-full pl-4">
|
||||
<td class="pl-[1rem]">
|
||||
@if ($tarifa->visible == 'activo')
|
||||
<div class="bg-green-500 rounded-full w-3 h-3"></div>
|
||||
@else
|
||||
<div class="bg-red-500 rounded-full w-3 h-3"></div>
|
||||
@endif
|
||||
</td>
|
||||
<td class="pl-[1rem]">{{ $tarifa->rol->nombre ?? '' }}</td>
|
||||
<td class="pl-[1rem]">{{ number_format($tarifa->precio) ?? 0 }}</td>
|
||||
<td class="pl-[1rem]">{{ number_format($tarifa->utilidad) ?? 0 }}</td>
|
||||
<td class="pl-[1rem]">
|
||||
{{-- <button wire:click="editarTarifaPromo({{ $tarifa }})" class="justify-center flex px-3 py-2 rounded-lg text-xs cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Editar</button> --}}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="bg-white px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse sm:justify-evenly gap-5 mt-4">
|
||||
<span>
|
||||
<button x-on:click="modTarifasPromo=false" wire:click="" type="button"
|
||||
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 text-white bg-[#585858] hover:bg-[#3a3a3a] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Cerrar</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
@if (auth()->user()->rol->nombre === 'super' || auth()->user()->rol->nombre === 'administrador')
|
||||
<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.
|
||||
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" />
|
||||
@@ -184,29 +184,22 @@
|
||||
<option value="" selected>Tarifas</option>
|
||||
@if (!empty($consulta_tarifas))
|
||||
@foreach ($consulta_tarifas as $consulta_tarifa)
|
||||
@if ($consulta_tarifa->servicio && $consulta_tarifa->servicio->por_tiempo)
|
||||
<option value="{{ $consulta_tarifa->id }}">
|
||||
{{ $consulta_tarifa->servicio->nombre ?? '' }}:
|
||||
{{ $consulta_tarifa->dias ?? '' }}
|
||||
{{ $consulta_tarifa->dias == 1 ? 'día' : 'días' }}
|
||||
</option>
|
||||
@elseif ($consulta_tarifa->servicio)
|
||||
<option value="{{ $consulta_tarifa->id }}">
|
||||
{{ $consulta_tarifa->servicio->nombre ?? '' }}:
|
||||
{{ $consulta_tarifa->pantallas ?? '' }}
|
||||
{{ $consulta_tarifa->pantallas == 1 ? 'pantalla' : 'pantallas' }} -
|
||||
{{ $consulta_tarifa->dias ?? '' }}
|
||||
{{ $consulta_tarifa->dias == 1 ? 'día' : 'días' }}
|
||||
</option>
|
||||
@endif
|
||||
|
||||
@if ($consulta_tarifa->servicio && $consulta_tarifa->servicio->por_tiempo)
|
||||
<option value="{{ $consulta_tarifa->id }}">
|
||||
{{ $consulta_tarifa->servicio->nombre ?? '' }}: {{ $consulta_tarifa->dias ?? '' }} {{ $consulta_tarifa->dias == 1 ? 'día' : 'días' }}
|
||||
</option>
|
||||
@elseif ($consulta_tarifa->servicio)
|
||||
<option value="{{ $consulta_tarifa->id }}">
|
||||
{{ $consulta_tarifa->servicio->nombre ?? '' }}: {{ $consulta_tarifa->pantallas ?? '' }} {{ $consulta_tarifa->pantallas == 1 ? 'pantalla' : 'pantallas' }} - {{ $consulta_tarifa->dias ?? '' }} {{ $consulta_tarifa->dias == 1 ? 'día' : 'días' }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
<div class="w-[7rem]">
|
||||
<input placeholder="$25000" type="number" id="precioTarifasGestion"
|
||||
wire:model="precioTarifasGestion" min="0"
|
||||
wire:model.debounce.500ms="precioTarifasGestion" min="0"
|
||||
class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
</div>
|
||||
<div class="w-[5rem] self-center justify-self-center mx-auto">
|
||||
@@ -223,9 +216,14 @@
|
||||
<p class="font-semibold text-gray-500">
|
||||
Utilidad
|
||||
</p>
|
||||
<input placeholder="$12000" type="number" id="utilidad" wire:model="utilidad"
|
||||
min="0"
|
||||
class="w-1/2 border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
|
||||
|
||||
@if (auth()->user()->rol->nombre === 'super' || auth()->user()->rol->nombre === 'administrador')
|
||||
<input placeholder="$12000" type="number" id="utilidad" wire:model="utilidad" min="0" class="w-1/2 border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
@else
|
||||
<input disabled placeholder="$12000" type="number" id="utilidad" wire:model="utilidad" min="0" class="w-1/2 border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
@endif
|
||||
|
||||
<span>
|
||||
<button wire:click="addtarifas" type="button"
|
||||
class="inline-flex justify-center w-full md:w-auto rounded-md border border-transparent px-4 py-1 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Añadir</button>
|
||||
@@ -366,9 +364,11 @@
|
||||
<p class="font-semibold text-gray-500">
|
||||
Utilidad
|
||||
</p>
|
||||
<input placeholder="$12000" type="number" id="utilidad" wire:model="utilidad"
|
||||
min="0"
|
||||
class="w-1/2 border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
@if (auth()->user()->rol->nombre === 'super' || auth()->user()->rol->nombre === 'administrador')
|
||||
<input placeholder="$12000" type="number" id="utilidad" wire:model="utilidad" min="0" class="w-1/2 border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
@else
|
||||
<input disabled placeholder="$12000" type="number" id="utilidad" wire:model="utilidad" min="0" class="w-1/2 border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
||||
@endif
|
||||
<span>
|
||||
<button wire:click="addpromos" type="button"
|
||||
class="inline-flex justify-center w-full md:w-auto rounded-md border border-transparent px-4 py-1 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Añadir</button>
|
||||
|
||||
+1
-1
@@ -44,12 +44,12 @@ Route::middleware(["auth"])->group(function () {
|
||||
Route::any('/usuarios', [MenuController::class, 'showusuarios'])->name('usuarios');
|
||||
Route::any('/roles', [MenuController::class, 'showroles'])->name('roles');
|
||||
Route::any('/tarifas', [MenuController::class, 'showtarifas'])->name('tarifas');
|
||||
Route::any('/planes', [MenuController::class, 'showplanes'])->name('planes');
|
||||
});
|
||||
|
||||
// Editores
|
||||
Route::middleware(["auth", "solo_usuario_editor"])->group(function () {
|
||||
Route::get('/import', [MenuController::class, 'showimport'])->name('import');
|
||||
Route::any('/planes', [MenuController::class, 'showplanes'])->name('planes');
|
||||
});
|
||||
|
||||
//Administradores
|
||||
|
||||
Reference in New Issue
Block a user