|
|
@@ -177,7 +177,7 @@ class EventoController extends AuthController {
|
|
|
$fechaInicio = trim($this->req->getBodyParam("fechaInicio", ""));
|
|
|
$fechaFinal = trim($this->req->getBodyParam("fechaFinal", ""));
|
|
|
|
|
|
- $query = (new Query())
|
|
|
+ /* $query = (new Query())
|
|
|
->select([
|
|
|
"{{Evento}}.id as eventoId",
|
|
|
"{{Resultado}}.accion as accionRes",
|
|
|
@@ -194,9 +194,86 @@ class EventoController extends AuthController {
|
|
|
["<=", "fechaFinal", $fechaFinal],
|
|
|
])
|
|
|
->andWhere(["{{UsuarioDependencia}}.[[idDependencia]]" => $idDependencia])
|
|
|
- ->orderBy(["eventoId" => SORT_ASC]);
|
|
|
-
|
|
|
- $total = 0;
|
|
|
+ ->orderBy(["eventoId" => SORT_ASC]); */
|
|
|
+
|
|
|
+ $query = (new Query())
|
|
|
+ ->select([
|
|
|
+ "{{Usuario}}.nombre as nombre",
|
|
|
+ "{{UsuarioDependencia}}.[[idDependencia]]",
|
|
|
+ "{{Usuario}}.facebook as facebook",
|
|
|
+ "{{Usuario}}.facebookVerificado as facebookVerificado",
|
|
|
+ "{{Usuario}}.twitter as twitter",
|
|
|
+ "{{Usuario}}.twitterVerificado as twitterVerificado",
|
|
|
+ "{{Usuario}}.instagram as instagram",
|
|
|
+ "{{Usuario}}.instagramVerificado as instagramVerificado",
|
|
|
+ "{{Usuario}}.id as uId",
|
|
|
+ "count({{Evento}}.id) as cantidadEventos",
|
|
|
+ "count({{Evento}}.[[redSocial]]) filter (where {{Evento}}.[[redSocial]] = 'Facebook' and {{Usuario}}.[[facebookVerificado]]) as eventosFacebook",
|
|
|
+ "count({{Evento}}.[[redSocial]]) filter (where {{Evento}}.[[redSocial]] = 'Twitter' and {{Usuario}}.[[twitterVerificado]]) as eventosTwitter",
|
|
|
+ "count({{Evento}}.[[redSocial]]) filter (where {{Evento}}.[[redSocial]] = 'Instagram' and {{Usuario}}.[[instagramVerificado]]) as eventosInstagram",
|
|
|
+ "count({{Resultado}}.accion) as cantidadResultados",
|
|
|
+ "(count({{Evento}}.id) - count({{Resultado}}.accion)) as cantidadPendientes",
|
|
|
+ ])
|
|
|
+ ->from("Evento")
|
|
|
+ ->innerJoin("EventoGrupo", "{{EventoGrupo}}.[[idEvento]] = {{Evento}}.id")
|
|
|
+ ->innerJoin("Grupo", "{{Grupo}}.id = {{EventoGrupo}}.[[idGrupo]]")
|
|
|
+ ->innerJoin("UsuarioGrupo", "{{UsuarioGrupo}}.[[idGrupo]] = {{Grupo}}.id")
|
|
|
+ ->innerJoin("Usuario", "{{Usuario}}.[[id]] = {{UsuarioGrupo}}.[[idUsuario]]")
|
|
|
+ ->innerJoin("UsuarioDependencia", "{{UsuarioDependencia}}.[[idUsuario]] = {{Usuario}}.id")
|
|
|
+ ->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id and {{Resultado}}.[[idUsuario]] = {{Usuario}}.id")
|
|
|
+ ->groupBy([
|
|
|
+ "{{Usuario}}.nombre",
|
|
|
+ "{{UsuarioDependencia}}.[[idDependencia]]",
|
|
|
+ "facebook",
|
|
|
+ "[[facebookVerificado]]",
|
|
|
+ "twitter",
|
|
|
+ "[[twitterVerificado]]",
|
|
|
+ "instagram",
|
|
|
+ "[[instagramVerificado]]",
|
|
|
+ "uId"
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($idDependencia > 0) {
|
|
|
+ $query->andWhere(["{{UsuarioDependencia}}.[[idDependencia]]" => $idDependencia]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($fechaInicio != "" && $fechaFinal != ""){
|
|
|
+ $query->andWhere([
|
|
|
+ "AND",
|
|
|
+ [">=", "fechaInicio", $fechaInicio],
|
|
|
+ ["<=", "fechaFinal", $fechaFinal],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $query2 = (new Query())
|
|
|
+ ->select([
|
|
|
+ "*",
|
|
|
+ "([[eventosFacebook]] + [[eventosTwitter]] + [[eventosInstagram]]) as [[cantidadEventos]]",
|
|
|
+ "([[eventosFacebook]] + [[eventosTwitter]] + [[eventosInstagram]]) - [[cantidadResultados]] as [[cantidadPendientes]]"
|
|
|
+ ])
|
|
|
+ ->from(["t" => $query]);
|
|
|
+
|
|
|
+ // return new Respuesta($query2);
|
|
|
+
|
|
|
+ $info = [];
|
|
|
+ $totalEventos = 0;
|
|
|
+ $eventosAtendidos = 0;
|
|
|
+ $eventosPendientes = 0;
|
|
|
+ foreach($query2->each() as $resultado) {
|
|
|
+ $info[] = $resultado;
|
|
|
+ $totalEventos += $resultado["cantidadEventos"];
|
|
|
+ $eventosAtendidos += $resultado["cantidadResultados"];
|
|
|
+ $eventosPendientes += $resultado["cantidadPendientes"];
|
|
|
+ }
|
|
|
+
|
|
|
+ return (new Respuesta())->detalle([
|
|
|
+ "total" => $totalEventos,
|
|
|
+ "participo" => $eventosAtendidos,
|
|
|
+ "pendientes" => $eventosPendientes,
|
|
|
+ "usuarios" => $info
|
|
|
+ ]);
|
|
|
+
|
|
|
+ /* $total = 0;
|
|
|
$participo = 0;
|
|
|
foreach($query->each() as $resultado) {
|
|
|
$total++;
|
|
|
@@ -210,7 +287,7 @@ class EventoController extends AuthController {
|
|
|
"total" => $total,
|
|
|
"participo" => $participo,
|
|
|
"pendientes" => ($total - $participo)
|
|
|
- ]);
|
|
|
+ ]); */
|
|
|
}
|
|
|
|
|
|
public function actionComparativaDependencia() {
|