Esempio n. 1
0
 public function modifyDepartment()
 {
     if ($this->session->admin) {
         $post = $this->input->post();
         $data = array('deptDetails' => Department_Model::getDepartmentById($post['id']));
         $this->load->view('department/modify_department_view', $data);
     } else {
         $this->session->set_flashdata('error', 'You do not have permission to modify a department');
         redirect('home');
     }
 }
Esempio n. 2
0
 public function emailPeople($id)
 {
     $fileObj = new Document_Model($id);
     /**
      * Send out email notifications to reviewers
      */
     $fullName = $this->session->firstName . ' ' . $this->session->lastName;
     $from = $this->session->email;
     $phone = $this->session->phone;
     $department = $fileObj->getDepartment();
     $departmentName = Department_Model::getDepartmentById($department);
     $reviewerList = $this->reviewer->getReviewersForDepartment($department) ? $this->reviewer->getReviewersForDepartment($department) : null;
     $userList = null;
     $emailList = null;
     if (null !== $reviewerList) {
         $userList = $this->emailModel->getEmailUserObj($reviewerList) ? $this->emailModel->getEmailUserObj($reviewerList) : null;
     }
     if (null !== $userList) {
         $emailList = $this->emailModel->getEmailList($userList) ? $this->emailModel->getEmailList($userList) : null;
     }
     $newArray = array();
     $usedEmails = array();
     if (null !== $emailList) {
         foreach ($emailList as $email) {
             if (!in_array($email['email'], $usedEmails)) {
                 $usedEmails[] = $email['email'];
                 $newArray[] = $email;
             }
         }
         $emailList = $newArray;
         unset($newArray, $usedEmails);
         $comment = $fileObj->getComment();
         if ($comment === '') {
             $comment = 'No Comments.';
         }
         $date = date('M-d-Y H:i');
         $emailData = array('uploader' => $fullName, 'title' => 'Reviewer', 'fileName' => $fileObj->getRealName(), 'status' => 'Pending', 'date' => date('l \\t\\h\\e jS'), 'msg' => 'was submitted into the document repository by', 'email' => $from, 'phoneNumber' => $phone, 'department' => $departmentName[0]->name, 'comment' => $comment);
         $body = $this->load->view('emails/new_file_submission', $emailData, true);
         $subject = $fileObj->getRealName() . ' has been submitted by ' . $fullName;
         foreach ($emailList as $email) {
             if ($email['email'] != '' && $email['fullname'] != '') {
                 $this->email->from($from, $fullName);
                 $this->email->to($email['email'], $email['fullname']);
                 $this->email->subject = $subject;
                 $this->email->message($body);
                 $this->email->send();
             }
         }
     }
 }