|
@@ -429,7 +429,7 @@ class EventoController extends Controller {
|
|
|
$ultimaFecha = null;
|
|
$ultimaFecha = null;
|
|
|
$limite = 100; // 1000;
|
|
$limite = 100; // 1000;
|
|
|
$continuar = true;
|
|
$continuar = true;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$fechaActual = new DateTime();
|
|
$fechaActual = new DateTime();
|
|
|
$finFirebase = new Timestamp($fechaActual);
|
|
$finFirebase = new Timestamp($fechaActual);
|
|
|
|
|
|
|
@@ -798,7 +798,7 @@ class EventoController extends Controller {
|
|
|
->indexBy("tag")
|
|
->indexBy("tag")
|
|
|
->column();
|
|
->column();
|
|
|
|
|
|
|
|
- $dependencias = Dependencia::find()
|
|
|
|
|
|
|
+ $dependencias = Dependencia::find()
|
|
|
->select("nombre")
|
|
->select("nombre")
|
|
|
->indexBy("id")
|
|
->indexBy("id")
|
|
|
->column();
|
|
->column();
|
|
@@ -934,7 +934,7 @@ class EventoController extends Controller {
|
|
|
->andWhere(["idDependencia" => $id]);
|
|
->andWhere(["idDependencia" => $id]);
|
|
|
|
|
|
|
|
$nombreDependencia = "";
|
|
$nombreDependencia = "";
|
|
|
- if(isset($dependencias[$id])) {
|
|
|
|
|
|
|
+ if (isset($dependencias[$id])) {
|
|
|
$nombreDependencia = $dependencias[$id];
|
|
$nombreDependencia = $dependencias[$id];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -966,7 +966,7 @@ class EventoController extends Controller {
|
|
|
} else if ($totalParticipaciones > 0) {
|
|
} else if ($totalParticipaciones > 0) {
|
|
|
$parametros[] = [
|
|
$parametros[] = [
|
|
|
"type" => "text",
|
|
"type" => "text",
|
|
|
- "text" => ", gracias por tu participación. Vamos por el 100% de"
|
|
|
|
|
|
|
+ "text" => " gracias por tu participación. Vamos por el 100% de"
|
|
|
];
|
|
];
|
|
|
} else {
|
|
} else {
|
|
|
$parametros[] = [
|
|
$parametros[] = [
|
|
@@ -983,17 +983,80 @@ class EventoController extends Controller {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //LIDER GLOBAL
|
|
|
|
|
+ $liderGlobal = Usuario::find()
|
|
|
|
|
+ ->andWhere(["liderGlobal" => true]);
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($liderGlobal->each() as $lider) {
|
|
|
|
|
+ $mensaje = "";
|
|
|
|
|
+ $participaciones = 0;
|
|
|
|
|
+ foreach ($auxDependencia as $id => $dependencia) {
|
|
|
|
|
+ $nombreDependencia = "";
|
|
|
|
|
+ if (isset($dependencias[$id])) {
|
|
|
|
|
+ $nombreDependencia = $dependencias[$id];
|
|
|
|
|
+
|
|
|
|
|
+ $totalParticipaciones = $dependencia["eventosParticipo"];
|
|
|
|
|
+ $totalEventosDependencia = $dependencia["eventosParticipo"] + $dependencia["eventosFaltantes"];
|
|
|
|
|
+
|
|
|
|
|
+ $mensaje .= "*{$nombreDependencia}* fue {$totalParticipaciones}/{$totalEventosDependencia} eventos || ";
|
|
|
|
|
+ $participaciones += $totalParticipaciones;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $notificacionUsuario = new NotificacionUsuario();
|
|
|
|
|
+
|
|
|
|
|
+ $notificacionUsuario->idNotificacion = $notificacion->id;
|
|
|
|
|
+ $notificacionUsuario->idUsuario = $lider->id;
|
|
|
|
|
+ $notificacionUsuario->nombre = $lider->nombre;
|
|
|
|
|
+ $notificacionUsuario->telefono = $lider->telefono;
|
|
|
|
|
+ $notificacionUsuario->plantilla = Notificacion::PLANTILLA_LIDER_GLOBAL;
|
|
|
|
|
+
|
|
|
|
|
+ // $totalParticipaciones = $dependencia["eventosParticipo"];
|
|
|
|
|
+ // $totalEventosDependencia = $dependencia["eventosParticipo"] + $dependencia["eventosFaltantes"];
|
|
|
|
|
+
|
|
|
|
|
+ $parametros = [
|
|
|
|
|
+ [
|
|
|
|
|
+ "type" => "text",
|
|
|
|
|
+ "text" => $mensaje
|
|
|
|
|
+ ],
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if ($participaciones === $totalEventosDependencia) {
|
|
|
|
|
+ $parametros[] = [
|
|
|
|
|
+ "type" => "text",
|
|
|
|
|
+ "text" => "Gracias por tu"
|
|
|
|
|
+ ];
|
|
|
|
|
+ } else if ($participaciones > 0) {
|
|
|
|
|
+ $parametros[] = [
|
|
|
|
|
+ "type" => "text",
|
|
|
|
|
+ "text" => "Gracias por tu participación. Vamos por el 100% de"
|
|
|
|
|
+ ];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $parametros[] = [
|
|
|
|
|
+ "type" => "text",
|
|
|
|
|
+ "text" => "Vamos por el 100% de"
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ $notificacionUsuario->parametros = $parametros;
|
|
|
|
|
+
|
|
|
|
|
+ if (!$notificacionUsuario->save()) {
|
|
|
|
|
+ return (new Respuesta($notificacionUsuario))
|
|
|
|
|
+ ->mensaje("Hubo un problema al generar la notificación");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$notificacion->estatus = Notificacion::ESTATUS_NUEVO;
|
|
$notificacion->estatus = Notificacion::ESTATUS_NUEVO;
|
|
|
$domingo = 0;
|
|
$domingo = 0;
|
|
|
$d = new \DateTime('now', new \DateTimeZone('America/Hermosillo'));
|
|
$d = new \DateTime('now', new \DateTimeZone('America/Hermosillo'));
|
|
|
$fecha = strtotime('now');
|
|
$fecha = strtotime('now');
|
|
|
$dia = intval($d->format("w"));
|
|
$dia = intval($d->format("w"));
|
|
|
- if($dia !== $domingo) {
|
|
|
|
|
|
|
+ if ($dia !== $domingo) {
|
|
|
$d = new \DateTime('next Sunday', new \DateTimeZone('America/Hermosillo'));
|
|
$d = new \DateTime('next Sunday', new \DateTimeZone('America/Hermosillo'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$d->setTime(18, 0, 0, 0);
|
|
$d->setTime(18, 0, 0, 0);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$siguienteDomingo = $d->format(\DateTime::ISO8601);
|
|
$siguienteDomingo = $d->format(\DateTime::ISO8601);
|
|
|
$notificacion->envio = $siguienteDomingo;
|
|
$notificacion->envio = $siguienteDomingo;
|
|
|
|
|
|