nuevo formulario
This commit is contained in:
@@ -38,6 +38,7 @@ class ShowServicio extends Component
|
||||
public $url;
|
||||
public $precio;
|
||||
public $renovacion = false;
|
||||
public $dgo = false;
|
||||
|
||||
protected $rules = [
|
||||
'nombre_servicio' => 'required',
|
||||
@@ -110,6 +111,7 @@ class ShowServicio extends Component
|
||||
$servicio->url = $this->url;
|
||||
$servicio->renovacion = $this->renovacion;
|
||||
$servicio->precio = $this->precio;
|
||||
$servicio->dgo = $this->dgo;
|
||||
$servicio->save();
|
||||
|
||||
$this->alert('success', 'Servicio creado correctamente!', [
|
||||
@@ -141,6 +143,7 @@ class ShowServicio extends Component
|
||||
$this->url = $consulta_servicios->url;
|
||||
$this->renovacion = $consulta_servicios->renovacion == 1 ? true : false;
|
||||
$this->precio = $consulta_servicios->precio;
|
||||
$this->dgo = $consulta_servicios->dgo == 1 ? true : false;
|
||||
}
|
||||
public function guardar()
|
||||
{
|
||||
@@ -200,7 +203,8 @@ class ShowServicio extends Component
|
||||
'ver_url' => $this->ver_url,
|
||||
'url' => $this->url,
|
||||
'renovacion' => $this->renovacion == 1 ? true : false,
|
||||
'precio'=> $this->precio
|
||||
'precio'=> $this->precio,
|
||||
'dgo' => $this->dgo
|
||||
]);
|
||||
|
||||
$this->serviciosEditar = false;
|
||||
@@ -270,6 +274,7 @@ class ShowServicio extends Component
|
||||
$this->completa = null;
|
||||
$this->tiempo = null;
|
||||
$this->renovacion = null;
|
||||
$this->dgo = null;
|
||||
$this->servicio = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Models\Log_general;
|
||||
use App\Models\Promociones;
|
||||
use App\Models\Saldo;
|
||||
use App\Models\Servicio;
|
||||
use App\Models\CompatibilidadDgo;
|
||||
use App\Models\Tarifas;
|
||||
use App\Models\User;
|
||||
use App\Models\Usuario_tarifa;
|
||||
@@ -65,6 +66,10 @@ class ShowServicios extends Component
|
||||
public $utilidad;
|
||||
public $tp = false;
|
||||
public $usuario_actual;
|
||||
public $dgo = false;
|
||||
public $tipo_dispositivo;
|
||||
public $marca_dispositivo;
|
||||
public $ciudad;
|
||||
|
||||
use LivewireAlert;
|
||||
protected $rules = [
|
||||
@@ -156,6 +161,7 @@ class ShowServicios extends Component
|
||||
$this->valor_tarjetaPlan = ($usuario_tarifa) ? $usuario_tarifa->precio : $tarifa_seleccionada->valor;
|
||||
//Si tiene tarifa personalizada toma la utilidad, si no tiene toma la utilidad de la tarifa.
|
||||
$this->utilidad = ($usuario_tarifa) ? $usuario_tarifa->utilidad : $tarifa_seleccionada->utilidad;
|
||||
$this->dgo = $servicio_tarifa->dgo == 1 ? true : false;
|
||||
//Fecha de vencimiento del servicio.
|
||||
$this->fechaFinal = $this->fechaActual->addDay($tarifa_seleccionada->dias);
|
||||
|
||||
@@ -223,6 +229,9 @@ class ShowServicios extends Component
|
||||
$this->cantidad_tarjetaPlan = 1;
|
||||
$this->tarjetaPlan = false;
|
||||
$this->tarifa_id = '';
|
||||
$this->tipo_dispositivo = null;
|
||||
$this->marca_dispositivo = null;
|
||||
$this->ciudad = null;
|
||||
}
|
||||
|
||||
public function notificacionPocas($servicio, $restantes)
|
||||
@@ -269,6 +278,14 @@ class ShowServicios extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->dgo) {
|
||||
$this->validate([
|
||||
'tipo_dispositivo' => 'required',
|
||||
'marca_dispositivo' => 'required',
|
||||
'ciudad' => 'required',
|
||||
]);
|
||||
}
|
||||
|
||||
$cantidad_solicitada = (int) $this->cantidad_tarjetaPlan * (int) $this->pantallas_tarjetaPlan;
|
||||
$total_valor = (int) $this->valor_tarjetaPlan * (int) $this->cantidad_tarjetaPlan;
|
||||
$utilidad_total = (int) $this->utilidad * (int) $this->cantidad_tarjetaPlan;
|
||||
@@ -575,10 +592,22 @@ class ShowServicios extends Component
|
||||
}
|
||||
|
||||
|
||||
if ($this->dgo) {
|
||||
CompatibilidadDgo::create([
|
||||
'historial_id' => $historial->id,
|
||||
'tipo_dispositivo' => $this->tipo_dispositivo,
|
||||
'marca_dispositivo' => $this->marca_dispositivo,
|
||||
'ciudad' => $this->ciudad,
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
$this->tarjetaPlan = false;
|
||||
$this->cantidad_tarjetaPlan = 1;
|
||||
$this->tipo_dispositivo = null;
|
||||
$this->marca_dispositivo = null;
|
||||
$this->ciudad = null;
|
||||
|
||||
// si todo salió bien → salir del bucle
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CompatibilidadDgo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'historial_id',
|
||||
'tipo_dispositivo',
|
||||
'marca_dispositivo',
|
||||
'ciudad',
|
||||
];
|
||||
|
||||
public function historial()
|
||||
{
|
||||
return $this->belongsTo(Historiale::class);
|
||||
}
|
||||
}
|
||||
@@ -52,4 +52,9 @@ class Historiale extends Model
|
||||
{
|
||||
return $this->belongsToMany(Cuentas::class, 'logs', 'historial_id', 'cuenta_id');
|
||||
}
|
||||
|
||||
public function compatibilidadDgo()
|
||||
{
|
||||
return $this->hasOne(CompatibilidadDgo::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class Servicio extends Model
|
||||
'por_tiempo',
|
||||
'renovacion',
|
||||
'precio',
|
||||
'ubicacion'
|
||||
|
||||
'ubicacion',
|
||||
'dgo',
|
||||
];
|
||||
|
||||
public function promocion(){
|
||||
@@ -41,4 +41,9 @@ class Servicio extends Model
|
||||
public function cuentas(){
|
||||
return $this ->hasMany(Cuentas::class,'servicio_id');
|
||||
}
|
||||
|
||||
public function compatibilidadDgo()
|
||||
{
|
||||
return $this->hasMany(CompatibilidadDgo::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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('servicios', function (Blueprint $table) {
|
||||
$table->boolean('dgo')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('servicios', function (Blueprint $table) {
|
||||
$table->dropColumn('dgo');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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::create('compatibilidad_dgos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('historial_id')->constrained()->onDelete('cascade');
|
||||
$table->string('tipo_dispositivo');
|
||||
$table->string('marca_dispositivo');
|
||||
$table->string('ciudad');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('compatibilidad_dgos');
|
||||
}
|
||||
};
|
||||
@@ -88,6 +88,7 @@
|
||||
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Contraseña de perfiles</th>
|
||||
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">URL</th>
|
||||
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Renovación</th>
|
||||
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">DGO</th>
|
||||
<th class="font-normal w-1/12 pl-[1rem] sm:pr-[2rem]">Precio</th>
|
||||
<th class="rounded-r-lg font-normal pr-[1rem] pl-[1rem] sm:pr-[2rem] sm:pl-[2rem] w-1/11">
|
||||
</th>
|
||||
@@ -157,6 +158,15 @@
|
||||
@endif
|
||||
|
||||
</td>
|
||||
<td class="pl-[1rem] sm:pl-[2rem] text-center border-x">
|
||||
@if ($servicio->dgo)
|
||||
<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">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
@endif
|
||||
</td>
|
||||
<td class="pl-[1rem] sm:pl-[2rem] text-center border-x">
|
||||
{{ $servicio->precio ?? '' }}
|
||||
|
||||
@@ -282,6 +292,8 @@
|
||||
<input type="checkbox" name="solo_tiempo" id="solo_tiempo" wire:model="tiempo">
|
||||
<label for="renovacion" class=" text-gray-700 text-sm font-bold mb-2 ">Renovación</label>
|
||||
<input type="checkbox" name="renovacion" id="renovacion" wire:model="renovacion">
|
||||
<label for="dgo" class=" text-gray-700 text-sm font-bold mb-2 ">Requiere DGO</label>
|
||||
<input type="checkbox" name="dgo" id="dgo" wire:model="dgo">
|
||||
</div>
|
||||
|
||||
<div x-transition x-show="!tiempo">
|
||||
@@ -448,6 +460,8 @@
|
||||
<input type="checkbox" name="solo_tiempo" id="solo_tiempo" wire:model="tiempo">
|
||||
<label for="renovacion" class=" text-gray-700 text-sm font-bold mb-2 ">Renovación</label>
|
||||
<input type="checkbox" name="renovacion" id="renovacion" wire:model="renovacion">
|
||||
<label for="dgo" class=" text-gray-700 text-sm font-bold mb-2 ">Requiere DGO</label>
|
||||
<input type="checkbox" name="dgo" id="dgo" wire:model="dgo">
|
||||
</div>
|
||||
|
||||
<div x-transition x-show="!tiempo">
|
||||
|
||||
@@ -275,6 +275,97 @@
|
||||
|
||||
{{ $disponibles < 0 ? 0 : (int) $disponibles }}
|
||||
{{ $disponibles == 1 ? 'plan disponible' : 'planes disponibles' }} para esta cantidad </div>
|
||||
@if ($dgo)
|
||||
<div class="mb-4 border-t pt-4">
|
||||
<p class="text-sm font-bold mb-2">Compatibilidad DGO</p>
|
||||
<p class="text-xs text-gray-400 mb-3">Identifica desde qué dispositivo accederás</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">Tipo de dispositivo:</label>
|
||||
<input list="lista-tipos" wire:model.lazy="tipo_dispositivo"
|
||||
class="border-2 border-neutral-200 rounded-[0.8rem] shadow w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||
placeholder="Buscar o escribir...">
|
||||
<datalist id="lista-tipos">
|
||||
<option value="Navegador Web (Chrome, Firefox, Edge)">
|
||||
<option value="Celular Android">
|
||||
<option value="Tablet Android">
|
||||
<option value="iPhone">
|
||||
<option value="iPad">
|
||||
<option value="Apple TV">
|
||||
<option value="Samsung TV">
|
||||
<option value="LG TV">
|
||||
<option value="Android TV">
|
||||
<option value="Amazon Fire TV">
|
||||
<option value="Chromecast">
|
||||
<option value="Roku">
|
||||
<option value="TCL TV">
|
||||
<option value="TV VIDAA">
|
||||
<option value="TV Zeasn">
|
||||
<option value="Otro">
|
||||
</datalist>
|
||||
@error('tipo_dispositivo')
|
||||
<span class="text-red-400 text-sm">Requerido*</span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">Marca del dispositivo:</label>
|
||||
<input list="lista-marcas" wire:model.lazy="marca_dispositivo"
|
||||
class="border-2 border-neutral-200 rounded-[0.8rem] shadow w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||
placeholder="Buscar o escribir...">
|
||||
<datalist id="lista-marcas">
|
||||
<option value="Samsung">
|
||||
<option value="LG">
|
||||
<option value="Apple">
|
||||
<option value="TCL">
|
||||
<option value="Kalley">
|
||||
<option value="Hyundai">
|
||||
<option value="Challenger">
|
||||
<option value="Xiaomi">
|
||||
<option value="Huawei">
|
||||
<option value="Sony">
|
||||
<option value="Panasonic">
|
||||
<option value="Philips">
|
||||
<option value="Hisense">
|
||||
<option value="Otro">
|
||||
</datalist>
|
||||
@error('marca_dispositivo')
|
||||
<span class="text-red-400 text-sm">Requerido*</span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">Ciudad:</label>
|
||||
<input list="lista-ciudades" wire:model.lazy="ciudad"
|
||||
class="border-2 border-neutral-200 rounded-[0.8rem] shadow w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||
placeholder="Buscar o escribir...">
|
||||
<datalist id="lista-ciudades">
|
||||
<option value="Bogotá">
|
||||
<option value="Medellín">
|
||||
<option value="Cali">
|
||||
<option value="Barranquilla">
|
||||
<option value="Cartagena">
|
||||
<option value="Cúcuta">
|
||||
<option value="Bucaramanga">
|
||||
<option value="Pereira">
|
||||
<option value="Santa Marta">
|
||||
<option value="Ibagué">
|
||||
<option value="Manizales">
|
||||
<option value="Villavicencio">
|
||||
<option value="Pasto">
|
||||
<option value="Armenia">
|
||||
<option value="Neiva">
|
||||
<option value="Sincelejo">
|
||||
<option value="Valledupar">
|
||||
<option value="Montería">
|
||||
</datalist>
|
||||
@error('ciudad')
|
||||
<span class="text-red-400 text-sm">Requerido*</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mb-4">
|
||||
<p class="text-xs text-gray-400 text-center">
|
||||
|
||||
@@ -436,6 +527,15 @@
|
||||
{!! $msj->msj_compra !!}
|
||||
</div>
|
||||
|
||||
@if ($cuentas && $cuentas->compatibilidadDgo)
|
||||
<div class="mb-3 p-3 bg-gray-50 rounded-lg border">
|
||||
<p class="text-sm font-bold mb-1">Compatibilidad DGO</p>
|
||||
<p class="text-xs">Tipo: <span class="font-semibold">{{ $cuentas->compatibilidadDgo->tipo_dispositivo }}</span></p>
|
||||
<p class="text-xs">Marca: <span class="font-semibold">{{ $cuentas->compatibilidadDgo->marca_dispositivo }}</span></p>
|
||||
<p class="text-xs">Ciudad: <span class="font-semibold">{{ $cuentas->compatibilidadDgo->ciudad }}</span></p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div>
|
||||
<p>
|
||||
Información de cuentas:
|
||||
|
||||
Reference in New Issue
Block a user