/** * Check if a page has any answers associated with it in a specific cycle * @param Page $page * @param Cycle $cycle * @return boolean */ public function hasCycleAnswers(Page $page, Cycle $cycle) { $query = $this->_em->createQuery('SELECT answer.id FROM Jazzee\\Entity\\Answer answer JOIN answer.applicant applicant JOIN applicant.application application WHERE answer.page = :pageId AND application.cycle = :cycleId'); $query->setParameter('pageId', $page->getId()); $query->setParameter('cycleId', $cycle->getId()); $query->setMaxResults(1); $result = $query->getResult(); return count($result); }
/** * findOneByProgramAndCycle * Search for an Application using its Program and Cycle * @param Program $program * @param Cycle $cycle * @return Application */ public function findOneByProgramAndCycle(Program $program, Cycle $cycle) { $query = $this->_em->createQuery('SELECT a FROM Jazzee\\Entity\\Application a WHERE a.program = :programId AND a.cycle = :cycleId'); $query->setParameter('programId', $program->getId()); $query->setParameter('cycleId', $cycle->getId()); $result = $query->getResult(); if (count($result)) { return $result[0]; } return false; }
/** * find applicants in a cycle * * Search for an Applicant by cycle * @param Cycle $cycle * @return array */ public function findByCycle(Cycle $cycle) { $query = $this->_em->createQuery('SELECT a FROM Jazzee\\Entity\\Applicant a WHERE a.application IN (SELECT app FROM Jazzee\\Entity\\Application app WHERE app.cycle = :cycleId) AND a.deactivated=false'); $query->setParameter('cycleId', $cycle->getId()); return $query->getResult(); }