This commit is contained in:
2023-06-26 10:49:25 -04:00
parent 42a97bb074
commit 4d00f10274
20 changed files with 350 additions and 33 deletions

View File

@ -23,4 +23,19 @@ class ProyectoAgente extends Mapper
{
// TODO: Implement save() method.
}
public function fetchOperadoresVigenteByProyecto(int $proyecto_id): array
{
$qb = $this->connection->createQueryBuilder()
->select('pa.*')
->from($this->table, 'pa')
->innerJoin('pa', 'agente_tipo', 'at', 'at.id = pa.agente')
->innerJoin('at', 'tipo_agente', 'ta', 'ta.id = at.tipo')
->innerJoin('pa', '(SELECT e1.* FROM estado_proyecto_agente e1 JOIN (SELECT MAX(id) AS id, agente FROM estado_proyecto_agente GROUP BY agente) e0 ON e0.id = e1.id)', 'ep', 'ep.agente = pa.id')
->innerJoin('ep', 'tipo_estado_proyecto_agente', 'tep', 'tep.id = ep.tipo')
->where('pa.proyecto = ?')
->andWhere('ta.descripcion = ?')
->andWhere('tep.descripcion = ?');
return array_map([$this, 'load'], $this->connection->executeQuery($qb, [$proyecto_id, 'operador', 'vigente'])->fetchAllAssociative());
}
}