|
|
@@ -782,6 +782,11 @@ class EventoController extends Controller {
|
|
|
->indexBy("tag")
|
|
|
->column();
|
|
|
|
|
|
+ $dependencias = Dependencia::find()
|
|
|
+ ->select("nombre")
|
|
|
+ ->indexBy("id")
|
|
|
+ ->column();
|
|
|
+
|
|
|
$totalEventos = count($eventos);
|
|
|
if ($totalEventos === 0) {
|
|
|
# ¿Si no hubo eventos en el período de tiempo también hay que avisar?
|
|
|
@@ -859,7 +864,7 @@ class EventoController extends Controller {
|
|
|
if (!$notificacion->save()) {
|
|
|
return (new Respuesta($notificacion))
|
|
|
->mensaje("Hubo un problema al generar la notificación");
|
|
|
- }
|
|
|
+ } // */
|
|
|
# TODO: Revisar si es necesario consultar la información del modelo
|
|
|
# $notificacion->refresh();
|
|
|
|
|
|
@@ -871,6 +876,7 @@ class EventoController extends Controller {
|
|
|
$notificacionUsuario->idUsuario = $usuario['id'];
|
|
|
$notificacionUsuario->nombre = $usuario['nombreUsuario'];
|
|
|
$notificacionUsuario->telefono = $usuario['telefono'];
|
|
|
+ $notificacionUsuario->plantilla = Notificacion::PLANTILLA_EVENTO;
|
|
|
|
|
|
# Es mejor guardar el valor del count en lugar de evaluarlo multiples veces
|
|
|
$totalParticipaciones = count($usuario["eventosParticipo"]);
|
|
|
@@ -911,6 +917,11 @@ class EventoController extends Controller {
|
|
|
$dependenciaLider = DependenciaLider::find()
|
|
|
->andWhere(["idDependencia" => $id]);
|
|
|
|
|
|
+ $nombreDependencia = "";
|
|
|
+ if(isset($dependencias[$id])) {
|
|
|
+ $nombreDependencia = $dependencias[$id];
|
|
|
+ }
|
|
|
+
|
|
|
foreach ($dependenciaLider->each() as $lider) {
|
|
|
$usuario = Usuario::findOne($lider["idUsuario"]);
|
|
|
$notificacionUsuario = new NotificacionUsuario();
|
|
|
@@ -919,15 +930,15 @@ class EventoController extends Controller {
|
|
|
$notificacionUsuario->idUsuario = $usuario->id;
|
|
|
$notificacionUsuario->nombre = $usuario->nombre;
|
|
|
$notificacionUsuario->telefono = $usuario->telefono;
|
|
|
+ $notificacionUsuario->plantilla = Notificacion::PLANTILLA_LIDER_EVENTO;
|
|
|
|
|
|
- # Es mejor guardar el valor del count en lugar de evaluarlo multiples veces
|
|
|
$totalParticipaciones = $dependencia["eventosParticipo"];
|
|
|
$totalEventosDependencia = $dependencia["eventosParticipo"] + $dependencia["eventosFaltantes"];
|
|
|
|
|
|
$parametros = [
|
|
|
[
|
|
|
"type" => "text",
|
|
|
- "text" => "{$totalParticipaciones}/{$totalEventosDependencia} eventos"
|
|
|
+ "text" => "*{$nombreDependencia}* fue {$totalParticipaciones}/{$totalEventosDependencia} eventos"
|
|
|
],
|
|
|
];
|
|
|
|
|
|
@@ -957,6 +968,18 @@ class EventoController extends Controller {
|
|
|
}
|
|
|
|
|
|
$notificacion->estatus = Notificacion::ESTATUS_NUEVO;
|
|
|
+ $domingo = 0;
|
|
|
+ $d = new \DateTime('now', new \DateTimeZone('America/Hermosillo'));
|
|
|
+ $fecha = strtotime('now');
|
|
|
+ $dia = intval($d->format("w"));
|
|
|
+ if($dia !== $domingo) {
|
|
|
+ $d = new \DateTime('next Sunday', new \DateTimeZone('America/Hermosillo'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $d->setTime(18, 0, 0, 0);
|
|
|
+
|
|
|
+ $siguienteDomingo = $d->format(\DateTime::ISO8601);
|
|
|
+ $notificacion->envio = $siguienteDomingo;
|
|
|
|
|
|
$notificacion->save();
|
|
|
|