nuevo formulario
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user