Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. function sendMissCallNotification($config, $lead) {
  2.  
  3. $notifications = array();
  4. $notifications['agents'] = array();
  5. $notifications['managers'] = array();
  6. $notifications['others'] = array();
  7.  
  8. $contactTypes = input($config, 'GLOBAL.NOTIFICATION.LEAD_CALL_MISSED', array());
  9.  
  10. //Agents
  11. if(in_array('AGENTS', $contactTypes)){
  12. $Query = new Doctrine_Query();
  13. $Query->from('Account a');
  14. $Query->innerJoin('a.CampaignAgent ca WITH ca.campaign_id = ?', $lead->Lead->campaign_id);
  15. $Query->andWhere('a.active = 1');
  16.  
  17. if($lead->assigned_to_id){
  18. $Query->andWhere('a.id = ?', $lead->assigned_to_id);
  19. }
  20.  
  21. $Query->groupBy('a.id');
  22.  
  23. //Get Agents
  24. $notifications['agents'] = getNotificationAgents($Query->execute());
  25. }
  26.  
  27. //Agents
  28. if(in_array('MANAGERS', $contactTypes)){
  29.  
  30. $Query = new Doctrine_Query();
  31. $Query->from('Account a');
  32. $Query->innerJoin('a.AccountRole ar ON a.id = ar.account_id');
  33. $Query->andWhere('a.active = 1');
  34. $Query->andWhere('a.company_id = ? AND ar.role_id = ?', array($lead->Lead->Campaign->company_id, 'company.manager'));
  35. $Query->orWhere('a.organization_id = ? AND ar.role_id = ?', array($lead->Lead->Campaign->Company->organization_id, 'organization.admin'));
  36.  
  37. $Query->groupBy('a.id');
  38.  
  39. //Get Managers
  40. $notifications['managers'] = getNotificationAgents($Query->execute());
  41. }
  42.  
  43. //Others
  44. if(in_array('OTHERS', $contactTypes)){
  45. $notifications['others'] = getNotificationOthers($config, 'LEAD_CALL_MISSED_OTHERS');
  46. }
  47.  
  48. return $notifications;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement