Example #1
0
    public function sendRequestNotification($requestId)
   {
        $request=new Application_Model_Request();
        $request=$request->find($requestId);
        if(false===$request)
        {
            return false;   
        }

        $departmentId=$request->getDepartmentId();
        
        $dept=new Application_Model_Department();
         $dept=$dept->find($departmentId);
         if($dept===false)
             return false;
         
        
        
        $user=new Security_Model_User();
        $users=$user->fetchAll("department_id='{$departmentId}' and status='active' and id ='{$dept->getDepartmentHeadId()}'");
        
        
        if(count($users)==0)
            return false;
        $emails=array();
        foreach($users as $_user)
        {
            
            $emails[$_user->getFirstName()." ".$_user->getLastName()]=$_user->getEmail();
        }
        if(count($emails)==0)
            return false;

        $user=new Security_Model_User();
        $requestedBy=$user->find($request->getRequestedBy());


        $from_email=$this->settingValue('admin_email');
        $from_name=$this->settingLable('admin_email');

        /*---Template-----*/
        $template=$this->getEmailTemplate('request_notification_email');		
        $htmlBody=$template['body'];
        $htmlBody=str_replace("__REQUESTER_NAME__", $requestedBy->getFirstName()." ".$requestedBy->getLastName(), $htmlBody);
        $htmlBody=str_replace("__REQUESTER_EMAIL__", $requestedBy->getEmail(), $htmlBody);
        $htmlBody=str_replace("__REQUESTER_EMP_CODE__", $requestedBy->getEmployeeCode(), $htmlBody);
        $htmlBody=str_replace("__REQUEST__", $request->getRequest(), $htmlBody);
        /*---------------------*/

        $subject=$template['subject'];
        $this->setBodyHtml ( $htmlBody);
        $this->setFrom ($from_email, $from_name);
        $this->addTo($emails);
        $this->setSubject ($subject);
        $this->send();

   }
Example #2
0
 public function getids()
 {
     $obj = new Security_Model_User();
     $entries = $obj->fetchAll();
     $arrUser = array();
     foreach ($entries as $entry) {
         $arrUser[$entry->getId()] = $entry->getUsername();
     }
     return $arrUser;
 }