1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| public function findActiveUsersByOrganizationQuery($pos, $absent = null, $sourceId = false, $lead = false, $appointment = false, $keywords = null, $sort = array(), $enabled = false)
{
if (!is_array($pos)) {
$pos = array($pos);
}
$sort = $this->checkSort($sort);
$qb = $this->createQueryBuilder('u')
->where('u.organization IN(:pos)')
->leftJoin('u.organization', 'p')
->setParameter('pos', $pos);
/* SELECT u FROM User u LEFT JOIN u.organization p WHERE u.organization IN(:pos) */
if ($sourceId === false) {
} elseif (is_null($sourceId)) {
$qb->leftJoin('u.assignedSources', 's')
->andWhere('s.id IS NULL');
} else {
$qb->leftJoin('u.assignedSources', 's')
->andWhere('s.id = :source')
->setParameter('source', $sourceId);
}
if ($appointment) {
$qb->andWhere('u.availableForAppointment = :appointment')
->setParameter('appointment', true);
}
if ($lead) {
$qb->andWhere('u.availableForLead = :lead')
->setParameter('lead', true);
}
if (!is_null($absent)) {
$qb->andWhere('u.absent = :absent')
->setParameter('absent', $absent);
}
if (!is_null($keywords)) {
$qb = $this->addKeywordsSubquery($qb, $keywords);
}
if (!$enabled) {
$qb->andWhere('u.enabled = :enabled')
->setParameter('enabled', true);
}
$qb->orderBy($sort['sortColumn'], $sort['sortOrder']);
return $qb;
}
public function findActiveUsersByOrganization($pos, $absent = null, $sourceId = false, $lead = false, $appointment = false, $keywords = null, $sort = array(), $enabled = false)
{
return $this->findActiveUsersByOrganizationQuery($pos, $absent, $sourceId, $lead, $appointment, $keywords, $sort, $enabled)->getQuery()->getResult();
} |