solo asignar cuentas por pantallas

This commit is contained in:
Lizandro Guarnizo
2024-10-07 17:36:33 -05:00
parent 0921d720f9
commit e7a397ebd2
+25 -25
View File
@@ -320,37 +320,37 @@ class ShowPlanes extends Component
$servicio_id = $cuenta_renovar->servicio->id; $servicio_id = $cuenta_renovar->servicio->id;
$servicioPantallas = Servicio::find($servicio_id)->pantallas; $servicioPantallas = Servicio::find($servicio_id)->pantallas;
$cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $servicio_id)->take($servicioPantallas)->get(); if($this->estado === 'activo'){
$cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $servicio_id)->take($servicioPantallas)->get();
foreach ($cuentasPendientes as $i => $cuentaPendiente) { foreach ($cuentasPendientes as $i => $cuentaPendiente) {
$servicioName = $cuentaPendiente->servicio->nombre; $servicioName = $cuentaPendiente->servicio->nombre;
$historial_cuenta = new Historial_cuenta(); $historial_cuenta = new Historial_cuenta();
$historial_cuenta->historial_id = $cuentaPendiente->historial_id; $historial_cuenta->historial_id = $cuentaPendiente->historial_id;
$historial_cuenta->cuenta_id = $id; $historial_cuenta->cuenta_id = $id;
$historial_cuenta->perfil = $i + 1; $historial_cuenta->perfil = $i + 1;
$historial_cuenta->save(); $historial_cuenta->save();
$cuentaPendiente->update(['estado' => 'cerrado']); $cuentaPendiente->update(['estado' => 'cerrado']);
$cuentaPendiente->historial->vendedor->notify(new NotificacionPendiente($servicioName)); $cuentaPendiente->historial->vendedor->notify(new NotificacionPendiente($servicioName));
$consulta = new Notificacion(); $consulta = new Notificacion();
$consulta->remitente_id = Auth::user()->id; $consulta->remitente_id = Auth::user()->id;
$consulta->destinatario_id = $historial_cuenta->historial->vendedor_id; $consulta->destinatario_id = $historial_cuenta->historial->vendedor_id;
$consulta->titulo = "Licencia asignada para $servicioName"; $consulta->titulo = "Licencia asignada para $servicioName";
$consulta->descripcion = 'La licencia de ' . $servicioName . ' ha sido activada y ahora puedes utilizar tu cuenta sin problemas. Tus credenciales son: correo: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password; $consulta->descripcion = 'La licencia de ' . $servicioName . ' ha sido activada y ahora puedes utilizar tu cuenta sin problemas. Tus credenciales son: correo: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password;
$consulta->estado = true; $consulta->estado = true;
$consulta->todos = false; $consulta->todos = false;
$consulta->save(); $consulta->save();
$logsGeneral = new Log_general(); $logsGeneral = new Log_general();
$logsGeneral->user_id = $historial_cuenta->historial->vendedor_id; $logsGeneral->user_id = $historial_cuenta->historial->vendedor_id;
$logsGeneral->detalle = 'Se asigno una cuenta ' . $servicioName . ', con credenciales: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password . ' Que se encontraba en estado pendiente'; $logsGeneral->detalle = 'Se asigno una cuenta ' . $servicioName . ', con credenciales: ' . $historial_cuenta->cuenta->correo . ' contraseña: ' . $historial_cuenta->cuenta->password . ' Que se encontraba en estado pendiente';
$logsGeneral->save(); $logsGeneral->save();
}
} }
$this->alert('success', 'Cuenta renovada y liberada correctamente!', [ $this->alert('success', 'Cuenta renovada y liberada correctamente!', [
'position' => 'top' 'position' => 'top'
]); ]);
@@ -464,7 +464,7 @@ class ShowPlanes extends Component
if ($this->estado === 'activo') { if ($this->estado === 'activo') {
$servicioPantallas = Servicio::find($this->servicio_newCuenta)->pantallas; $servicioPantallas = Servicio::find($this->servicio_newCuenta)->pantallas;
$cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $this->servicio_newCuenta)->take($servicioPantallas)->get(); $cuentasPendientes = ('estado', 'pendiente')->where('servicio_id', $this->servicio_newCuenta)->take($servicioPantallas)->get();
foreach ($cuentasPendientes as $i => $cuentaPendiente) { foreach ($cuentasPendientes as $i => $cuentaPendiente) {
$servicioName = $cuentaPendiente->servicio->nombre; $servicioName = $cuentaPendiente->servicio->nombre;