|
@@ -4,6 +4,8 @@ namespace v1\controllers;
|
|
|
|
|
|
|
|
use common\data\Respuesta;
|
|
use common\data\Respuesta;
|
|
|
use common\rest\AuthController;
|
|
use common\rest\AuthController;
|
|
|
|
|
+use v1\models\Evento;
|
|
|
|
|
+use v1\models\Usuario;
|
|
|
use yii\db\Expression;
|
|
use yii\db\Expression;
|
|
|
use yii\db\Query;
|
|
use yii\db\Query;
|
|
|
|
|
|
|
@@ -294,7 +296,7 @@ class EventoController extends AuthController {
|
|
|
$fechaInicio = trim($this->req->getBodyParam("fechaInicio", ""));
|
|
$fechaInicio = trim($this->req->getBodyParam("fechaInicio", ""));
|
|
|
$fechaFinal = trim($this->req->getBodyParam("fechaFinal", ""));
|
|
$fechaFinal = trim($this->req->getBodyParam("fechaFinal", ""));
|
|
|
|
|
|
|
|
- $query = (new Query())
|
|
|
|
|
|
|
+ /* $query = (new Query())
|
|
|
->select([
|
|
->select([
|
|
|
"{{Dependencia}}.id as dependenciaId",
|
|
"{{Dependencia}}.id as dependenciaId",
|
|
|
"{{Dependencia}}.nombre as dependenciaNombre",
|
|
"{{Dependencia}}.nombre as dependenciaNombre",
|
|
@@ -317,10 +319,48 @@ class EventoController extends AuthController {
|
|
|
"dependenciaId",
|
|
"dependenciaId",
|
|
|
"dependenciaNombre"
|
|
"dependenciaNombre"
|
|
|
])
|
|
])
|
|
|
|
|
+ ->orderBy(["dependenciaNombre" => SORT_ASC]); */
|
|
|
|
|
+
|
|
|
|
|
+ $query = (new Query())
|
|
|
|
|
+ ->select([
|
|
|
|
|
+ "{{Dependencia}}.id as dependenciaId",
|
|
|
|
|
+ "{{Dependencia}}.nombre as dependenciaNombre",
|
|
|
|
|
+ "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("UsuarioDependencia", "{{UsuarioDependencia}}.[[idUsuario]] = {{UsuarioGrupo}}.[[idUsuario]]")
|
|
|
|
|
+ ->innerJoin("Dependencia", "{{Dependencia}}.id = {{UsuarioDependencia}}.[[idDependencia]]")
|
|
|
|
|
+ ->innerJoin("Usuario", "{{Usuario}}.id = {{UsuarioDependencia}}.[[idUsuario]]")
|
|
|
|
|
+ ->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id and {{Resultado}}.[[idUsuario]] = {{Usuario}}.id")
|
|
|
|
|
+ ->andWhere([
|
|
|
|
|
+ "AND",
|
|
|
|
|
+ [">=", "fechaInicio", $fechaInicio],
|
|
|
|
|
+ ["<=", "fechaFinal", $fechaFinal],
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->groupBy([
|
|
|
|
|
+ "dependenciaId",
|
|
|
|
|
+ "dependenciaNombre",
|
|
|
|
|
+ ])
|
|
|
->orderBy(["dependenciaNombre" => SORT_ASC]);
|
|
->orderBy(["dependenciaNombre" => SORT_ASC]);
|
|
|
|
|
|
|
|
|
|
+ $query2 = (new Query())
|
|
|
|
|
+ ->select([
|
|
|
|
|
+ "*",
|
|
|
|
|
+ "([[eventosFacebook]] + [[eventosTwitter]] + [[eventosInstagram]]) as [[cantidadEventos]]",
|
|
|
|
|
+ "([[eventosFacebook]] + [[eventosTwitter]] + [[eventosInstagram]]) - [[cantidadResultados]] as [[cantidadPendientes]]"
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->from(["t" => $query]);
|
|
|
|
|
+
|
|
|
$data = [];
|
|
$data = [];
|
|
|
- foreach($query->each() as $resultado) {
|
|
|
|
|
|
|
+ /* foreach($query->each() as $resultado) {
|
|
|
$data[] = [
|
|
$data[] = [
|
|
|
"id" => $resultado["dependenciaId"],
|
|
"id" => $resultado["dependenciaId"],
|
|
|
"nombre" => $resultado["dependenciaNombre"],
|
|
"nombre" => $resultado["dependenciaNombre"],
|
|
@@ -330,23 +370,42 @@ class EventoController extends AuthController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (new Respuesta())
|
|
return (new Respuesta())
|
|
|
|
|
+ ->detalle($data); */
|
|
|
|
|
+
|
|
|
|
|
+ $eventosAtendidos = 0;
|
|
|
|
|
+ $eventosPendientes = 0;
|
|
|
|
|
+ foreach($query2->each() as $resultado) {
|
|
|
|
|
+ $eventosAtendidos += $resultado["cantidadResultados"];
|
|
|
|
|
+ $eventosPendientes += $resultado["cantidadPendientes"];
|
|
|
|
|
+
|
|
|
|
|
+ $data[] = [
|
|
|
|
|
+ "id" => $resultado["dependenciaId"],
|
|
|
|
|
+ "nombre" => $resultado["dependenciaNombre"],
|
|
|
|
|
+ "participaciones" => $resultado["cantidadResultados"],
|
|
|
|
|
+ "pendientes" => $resultado["cantidadPendientes"],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (new Respuesta())
|
|
|
->detalle($data);
|
|
->detalle($data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function actionPorEvento() {
|
|
public function actionPorEvento() {
|
|
|
- $idEvento = intval($this->req->getBodyParam("idEvento", null));
|
|
|
|
|
|
|
+ $idEvento = trim($this->req->getBodyParam("tag", null));
|
|
|
$fechaInicio = trim($this->req->getBodyParam("fechaInicio", ""));
|
|
$fechaInicio = trim($this->req->getBodyParam("fechaInicio", ""));
|
|
|
$fechaFinal = trim($this->req->getBodyParam("fechaFinal", ""));
|
|
$fechaFinal = trim($this->req->getBodyParam("fechaFinal", ""));
|
|
|
|
|
|
|
|
- $queryUsuario = (new Query())
|
|
|
|
|
|
|
+ /* $queryUsuario = (new Query())
|
|
|
->select([
|
|
->select([
|
|
|
"{{Evento}}.id as eventoId",
|
|
"{{Evento}}.id as eventoId",
|
|
|
|
|
+ // "{{Usuario}}.id",
|
|
|
"{{Resultado}}.accion as accionRes",
|
|
"{{Resultado}}.accion as accionRes",
|
|
|
])
|
|
])
|
|
|
->from("Evento")
|
|
->from("Evento")
|
|
|
->innerJoin("EventoGrupo", "{{EventoGrupo}}.[[idEvento]] = {{Evento}}.id")
|
|
->innerJoin("EventoGrupo", "{{EventoGrupo}}.[[idEvento]] = {{Evento}}.id")
|
|
|
->innerJoin("Grupo", "{{Grupo}}.id = {{EventoGrupo}}.[[idGrupo]]")
|
|
->innerJoin("Grupo", "{{Grupo}}.id = {{EventoGrupo}}.[[idGrupo]]")
|
|
|
->innerJoin("UsuarioGrupo", "{{UsuarioGrupo}}.[[idGrupo]] = {{Grupo}}.id")
|
|
->innerJoin("UsuarioGrupo", "{{UsuarioGrupo}}.[[idGrupo]] = {{Grupo}}.id")
|
|
|
|
|
+ // ->innerJoin("Usuario", "{{Usuario}}.[[id]] = {{UsuarioGrupo}}.[[idUsuario]]")
|
|
|
->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id and {{Resultado}}.[[idUsuario]] = {{UsuarioGrupo}}.[[idUsuario]]")
|
|
->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id and {{Resultado}}.[[idUsuario]] = {{UsuarioGrupo}}.[[idUsuario]]")
|
|
|
->andWhere([
|
|
->andWhere([
|
|
|
"AND",
|
|
"AND",
|
|
@@ -354,14 +413,42 @@ class EventoController extends AuthController {
|
|
|
["<=", "fechaFinal", $fechaFinal],
|
|
["<=", "fechaFinal", $fechaFinal],
|
|
|
])
|
|
])
|
|
|
->andWhere(["{{Evento}}.id" => $idEvento])
|
|
->andWhere(["{{Evento}}.id" => $idEvento])
|
|
|
- ->orderBy(["eventoId" => SORT_ASC]);
|
|
|
|
|
|
|
+ ->orderBy(["eventoId" => SORT_ASC]); */
|
|
|
|
|
+
|
|
|
|
|
+ $queryUsuario = (new Query())
|
|
|
|
|
+ ->select([
|
|
|
|
|
+ "{{Usuario}}.id as idUsuario",
|
|
|
|
|
+ "{{Resultado}}.accion as accionRes",
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->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]]")
|
|
|
|
|
+ ->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id and {{Resultado}}.[[idUsuario]] = {{Usuario}}.[[id]]")
|
|
|
|
|
+ ->andWhere([
|
|
|
|
|
+ "AND",
|
|
|
|
|
+ [">=", "fechaInicio", $fechaInicio],
|
|
|
|
|
+ ["<=", "fechaFinal", $fechaFinal],
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->andWhere(["{{Evento}}.tag" => $idEvento])
|
|
|
|
|
+ ->groupBy([
|
|
|
|
|
+ "{{Usuario}}.id",
|
|
|
|
|
+ "{{Resultado}}.accion",
|
|
|
|
|
+ "{{Evento}}.tag"
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->orderBy(["{{Evento}}.tag" => SORT_ASC]);
|
|
|
|
|
|
|
|
$totalUsuario = 0;
|
|
$totalUsuario = 0;
|
|
|
$participoUsuario = 0;
|
|
$participoUsuario = 0;
|
|
|
|
|
+ $idUsuarios = [];
|
|
|
foreach($queryUsuario->each() as $resultado) {
|
|
foreach($queryUsuario->each() as $resultado) {
|
|
|
$totalUsuario++;
|
|
$totalUsuario++;
|
|
|
- if ($resultado["accionRes"] !== null) {
|
|
|
|
|
|
|
+ if ($resultado["accionRes"] !== null && !in_array($resultado["idUsuario"], $idUsuarios)) {
|
|
|
$participoUsuario ++;
|
|
$participoUsuario ++;
|
|
|
|
|
+ $idUsuarios[] = $resultado["idUsuario"];
|
|
|
|
|
+ } else if ($resultado["accionRes"] === null && in_array($resultado["idUsuario"], $idUsuarios)) {
|
|
|
|
|
+ $totalUsuario--;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -384,15 +471,24 @@ class EventoController extends AuthController {
|
|
|
[">=", "fechaInicio", $fechaInicio],
|
|
[">=", "fechaInicio", $fechaInicio],
|
|
|
["<=", "fechaFinal", $fechaFinal],
|
|
["<=", "fechaFinal", $fechaFinal],
|
|
|
])
|
|
])
|
|
|
- ->andWhere(["{{Evento}}.id" => $idEvento])
|
|
|
|
|
|
|
+ ->andWhere(["{{Evento}}.tag" => $idEvento])
|
|
|
->groupBy([
|
|
->groupBy([
|
|
|
|
|
+ "{{Evento}}.tag",
|
|
|
"dependenciaId",
|
|
"dependenciaId",
|
|
|
"dependenciaNombre"
|
|
"dependenciaNombre"
|
|
|
])
|
|
])
|
|
|
->orderBy(["dependenciaNombre" => SORT_ASC]);
|
|
->orderBy(["dependenciaNombre" => SORT_ASC]);
|
|
|
|
|
|
|
|
|
|
+ // $this->res->format = \yii\web\Response::FORMAT_RAW;
|
|
|
|
|
+ // $sql = $queryDependencia->createCommand()->getRawSql();
|
|
|
|
|
+ // return $sql;
|
|
|
|
|
+
|
|
|
$dataDependencias = [];
|
|
$dataDependencias = [];
|
|
|
|
|
+ $totalParticipantesDependencias = 0;
|
|
|
|
|
+ $totalPendientesDependencias = 0;
|
|
|
foreach($queryDependencia->each() as $resultado) {
|
|
foreach($queryDependencia->each() as $resultado) {
|
|
|
|
|
+ $totalParticipantesDependencias += $resultado["conteoNotNull"];
|
|
|
|
|
+ $totalPendientesDependencias += $resultado["totalDependencia"] - $resultado["conteoNotNull"];
|
|
|
$dataDependencias[] = [
|
|
$dataDependencias[] = [
|
|
|
"id" => $resultado["dependenciaId"],
|
|
"id" => $resultado["dependenciaId"],
|
|
|
"nombre" => $resultado["dependenciaNombre"],
|
|
"nombre" => $resultado["dependenciaNombre"],
|
|
@@ -406,7 +502,229 @@ class EventoController extends AuthController {
|
|
|
"totalResultadosUsuarios" => $totalUsuario,
|
|
"totalResultadosUsuarios" => $totalUsuario,
|
|
|
"participoResultadosUsuarios" => $participoUsuario,
|
|
"participoResultadosUsuarios" => $participoUsuario,
|
|
|
"pendientesResultadosUsuarios" => ($totalUsuario - $participoUsuario),
|
|
"pendientesResultadosUsuarios" => ($totalUsuario - $participoUsuario),
|
|
|
- "datosDependencias" => $dataDependencias
|
|
|
|
|
|
|
+ "datosDependencias" => $dataDependencias,
|
|
|
|
|
+ "totalParticipantesDependencias" => $totalParticipantesDependencias,
|
|
|
|
|
+ "totalPendientesDependencias" => $totalPendientesDependencias,
|
|
|
|
|
+ "totalDependencias" => $totalPendientesDependencias + $totalPendientesDependencias
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionTag() {
|
|
|
|
|
+ $id = intval($this->req->get("id", ""));
|
|
|
|
|
+ $q = trim($this->req->get("q", ""));
|
|
|
|
|
+
|
|
|
|
|
+ // $query = $this->queryInicial;
|
|
|
|
|
+ $query = (new Query())
|
|
|
|
|
+ ->select([
|
|
|
|
|
+ '{{Evento}}.tag',
|
|
|
|
|
+ '{{Evento}}.nombre',
|
|
|
|
|
+ '{{Evento}}.[[fechaInicio]]',
|
|
|
|
|
+ '{{Evento}}.[[fechaFinal]]',
|
|
|
|
|
+ 'case when count({{Resultado}}.accion) > 0 then true else false end as paticipo'
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->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]]")
|
|
|
|
|
+ ->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id and {{Resultado}}.[[idUsuario]] = {{Usuario}}.id")
|
|
|
|
|
+ ->andWhere(["{{Evento}}.eliminado" => null])
|
|
|
|
|
+ ->andWhere("{{Evento}}.tag is not null")
|
|
|
|
|
+ ->groupBy([
|
|
|
|
|
+ '{{Evento}}.tag',
|
|
|
|
|
+ '{{Evento}}.nombre',
|
|
|
|
|
+ '{{Evento}}.[[fechaInicio]]',
|
|
|
|
|
+ '{{Evento}}.[[fechaFinal]]',
|
|
|
]);
|
|
]);
|
|
|
|
|
+
|
|
|
|
|
+ /* if($id > 0) {
|
|
|
|
|
+ $query->andWhere(["id" => $id]);
|
|
|
|
|
+ } */
|
|
|
|
|
+
|
|
|
|
|
+ if($q !== "") {
|
|
|
|
|
+ # Ejemplo de buscador
|
|
|
|
|
+ $query->andWhere([
|
|
|
|
|
+ "OR",
|
|
|
|
|
+ ["ilike", "{{Evento}}.nombre", $q],
|
|
|
|
|
+ // ["ilike", "direccion", $q],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ //
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCondensado() {
|
|
|
|
|
+ $tag = trim($this->req->getBodyParam("tag", null));
|
|
|
|
|
+ $fechaInicio = trim($this->req->getBodyParam("fechaInicio", ""));
|
|
|
|
|
+ $fechaFinal = trim($this->req->getBodyParam("fechaFinal", ""));
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ $usuarios = (new Query())
|
|
|
|
|
+ ->select([
|
|
|
|
|
+ "{{Usuario}}.id as usuarioId",
|
|
|
|
|
+ "{{Usuario}}.uid as uid",
|
|
|
|
|
+ "{{Usuario}}.nombre as nombre",
|
|
|
|
|
+ "case when {{Usuario}}.[[facebookVerificado]] = true then 1 else 0 end as [[tieneFb]]",
|
|
|
|
|
+ "case when {{Usuario}}.[[twitterVerificado]] = true then 1 else 0 end as [[tieneTw]]",
|
|
|
|
|
+ "case when {{Usuario}}.[[instagramVerificado]] = true then 1 else 0 end as [[tieneIg]]",
|
|
|
|
|
+ "{{Usuario}}.facebook as facebook",
|
|
|
|
|
+ "{{Usuario}}.instagram as instagram",
|
|
|
|
|
+ "{{Usuario}}.twitter as twitter",
|
|
|
|
|
+ "{{Usuario}}.verificado as verificado",
|
|
|
|
|
+ "{{Dependencia}}.id as [[idDependencia]]",
|
|
|
|
|
+ "{{Dependencia}}.nombre as dependencia",
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->from("Usuario")
|
|
|
|
|
+ ->innerJoin("UsuarioGrupo", "{{UsuarioGrupo}}.[[idUsuario]] = {{Usuario}}.id")
|
|
|
|
|
+ ->innerJoin("UsuarioDependencia", "{{UsuarioDependencia}}.[[idUsuario]] = {{Usuario}}.id")
|
|
|
|
|
+ ->innerJoin("Dependencia", "{{Dependencia}}.id = {{UsuarioDependencia}}.[[idDependencia]]")
|
|
|
|
|
+ ->andWhere(["{{Usuario}}.eliminado" => null])
|
|
|
|
|
+ ->andWhere(["{{UsuarioGrupo}}.[[idGrupo]]" => 1]) //Grupo ENLACES 2022
|
|
|
|
|
+ ->andWhere(["!=", "{{UsuarioDependencia}}.[[idDependencia]]", 33]) //Diferente a dependencia Soporte
|
|
|
|
|
+ ->orderBy(['dependencia' => SORT_ASC, 'nombre' => SORT_ASC])
|
|
|
|
|
+ ->indexBy("usuarioId")
|
|
|
|
|
+ ->all();
|
|
|
|
|
+
|
|
|
|
|
+ $eventos = Evento::find()
|
|
|
|
|
+ ->leftJoin("Resultado", "{{Resultado}}.[[idEvento]] = {{Evento}}.id")
|
|
|
|
|
+ ->andWhere(["{{Evento}}.eliminado" => null])
|
|
|
|
|
+ ->andWhere(["tag" => $tag])
|
|
|
|
|
+ ->andWhere([
|
|
|
|
|
+ "AND",
|
|
|
|
|
+ [">=", "fechaInicio", $fechaInicio],
|
|
|
|
|
+ ["<=", "fechaFinal", $fechaFinal],
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $auxiliar = [];
|
|
|
|
|
+ $auxiliarDependencias = [];
|
|
|
|
|
+
|
|
|
|
|
+ foreach($eventos->each() as $e) {
|
|
|
|
|
+ foreach($e->resultados as $resultado) {
|
|
|
|
|
+ if (isset($usuarios[$resultado->idUsuario])) {
|
|
|
|
|
+ $usuario = $usuarios[$resultado->idUsuario];
|
|
|
|
|
+ if (!isset($auxiliar[$resultado->idUsuario])) {
|
|
|
|
|
+ $auxiliar[$resultado->idUsuario] = [
|
|
|
|
|
+ "id" => $usuario['usuarioId'],
|
|
|
|
|
+ "uid" => $usuario['uid'],
|
|
|
|
|
+ "nombre" => $usuario['nombre'],
|
|
|
|
|
+ "idDependencia" => $usuario['idDependencia'],
|
|
|
|
|
+ "dependencia" => $usuario['dependencia'],
|
|
|
|
|
+ "tieneFb" => $usuario['tieneFb'],
|
|
|
|
|
+ "facebook" => $usuario['facebook'],
|
|
|
|
|
+ "tieneTw" => $usuario['tieneTw'],
|
|
|
|
|
+ "twitter" => $usuario['twitter'],
|
|
|
|
|
+ "tieneIg" => $usuario['tieneIg'],
|
|
|
|
|
+ "instagram" => $usuario['instagram'],
|
|
|
|
|
+ "verificado" => $usuario['verificado'],
|
|
|
|
|
+ "participoFacebook" => 0,
|
|
|
|
|
+ "participoTwitter" => 0,
|
|
|
|
|
+ "participoInstagram" => 0,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset($auxiliarDependencias[$usuario['idDependencia']])) {
|
|
|
|
|
+ $auxiliarDependencias[$usuario['idDependencia']] = [
|
|
|
|
|
+ "id" => $usuario['idDependencia'],
|
|
|
|
|
+ "nombre" => $usuario['dependencia'],
|
|
|
|
|
+ "participaciones" => 0,
|
|
|
|
|
+ "pendientes" => 0
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($e->redSocial === 'Facebook') {
|
|
|
|
|
+ $auxiliar[$resultado->idUsuario]["participoFacebook"] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($e->redSocial === 'Twitter') {
|
|
|
|
|
+ $auxiliar[$resultado->idUsuario]["participoTwitter"] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($e->redSocial === 'Instagram') {
|
|
|
|
|
+ $auxiliar[$resultado->idUsuario]["participoInstagram"] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($usuarios as $usr) {
|
|
|
|
|
+ if (!isset($auxiliar[$usr["usuarioId"]])) {
|
|
|
|
|
+ $auxiliar[$usr["usuarioId"]] = [
|
|
|
|
|
+ "id" => $usr['usuarioId'],
|
|
|
|
|
+ "uid" => $usr['uid'],
|
|
|
|
|
+ "nombre" => $usr['nombre'],
|
|
|
|
|
+ "idDependencia" => $usr['idDependencia'],
|
|
|
|
|
+ "dependencia" => $usr['dependencia'],
|
|
|
|
|
+ "tieneFb" => $usr['tieneFb'],
|
|
|
|
|
+ "facebook" => $usr['facebook'],
|
|
|
|
|
+ "tieneTw" => $usr['tieneTw'],
|
|
|
|
|
+ "twitter" => $usr['twitter'],
|
|
|
|
|
+ "tieneIg" => $usr['tieneIg'],
|
|
|
|
|
+ "instagram" => $usr['instagram'],
|
|
|
|
|
+ "verificado" => $usr['verificado'],
|
|
|
|
|
+ "participoFacebook" => 0,
|
|
|
|
|
+ "participoTwitter" => 0,
|
|
|
|
|
+ "participoInstagram" => 0,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset($auxiliarDependencias[$usr['idDependencia']])) {
|
|
|
|
|
+ $auxiliarDependencias[$usr['idDependencia']] = [
|
|
|
|
|
+ "id" => $usr['idDependencia'],
|
|
|
|
|
+ "nombre" => $usr['dependencia'],
|
|
|
|
|
+ "participaciones" => 0,
|
|
|
|
|
+ "pendientes" => 0
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $segundoAuxiliar = [];
|
|
|
|
|
+ $segundoAuxiliarDependencias = [];
|
|
|
|
|
+ foreach($auxiliar as $aux) {
|
|
|
|
|
+ if ($aux['tieneFb'] > 0) {
|
|
|
|
|
+ if ($aux['participoFacebook'] > 0) {
|
|
|
|
|
+ $auxiliarDependencias[$aux['idDependencia']]['participaciones'] += 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $auxiliarDependencias[$aux['idDependencia']]['pendientes'] += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($aux['tieneTw'] > 0) {
|
|
|
|
|
+ if ($aux['participoTwitter'] > 0) {
|
|
|
|
|
+ $auxiliarDependencias[$aux['idDependencia']]['participaciones'] += 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $auxiliarDependencias[$aux['idDependencia']]['pendientes'] += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($aux['tieneIg'] > 0) {
|
|
|
|
|
+ if ($aux['participoInstagram'] > 0) {
|
|
|
|
|
+ $auxiliarDependencias[$aux['idDependencia']]['participaciones'] += 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $auxiliarDependencias[$aux['idDependencia']]['pendientes'] += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $segundoAuxiliar[] = $aux;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $participaciones = 0;
|
|
|
|
|
+ $pendientes = 0;
|
|
|
|
|
+ foreach($auxiliarDependencias as $aux) {
|
|
|
|
|
+ $participaciones += $aux['participaciones'];
|
|
|
|
|
+ $pendientes += $aux['pendientes'];
|
|
|
|
|
+ $segundoAuxiliarDependencias[] = $aux;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $total = $pendientes + $participaciones;
|
|
|
|
|
+
|
|
|
|
|
+ $detalle = [
|
|
|
|
|
+ "usuarios" => $segundoAuxiliar,
|
|
|
|
|
+ "dependencias" => $segundoAuxiliarDependencias,
|
|
|
|
|
+ "total" => $total,
|
|
|
|
|
+ "participaciones" => $participaciones,
|
|
|
|
|
+ "pendientes" => $pendientes
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ return (new Respuesta())->detalle($detalle);
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ return (new Respuesta())
|
|
|
|
|
+ ->mensaje($e->getLine().'. '.$e->getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|