editar tarifas promociones
This commit is contained in:
@@ -61,7 +61,9 @@ class ShowUsuarios extends Component
|
||||
public $usuario_nombre;
|
||||
public $precioTarifa;
|
||||
public $tarifasGestion;
|
||||
public $estadoTarifa;
|
||||
|
||||
public $estadoTarifa = true;
|
||||
|
||||
public $usuarioGestion_id;
|
||||
public $precioTarifasGestion;
|
||||
public $buscar_servicio;
|
||||
@@ -81,7 +83,8 @@ class ShowUsuarios extends Component
|
||||
public $modTarifas;
|
||||
public $modalSaldoDesc;
|
||||
|
||||
|
||||
public $editarTarifaRol = false;
|
||||
public $informacionTarifaRol;
|
||||
|
||||
protected $rules = [
|
||||
'nombre' => 'required',
|
||||
@@ -259,6 +262,54 @@ class ShowUsuarios extends Component
|
||||
|
||||
$this->editar = true;
|
||||
}
|
||||
|
||||
public function editarTarifa($tarifa)
|
||||
{
|
||||
$this->editarTarifaRol = true;
|
||||
|
||||
$this->informacionTarifaRol = $tarifa;
|
||||
|
||||
$this->roles_modTarifas = $tarifa['rol_id'];
|
||||
$this->precio_modTarifas = $tarifa['precio'];
|
||||
$this->utilidad = $tarifa['utilidad'];
|
||||
$this->estadoTarifa = $tarifa['visible'] == 'activo' ? 1 : 0;
|
||||
$this->servicio_modTarifas = $tarifa['promocion_id'];
|
||||
}
|
||||
|
||||
public function actualizarTarifaRol($id)
|
||||
{
|
||||
if (empty($this->roles_modTarifas)) {
|
||||
$this->alert('warning', '¡Seleccione un rol!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
if (empty($this->precio_modTarifas)) {
|
||||
$this->alert('warning', '¡Coloque un precio!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
if (empty($this->utilidad)) {
|
||||
$this->alert('warning', '¡Coloque una utilidad!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
|
||||
TarifaPromo::find($id)->update([
|
||||
'precio' => $this->precio_modTarifas,
|
||||
'utilidad' => $this->utilidad,
|
||||
'visible' => $this->estadoTarifa == 1 ? 'activo' : 'inactivo',
|
||||
'rol_id' => $this->roles_modTarifas,
|
||||
'promocion_id' => $this->servicio_modTarifas
|
||||
]);
|
||||
|
||||
$this->alert('success', 'Tarifa actualizada con exito!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
$this->editarTarifaRol = false;
|
||||
}
|
||||
|
||||
|
||||
public function actualizar()
|
||||
{
|
||||
$this->validate(
|
||||
@@ -324,7 +375,7 @@ class ShowUsuarios extends Component
|
||||
$usuarioTarifa->utilidad = $this->utilidad;
|
||||
$usuarioTarifa->tarifa_id = $this->tarifasGestion;
|
||||
$usuarioTarifa->usuario_id = $this->usuarioGestion_id;
|
||||
$usuarioTarifa->visible = $this->estadoTarifa ? 'false' : 'true';
|
||||
$usuarioTarifa->visible = $this->estadoTarifa ? 'activo' : 'inactivo';
|
||||
$usuarioTarifa->save();
|
||||
|
||||
$this->alert('success', '¡Tarifas del usuario actualizadas correctamente!', [
|
||||
@@ -516,38 +567,42 @@ class ShowUsuarios extends Component
|
||||
/* ------------- ACTUALIZAR ------------- */
|
||||
public function updateTarifas()
|
||||
{
|
||||
$consulta_existe = TarifaPromo::where('promocion_id', $this->servicio_modTarifas)
|
||||
->where('rol_id', $this->roles_modTarifas)
|
||||
->exists();
|
||||
|
||||
$consulta_existe = TarifaPromo::where('promocion_id', $this->servicio_modTarifas)->where('rol_id', $this->roles_modTarifas)->get();
|
||||
//dd($consulta_existe);
|
||||
|
||||
if (empty($this->servicio_modTarifas)) {
|
||||
$this->alert('warning', 'Seleccione una promocion!', [
|
||||
if ($consulta_existe) {
|
||||
$this->alert('warning', '¡Esta tarifa ya existe!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
} elseif (empty($this->servicio_modTarifas)) {
|
||||
$this->alert('warning', '¡Seleccione una promocion!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
} elseif (empty($this->precio_modTarifas)) {
|
||||
$this->alert('warning', '¡Coloque un precio!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
} elseif (empty($this->utilidad)) {
|
||||
$this->alert('warning', '¡Coloque la utilidad!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
} else {
|
||||
$tarifa = new TarifaPromo;
|
||||
$tarifa->utilidad = $this->utilidad;
|
||||
$tarifa->promocion_id = $this->servicio_modTarifas;
|
||||
$tarifa->rol_id = $this->roles_modTarifas;
|
||||
$tarifa->precio = $this->precio_modTarifas;
|
||||
$tarifa->visible = $this->estadoTarifa ? 'activo' : 'inactivo';
|
||||
$tarifa->save();
|
||||
|
||||
if ($consulta_existe->count() > 0) {
|
||||
|
||||
$this->alert('warning', 'Esta tarifa ya existe!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
} else {
|
||||
$tarifa = new TarifaPromo;
|
||||
$tarifa->precio = $this->precio_modTarifas;
|
||||
$tarifa->utilidad = $this->utilidad;
|
||||
$tarifa->promocion_id = $this->servicio_modTarifas;
|
||||
$tarifa->rol_id = $this->roles_modTarifas;
|
||||
$tarifa->save();
|
||||
|
||||
$this->alert('success', 'Tarifas actualizadas correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
$this->alert('success', '¡Tarifas actualizadas correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------- ELIMINAR ------------- */
|
||||
|
||||
public function eliminarModTarifa($id)
|
||||
{
|
||||
TarifaPromo::where('id', $id)->delete();
|
||||
|
||||
Reference in New Issue
Block a user