public function save($requisitionform, $data)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $jobtitleModel = new Default_Model_Jobtitles();
     $appr_mail = '';
     $appr_per = '';
     if ($requisitionform->isValid($this->_request->getPost())) {
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $id = (int) $this->_getParam('id', null);
             $requisition_code = $this->_getParam('requisition_code', null);
             $onboard_date = $this->_getParam('onboard_date', null);
             $business_unit = $this->_getParam('business_unit', null);
             $department = $this->_getParam('department', null);
             $jobtitle = $this->_getParam('jobtitle', null);
             $position_id = $this->_getParam('position_id', null);
             $reporting_id = $this->_getParam('reporting_id', null);
             $req_no_positions = $this->_getParam('req_no_positions', null);
             $jobdescription = $this->_getParam('jobdescription', null);
             $req_skills = $this->_getParam('req_skills', null);
             $req_qualification = $this->_getParam('req_qualification', null);
             $req_exp_years = $this->_getParam('req_exp_years', null);
             $emp_type = $this->_getParam('emp_type', null);
             $req_priority = $this->_getParam('req_priority', null);
             $additional_info = $this->_getParam('additional_info', null);
             $req_status = $this->_getParam('req_status', null);
             $approver1 = $this->_getParam('approver1', null);
             $approver2 = $this->_getParam('approver2', null);
             $approver3 = $this->_getParam('approver3', null);
             $aflag = $this->_getParam('aflag', null);
             $edit_flag = $this->_getParam('edit_flag', null);
             $edit_order = $this->_getParam('edit_order', null);
             $aorder = $this->_getParam('aorder', null);
             //1= approver1,2=approver2,3=approver3
             if ($aflag != '' && $aflag == 'approver') {
                 if ($req_status == 3) {
                     $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'appstatus' . $aorder => $req_status, 'req_status' => $req_status);
                 } else {
                     if ($aorder == 1) {
                         if ($approver2 != '') {
                             $data = array('appstatus1' => $req_status, 'appstatus2' => 'Initiated');
                             $appr_mail = $approver2;
                             $appr_per = $approver1;
                         } else {
                             $data = array('appstatus1' => $req_status, 'req_status' => $req_status);
                             $appr_mail = 'approved';
                         }
                     } else {
                         if ($aorder == 2) {
                             if ($approver3 != '') {
                                 $data = array('appstatus2' => $req_status, 'appstatus3' => 'Initiated');
                                 $appr_mail = $approver3;
                                 $appr_per = $approver2;
                             } else {
                                 $data = array('appstatus2' => $req_status, 'req_status' => $req_status);
                                 $appr_mail = 'approved';
                             }
                         } else {
                             if ($aorder == 3) {
                                 $data = array('appstatus3' => $req_status, 'req_status' => $req_status);
                                 $appr_mail = 'approved';
                             }
                         }
                     }
                     $data['modifiedby'] = trim($loginUserId);
                     $data['modifiedon'] = gmdate("Y-m-d H:i:s");
                 }
             } else {
                 $data = array('requisition_code' => trim($requisition_code), 'onboard_date' => sapp_Global::change_date(trim($onboard_date), 'database'), 'position_id' => trim($position_id), 'reporting_id' => trim($reporting_id), 'businessunit_id' => trim($business_unit), 'department_id' => trim($department), 'req_no_positions' => trim($req_no_positions), 'jobdescription' => trim($jobdescription), 'jobtitle' => trim($jobtitle), 'req_skills' => trim($req_skills), 'req_qualification' => trim($req_qualification), 'req_exp_years' => trim($req_exp_years), 'emp_type' => trim($emp_type), 'req_priority' => trim($req_priority), 'additional_info' => trim($additional_info), 'approver1' => $approver1, 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'req_status' => 'Initiated', 'appstatus1' => 'Initiated', 'appstatus2' => null, 'appstatus3' => null, 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createdon' => gmdate("Y-m-d H:i:s"), 'modifiedon' => gmdate("Y-m-d H:i:s"));
                 if ($loginuserGroup == MANAGER_GROUP) {
                     $data['reporting_id'] = $loginUserId;
                 }
                 if ($edit_flag != '' && $edit_flag == 'yes') {
                     if ($edit_order == 1) {
                         $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus2' => 'Initiated');
                         if ($approver2 == '') {
                             $data['appstatus2'] = null;
                         } else {
                             $appr_per = $edit_order;
                             $appr_mail = $approver2;
                         }
                     }
                     if ($edit_order == 2) {
                         $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus3' => 'Initiated');
                         if ($approver3 == '') {
                             $data['appstatus3'] = null;
                         } else {
                             $appr_per = $edit_order;
                             $appr_mail = $approver3;
                         }
                     }
                 }
             }
             $where = "";
             $actionflag = 1;
             //for mailing
             if ($id == '') {
                 //for requisition code
                 $identity_code_model = new Default_Model_Identitycodes();
                 $identity_codes = $identity_code_model->getIdentitycodesRecord();
                 $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : "";
                 if ($irequistion_code != '') {
                     $req_id = $requi_model->getMaxReqCode($irequistion_code . "/");
                 } else {
                     $req_id = '';
                 }
                 $data['requisition_code'] = $req_id;
                 //end of requisition code
                 $report_person_data = $user_model->getUserDataById($data['reporting_id']);
                 $approver1_person_data = $user_model->getUserDataById($approver1);
                 $Raisedby_person_data = $user_model->getUserDataById($data['createdby']);
                 $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($jobtitle));
                 if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                     $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename'];
                 } else {
                     $jobtitlename = '';
                 }
                 $mail_arr[0]['name'] = 'HR';
                 $mail_arr[0]['email'] = defined('REQ_HR_' . $business_unit) ? constant('REQ_HR_' . $business_unit) : "";
                 $mail_arr[0]['type'] = 'HR';
                 $mail_arr[1]['name'] = 'Management';
                 $mail_arr[1]['email'] = defined('REQ_MGMT_' . $business_unit) ? constant('REQ_MGMT_' . $business_unit) : "";
                 $mail_arr[1]['type'] = 'Management';
                 $mail_arr[2]['name'] = $Raisedby_person_data['userfullname'];
                 $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress'];
                 $mail_arr[2]['type'] = 'Raise';
                 $mail_arr[3]['name'] = $approver1_person_data['userfullname'];
                 $mail_arr[3]['email'] = $approver1_person_data['emailaddress'];
                 $mail_arr[3]['type'] = 'Approver';
                 $appr_str = "";
                 $appr_str = $approver1_person_data['userfullname'];
                 if ($data['approver2'] != '') {
                     $approver2_person_data = $user_model->getUserDataById($data['approver2']);
                     $appr_str .= ", " . $approver2_person_data['userfullname'];
                     $mail_arr[4]['name'] = $approver2_person_data['userfullname'];
                     $mail_arr[4]['email'] = $approver2_person_data['emailaddress'];
                     $mail_arr[4]['type'] = 'Approver';
                 }
                 if ($data['approver3'] != '') {
                     $approver3_person_data = $user_model->getUserDataById($data['approver3']);
                     $appr_str .= " and " . $approver3_person_data['userfullname'];
                     $mail_arr[5]['name'] = $approver3_person_data['userfullname'];
                     $mail_arr[5]['email'] = $approver3_person_data['emailaddress'];
                     $mail_arr[5]['type'] = 'Approver';
                 }
                 for ($ii = 0; $ii < count($mail_arr); $ii++) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $mail_arr[$ii]['name'];
                     $this->view->base_url = $base_url;
                     $this->view->type = $mail_arr[$ii]['type'];
                     $this->view->jobtitle = $jobtitlename;
                     $this->view->requisition_code = $requisition_code;
                     $this->view->approver_str = $appr_str;
                     $this->view->raised_name = $Raisedby_person_data['userfullname'];
                     $text = $view->render('mailtemplates/requisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Requisition for approval';
                     $options['header'] = 'Requisition Status';
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     if ($options['toEmail'] != '') {
                         sapp_Global::_sendEmail($options);
                     }
                 }
             }
             if ($id != '') {
                 unset($data['createdby']);
                 unset($data['createdon']);
                 unset($data['isactive']);
                 $where = "id = " . $id;
                 $tableid = $id;
                 $actionflag = 2;
             }
             $result = $requi_model->SaveorUpdateRequisitionData($data, $where);
             if ($id == '') {
                 $tableid = $result;
             }
             if ($result != '') {
                 if ($actionflag == 2) {
                     //start of mailing
                     $requisition_data = $requi_model->getRequisitionDataById($id);
                     $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']);
                     $st_arr = array('0' => 'Select status', '2' => 'Approved', '3' => 'Rejected');
                     if ($req_status == 3 || $appr_mail == 'approved') {
                         $approver1_person_data = $user_model->getUserDataById($requisition_data['approver1']);
                         $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                         $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($requisition_data['jobtitle']));
                         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                             $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename'];
                         } else {
                             $jobtitlename = '';
                         }
                         $mail_arr[0]['name'] = 'HR';
                         $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "";
                         $mail_arr[0]['type'] = 'HR';
                         $mail_arr[1]['name'] = 'Management';
                         $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : "";
                         $mail_arr[1]['type'] = 'Management';
                         $mail_arr[2]['name'] = $Raisedby_person_data['userfullname'];
                         $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress'];
                         $mail_arr[2]['type'] = 'Raise';
                         $mail_arr[3]['name'] = $approver1_person_data['userfullname'];
                         $mail_arr[3]['email'] = $approver1_person_data['emailaddress'];
                         $mail_arr[3]['type'] = 'Approver';
                         // Check if the reporting person and raised person are same - Requisition raised by Manager case
                         if ($requisition_data['reporting_id'] != $requisition_data['createdby']) {
                             $mail_arr[4]['name'] = $report_person_data['userfullname'];
                             $mail_arr[4]['email'] = $report_person_data['emailaddress'];
                             $mail_arr[4]['type'] = 'Report';
                         }
                         $appr_str = "";
                         $appr_str = $approver1_person_data['userfullname'];
                         if ($requisition_data['approver2'] != '') {
                             $approver2_person_data = $user_model->getUserDataById($requisition_data['approver2']);
                             $appr_str .= ", " . $approver2_person_data['userfullname'];
                             $mail_arr[5]['name'] = $approver2_person_data['userfullname'];
                             $mail_arr[5]['email'] = $approver2_person_data['emailaddress'];
                             $mail_arr[5]['type'] = 'Approver';
                         }
                         if ($requisition_data['approver3'] != '') {
                             $approver3_person_data = $user_model->getUserDataById($requisition_data['approver3']);
                             $appr_str .= " and " . $approver3_person_data['userfullname'];
                             $mail_arr[6]['name'] = $approver3_person_data['userfullname'];
                             $mail_arr[6]['email'] = $approver3_person_data['emailaddress'];
                             $mail_arr[6]['type'] = 'Approver';
                         }
                         $mail = array();
                         for ($ii = 0; $ii < count($mail_arr); $ii++) {
                             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                             $view = $this->getHelper('ViewRenderer')->view;
                             $this->view->emp_name = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : '';
                             $this->view->base_url = $base_url;
                             $this->view->type = !empty($mail_arr[$ii]['type']) ? $mail_arr[$ii]['type'] : '';
                             $this->view->jobtitle = $jobtitlename;
                             $this->view->requisition_code = $requisition_data['requisition_code'];
                             $this->view->approver_str = $appr_str;
                             $this->view->raised_name = $Raisedby_person_data['userfullname'];
                             $this->view->req_status = $st_arr[$req_status];
                             $this->view->reporting_manager = $report_person_data['userfullname'];
                             $text = $view->render('mailtemplates/changedrequisition.phtml');
                             $options['subject'] = $st_arr[$req_status] == 'approved' ? APPLICATION_NAME . ': Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected';
                             $options['header'] = 'Requisition Status';
                             $options['toEmail'] = !empty($mail_arr[$ii]['email']) ? $mail_arr[$ii]['email'] : '';
                             $options['toName'] = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : '';
                             $options['message'] = $text;
                             $mail[$ii] = $options;
                             $options['cron'] = 'yes';
                             if ($options['toEmail'] != '') {
                                 sapp_Global::_sendEmail($options);
                             }
                         }
                     } else {
                         if ($req_status == 2) {
                             $approver_person_data = $user_model->getUserDataById($appr_mail);
                             $mail_arr[0]['name'] = $approver_person_data['userfullname'];
                             $mail_arr[0]['email'] = $approver_person_data['emailaddress'];
                             $mail_arr[0]['type'] = 'Approver';
                             if ($edit_flag == 'yes') {
                                 $approved_by_data = $user_model->getUserDataById($requisition_data['approver' . $appr_per]);
                                 $req_status = 2;
                             } else {
                                 $approved_by_data = $user_model->getUserDataById($appr_per);
                             }
                             $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                             $appr_str = $approved_by_data['userfullname'];
                             for ($ii = 0; $ii < count($mail_arr); $ii++) {
                                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                                 $view = $this->getHelper('ViewRenderer')->view;
                                 $this->view->emp_name = $mail_arr[$ii]['name'];
                                 $this->view->base_url = $base_url;
                                 $this->view->type = $mail_arr[$ii]['type'];
                                 $this->view->requisition_code = $requisition_data['requisition_code'];
                                 $this->view->req_status = $st_arr[$req_status];
                                 $this->view->raised_name = $Raisedby_person_data['userfullname'];
                                 $this->view->approver_str = $appr_str;
                                 $text = $view->render('mailtemplates/changedrequisition.phtml');
                                 $options['subject'] = $st_arr[$req_status] == 'approved' ? APPLICATION_NAME . ': Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected';
                                 $options['header'] = 'Requisition Status';
                                 $options['toEmail'] = $mail_arr[$ii]['email'];
                                 $options['toName'] = $mail_arr[$ii]['name'];
                                 $options['message'] = $text;
                                 $options['cron'] = 'yes';
                                 if ($options['toEmail'] != '') {
                                     sapp_Global::_sendEmail($options);
                                 }
                             }
                         }
                     }
                     //end of mailing
                 }
                 $menumodel = new Default_Model_Menu();
                 $objidArr = $menumodel->getMenuObjID('/requisition');
                 $objID = $objidArr[0]['id'];
                 $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
                 if ($id != '') {
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition updated successfully."));
                 } else {
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition added successfully."));
                 }
                 $trDb->commit();
                 $this->_redirect('/requisition');
             }
         } catch (Exception $e) {
             $trDb->rollBack();
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
             $this->_redirect('/requisition');
         }
     } else {
         $messages = $requisitionform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 public function getactiveuserdataAction()
 {
     $search_arr = array();
     $search_arr['createddate'] = $this->_getParam('createddate', null);
     $search_arr['u.emprole'] = $this->_getParam('emprole', null);
     $search_arr['u.isactive'] = $this->_getParam('isactive', null);
     $search_arr['logindatetime'] = $this->_getParam('logindatetime', null);
     $page_no = $this->_getParam('page_no', 1);
     $per_page = $this->_getParam('per_page', PERPAGE);
     $sort_name = $this->_getParam('sort_name', null);
     $sort_type = $this->_getParam('sort_type', null);
     $cols_param_arr = $this->_getParam('cols_arr', array());
     $user_model = new Default_Model_Usermanagement();
     $user_data_org = $user_model->getdata_user_report($search_arr, $per_page, $page_no, $sort_name, $sort_type);
     $page_cnt = $user_data_org['page_cnt'];
     $user_data = $user_data_org['rows'];
     $columns_arr = array('userfullname' => 'Name', 'rolename' => 'Role', 'emailaddress' => 'Email', 'employeeId' => 'ID', 'lastlog' => 'Last Login', 'isactive' => 'Status', 'createdate' => 'Created On');
     if (count($cols_param_arr) == 0) {
         $cols_param_arr = $columns_arr;
     }
     $this->view->user_data = $user_data;
     $this->view->per_page = $per_page;
     $this->view->page_no = $page_no;
     $this->view->sort_name = $sort_name;
     $this->view->sort_type = $sort_type;
     $this->view->cols_param_arr = $cols_param_arr;
     $this->view->page_cnt = $page_cnt;
     $this->view->columns_arr = $columns_arr;
 }
 public function sessiontourAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usermanagementModel = new Default_Model_Usermanagement();
     $status = $usermanagementModel->SaveorUpdateUserData(array('tourflag' => 1), "id=" . $loginUserId);
     if ($status == 'update') {
         $auth->getStorage()->read()->tourflag = 1;
     }
     $this->_helper->json($status);
 }
 /**
  * This function acts as a service for onchange of mode of employment to get candidates or referers.
  * @param array $params_arr  = array of parameters
  * @return array  Array of options.
  */
 public function modeempOnchange($params_arr)
 {
     $result = array();
     $status = 0;
     $message = "Invalid mode of employment.";
     if (isset($params_arr['role_id']) && $params_arr['role_id'] != '' && isset($params_arr['group_id']) && $params_arr['group_id'] != '' && isset($params_arr['modeofentry']) && $params_arr['modeofentry'] != '' && isset($params_arr['userid']) && $params_arr['userid'] != '') {
         $role_id = $params_arr['role_id'];
         $group_id = $params_arr['group_id'];
         $userid = $params_arr['userid'];
         $modeofentry = $params_arr['modeofentry'];
         if ($role_id == SUPERADMINROLE || $group_id == MANAGEMENT_GROUP || $group_id == HR_GROUP) {
             $privilege_flag = sapp_Global::_checkprivileges(EMPLOYEE, $group_id, $role_id, 'add');
             if ($privilege_flag == 'Yes') {
                 if ($modeofentry == "Interview" || $modeofentry == 'Other') {
                     $candidate_model = new Default_Model_Candidatedetails();
                     $candidate_options = $candidate_model->getCandidatesNamesForUsers();
                     $candidate_str = sapp_Global::selectOptionBuilder("", "Select Candidate");
                     //echo "<pre>";print_r($candidate_options);echo "</pre>";
                     if (!empty($candidate_options)) {
                         $status = 1;
                         $message = "success";
                         foreach ($candidate_options as $id => $name) {
                             $candidate_str .= sapp_Global::selectOptionBuilder($id, $name);
                         }
                     } else {
                         $status = 0;
                         $message = "No selected candidates.";
                     }
                     $result['candidates'] = $candidate_str;
                 } else {
                     if ($modeofentry == "Reference") {
                         $user_model = new Default_Model_Usermanagement();
                         $referedby_options = $user_model->getRefferedByForUsers();
                         $refered_str = sapp_Global::selectOptionBuilder("", "Select Referred By");
                         //echo "<pre>";print_r($candidate_options);echo "</pre>";
                         if (!empty($referedby_options)) {
                             $status = 1;
                             $message = "success";
                             foreach ($referedby_options as $id => $name) {
                                 $refered_str .= sapp_Global::selectOptionBuilder($id, $name);
                             }
                         } else {
                             $status = 0;
                             $message = "Employees are not added yet.";
                         }
                         $result['referred_by'] = $refered_str;
                     }
                 }
             }
         }
     }
     return array('status' => $status, 'message' => $message, 'result' => $result);
 }
 public function updateempdetails($employeeform)
 {
     $emproleStr = '';
     $roleArr = array();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usersModel = new Default_Model_Usermanagement();
     $employeeModal = new Default_Model_Employee();
     $businessunit_id = $this->_request->getParam('businessunit_id', null);
     $department_id = $this->_request->getParam('department_id', null);
     $reporting_manager = $this->_request->getParam('reporting_manager', null);
     $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
     $position_id = $this->_request->getParam('position_id', null);
     $user_id = $this->_getParam('user_id', null);
     $prefix_id = $this->_getParam('prefix_id', null);
     $extension_number = $this->_getParam('extension_number', null);
     if ($employeeform->isValid($this->_request->getPost())) {
         $id = $this->_request->getParam('id');
         $emp_status_id = $this->_request->getParam('emp_status_id', null);
         $date_of_joining = $this->_request->getParam('date_of_joining', null);
         $date_of_joining = sapp_Global::change_date($date_of_joining, 'database');
         $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
         $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
         $years_exp = $this->_request->getParam('years_exp');
         //FOR USER table
         $employeeId = $this->_getParam('employeeId', null);
         $modeofentry = $this->_getParam('modeofentry', null);
         $hid_modeofentry = $this->_getParam('hid_modeofentry', null);
         $other_modeofentry = $this->_getParam('other_modeofentry', null);
         $userfullname = $this->_getParam('userfullname', null);
         $candidatereferredby = $this->_getParam('candidatereferredby', null);
         $rccandidatename = $this->_getParam('rccandidatename', null);
         $emprole = $this->_getParam('emprole', null);
         //roleid_group_id
         if ($emprole != "") {
             $roleArr = explode('_', $emprole);
             if (!empty($roleArr)) {
                 $emproleStr = $roleArr[0];
             }
         }
         $emailaddress = $this->_getParam('emailaddress', null);
         $tmp_name = $this->_request->getParam('tmp_emp_name', null);
         $act_inact = $this->_request->getParam("act_inact", null);
         //end of user table
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $empstatusarray = array(8, 9, 10);
         $actionflag = '';
         $tableid = '';
         if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') {
             $candidate_key = 'userfullname';
             $candidate_value = $userfullname;
             $emp_name = $userfullname;
             $candidate_flag = 'no';
         } else {
             $candidate_key = 'rccandidatename';
             $candidate_value = $rccandidatename;
             $emp_name = $tmp_name;
             $candidate_flag = 'yes';
         }
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $emppassword = sapp_Global::generatePassword();
             $user_data = array('emprole' => $emproleStr, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'modifiedby' => $loginUserId, 'modifieddate' => Zend_Registry::get('currentdate'), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry);
             if ($id != '') {
                 $where = array('user_id=?' => $user_id);
                 $actionflag = 2;
                 $user_where = "id = " . $user_id;
                 unset($user_data['candidatereferredby']);
                 unset($user_data['userstatus']);
                 unset($user_data['emppassword']);
                 unset($user_data['employeeId']);
                 unset($user_data['modeofentry']);
                 unset($user_data['other_modeofentry']);
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $user_data['createdby'] = $loginUserId;
                 $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $user_data['isactive'] = 1;
                 if ($modeofentry != 'Direct') {
                     $user_data['userfullname'] = $emp_name;
                 }
                 $where = '';
                 $actionflag = 1;
                 $user_where = '';
             }
             $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where);
             if ($id == '') {
                 $user_id = $user_status;
             }
             $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where);
             $statuswhere = array('id=?' => $user_id);
             if (in_array($emp_status_id, $empstatusarray)) {
                 $isactivestatus = '';
                 if ($emp_status_id == 8) {
                     $isactivestatus = 2;
                 } else {
                     if ($emp_status_id == 9) {
                         $isactivestatus = 3;
                     } else {
                         if ($emp_status_id == 10) {
                             $isactivestatus = 4;
                         }
                     }
                 }
                 $statusdata = array('isactive' => $isactivestatus);
                 $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
             } else {
                 $statusdata = array('isactive' => 1);
                 $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
             }
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully."));
             } else {
                 //start of mailing
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $emp_name;
                 $this->view->password = $emppassword;
                 $this->view->emp_id = $employeeId;
                 $this->view->base_url = $base_url;
                 $text = $view->render('mailtemplates/newpassword.phtml');
                 $options['subject'] = APPLICATION_NAME . ' login credentials';
                 $options['header'] = 'Greetings from Sentrifugo';
                 $options['toEmail'] = $emailaddress;
                 $options['toName'] = $this->view->emp_name;
                 $options['message'] = $text;
                 $result = sapp_Global::_sendEmail($options);
                 //end of mailing
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully."));
             }
             $menuidArr = $menumodel->getMenuObjID('/employee');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $menuidArr = $menumodel->getMenuObjID('/usermanagement');
             $menuID_user = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id);
             if ($act_inact == 1) {
                 if ($user_data['isactive'] == 1) {
                     $act_str = array("Activated" => Zend_Registry::get('currentdate'));
                 } else {
                     $act_str = array("Inactivated" => Zend_Registry::get('currentdate'));
                 }
                 $result = sapp_Global::logManager($menuID_user, 4, $loginUserId, $user_id, '', $act_str);
             }
             $trDb->commit();
             $this->_redirect('employee/edit/id/' . $user_id);
         } catch (Exception $e) {
             $trDb->rollBack();
             $msgarray['employeeId'] = "Something went wrong,please try again later.";
             return $msgarray;
         }
     } else {
         $messages = $employeeform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         $usersModel = new Default_Model_Users();
         if (isset($businessunit_id) && $businessunit_id != 0 && $businessunit_id != '') {
             $departmentsmodel = new Default_Model_Departments();
             $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id);
             $employeeform->department_id->clearMultiOptions();
             $employeeform->reporting_manager->clearMultiOptions();
             $employeeform->department_id->addMultiOption('', 'Select Department');
             foreach ($departmentlistArr as $departmentlistresult) {
                 $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname']));
             }
             if (isset($department_id) && $department_id != 0 && $department_id != '') {
                 $employeeform->setDefault('department_id', $department_id);
             }
         }
         if (isset($department_id) && $department_id != 0 && $department_id != '') {
             $reportingManagerArr = $usersModel->getReportingManagerList($department_id, $user_id);
             $employeeform->reporting_manager->addMultiOption('', 'Select Reporting Manager');
             foreach ($reportingManagerArr as $reportingManagerresult) {
                 $employeeform->reporting_manager->addMultiOption($reportingManagerresult['id'], utf8_encode($reportingManagerresult['userfullname']));
             }
             if (isset($reporting_manager) && $reporting_manager != 0 && $reporting_manager != '') {
                 $employeeform->setDefault('reporting_manager', $reporting_manager);
             }
         }
         if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') {
             $positionsmodel = new Default_Model_Positions();
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             $employeeform->position_id->clearMultiOptions();
             $employeeform->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistRes) {
                 $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname']));
             }
             if (isset($position_id) && $position_id != 0 && $position_id != '') {
                 $employeeform->setDefault('position_id', $position_id);
             }
         }
         return $msgarray;
     }
 }
 /**
  * Send Emails
  * @param type $RequisitionCode
  * @param type $action
  */
 public function requisition_cvupload_emails($requisition_id, $action, $candDetails)
 {
     $user_model = new Default_Model_Usermanagement();
     $requi_model = new Default_Model_Requisition();
     #$identity_code_model = new Default_Model_Identitycodes();
     #$candiate_model = new Default_Model_Candidatedetails();
     //Requisition Summary Data
     $requisition_data = $requi_model->getrequisitiondetails($requisition_id);
     if (isset($requisition_data)) {
         $reqDetails = sprintf("%s-%s-%s (%s)", $requisition_data['businessunit_name'], $requisition_data['department_name'], $requisition_data['jobtitle_name'], $requisition_data['requisition_code']);
         $RequisitionCode = $requisition_data["requisition_code"];
         $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($RequisitionCode);
         //HRExecutive Details
         $hrexecutive_person_data = $user_model->getUserDataById($requisition_data["hrexecutive_id"]);
         //Requester Details
         $Raisedby_person_data = $user_model->getUserDataById($requisition_data["createdby"]);
         //Reporting Manager Details
         $Reportedto_person_data = $user_model->getUserDataById($requisition_data["reporting_id"]);
         //HR Group
         $mail_arr[0]['name'] = 'HR';
         $mail_arr[0]['email'] = constant('REQ_HR_0');
         $mail_arr[0]['type'] = 'CandidateCV';
         //Requester
         $mail_arr[1]['name'] = $Raisedby_person_data['userfullname'];
         $mail_arr[1]['email'] = $Raisedby_person_data['emailaddress'];
         $mail_arr[1]['type'] = 'CandidateCV';
         //HR Executive
         $mail_arr[2]['name'] = $hrexecutive_person_data['userfullname'];
         $mail_arr[2]['email'] = $hrexecutive_person_data['emailaddress'];
         $mail_arr[2]['type'] = 'CandidateCV';
         //Reporting Manager
         $mail_arr[3]['name'] = $Reportedto_person_data['userfullname'];
         $mail_arr[3]['email'] = $Reportedto_person_data['emailaddress'];
         $mail_arr[3]['type'] = 'CandidateCV';
         //Management Group
         $mail_arr[4]['name'] = 'Management';
         $mail_arr[4]['email'] = constant('REQ_MGMT_0');
         $mail_arr[4]['type'] = 'CandidateCV';
         $emailCnt = 5;
         foreach ($requisition_recruiters_data as $requisition_recruiters_data1) {
             $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname'];
             $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress'];
             $mail_arr[$emailCnt]['type'] = 'CandidateCV';
             $emailCnt = $emailCnt + 1;
         }
         $appr_str = $hrexecutive_person_data['userfullname'];
         $jobtitle_name = $requisition_data["jobtitle_name"];
         for ($ii = 0; $ii < count($mail_arr); $ii++) {
             $subjMsg = 'Uploaded CV modified for requisition.';
             if ($action == "New") {
                 $subjMsg = 'New CV uploaded to requisition.';
             }
             if ($action == "Update") {
                 $subjMsg = 'Uploaded CV modified for requisition.';
             }
             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
             $view = $this->getHelper('ViewRenderer')->view;
             $this->view->emp_name = $mail_arr[$ii]['name'];
             $this->view->subjMsg = $subjMsg;
             $this->view->base_url = $base_url;
             $this->view->type = $mail_arr[$ii]['type'];
             $this->view->requisition_details = $reqDetails;
             $this->view->candidate_details = $candDetails;
             $text = $view->render('mailtemplates/requisition.phtml');
             $options['subject'] = APPLICATION_NAME . ':' . $subjMsg;
             $options['header'] = 'Requisition Status';
             $options['toEmail'] = $mail_arr[$ii]['email'];
             $options['toName'] = $mail_arr[$ii]['name'];
             $options['message'] = $text;
             $options['cron'] = 'yes';
             if ($options['toEmail'] != '') {
                 sapp_Global::_sendEmail($options, "requisition", REQUISITIONMODULESENDEMAIL);
             }
         }
     }
 }
 /**
  * This action is used to delete roles and their child data.
  * @parameters
  * @param objid    =   id of role.
  * 
  * @return String    success/failure message 
  */
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $baseUrl = $this->generateBaseurl();
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $actionflag = 3;
     $agencyuser = '******';
     $Id = '';
     if ($id) {
         $user_model = new Default_Model_Usermanagement();
         $menumodel = new Default_Model_Menu();
         $agencylistmodel = new Default_Model_Agencylist();
         $agencyroles = $agencylistmodel->getagencyrole();
         $userData = $user_model->getUserDataById($id);
         $user_role = $userData['emprole'];
         foreach ($agencyroles as $agrole) {
             if ($agrole['id'] == $user_role) {
                 $agencyuser = '******';
             }
         }
         $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = array('id=?' => $id);
         $Id = $user_model->SaveorUpdateUserData($data, $where);
         if ($agencyuser == 'yes') {
             $agencyData = $user_model->getAgencyData($id);
             $user_model->deleteAllagencydetails($agencyData['agencyid'], $loginUserId);
             $emailids = $agencylistmodel->getAllHRManagementEMails();
             $this->sendEMails($agencyData, 'inactivated');
         }
         if ($Id == 'update') {
             $objidArr = $menumodel->getMenuObjID('/roles');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $id);
             $messages['message'] = 'User deleted successfully';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'User cannot be deleted';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'User cannot be deleted';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
Exemple #8
0
 public function changeRM($oldRM, $newRM, $status, $ishead)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $db = Zend_Db_Table::getDefaultAdapter();
     $db->beginTransaction();
     $oldRMData = $this->getsingleEmployeeData($oldRM);
     try {
         if ($status == 'active') {
             $data = array('isactive' => 1, 'emptemplock' => 0, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId);
             $Query1 = "UPDATE main_employees SET isactive = 1, modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE user_id=" . $oldRM . " ;";
             $db->query($Query1);
         } else {
             if ($status == 'inactive') {
                 $data = array('isactive' => 0, 'emptemplock' => 1, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId);
             }
         }
         $where = "id = " . $oldRM;
         $user_model = new Default_Model_Usermanagement();
         $result = $user_model->SaveorUpdateUserData($data, $where);
         if ($status == 'inactive') {
             $empQuery1 = "UPDATE main_employees SET reporting_manager = " . $newRM . ", modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE reporting_manager=" . $oldRM . " and isactive = 1 AND user_id <> " . $newRM . ";";
             $empQuery2 = "UPDATE main_employees SET reporting_manager = " . $oldRMData[0]['reporting_manager'] . ", modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE reporting_manager=" . $oldRM . " and isactive = 1 AND user_id = " . $newRM . ";";
             if ($ishead == '1') {
                 $orgQuery1 = "UPDATE main_employees SET is_orghead = 0,isactive = 0, reporting_manager= " . $newRM . ", modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE user_id=" . $oldRM . " ;";
                 $db->query($orgQuery1);
                 $orgQuery2 = "UPDATE main_employees SET is_orghead = 1,reporting_manager= 0, modifieddate = '" . gmdate("Y-m-d H:i:s") . "', modifiedby = " . $loginUserId . " WHERE user_id=" . $newRM . " ;";
                 $db->query($orgQuery2);
             }
             $db->query($empQuery1);
             $db->query($empQuery2);
         }
         $db->commit();
         return 'success';
     } catch (Exception $e) {
         return 'failed';
         $db->rollBack();
     }
 }
 public function save($form, $data)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $interview_model = new Default_Model_Interviewdetails();
     $user_model = new Default_Model_Usermanagement();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $cand_status = $this->_getParam('cand_status', null);
     $interview_status = $this->_getParam('interview_status', null);
     $flag = 'true';
     if ($interview_status == 'On hold' && $cand_status != 'On hold') {
         $msgarray['statusErr'] = 'Since the interview status is onhold, the candidate status should be onhold.';
         $flag = 'false';
     }
     if ($interview_status == 'Completed' && ($cand_status != 'Disqualified' && $cand_status != 'Shortlisted')) {
         $msgarray['statusErr'] = 'Since interview status is completed, the candidate status can be either disqualified or shortlisted.';
         $flag = 'false';
     }
     if ($interview_status == 'In process' && ($cand_status == 'Disqualified' || $cand_status == 'Shortlisted')) {
         $msgarray['statusErr'] = 'Since the interview status is in process, the candidate cannot be shortlisted or disqualified.';
         $flag = 'false';
     }
     if ($form->isValid($this->_request->getPost()) && $flag != 'false') {
         $id = $this->_getParam('id', null);
         $requisition_id = $this->_getParam('req_id', null);
         $candidate_id = $this->_getParam('candidate_name', null);
         $interviewer_id = $this->_getParam('interviewer_id', null);
         $int_location = $this->_getParam('int_location', null);
         $country = $this->_getParam('country', null);
         $state = $this->_getParam('state', null);
         $city = $this->_getParam('city', null);
         $interview_mode = $this->_getParam('interview_mode', null);
         $interview_time = $this->_getParam('interview_time', null);
         $interview_date = $this->_getParam('interview_date', null);
         $interview_round = $this->_getParam('interview_round', null);
         if (!isset($candidate_id)) {
             $candidate_id = $data['id'];
         }
         if (empty($data)) {
             $getExistingCandidateRecord = $interview_model->getCandidateInInterviewProcess(trim($candidate_id));
             if ($getExistingCandidateRecord > 0) {
                 $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview already scheduled for this candidate.');
                 $this->_redirect('/scheduleinterviews');
             }
         }
         if (empty($data)) {
             $idata = array('req_id' => $requisition_id, 'candidate_id' => trim($candidate_id), 'interview_status' => trim($interview_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $idata['interview_status'] = 'In process';
             $iwhere = "";
             $actionflag = 1;
             $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere);
             if ($id == '') {
                 $tableid = $iresult;
             }
             if ($iresult != '') {
                 $irdata = array('interview_id' => $iresult, 'req_id' => $requisition_id, 'candidate_id' => $candidate_id, 'interviewer_id' => $interviewer_id, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date($interview_date, 'database'), 'interview_mode' => $interview_mode, 'interview_round_number' => 1, 'interview_round' => trim($interview_round), 'int_location' => trim($int_location), 'int_country' => trim(intval($country)), 'int_state' => trim(intval($state)), 'int_city' => trim(intval($city)), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $ir_result = $interview_round_model->SaveorUpdateInterviewroundData($irdata, '');
                 $requisition_data = $requi_model->getRequisitionDataById($requisition_id);
                 $cand_data = $cand_model->getCandidateById($candidate_id);
                 $report_person_data = $user_model->getUserDataById($interviewer_id);
                 $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
                 foreach ($mail_arr as $ename => $email) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $ename;
                     $this->view->base_url = $base_url;
                     $this->view->candidate_name = $cand_data['candidate_name'];
                     $this->view->interview_type = $interview_mode;
                     $this->view->interview_location = $int_location;
                     $this->view->interview_date = $interview_date;
                     $this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                     $this->view->requisition_code = $requisition_data['requisition_code'];
                     $text = $view->render('mailtemplates/interviewrounds.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Interview schedule';
                     $options['header'] = 'Interview schedule';
                     $options['toEmail'] = $email;
                     $options['toName'] = $ename;
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     sapp_Global::_sendEmail($options);
                 }
                 $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = "id = " . $candidate_id;
                 $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where);
             }
         } else {
             $idata = array('interview_status' => trim($interview_status), 'isactive' => 1, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $iwhere = "id = " . $id;
             $tableid = $id;
             $actionflag = 2;
             $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere);
             $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($cand_status && $cand_status != '0') {
                 $candData['cand_status'] = $cand_status;
             }
             $where = "id = " . $candidate_id;
             $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where);
         }
         $menumodel = new Default_Model_Menu();
         $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
         $objID = $objidArr[0]['id'];
         $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
         if ($id == '') {
             $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview scheduled successfully.');
         } else {
             $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview details updated successfully.');
         }
         $this->_redirect('/scheduleinterviews');
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 /**
  * 
  * @param array $data
  * @param type $requisition_code
  * @param type $hrExecutiveID
  */
 public function hrexecutive_to_requisition_emails($data, $requisition_code, $hrExecutiveID)
 {
     $user_model = new Default_Model_Usermanagement();
     $requi_model = new Default_Model_Requisition();
     $identity_code_model = new Default_Model_Identitycodes();
     //for requisition code
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : "";
     if ($irequistion_code != '') {
         $req_id = $requi_model->getMaxReqCode($irequistion_code . "/");
     } else {
         $req_id = '';
     }
     $data['requisition_code'] = $req_id;
     //end of requisition code
     $Raisedby_person_data = $user_model->getUserDataById($data['createdby']);
     $business_unit = $data['businessunit_id'];
     //HR Group
     $mail_arr[0]['name'] = 'HR';
     $mail_arr[0]['email'] = constant('REQ_HR_0');
     $mail_arr[0]['type'] = 'HR';
     //Management Group
     $mail_arr[1]['name'] = 'Management';
     $mail_arr[1]['email'] = constant('REQ_MGMT_0');
     $mail_arr[1]['type'] = 'Management';
     //Requester
     $mail_arr[2]['name'] = $Raisedby_person_data['userfullname'];
     $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress'];
     $mail_arr[2]['type'] = 'Raise';
     $currEmailCount = 3;
     foreach ($hrExecutiveID as $ipid) {
         $hrexecutive_person_data = $user_model->getUserDataById($ipid);
         $mail_arr[$currEmailCount]['name'] = $hrexecutive_person_data['userfullname'];
         $mail_arr[$currEmailCount]['email'] = $hrexecutive_person_data['emailaddress'];
         $mail_arr[$currEmailCount]['type'] = 'HRExecutive';
         $currEmailCount = $currEmailCount + 1;
     }
     #$appr_str = $hrexecutive_person_data['userfullname'];
     $appr_str = $Raisedby_person_data['userfullname'];
     for ($ii = 0; $ii < count($mail_arr); $ii++) {
         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
         $view = $this->getHelper('ViewRenderer')->view;
         $this->view->emp_name = $mail_arr[$ii]['name'];
         $this->view->base_url = $base_url;
         $this->view->type = $mail_arr[$ii]['type'];
         $this->view->jobtitle = "";
         //Job doesnt require for this emails
         $this->view->requisition_code = $requisition_code;
         $this->view->approver_str = $appr_str;
         $this->view->raised_name = $Raisedby_person_data['userfullname'];
         $text = $view->render('mailtemplates/requisition.phtml');
         $options['subject'] = APPLICATION_NAME . ':' . $requisition_code . '-Recruiter allocated for requisition.';
         $options['header'] = 'Requisition Status';
         $options['toEmail'] = $mail_arr[$ii]['email'];
         $options['toName'] = $mail_arr[$ii]['name'];
         $options['message'] = $text;
         //$options['cron'] = 'yes';
         if ($options['toEmail'] != '') {
             sapp_Global::_sendEmail($options, "requisition", REQUISITIONMODULESENDEMAIL);
         }
     }
 }
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $round_model = new Default_Model_Interviewrounddetails();
     $intrvwModel = new Default_Model_Interviewdetails();
     $user_model = new Default_Model_Usermanagement();
     $cand_model = new Default_Model_Candidatedetails();
     $intrvwId = $this->getRequest()->getParam('unitId');
     if ($form->isValid($this->_request->getPost())) {
         $reqData = $intrvwModel->getReqByintrvwID($intrvwId);
         if (!empty($reqData)) {
             $reqId = $reqData['req_id'];
             $candid = $reqData['candidate_id'];
             $id = $this->getRequest()->getParam('id');
             $interview_id = $intrvwId;
             $interviewer_id = $this->getRequest()->getParam('interviewer_id');
             $interview_round = $this->getRequest()->getParam('interview_round');
             $interview_mode = $this->getRequest()->getParam('interview_mode');
             $int_location = $this->getRequest()->getParam('int_location');
             $interview_time = $this->getRequest()->getParam('interview_time');
             $interview_date = $this->getRequest()->getParam('interview_date');
             $interview_feedback = $this->getRequest()->getParam('interview_feedback');
             $interview_comments = $this->getRequest()->getParam('interview_comments');
             $round_status = $this->getRequest()->getParam('round_status', null);
             $hid_round_status = $this->getRequest()->getParam('hid_round_status', null);
             $data = array('candidate_id' => $candid, 'req_id' => $reqId, 'interview_id' => trim($intrvwId), 'interviewer_id' => trim($interviewer_id), 'interview_mode' => trim($interview_mode), 'int_location' => trim($int_location), 'int_country' => trim($this->_getParam('country', null)), 'int_state' => trim($this->_getParam('state', null)), 'int_city' => trim($this->_getParam('city', null)), 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_round' => trim($interview_round), 'interview_feedback' => trim($interview_feedback), 'interview_comments' => trim($interview_comments), 'round_status' => trim($round_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $roundnumberData = $intrvwModel->getinterviewroundnumber($interview_id);
             $roundnumber = $roundnumberData['interview_round_number'];
             $data['interview_round_number'] = $roundnumber + 1;
             $where = "";
             $actionflag = 1;
             if ($id != '') {
                 unset($data['createdby']);
                 unset($data['createdon']);
                 unset($data['isactive']);
                 unset($data['interview_round_number']);
                 $where = array("id = " . $id);
                 $tableid = $id;
                 $actionflag = 2;
                 if ($hid_round_status != '') {
                     $data = array();
                     $data['round_status'] = trim($round_status);
                 }
             }
             if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) && $interviewer_id == $loginUserId) {
                 unset($data['interviewer_id']);
                 unset($data['interview_mode']);
                 unset($data['int_location']);
                 unset($data['int_country']);
                 unset($data['int_state']);
                 unset($data['int_city']);
                 unset($data['interview_time']);
                 unset($data['interview_date']);
                 unset($data['interview_round']);
             }
             $result = $round_model->SaveorUpdateInterviewroundData($data, $where);
             if ($id == '') {
                 //start of mailing
                 $requisition_data = $requi_model->getRequisitionDataById($reqId);
                 $cand_data = $cand_model->getCandidateById($candid);
                 $report_person_data = $user_model->getUserDataById($interviewer_id);
                 $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
                 foreach ($mail_arr as $ename => $email) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $ename;
                     $this->view->base_url = $base_url;
                     $this->view->candidate_name = $cand_data['candidate_name'];
                     $this->view->interview_type = $interview_mode;
                     $this->view->interview_location = $int_location;
                     $this->view->interview_date = $interview_date;
                     $this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                     $this->view->requisition_code = $requisition_data['requisition_code'];
                     $text = $view->render('mailtemplates/interviewrounds.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Interview schedule';
                     $options['header'] = 'Interview schedule';
                     $options['toEmail'] = $email;
                     $options['toName'] = $ename;
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     sapp_Global::_sendEmail($options);
                 }
                 //end of mailing
                 $tableid = $result;
                 $this->view->eventact = 'scheduled';
             } else {
                 if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == MANAGEMENT_GROUP) {
                     $requisition_data = $requi_model->getRequisitionDataById($reqId);
                     $cand_data = $cand_model->getCandidateById($candid);
                     $round_data = $round_model->getSingleRoundData($id);
                     $report_person_data = $user_model->getUserDataById($loginUserId);
                     $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
                     foreach ($mail_arr as $ename => $email) {
                         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $view = $this->getHelper('ViewRenderer')->view;
                         $this->view->emp_name = $ename;
                         $this->view->base_url = $base_url;
                         $this->view->candidate_name = $cand_data['candidate_name'];
                         $this->view->interview_type = $round_data['interview_mode'];
                         $this->view->interview_location = $round_data['int_location'];
                         $this->view->interview_date = sapp_Global::change_date($round_data['interview_date'], 'view');
                         $this->view->interview_time = sapp_Global::change_time($round_data['interview_time'], 'view');
                         $this->view->interview_feedback = $interview_feedback;
                         $this->view->interview_comments = $interview_comments;
                         $this->view->round_status = $round_status;
                         $this->view->reporting_person = $report_person_data['userfullname'];
                         $text = $view->render('mailtemplates/interviewrounds_feedback.phtml');
                         $options['subject'] = APPLICATION_NAME . ': Interview feedback';
                         $options['header'] = 'Interview feedback';
                         $options['toEmail'] = $email;
                         $options['toName'] = $ename;
                         $options['message'] = $text;
                         $options['cron'] = 'yes';
                         sapp_Global::_sendEmail($options);
                     }
                 }
                 $tableid = $id;
                 $this->view->eventact = 'updated';
             }
             $menumodel = new Default_Model_Menu();
             $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $intrvwId);
             $close = 'close';
             $this->view->popup = $close;
             $this->view->ermsg = '';
         } else {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $candidatesmodel = new Default_Model_Shortlistedcandidates();
     $cand_model = new Default_Model_Candidatedetails();
     $requimodel = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     if ($form->isValid($this->_request->getPost())) {
         $id = $this->getRequest()->getParam('id');
         $status = $this->getRequest()->getParam('selectionstatus');
         $txtReason = $this->getRequest()->getParam('txtReason');
         $txtJoiningDate = $this->getRequest()->getParam('txtJoiningDate');
         $candidateData = $candidatesmodel->getcandidateData($id);
         $req_id = $candidateData['requisition_id'];
         $selsctionopt = array('0' => 'Select status', '1' => 'Selected', '2' => 'Rejected', '3' => 'Offered', '4' => 'Offer Accepted', '5' => 'Joined', '6' => 'On Hold', '7' => 'Offer Declined', '8' => 'Yet to offer');
         //validation
         if ($status == "4" && $txtJoiningDate == "") {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("failure" => "Joining Date required."));
             $messages = $form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             return $msgarray;
         } else {
             if (($status == "7" || $status == "2" || $status == "6" || $status == "8") && $txtReason == "") {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("failure" => "Comments required."));
                 $messages = $form->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                 }
                 return $msgarray;
             } else {
                 if ($txtReason == '' && $txtJoiningDate == '') {
                     $data = array('cand_status' => $selsctionopt[$status], 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 } else {
                     if ($txtReason == '' && $txtJoiningDate != '') {
                         $data = array('cand_status' => $selsctionopt[$status], 'joiningdate' => sapp_Global::change_date(trim($txtJoiningDate), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     } else {
                         if ($txtReason != '' && $txtJoiningDate == '') {
                             $data = array('cand_status' => $selsctionopt[$status], 'comments' => $txtReason, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         } else {
                             $data = array('cand_status' => $selsctionopt[$status], 'comments' => $txtReason, 'joiningdate' => sapp_Global::change_date(trim($txtJoiningDate), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         }
                     }
                 }
                 $where = "id = " . $id;
                 $result = $candidatesmodel->SaveorUpdateCandidateDetails($data, $where);
                 //if (($status == '1' || $status == 'Selected' ) && ($result != '')) {
                 //increment selected members count
                 $requimodel->incrementselected_members($req_id);
                 //start of mailing
                 $cand_data = $cand_model->getCandidateById($id);
                 $requisition_data = $requimodel->getRequisitionDataById($req_id);
                 $requisition_data_view = $requimodel->getReqDataForView($req_id);
                 $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']);
                 $requester_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                 /* $mail_arr = array(
                    'HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "",
                    'Management' => defined("REQ_MGMT_" . $requisition_data['businessunit_id']) ? constant("REQ_MGMT_" . $requisition_data['businessunit_id']) : "",
                    $report_person_data['userfullname'] => $report_person_data['emailaddress']
                    );
                    $cstat_arr = array(
                    '0' => 'Select status',
                    '1' => 'Selected',
                    '2' => 'Rejected'
                    ); */
                 //HR Group
                 $mail_arr[0]['name'] = 'HR';
                 $mail_arr[0]['email'] = constant('REQ_HR_0');
                 $mail_arr[0]['type'] = 'CandidateFinalChange';
                 //Requester
                 $mail_arr[1]['name'] = $requester_person_data['userfullname'];
                 $mail_arr[1]['email'] = $requester_person_data['emailaddress'];
                 $mail_arr[1]['type'] = 'CandidateFinalChange';
                 //Management Group
                 $mail_arr[2]['name'] = 'Management';
                 $mail_arr[2]['email'] = constant('REQ_MGMT_0');
                 $mail_arr[2]['type'] = 'CandidateFinalChange';
                 //Reporting Manager
                 $mail_arr[3]['name'] = $report_person_data['userfullname'];
                 $mail_arr[3]['email'] = $report_person_data['emailaddress'];
                 $mail_arr[3]['type'] = 'CandidateFinalChange';
                 for ($ii = 0; $ii < count($mail_arr); $ii++) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $mail_arr[$ii]['name'];
                     $this->view->type = $mail_arr[$ii]['type'];
                     $this->view->base_url = $base_url;
                     $this->view->requisition_data = $requisition_data_view[0];
                     $this->view->candidate_details = $cand_data;
                     $text = $view->render('mailtemplates/requisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ':Candidate ' . $cand_data['cand_status'];
                     $options['header'] = 'Candidate ' . $cstat_arr[$status];
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     sapp_Global::_sendEmail($options, "selectedcandidates", REQUISITIONMODULESENDEMAIL);
                 }
                 //end of mailing
                 //}
                 $actionflag = 2;
                 $tableid = $id;
                 $menumodel = new Default_Model_Menu();
                 $objidArr = $menumodel->getMenuObjID('/shortlistedcandidates');
                 $objID = $objidArr[0]['id'];
                 $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Request updated successfully."));
                 $this->_redirect('/shortlistedcandidates');
             }
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $candidatesmodel = new Default_Model_Shortlistedcandidates();
     $cand_model = new Default_Model_Candidatedetails();
     $requimodel = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     if ($form->isValid($this->_request->getPost())) {
         $id = $this->getRequest()->getParam('id');
         $status = $this->getRequest()->getParam('selectionstatus');
         $candidateData = $candidatesmodel->getcandidateData($id);
         $req_id = $candidateData['requisition_id'];
         $data = array('cand_status' => trim($status), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = "id = " . $id;
         $result = $candidatesmodel->SaveorUpdateCandidateDetails($data, $where);
         if (($status == '2' || $status == 'Selected') && $result != '') {
             //increment selected members count
             $requimodel->incrementselected_members($req_id);
             //start of mailing
             $cand_data = $cand_model->getCandidateById($id);
             $requisition_data = $requimodel->getRequisitionDataById($req_id);
             $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']);
             $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", 'Management' => defined("REQ_MGMT_" . $requisition_data['businessunit_id']) ? constant("REQ_MGMT_" . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
             $cstat_arr = array('0' => 'Select status', '2' => 'Selected', '3' => 'Rejected');
             foreach ($mail_arr as $ename => $email) {
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $ename;
                 $this->view->base_url = $base_url;
                 $this->view->requisition_code = $requisition_data['requisition_code'];
                 $this->view->candidate_name = $cand_data['candidate_name'];
                 $this->view->status = $cstat_arr[$status];
                 $text = $view->render('mailtemplates/selectedcandidates.phtml');
                 $options['subject'] = APPLICATION_NAME . ': Candidate ' . $cstat_arr[$status];
                 $options['header'] = 'Candidate ' . $cstat_arr[$status];
                 $options['toEmail'] = $email;
                 $options['toName'] = $ename;
                 $options['message'] = $text;
                 $options['cron'] = 'yes';
                 sapp_Global::_sendEmail($options);
             }
             //end of mailing
         }
         $actionflag = 2;
         $tableid = $id;
         $menumodel = new Default_Model_Menu();
         $objidArr = $menumodel->getMenuObjID('/shortlistedcandidates');
         $objID = $objidArr[0]['id'];
         $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Request updated successfully."));
         $this->_redirect('/shortlistedcandidates');
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
Exemple #14
0
 /**
  * This action is used to delete roles and their child data.
  * @parameters
  * @param $objid    =   id of role.
  * 
  * @return   {String}   success/failure message 
  */
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $actionflag = 3;
     if ($id) {
         $roles_model = new Default_Model_Roles();
         $user_model = new Default_Model_Usermanagement();
         $user_cnt = $user_model->getUserCntByRole($id);
         if ($user_cnt == 0) {
             $previleges_model = new Default_Model_Privileges();
             $menumodel = new Default_Model_Menu();
             $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $where = array('id=?' => $id);
             $Id = $roles_model->SaveorUpdateRolesData($data, $where);
             if ($Id == 'update') {
                 sapp_Global::generateAccessControl();
                 $prev_data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where_prev = "role = " . $id;
                 $previleges_model->SaveorUpdatePrivilegesData($prev_data, $where_prev);
                 $objidArr = $menumodel->getMenuObjID('/roles');
                 $objID = $objidArr[0]['id'];
                 $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $id);
                 $messages['message'] = 'Role deleted successfully';
                 $messages['msgtype'] = 'success';
             } else {
                 $messages['message'] = 'Role cannot be deleted as Employees with the role exist.';
                 $messages['msgtype'] = 'error';
             }
         } else {
             $messages['message'] = 'Role cannot be deleted as Employees with the role exist.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Role cannot be deleted as Employees with the role exist.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
 public function addorgheadAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $org_id = $this->_request->getParam('orgid', null);
     $msgarray = array();
     $prevorgheadId = '';
     $posted_prevorghead_rm = '';
     try {
         $user_model = new Default_Model_Usermanagement();
         $orgInfoModel = new Default_Model_Organisationinfo();
         $countriesModel = new Default_Model_Countries();
         $statesmodel = new Default_Model_States();
         $citiesmodel = new Default_Model_Cities();
         $role_model = new Default_Model_Roles();
         $prefixModel = new Default_Model_Prefix();
         $identity_code_model = new Default_Model_Identitycodes();
         $jobtitlesModel = new Default_Model_Jobtitles();
         $employeeModal = new Default_Model_Employee();
         $positionsmodel = new Default_Model_Positions();
         $form = new Default_Form_Organisationhead();
         $form->setAttrib('action', BASE_URL . 'organisationinfo/addorghead/orgid/' . $org_id);
         $identity_codes = $identity_code_model->getIdentitycodesRecord();
         $role_data = $role_model->getRolesList_orginfo();
         $flag = 'true';
         $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
         if ($emp_identity_code != '') {
             $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
         } else {
             $emp_id = '';
             $msgarray['employeeId'] = 'Identity codes are not configured yet.';
             $flag = 'false';
         }
         $form->employeeId->setValue($emp_id);
         $form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
         if (empty($role_data)) {
             $msgarray['emprole'] = 'Roles are not added yet.';
             $flag = 'false';
         }
         $prefixData = $prefixModel->getPrefixList();
         $form->prefix_id->addMultiOption('', 'Select Prefix');
         if (!empty($prefixData)) {
             foreach ($prefixData as $prefixres) {
                 $form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
             }
         } else {
             $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         }
         $jobtitleData = $jobtitlesModel->getJobTitleList();
         if (!empty($jobtitleData)) {
             foreach ($jobtitleData as $jobtitleres) {
                 $form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
             }
         } else {
             $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
             $msgarray['position_id'] = 'Positions are not configured yet.';
         }
         $form->position_id->addMultiOption('', 'Select a Position');
         if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
             $jobtitle_id = $_POST['jobtitle_id'];
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             if (sizeof($positionlistArr) > 0) {
                 foreach ($positionlistArr as $positionlistres) {
                     $form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                 }
             }
         }
         if (isset($_POST['prevorghead_rm']) && $_POST['prevorghead_rm'] != '') {
             $posted_prevorghead_rm = $_POST['prevorghead_rm'];
         }
         $orgheadsData = $employeeModal->getEmployeesForOrgHead();
         $emp_data = $employeeModal->fetchRow("is_orghead = 1");
         if (!empty($emp_data)) {
             $user_data = $user_model->fetchRow("id = " . $emp_data->user_id);
             if (!empty($user_data)) {
                 $prevorgheadId = $user_data->id;
             } else {
                 $form->removeElement('prevorghead_rm');
             }
         } else {
             $form->removeElement('prevorghead_rm');
         }
         if ($this->getRequest()->getPost()) {
             if ($form->isValid($this->_request->getPost()) && $flag != 'false') {
                 $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
                 $position_id = $this->_request->getParam('position_id', null);
                 $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining_head', null), 'database');
                 $employeeId = $this->_request->getParam('employeeId', null);
                 $emprole = $this->_request->getParam('emprole', null);
                 $emailaddress = $this->_request->getParam('emailaddress', null);
                 $emppassword = sapp_Global::generatePassword();
                 $first_name = trim($this->_request->getParam('firstname_orghead', null));
                 $last_name = trim($this->_request->getParam('lastname_orghead', null));
                 //$userfullname = trim($this->_request->getParam('orghead',null));
                 $userfullname = $first_name . ' ' . $last_name;
                 $prefix_id = $this->_request->getParam('prefix_id', null);
                 $user_id = $this->_request->getParam('user_id', null);
                 $prevorghead_rm = $this->_request->getParam('prevorghead_rm', null);
                 $prevheadid = $this->_request->getParam('prevheadid', null);
                 $user_data = array('emprole' => $emprole, 'firstname' => $first_name, 'lastname' => $last_name, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'selecteddate' => $date_of_joining, 'userstatus' => 'old', 'modeofentry' => 'Direct', 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
                 $emp_data = array('jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'reporting_manager' => 0, 'date_of_joining' => $date_of_joining, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1, 'is_orghead' => 1);
                 $org_data = array('modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 if ($emp_identity_code != '') {
                     $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                 } else {
                     $emp_id = '';
                 }
                 $user_data['employeeId'] = $emp_id;
                 $db = Zend_Db_Table::getDefaultAdapter();
                 $db->beginTransaction();
                 try {
                     $user_id = $user_model->SaveorUpdateUserData($user_data, '');
                     $emp_data['user_id'] = $user_id;
                     $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
                     if (isset($prevheadid) && $prevheadid != '') {
                         $org_data['orghead'] = $user_id;
                         $orgwhere = array('id=?' => $org_id);
                         $orgInfoModel->SaveorUpdateData($org_data, $orgwhere);
                         $orgInfoModel->changeOrgHead($prevheadid, $user_id, $prevorghead_rm);
                         $this->sendmailstoemployees($prevheadid, $user_id);
                     }
                     $tableid = $user_id;
                     $actionflag = 1;
                     $menuID = EMPLOYEE;
                     try {
                         $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                     } catch (Exception $e) {
                         echo $e->getMessage();
                     }
                     $close = 'close';
                     $this->view->popup = $close;
                     $this->view->eventact = 'added';
                     $db->commit();
                 } catch (Exception $e) {
                     $db->rollBack();
                 }
             } else {
                 $messages = $form->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                 }
             }
         }
         $this->view->prevorgheadId = $prevorgheadId;
         $this->view->form = $form;
         $this->view->msgarray = $msgarray;
         $this->view->orgheadsData = $orgheadsData;
         $this->view->posted_prevorghead_rm = $posted_prevorghead_rm;
     } catch (Exception $e) {
         echo $e->getMessage();
         die;
     }
 }
 public function addemppopupAction()
 {
     $flag = 'true';
     $controllername = 'employee';
     $msgarray = array();
     $emptyFlag = 0;
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $deptidforhead = $this->_getParam('deptidforhead', null);
     $report_opt = array();
     $emp_form = new Default_Form_employee();
     $user_model = new Default_Model_Usermanagement();
     $role_model = new Default_Model_Roles();
     $prefixModel = new Default_Model_Prefix();
     $identity_code_model = new Default_Model_Identitycodes();
     $jobtitlesModel = new Default_Model_Jobtitles();
     $deptModel = new Default_Model_Departments();
     $positionsmodel = new Default_Model_Positions();
     $employeeModal = new Default_Model_Employee();
     $usersModel2 = new Default_Model_Users();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $emp_form->setAction(BASE_URL . 'employee/addemppopup/deptidforhead/' . $deptidforhead);
     $emp_form->removeElement('department_id');
     $emp_form->removeElement('modeofentry');
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
     if ($emp_identity_code != '') {
         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
     } else {
         $emp_id = '';
         $msgarray['employeeId'] = 'Identity codes are not configured yet.';
         $flag = 'false';
     }
     $emp_form->employeeId->setValue($emp_id);
     $role_data = $role_model->getRolesList_Dept();
     $emp_form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
     if (empty($role_data)) {
         $msgarray['emprole'] = 'Roles are not configured yet.';
         $flag = 'false';
     }
     $prefixData = $prefixModel->getPrefixList();
     $emp_form->prefix_id->addMultiOption('', 'Select Prefix');
     if (!empty($prefixData)) {
         foreach ($prefixData as $prefixres) {
             $emp_form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
         }
     } else {
         $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         //$flag = 'false';
     }
     $jobtitleData = $jobtitlesModel->getJobTitleList();
     if (!empty($jobtitleData)) {
         foreach ($jobtitleData as $jobtitleres) {
             $emp_form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
         }
     } else {
         $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
         $msgarray['position_id'] = 'Positions are not configured yet.';
         //$flag = 'false';
     }
     if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
         $positionlistArr = $positionsmodel->getPositionList($_POST['jobtitle_id']);
         if (sizeof($positionlistArr) > 0) {
             $emp_form->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistres) {
                 $emp_form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
             }
         }
     }
     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
     $emp_form->emp_status_id->addMultiOption('', 'Select Employment Status');
     if (!empty($employmentStatusData)) {
         foreach ($employmentStatusData as $employmentStatusres) {
             $emp_form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     } else {
         $msgarray['emp_status_id'] = 'Employment status is not configured yet.';
         $emptyFlag++;
     }
     $reportingManagerData = $usersModel2->getReportingManagerList_employees('', '', MANAGEMENT_GROUP);
     if (!empty($reportingManagerData)) {
         $report_opt = $reportingManagerData;
         if (isset($_POST['reporting_manager']) && $_POST['reporting_manager'] != '') {
             $emp_form->setDefault('reporting_manager', $_POST['reporting_manager']);
         }
     } else {
         $msgarray['reporting_manager'] = 'Reporting managers are not added yet.';
         $flag = 'false';
     }
     if ($this->getRequest()->getPost()) {
         if ($emp_form->isValid($this->_request->getPost()) && $flag == 'true') {
             $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
             $position_id = $this->_request->getParam('position_id', null);
             $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database');
             $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
             $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
             $employeeId = $this->_getParam('employeeId', null);
             $emprole = $this->_getParam('emprole', null);
             $reporting_manager = $this->_getParam('reporting_manager', null);
             $emailaddress = $this->_getParam('emailaddress', null);
             $emppassword = sapp_Global::generatePassword();
             $firstname = trim($this->_getParam('firstname', null));
             $lastname = trim($this->_getParam('lastname', null));
             $userfullname = $firstname . ' ' . $lastname;
             //$userfullname = trim($this->_request->getParam('userfullname',null));
             $prefix_id = $this->_getParam('prefix_id', null);
             $user_id = $this->_getParam('user_id', null);
             $emp_status_id = $this->_getParam('emp_status_id', null);
             $user_data = array('emprole' => $emprole, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => 'Direct', 'selecteddate' => $date_of_joining, 'userstatus' => 'old');
             $emp_data = array('user_id' => $user_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'department_id' => $deptidforhead, 'reporting_manager' => $reporting_manager, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'emp_status_id' => $emp_status_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $user_data['createdby'] = $loginUserId;
             $user_data['createddate'] = gmdate("Y-m-d H:i:s");
             $user_data['isactive'] = 1;
             if ($emp_identity_code != '') {
                 $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
             } else {
                 $emp_id = '';
             }
             $user_data['employeeId'] = $emp_id;
             $user_id = $user_model->SaveorUpdateUserData($user_data, '');
             $emp_data['user_id'] = $user_id;
             $emp_data['createdby'] = $loginUserId;
             $emp_data['createddate'] = gmdate("Y-m-d H:i:s");
             $emp_data['isactive'] = 1;
             $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
             //end of saving into employee table.
             $tableid = $user_id;
             $actionflag = 1;
             $menuID = ORGANISATIONINFO;
             try {
                 $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             } catch (Exception $e) {
             }
             $managementUsersData = $deptModel->getDeptHeads();
             $opt = '';
             foreach ($managementUsersData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['userfullname']);
             }
             $this->view->managementUsersData = $opt;
             /* Send Mail to the user */
             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
             $view = $this->getHelper('ViewRenderer')->view;
             $this->view->emp_name = $userfullname;
             $this->view->password = $emppassword;
             $this->view->emp_id = $employeeId;
             $this->view->base_url = $base_url;
             $text = $view->render('mailtemplates/newpassword.phtml');
             $options['subject'] = APPLICATION_NAME . ' login Credentials';
             $options['header'] = 'Greetings from Sentrifugo';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $this->view->emp_name;
             $options['message'] = $text;
             $result = sapp_Global::_sendEmail($options);
             /* END */
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $emp_form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->msgarray = $msgarray;
     $this->view->report_opt = $report_opt;
     $this->view->controllername = $controllername;
     $this->view->emp_form = $emp_form;
 }
 public function sendInvite($invitepanel, $loginUserId, $meetingdate, $meetingstarttime, $meetingendtime, $Id, $meetingnotes, $meetingtitle)
 {
     $cal_unique_id = $this->getCalendarUniqueID();
     $user_model = new Default_Model_Usermanagement();
     $requi_model = new Default_Model_Requisition();
     $meetingroomModel = new Default_Model_Meetingroom();
     $loginuser_person_data = $user_model->getUserDataById($loginUserId);
     $invitepanel = $invitepanel . "," . $loginUserId;
     $invitepanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($invitepanel);
     foreach ($invitepanelnamesemailaddresss as $invitepanelnamesemailaddress) {
         $description = trim($meetingnotes);
         $from_name = trim($loginuser_person_data['userfullname']);
         $from_address = trim($loginuser_person_data['emailaddress']);
         $to_name = trim($invitepanelnamesemailaddress['userfullname']);
         $to_address = trim($invitepanelnamesemailaddress['emailaddress']);
         $startTime = sapp_Global::_getMeetingScheduleTime(sapp_Global::change_date($meetingdate), sapp_Global::change_time(trim($meetingstarttime)));
         $endTime = sapp_Global::_getMeetingScheduleTime(sapp_Global::change_date($meetingdate), sapp_Global::change_time(trim($meetingendtime)));
         $subject = trim($meetingtitle);
         $location = "INDIA";
         $calRequest = 'REQUEST';
         sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
     }
     $where = "id = " . $Id;
     $irdata = array('calendarinviteid' => $cal_unique_id);
     $ir_result1 = $meetingroomModel->SaveorUpdateData($irdata, $where);
 }
Exemple #18
0
 public static function process_emp_excel($file_name)
 {
     require_once 'Classes/PHPExcel.php';
     require_once 'Classes/PHPExcel/IOFactory.php';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $emp_model = new Default_Model_Employee();
     $usersModel = new Default_Model_Usermanagement();
     $identity_code_model = new Default_Model_Identitycodes();
     $objReader = PHPExcel_IOFactory::createReaderForFile($file_name);
     $objPHPExcel = $objReader->load($file_name);
     //Read first sheet
     $sheet = $objPHPExcel->getSheet(0);
     // Get worksheet dimensions
     $sizeOfWorksheet = $sheet->getHighestDataRow();
     $highestColumn = $sheet->getHighestDataColumn();
     if ($sizeOfWorksheet > 1) {
         $arrReqHeaders = array('Prefix', 'First name', 'Last name', 'Role Type', 'Email', 'Business Unit', 'Department', 'Reporting manager', 'Job Title', 'Position', 'Employment Status', 'Date of joining', 'Date of leaving', 'Experience', 'Extension', 'Work telephone number', 'Fax');
         //Get first/header from excel
         $firstRow = $sheet->rangeToArray('A' . 1 . ':' . $highestColumn . 1, NULL, TRUE, TRUE);
         $arrGivenHeaders = $firstRow[0];
         $diffArray = array_diff_assoc($arrReqHeaders, $arrGivenHeaders);
         $prefix_arr = $emp_model->getPrefix_emp_excel();
         $roles_arr = $emp_model->getRoles_emp_excel();
         $bu_arr = $emp_model->getBU_emp_excel();
         $dep_arr = $emp_model->getDep_emp_excel();
         $job_arr = $emp_model->getJobs_emp_excel();
         $positions_arr = $emp_model->getPositions_emp_excel();
         $users_arr = $emp_model->getUsers_emp_excel();
         $emp_stat_arr = $emp_model->getEstat_emp_excel();
         $dol_emp_stat_arr = $emp_model->getDOLEstat_emp_excel();
         $mng_roles_arr = $emp_model->getMngRoles_emp_excel();
         $emps_arr = $emp_model->getEmps_emp_excel();
         $emails_arr = $emps_arr['email'];
         $emp_ids_arr = $emps_arr['ids'];
         $emp_depts_arr = $emp_model->getEmpsDeptWise();
         $dept_bu_arr = $emp_model->getDeptBUWise();
         $pos_jt_arr = $emp_model->getPosJTWise();
         $identity_codes = $identity_code_model->getIdentitycodesRecord();
         $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             //start of validations
             $ex_prefix_arr = array();
             //$ex_fullname_arr = array();
             $ex_firstname_arr = array();
             $ex_lastname_arr = array();
             $ex_role_arr = array();
             $ex_email_arr = array();
             $ex_bu_arr = array();
             $ex_dep_arr = array();
             $ex_rm_arr = array();
             $ex_jt_arr = array();
             $ex_pos_arr = array();
             $ex_es_arr = array();
             $ex_doj_arr = array();
             $ex_dol_arr = array();
             $ex_exp_arr = array();
             $ex_ext_arr = array();
             $ex_wn_arr = array();
             $ex_fax_arr = array();
             $tot_rec_cnt = 0;
             $err_msg = "";
             for ($i = 2; $i <= $sizeOfWorksheet; $i++) {
                 $rowData_org = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, NULL, TRUE, TRUE);
                 $rowData = $rowData_org[0];
                 $rowData_cpy = $rowData;
                 foreach ($rowData_cpy as $rkey => $rvalue) {
                     $rowData[$rkey] = trim($rvalue);
                 }
                 //start of mandatory checking
                 if (empty($rowData[0])) {
                     $err_msg = "Prefix cannot be empty at row " . $i . ".";
                     break;
                 }
                 /* if(empty($rowData[1]))
                    {
                        $err_msg = "Full Name cannot be empty at row ".$i.".";
                        break;
                    }*/
                 if (empty($rowData[1])) {
                     $err_msg = "First name cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[2])) {
                     $err_msg = "Last name cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[3])) {
                     $err_msg = "Role type cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[4])) {
                     $err_msg = "Email cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[7])) {
                     $err_msg = "Reporting manager cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[8])) {
                     $err_msg = "Job title cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[9])) {
                     $err_msg = "Position cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[10])) {
                     $err_msg = "Employment status cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (empty($rowData[11])) {
                     $err_msg = "Date of joining cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (!in_array($rowData[3], $mng_roles_arr) && empty($rowData[6])) {
                     $err_msg = "Department cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (in_array($rowData[10], $dol_emp_stat_arr) && empty($rowData[12])) {
                     $err_msg = "Date of leaving cannot be empty at row " . $i . ".";
                     break;
                 }
                 if (!in_array($rowData[10], $dol_emp_stat_arr) && !empty($rowData[12]) && in_array($rowData[10], $emp_stat_arr)) {
                     $err_msg = "Date of leaving must be empty for '" . $rowData[10] . "' at row " . $i . ".";
                     break;
                 }
                 // end of mandatory checking
                 // start of pattern checking
                 if (!preg_match("/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)\$/", trim($rowData[0])) && !empty($rowData[0])) {
                     $err_msg = "Prefix is not a valid format at row " . $i . ".";
                     break;
                 }
                 /* if (!preg_match("/^([a-zA-Z.]+ ?)+$/", $rowData[1])  && !empty($rowData[1]))
                    {
                        $err_msg = "Full Name is not a valid format at row ".$i.".";
                        break;
                    }*/
                 if (!preg_match("/^([a-zA-Z.]+ ?)+\$/", $rowData[1]) && !empty($rowData[1])) {
                     $err_msg = "First name is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^([a-zA-Z.]+ ?)+\$/", $rowData[2]) && !empty($rowData[2])) {
                     $err_msg = "Last name is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[a-zA-Z]+?\$/", $rowData[3]) && !empty($rowData[3])) {
                     $err_msg = "Role type is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^(?!.*\\.{2})[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+\$/", $rowData[4]) && !empty($rowData[4])) {
                     $err_msg = "Email is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[a-zA-Z0-9\\&\\'\\.\\s]+\$/", $rowData[5]) && !empty($rowData[5])) {
                     $err_msg = "Business unit is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[a-zA-Z0-9\\&\\'\\.\\s]+\$/", $rowData[6]) && !empty($rowData[6])) {
                     $err_msg = "Department is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[a-zA-Z0-9\\&\\'\\.\\s]+\$/", $rowData[7]) && !empty($rowData[7])) {
                     $err_msg = "Reporting manager is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\s]*\$/", $rowData[8]) && !empty($rowData[8])) {
                     $err_msg = "Job title is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\-\\s]*\$/i", $rowData[9]) && !empty($rowData[9])) {
                     $err_msg = "Position is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)\$/", $rowData[10]) && !empty($rowData[10])) {
                     $err_msg = "Employment status is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!empty($rowData[11])) {
                     try {
                         $test_doj = new DateTime($rowData[11]);
                     } catch (Exception $ex) {
                         return array('status' => 'error', 'msg' => "Date of joining is not a valid format at row " . $i . ".");
                     }
                 }
                 if (!empty($rowData[12])) {
                     try {
                         $test_dol = new DateTime($rowData[12]);
                     } catch (Exception $ex) {
                         return array('status' => 'error', 'msg' => "Date of leaving is not a valid format at row " . $i . ".");
                     }
                 }
                 if (!empty($rowData[12]) && $rowData[12] < $rowData[11]) {
                     $err_msg = "Date of leaving must be greater than date of joining at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[0-9]\\d{0,1}(\\.\\d*)?\$/", $rowData[13]) && !empty($rowData[13])) {
                     $err_msg = "Experience is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[0-9]+\$/", $rowData[14]) && !empty($rowData[14])) {
                     $err_msg = "Extension is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^(?!0{10})[0-9\\+\\-\\)\\(]+\$/", $rowData[15]) && !empty($rowData[15])) {
                     $err_msg = "Work telephone number is not a valid format at row " . $i . ".";
                     break;
                 }
                 if (!preg_match("/^[0-9\\+\\-\\)\\(]+\$/", $rowData[16]) && !empty($rowData[16])) {
                     $err_msg = "Fax is not a valid format at row " . $i . ".";
                     break;
                 }
                 // end of pattern checking
                 // start of checking existence in the system.
                 if (!array_key_exists(strtolower($rowData[0]), $prefix_arr) && !empty($rowData[0])) {
                     $err_msg = "Unknown prefix at row " . $i . ".";
                     break;
                 }
                 if (!array_key_exists(strtolower($rowData[3]), $roles_arr) && !empty($rowData[3])) {
                     $err_msg = "Unknown role type at row " . $i . ".";
                     break;
                 }
                 if (!array_key_exists(strtolower($rowData[5]), $bu_arr) && !empty($rowData[5])) {
                     $err_msg = "Unknown business unit at row " . $i . ".";
                     break;
                 }
                 if (!array_key_exists(strtolower($rowData[6]), $dep_arr) && !empty($rowData[6])) {
                     $err_msg = "Unknown department at row " . $i . ".";
                     break;
                 }
                 if (in_array(strtolower($rowData[4]), $emails_arr) && !empty($rowData[4])) {
                     $err_msg = "Email already exists at row " . $i . ".";
                     break;
                 }
                 if (!in_array(strtolower($rowData[7]), $emp_ids_arr) && !empty($rowData[7])) {
                     $err_msg = "Unknown reporting manager at row " . $i . ".";
                     break;
                 }
                 if (!array_key_exists(strtolower($rowData[8]), $job_arr) && !empty($rowData[8])) {
                     $err_msg = "Unknown job title at row " . $i . ".";
                     break;
                 }
                 if (!array_key_exists(strtolower($rowData[9]), $positions_arr) && !empty($rowData[9])) {
                     $err_msg = "Unknown position at row " . $i . ".";
                     break;
                 }
                 if (!array_key_exists(strtolower($rowData[10]), $emp_stat_arr) && !empty($rowData[10])) {
                     $err_msg = "Unknown employment status at row " . $i . ".";
                     break;
                 }
                 // end of checking existence in the system.
                 if (!empty($rowData[6])) {
                     if (isset($emp_depts_arr[$dep_arr[strtolower($rowData[6])]]) && !in_array(strtolower($rowData[7]), $emp_depts_arr[$dep_arr[strtolower($rowData[6])]])) {
                         if (isset($emp_depts_arr[0]) && is_array($emp_depts_arr[0])) {
                             if (!in_array(strtolower($rowData[7]), $emp_depts_arr[0])) {
                                 $err_msg = "Reporting manager is not belongs to '" . $rowData[6] . "' department at row " . $i . ".";
                                 break;
                             }
                         }
                     }
                 } else {
                     if (isset($emp_depts_arr[0]) && is_array($emp_depts_arr[0])) {
                         if (!in_array(strtolower($rowData[7]), $emp_depts_arr[0])) {
                             $err_msg = "Reporting manager is not belongs to management group at row " . $i . ".";
                             break;
                         }
                     }
                 }
                 if (!empty($rowData[6])) {
                     if (isset($dept_bu_arr[0]) && is_array($dept_bu_arr[0])) {
                         if (in_array(strtolower($rowData[6]), $dept_bu_arr[0]) && !empty($rowData[5])) {
                             $err_msg = "Business unit not needed for this department '" . $rowData[6] . "' at row " . $i . ".";
                             break;
                         }
                         if (!in_array(strtolower($rowData[6]), $dept_bu_arr[0]) && empty($rowData[5])) {
                             $err_msg = "Business unit cannot be empty at row " . $i . ".";
                             break;
                         }
                     }
                     if (!empty($rowData[5])) {
                         if (isset($dept_bu_arr[$bu_arr[strtolower($rowData[5])]]) && !in_array(strtolower($rowData[6]), $dept_bu_arr[$bu_arr[strtolower($rowData[5])]]) && !empty($rowData[5])) {
                             $err_msg = "Department is not belongs to '" . $rowData[5] . "' business unit at row " . $i . ".";
                             break;
                         }
                     }
                 }
                 if (!empty($rowData[8]) && !empty($rowData[9])) {
                     if (isset($pos_jt_arr[$job_arr[strtolower($rowData[8])]]) && !in_array(strtolower($rowData[9]), $pos_jt_arr[$job_arr[strtolower($rowData[8])]]) && !empty($rowData[8])) {
                         $err_msg = "Position is not belongs to '" . $rowData[8] . "' job title at row " . $i . ".";
                         break;
                     }
                 }
             }
             //end of for loop
             if (!empty($err_msg)) {
                 return array('status' => 'error', 'msg' => $err_msg);
             }
             $err_msg = "";
             for ($i = 2; $i <= $sizeOfWorksheet; $i++) {
                 $rowData_org = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, NULL, TRUE, TRUE);
                 $rowData = $rowData_org[0];
                 $rowData_cpy = $rowData;
                 foreach ($rowData_cpy as $rkey => $rvalue) {
                     $rowData[$rkey] = trim($rvalue);
                 }
                 $ex_prefix_arr[] = $rowData[0];
                 //$ex_fullname_arr[] = $rowData[1];
                 $ex_firstname_arr[] = $rowData[1];
                 $ex_lastname_arr[] = $rowData[2];
                 $ex_role_arr[] = $rowData[3];
                 $ex_email_arr[$i] = $rowData[4];
                 $ex_bu_arr[] = $rowData[5];
                 $ex_dep_arr[] = $rowData[6];
                 $ex_rm_arr[] = $rowData[7];
                 $ex_jt_arr[] = $rowData[8];
                 $ex_pos_arr[] = $rowData[9];
                 $ex_es_arr[] = $rowData[10];
                 $ex_doj_arr[] = $rowData[11];
                 $ex_dol_arr[] = $rowData[12];
                 $ex_exp_arr[] = $rowData[13];
                 $ex_ext_arr[] = $rowData[14];
                 $ex_wn_arr[] = $rowData[15];
                 $ex_fax_arr[] = $rowData[16];
                 $tot_rec_cnt++;
             }
             foreach ($ex_email_arr as $key1 => $value1) {
                 $d = 0;
                 foreach ($ex_email_arr as $key2 => $value2) {
                     if ($key1 != $key2 && $value1 == $value2) {
                         $err_msg = "Duplicate email entry at row " . $key2 . ".";
                         $d++;
                         break;
                     }
                 }
                 if ($d > 0) {
                     break;
                 }
             }
             if (!empty($err_msg)) {
                 return array('status' => 'error', 'msg' => $err_msg);
             }
             //end of validations
             //start of saving
             if ($tot_rec_cnt > 0) {
                 for ($i = 2; $i <= $sizeOfWorksheet; $i++) {
                     $emp_id = $emp_identity_code . str_pad($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                     $rowData_org = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, NULL, TRUE, TRUE);
                     $rowData = $rowData_org[0];
                     $rowData_cpy = $rowData;
                     foreach ($rowData_cpy as $rkey => $rvalue) {
                         $rowData[$rkey] = trim($rvalue);
                     }
                     $emppassword = sapp_Global::generatePassword();
                     $date = new DateTime($rowData[11]);
                     $date_of_joining = $date->format('Y-m-d');
                     $date_of_leaving = "";
                     if ($rowData[12] != '') {
                         $ldate = new DateTime($rowData[12]);
                         $date_of_leaving = $ldate->format('Y-m-d');
                     }
                     $userfullname = $rowData[1] . ' ' . $rowData[2];
                     $user_data = array('emprole' => $roles_arr[strtolower($rowData[3])], 'userfullname' => $userfullname, 'firstname' => $rowData[1], 'lastname' => $rowData[2], 'emailaddress' => $rowData[4], 'jobtitle_id' => $job_arr[strtolower($rowData[8])], 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $emp_id, 'modeofentry' => "Direct", 'selecteddate' => $date_of_joining, 'userstatus' => 'old');
                     $user_data['createdby'] = $loginUserId;
                     $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                     $user_data['isactive'] = 1;
                     $user_id = $usersModel->SaveorUpdateUserData($user_data, '');
                     $data = array('user_id' => $user_id, 'reporting_manager' => $users_arr[strtolower($rowData[7])], 'emp_status_id' => $emp_stat_arr[strtolower($rowData[10])], 'businessunit_id' => !empty($rowData[4]) ? $bu_arr[strtolower($rowData[5])] : 0, 'department_id' => !empty($rowData[5]) ? $dep_arr[strtolower($rowData[6])] : null, 'jobtitle_id' => $job_arr[strtolower($rowData[8])], 'position_id' => $positions_arr[strtolower($rowData[9])], 'prefix_id' => $prefix_arr[strtolower($rowData[0])], 'extension_number' => $rowData[13] != '' ? $rowData[14] : NULL, 'office_number' => $rowData[14] != '' ? $rowData[15] : NULL, 'office_faxnumber' => $rowData[15] != '' ? $rowData[16] : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $rowData[13] == '' ? null : $rowData[13], 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     $data['createdby'] = $loginUserId;
                     $data['createddate'] = gmdate("Y-m-d H:i:s");
                     $data['isactive'] = 1;
                     $emp_model->SaveorUpdateEmployeeData($data, '');
                     $text = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t<span style='color:#3b3b3b;'>Hello " . ucfirst($userfullname) . ",</span><br />\n\t\n\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>You have been added to " . APPLICATION_NAME . ". The login credentials for your Sentrifugo account are:</div>\n\t\n\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Username: <strong>" . $emp_id . "</strong></div>\n\t<div style='padding:5px 0 0 0;color:#3b3b3b;'>Password: <strong>" . $emppassword . "</strong></div>\n\t\n\t<div style='padding:20px 0 10px 0;'>Please <a href='" . DOMAIN . "index/popup' target='_blank' style='color:#b3512f;'>click here</a> to login  to your Sentrifugo account.</div>\n\n</div>";
                     $options['subject'] = APPLICATION_NAME . ': Login Credentials';
                     $options['header'] = 'Greetings from Sentrifugo';
                     $options['toEmail'] = $rowData[4];
                     $options['toName'] = $userfullname;
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     $result = sapp_Global::_sendEmail($options);
                 }
                 //end of for loop
                 $trDb->commit();
                 return array('status' => "success", 'msg' => 'Employees saved successfully.');
             } else {
                 return array('status' => 'error', 'msg' => "No records to save.");
             }
             //end of saving
         } catch (Exception $e) {
             $trDb->rollBack();
             return array('status' => 'error', 'msg' => "Something went wrong,please try again.");
         }
     } else {
         return array('status' => 'error', 'msg' => "No records to save.");
     }
 }
 /**
  * 
  * @param type $requisitionform
  * @param type $data
  * @return type
  */
 public function save($requisitionform, $data)
 {
     $ipreporting_id = "";
     $technicalskill_id = "";
     $nontechnicalskill_id = "";
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $jobtitleModel = new Default_Model_Jobtitles();
     $appr_mail = '';
     $appr_per = '';
     if ($requisitionform->isValid($this->_request->getPost())) {
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $id = (int) $this->_getParam('id', null);
             $requisition_code = $this->_getParam('requisition_code', null);
             $onboard_date = $this->_getParam('onboard_date', null);
             $business_unit = $this->_getParam('business_unit', null);
             $department = $this->_getParam('department', null);
             $jobtitle = $this->_getParam('jobtitle', null);
             $position_id = $this->_getParam('position_id', null);
             $reporting_id = $this->_getParam('reporting_id', null);
             $req_no_positions = $this->_getParam('req_no_positions', null);
             $jobdescription = $this->_getParam('jobdescription', null);
             $req_skills = $this->_getParam('req_skills', null);
             $req_qualification = $this->_getParam('req_qualification', null);
             $req_exp_years = $this->_getParam('req_exp_years', null);
             $emp_type = $this->_getParam('emp_type', null);
             $req_priority = $this->_getParam('req_priority', null);
             $additional_info = $this->_getParam('additional_info', null);
             $req_status = $this->_getParam('req_status', null);
             $approver1 = $this->_getParam('approver1', null);
             $approver2 = $this->_getParam('approver2', null);
             $approver3 = $this->_getParam('approver3', null);
             $aflag = $this->_getParam('aflag', null);
             $edit_flag = $this->_getParam('edit_flag', null);
             $edit_order = $this->_getParam('edit_order', null);
             $requ_jd = $this->_getParam('requ_jd', null);
             $billable = $this->_getParam('billable', null);
             $billablefor = $this->_getParam('billablefor', null);
             $billable_empname = $this->_getParam('billable_empname', null);
             $interviewroundscount = $this->_getParam('interviewroundscount', null);
             $technology = $this->_getParam('technology', null);
             try {
                 $ipbusiness_unit = 1;
                 $ipdepartment = 1;
                 $ipreporting_id = $this->_getParam('ipreporting_id', null);
                 $technicalskill_id = $this->_getParam('technicalskill_id', null);
                 $nontechnicalskill_id = $this->_getParam('nontechnicalskill_id', null);
             } catch (Exception $abc) {
             }
             $aorder = $this->_getParam('aorder', null);
             //1= approver1,2=approver2,3=approver3
             if ($aflag != '' && $aflag == 'approver') {
                 if ($req_status == 3) {
                     //for rejected
                     $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'appstatus' . $aorder => $req_status, 'req_status' => $req_status);
                 } else {
                     //for approved
                     if ($aorder == 1) {
                         if ($approver2 != '') {
                             $data = array('appstatus1' => $req_status, 'req_status' => $req_status);
                             $appr_mail = $approver1;
                             $appr_per = $approver1;
                         } else {
                             $data = array('appstatus1' => $req_status, 'req_status' => $req_status);
                             $appr_mail = 'approved';
                         }
                     } else {
                         if ($aorder == 2) {
                             if ($approver3 != '') {
                                 $data = array('appstatus2' => $req_status, 'req_status' => $req_status);
                                 $appr_mail = $approver2;
                                 $appr_per = $approver2;
                             } else {
                                 $data = array('appstatus2' => $req_status, 'req_status' => $req_status);
                                 $appr_mail = 'approved';
                             }
                         }
                     }
                     $data['modifiedby'] = trim($loginUserId);
                     $data['modifiedon'] = gmdate("Y-m-d H:i:s");
                 }
             } else {
                 $data = array('requisition_code' => trim($requisition_code), 'onboard_date' => sapp_Global::change_date(trim($onboard_date), 'database'), 'position_id' => trim($position_id), 'reporting_id' => trim($reporting_id), 'businessunit_id' => trim($business_unit), 'department_id' => trim($department), 'req_no_positions' => trim($req_no_positions), 'jobdescription' => trim($jobdescription), 'jobtitle' => trim($jobtitle), 'req_skills' => trim($req_skills), 'req_qualification' => trim($req_qualification), 'req_exp_years' => trim($req_exp_years), 'emp_type' => trim($emp_type), 'req_priority' => trim($req_priority), 'additional_info' => trim($additional_info), 'billable' => trim($billable), 'interviewroundscount' => trim($interviewroundscount), 'technology' => trim($technology), 'approver1' => $approver1, 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'req_status' => 'Initiated', 'appstatus1' => 'Initiated', 'appstatus2' => null, 'appstatus3' => null, 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createdon' => gmdate("Y-m-d H:i:s"), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'upload_jd' => trim($requ_jd), 'billable_for' => trim($billablefor), 'billable_empname' => trim($billable_empname));
                 if ($loginuserGroup == MANAGER_GROUP) {
                     $data['reporting_id'] = $loginUserId;
                 }
                 if ($edit_flag != '' && $edit_flag == 'yes') {
                     if ($edit_order == 1) {
                         $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus2' => 'Initiated');
                         if ($approver2 == '') {
                             $data['appstatus2'] = null;
                         } else {
                             $appr_per = $edit_order;
                             $appr_mail = $approver2;
                         }
                     }
                     if ($edit_order == 2) {
                         $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus3' => 'Initiated');
                         if ($approver3 == '') {
                             $data['appstatus3'] = null;
                         } else {
                             $appr_per = $edit_order;
                             $appr_mail = $approver3;
                         }
                     }
                 }
             }
             $where = "";
             $actionflag = 1;
             //for mailing
             if ($id == '') {
                 //for requisition code
                 $identity_code_model = new Default_Model_Identitycodes();
                 $identity_codes = $identity_code_model->getIdentitycodesRecord();
                 $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : "";
                 if ($irequistion_code != '') {
                     $req_id = $requi_model->getMaxReqCode($irequistion_code . "/");
                 } else {
                     $req_id = '';
                 }
                 $data['requisition_code'] = $req_id;
                 //end of requisition code
                 $report_person_data = $user_model->getUserDataById($data['reporting_id']);
                 $approver1_person_data = $user_model->getUserDataById($approver1);
                 $Raisedby_person_data = $user_model->getUserDataById($data['createdby']);
                 $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($jobtitle));
                 if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                     $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename'];
                 } else {
                     $jobtitlename = '';
                 }
                 //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $business_unit);
                 //if (isset($hrgroupemail)) {
                 //HR Group
                 $mail_arr[0]['name'] = 'HR';
                 $mail_arr[0]['email'] = constant('REQ_HR_0');
                 $mail_arr[0]['type'] = 'HR';
                 //}
                 //$mgmtgroupemail = $requi_model->getgroupemailid("REQ_MGMT", $business_unit);
                 //if (isset($mgmtgroupemail)) {
                 //HR Group
                 $mail_arr[1]['name'] = 'Management';
                 $mail_arr[1]['email'] = constant('REQ_MGMT_0');
                 $mail_arr[1]['type'] = 'Management';
                 //}
                 $mail_arr[2]['name'] = $Raisedby_person_data['userfullname'];
                 $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress'];
                 $mail_arr[2]['type'] = 'RaiseNew';
                 $mail_arr[3]['name'] = $approver1_person_data['userfullname'];
                 $mail_arr[3]['email'] = $approver1_person_data['emailaddress'];
                 $mail_arr[3]['type'] = 'Approver';
                 $appr_str = "";
                 $appr_str = $approver1_person_data['userfullname'];
                 $req_selected_skills = sprintf("Technical Skills (%s), Non-Technical Skills (%s).", $requi_model->getSkillNamesByIds(implode(",", $technicalskill_id), "Technical"), $requi_model->getSkillNamesByIds(implode(",", $nontechnicalskill_id), "Non-Technical"));
                 for ($ii = 0; $ii < count($mail_arr); $ii++) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $mail_arr[$ii]['name'];
                     $this->view->base_url = $base_url;
                     $this->view->type = $mail_arr[$ii]['type'];
                     $this->view->jobtitle = $jobtitlename;
                     $this->view->requisition_code = $requisition_code;
                     $this->view->approver_str = $appr_str;
                     $this->view->raised_name = $Raisedby_person_data['userfullname'];
                     if ($mail_arr[$ii]['type'] == "RaiseNew" || $mail_arr[$ii]['type'] == 'Raise' || $mail_arr[$ii]['type'] == 'RaiseNew' || $mail_arr[$ii]['type'] == 'HR' || $mail_arr[$ii]['type'] == 'Management' || $mail_arr[$ii]['type'] == 'Approver' || $mail_arr[$ii]['type'] == 'ReportingManager') {
                         //values for new email template
                         $bu_dept = $requi_model->getBusinessUnitDepartmentName(trim($department));
                         $this->view->department_name = $bu_dept['DepartmentName'];
                         $this->view->businessunit_name = $bu_dept['BusinessUnitName'];
                         $this->view->noofopenings = trim($req_no_positions);
                         $this->view->position_name = trim($jobtitlename);
                         $this->view->skills = trim($req_selected_skills);
                         $this->view->application_name = APPLICATION_NAME;
                     }
                     $text = $view->render('mailtemplates/requisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ': ' . $requisition_code . '-Requisition for approval';
                     $options['header'] = 'Requisition Status';
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     //var_dump($text);
                     //$options['cron'] = 'yes';
                     if ($options['toEmail'] != '') {
                         if ($mail_arr[$ii]['type'] == "RaiseNew" || $mail_arr[$ii]['type'] == 'Raise' || $mail_arr[$ii]['type'] == 'RaiseNew' || $mail_arr[$ii]['type'] == 'HR' || $mail_arr[$ii]['type'] == 'Management' || $mail_arr[$ii]['type'] == 'Approver' || $mail_arr[$ii]['type'] == 'ReportingManager') {
                             sapp_Global::_sendEmail($options, "New", REQUISITIONMODULESENDEMAIL);
                         } else {
                             sapp_Global::_sendEmail($options, '', REQUISITIONMODULESENDEMAIL);
                         }
                     }
                 }
             }
             if ($id != '') {
                 unset($data['createdby']);
                 unset($data['createdon']);
                 unset($data['isactive']);
                 $where = "id = " . $id;
                 $tableid = $id;
                 $actionflag = 2;
             }
             $result = $requi_model->SaveorUpdateRequisitionData($data, $where);
             //log approvals by approver
             if ($loginUserId == $approver1) {
                 $requisition_data1 = $requi_model->getRequisitionDataById($id);
                 $result1 = $requi_model->insert_requisition_approvalLog($id, $requisition_data1['requisition_code'], $req_status, $loginUserId, gmdate("Y-m-d H:i:s"));
             }
             /*
              * To Insert Interview Panel & Skill details when a new Requisition created
              */
             $currReqIDinDB = $id;
             if ($currReqIDinDB <= 0) {
                 $currReqIDinDB = $result;
             }
             $requisition_data2 = $requi_model->getRequisitionDataById($currReqIDinDB);
             $result1 = $requi_model->insert_requisition_interview_panel($requisition_data2['requisition_code'], $ipbusiness_unit, $ipdepartment, $ipreporting_id, $requ_jd);
             $result2 = $requi_model->insert_requisition_skills($requisition_data2['requisition_code'], $technicalskill_id, "Technical");
             $result3 = $requi_model->insert_requisition_skills($requisition_data2['requisition_code'], $nontechnicalskill_id, "Non-Technical");
             if ($id == '') {
                 $tableid = $result;
             }
             if ($result != '') {
                 if ($actionflag == 2) {
                     //start of mailing
                     $requisition_data = $requi_model->getRequisitionDataById($id);
                     $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']);
                     $st_arr = array('0' => 'Select status', '2' => 'Approved', '3' => 'Rejected');
                     if ($req_status == 3 || $appr_mail == 'approved') {
                         //for rejected
                         $approver1_person_data = $user_model->getUserDataById($requisition_data['approver1']);
                         $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                         $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($requisition_data['jobtitle']));
                         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                             $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename'];
                         } else {
                             $jobtitlename = '';
                         }
                         /* $mail_arr[0]['name'] = 'HR';
                            $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "";
                            $mail_arr[0]['type'] = 'HR';
                            $mail_arr[1]['name'] = 'Management';
                            $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : "";
                            $mail_arr[1]['type'] = 'Management'; */
                         //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data['businessunit_id']);
                         //if (isset($hrgroupemail)) {
                         //HR Group
                         $mail_arr[0]['name'] = 'HR';
                         $mail_arr[0]['email'] = constant('REQ_HR_0');
                         $mail_arr[0]['type'] = 'HR';
                         //}
                         //$mgmtgroupemail = $requi_model->getgroupemailid("REQ_MGMT", $requisition_data['businessunit_id']);
                         //if (isset($mgmtgroupemail)) {
                         //HR Group
                         $mail_arr[1]['name'] = 'Management';
                         $mail_arr[1]['email'] = constant('REQ_MGMT_0');
                         $mail_arr[1]['type'] = 'Management';
                         //}
                         $mail_arr[2]['name'] = $Raisedby_person_data['userfullname'];
                         $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress'];
                         $mail_arr[2]['type'] = 'Raise';
                         $mail_arr[3]['name'] = $approver1_person_data['userfullname'];
                         $mail_arr[3]['email'] = $approver1_person_data['emailaddress'];
                         $mail_arr[3]['type'] = 'Approver';
                         // Check if the reporting person and raised person are same - Requisition raised by Manager case
                         if ($requisition_data['reporting_id'] != $requisition_data['createdby']) {
                             $mail_arr[4]['name'] = $report_person_data['userfullname'];
                             $mail_arr[4]['email'] = $report_person_data['emailaddress'];
                             $mail_arr[4]['type'] = 'ReportingManager';
                         }
                         $appr_str = "";
                         $appr_str = $approver1_person_data['userfullname'];
                         if ($requisition_data['approver2'] != '') {
                             $approver2_person_data = $user_model->getUserDataById($requisition_data['approver2']);
                             $appr_str .= ", " . $approver2_person_data['userfullname'];
                             $mail_arr[5]['name'] = $approver2_person_data['userfullname'];
                             $mail_arr[5]['email'] = $approver2_person_data['emailaddress'];
                             $mail_arr[5]['type'] = 'Approver';
                         }
                         if ($requisition_data['approver3'] != '') {
                             $approver3_person_data = $user_model->getUserDataById($requisition_data['approver3']);
                             $appr_str .= " and " . $approver3_person_data['userfullname'];
                             $mail_arr[6]['name'] = $approver3_person_data['userfullname'];
                             $mail_arr[6]['email'] = $approver3_person_data['emailaddress'];
                             $mail_arr[6]['type'] = 'Approver';
                         }
                         $mail = array();
                         for ($ii = 0; $ii < count($mail_arr); $ii++) {
                             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                             $view = $this->getHelper('ViewRenderer')->view;
                             $this->view->emp_name = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : '';
                             $this->view->base_url = $base_url;
                             $this->view->type = !empty($mail_arr[$ii]['type']) ? $mail_arr[$ii]['type'] : '';
                             $this->view->jobtitle = $jobtitlename;
                             $this->view->requisition_code = $requisition_data['requisition_code'];
                             $this->view->approver_str = $appr_str;
                             $this->view->raised_name = $Raisedby_person_data['userfullname'];
                             $this->view->req_status = $st_arr[$req_status];
                             $this->view->reporting_manager = $report_person_data['userfullname'];
                             $text = $view->render('mailtemplates/changedrequisition.phtml');
                             $options['subject'] = strtolower($st_arr[$req_status]) == 'approved' ? APPLICATION_NAME . ': ' . $requisition_data['requisition_code'] . '-Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected';
                             $options['header'] = 'Requisition Status';
                             $options['toEmail'] = !empty($mail_arr[$ii]['email']) ? $mail_arr[$ii]['email'] : '';
                             $options['toName'] = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : '';
                             $options['message'] = $text;
                             $mail[$ii] = $options;
                             //$options['cron'] = 'yes';
                             if ($options['toEmail'] != '') {
                                 sapp_Global::_sendEmail($options, "by_approver1", REQUISITIONMODULESENDEMAIL);
                             } else {
                                 sapp_Global::_sendEmail($options, '', REQUISITIONMODULESENDEMAIL);
                             }
                         }
                     } else {
                         if ($req_status == 2) {
                             //Approver
                             $approver_person_data = $user_model->getUserDataById($appr_mail);
                             $mail_arr[0]['name'] = $approver_person_data['userfullname'];
                             $mail_arr[0]['email'] = $approver_person_data['emailaddress'];
                             $mail_arr[0]['type'] = 'Approver';
                             //HR Group
                             $mail_arr[1]['name'] = 'HR';
                             $mail_arr[1]['email'] = constant('REQ_HR_0');
                             $mail_arr[1]['type'] = 'HR';
                             //Management Group
                             $mail_arr[2]['name'] = 'Management';
                             $mail_arr[2]['email'] = constant('REQ_MGMT_0');
                             $mail_arr[2]['type'] = 'Management';
                             //Requester
                             $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                             $mail_arr[3]['name'] = $Raisedby_person_data['userfullname'];
                             $mail_arr[3]['email'] = $Raisedby_person_data['emailaddress'];
                             $mail_arr[3]['type'] = 'Raise';
                             if ($edit_flag == 'yes') {
                                 $approved_by_data = $user_model->getUserDataById($requisition_data['approver' . $appr_per]);
                                 $req_status = 2;
                             } else {
                                 $approved_by_data = $user_model->getUserDataById($appr_per);
                             }
                             $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                             $appr_str = $approved_by_data['userfullname'];
                             for ($ii = 0; $ii < count($mail_arr); $ii++) {
                                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                                 $view = $this->getHelper('ViewRenderer')->view;
                                 $this->view->emp_name = $mail_arr[$ii]['name'];
                                 $this->view->base_url = $base_url;
                                 $this->view->type = $mail_arr[$ii]['type'];
                                 $this->view->requisition_code = $requisition_data['requisition_code'];
                                 $this->view->req_status = $st_arr[$req_status];
                                 $this->view->raised_name = $Raisedby_person_data['userfullname'];
                                 $this->view->approver_str = $appr_str;
                                 $text = $view->render('mailtemplates/changedrequisition.phtml');
                                 $options['subject'] = strtolower($st_arr[$req_status]) == 'approved' ? APPLICATION_NAME . ':' . $requisition_data['requisition_code'] . '-Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected';
                                 $options['header'] = 'Requisition Status';
                                 $options['toEmail'] = $mail_arr[$ii]['email'];
                                 $options['toName'] = $mail_arr[$ii]['name'];
                                 $options['message'] = $text;
                                 //$options['cron'] = 'yes';
                                 if ($options['toEmail'] != '') {
                                     sapp_Global::_sendEmail($options, "by_approver2", REQUISITIONMODULESENDEMAIL);
                                 } else {
                                     sapp_Global::_sendEmail($options, '', REQUISITIONMODULESENDEMAIL);
                                 }
                             }
                         }
                     }
                     //end of mailing
                 }
                 $menumodel = new Default_Model_Menu();
                 $objidArr = $menumodel->getMenuObjID('/requisition');
                 $objID = $objidArr[0]['id'];
                 $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
                 if ($id != '') {
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition updated successfully."));
                 } else {
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition added successfully."));
                 }
                 $trDb->commit();
                 $this->_redirect('/requisition');
             }
         } catch (Exception $e) {
             $trDb->rollBack();
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
             $this->_redirect('/requisition');
         }
     } else {
         $messages = $requisitionform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
Exemple #20
0
 /**
  * This function is used to send mail when we delete any configurations.
  * @param String $config_menu_name  = name of configuration screen (Ex: Positions)
  * @param String $config_name       = name of configuration (Ex: "Developer one")
  */
 public static function send_configuration_mail($config_menu_name, $config_name)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $sess_values = $auth->getStorage()->read();
     }
     $users_model = new Default_Model_Usermanagement();
     $emp_arr = $users_model->getEmpForConfigMail();
     foreach ($emp_arr as $empdata) {
         $text = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\n                    <span style='color:#3b3b3b;'>Dear " . ucfirst($empdata['userfullname']) . ",</span><br />\n\n                        <div style='padding:20px 0 0 0;color:#3b3b3b;'><b>" . ucfirst($config_name) . "</b> " . $config_menu_name . " in configurations has been deleted by " . $sess_values->userfullname . ". </div>    \n                        <div style='padding:20px 0 10px 0;'>Please <a href='" . BASE_URL . "index/popup' target='_blank' style='color:#b3512f;'>click here</a> to login and check the details.</div>\t\t\n\n                    </div>  ";
         $options['subject'] = APPLICATION_NAME . ': ' . ucfirst($config_menu_name) . ' is deleted';
         $options['header'] = ucfirst($config_menu_name) . ' is deleted';
         $options['toEmail'] = $empdata['emailaddress'];
         $options['toName'] = $empdata['userfullname'];
         $options['message'] = $text;
         $options['cron'] = 'yes';
         sapp_Global::_sendEmail($options);
     }
 }
 public function save($requisitionform, $data)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $req_status = $this->_getParam('req_status', null);
     $flag = 'true';
     if ($requisitionform->isValid($this->_request->getPost()) && $flag != 'false') {
         $id = $this->_getParam('id', null);
         $req_status = $this->_getParam('req_status', null);
         $onboard_date = $this->_getParam('onboard_date', null);
         $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"));
         if ($onboard_date != '') {
             $data = $data + array('onboard_date' => sapp_Global::change_date($onboard_date, 'database'));
         }
         $where = "id = " . $id;
         $result = $requi_model->SaveorUpdateRequisitionData($data, $where);
         $tableid = $id;
         $actionflag = 2;
         if ($result != '') {
             if ($req_status == 'Complete' || $req_status == 'Closed') {
                 $requi_model->change_to_requisition_closed($id);
                 $requisition_data = $requi_model->getReqDataForView($id);
                 $requisition_data = $requisition_data[0];
                 $report_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                 $closed_person_data = $user_model->getUserDataById($loginUserId);
                 $mail_arr[0]['name'] = 'HR';
                 $requisition_data['businessunit_id'];
                 $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "";
                 $mail_arr[0]['type'] = 'HR';
                 $mail_arr[1]['name'] = 'Management';
                 $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : "";
                 $mail_arr[1]['type'] = 'Management';
                 $mail_arr[2]['name'] = $report_person_data['userfullname'];
                 $mail_arr[2]['email'] = $report_person_data['emailaddress'];
                 $mail_arr[2]['type'] = 'Raise';
                 for ($ii = 0; $ii < count($mail_arr); $ii++) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $mail_arr[$ii]['name'];
                     $this->view->base_url = $base_url;
                     $this->view->type = $mail_arr[$ii]['type'];
                     $this->view->requisition_code = $requisition_data['requisition_code'];
                     $this->view->req_status = $status = strtolower($req_status == 'Complete' ? "Completed" : $req_status);
                     $this->view->raised_name = $report_person_data['userfullname'];
                     $this->view->approver_str = $closed_person_data['userfullname'];
                     $text = $view->render('mailtemplates/changedrequisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Requisition is ' . $status;
                     $options['header'] = 'Requisition is ' . $status;
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     sapp_Global::_sendEmail($options);
                 }
             }
             $menumodel = new Default_Model_Menu();
             $objidArr = $menumodel->getMenuObjID('/approvedrequisitions');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
             if ($id != '') {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition updated successfully."));
             } else {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition added successfully."));
             }
             $this->_redirect('/approvedrequisitions');
         }
     } else {
         $messages = $requisitionform->getMessages();
         $msgarray = array();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 /**
  * This action is used to add/edit identity codes in popup
  */
 public function addpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $prev_cntrl = $this->_getParam('prev_cntrl', null);
     $user_id = $this->_getParam('user_id', null);
     $IdentityCodesform = new Default_Form_identitycodes();
     $IdentityCodesform->setAction(BASE_URL . 'identitycodes/addpopup/prev_cntrl/' . $prev_cntrl);
     $IdentityCodesModel = new Default_Model_Identitycodes();
     $identity_data = '';
     $IdentityCodesform->removeElement('vendor_code');
     $IdentityCodesform->removeElement('staffing_code');
     try {
         $identityCodesArr = $IdentityCodesModel->getIdentitycodesRecord();
         if (count($identityCodesArr) > 0) {
             $id = $identityCodesArr[0]['id'];
         } else {
             $id = '';
         }
         if ($id != '') {
             $id = abs($id);
             $data = $identityCodesArr;
             //print_r($data);exit;
             if (!empty($data)) {
                 $IdentityCodesform->setDefault("employee_code", $data[0]["employee_code"]);
                 $IdentityCodesform->setDefault("bg_code", $data[0]["backgroundagency_code"]);
                 $IdentityCodesform->setDefault("users_code", $data[0]["users_code"]);
                 $IdentityCodesform->setDefault("requisition_code", $data[0]["requisition_code"]);
                 $IdentityCodesform->setDefault("id", $data[0]["id"]);
                 $IdentityCodesform->submit->setLabel('Update');
                 $this->view->id = $id;
                 $this->view->nodata = '';
             } else {
                 $this->view->nodata = 'norecord';
             }
         } else {
             $IdentityCodesform->submit->setAttrib('value', 'Save');
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
     if (!sapp_Global::_isactivemodule(BGCHECKS)) {
         $IdentityCodesform->removeElement('bg_code');
     }
     if (!sapp_Global::_isactivemodule(RESOURCEREQUISITION)) {
         $IdentityCodesform->removeElement('requisition_code');
     }
     $this->view->form = $IdentityCodesform;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($IdentityCodesform, 'from popup');
         $this->view->msgarray = $result;
         if (isset($result['msg']) && $result['msg'] != '') {
             if ($prev_cntrl == 'usermanagement') {
                 $identityCodesArr = $IdentityCodesModel->getIdentitycodesRecord();
                 $identityCodesArr = $identityCodesArr[0];
                 $identity_data .= sapp_Global::selectOptionBuilder($identityCodesArr['users_code'], "Users (" . $identityCodesArr['users_code'] . ")");
                 /* Removing the codes which are not included for first phase*/
                 //$identity_data = sapp_Global::selectOptionBuilder($identityCodesArr['staffing_code'], "Staffing (".$identityCodesArr['staffing_code'].")");
                 //$identity_data .= sapp_Global::selectOptionBuilder($identityCodesArr['vendors_code'], "Vendors (".$identityCodesArr['vendors_code'].")");
             } else {
                 if ($prev_cntrl == 'organisationinfo' || $prev_cntrl == 'employee') {
                     $user_model = new Default_Model_Usermanagement();
                     if (isset($_POST['user_id']) && $_POST['user_id'] != '') {
                         $user_id = $_POST['user_id'];
                     }
                     if ($user_id != 'new') {
                         $user_data = $user_model->getUserDataById($user_id);
                         $identity_data = $user_data['employeeId'];
                     } else {
                         $identity_codes = $IdentityCodesModel->getIdentitycodesRecord();
                         $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
                         if ($emp_identity_code != '') {
                             $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                         }
                         $identity_data = $emp_id;
                     }
                 }
             }
         }
     }
     $this->view->identity_data = $identity_data;
     $this->view->prev_cntrl = $prev_cntrl;
     $this->view->user_id = $user_id;
 }
 /**
  * 
  * @param type $form
  * @param type $data
  * @return type
  */
 public function save($form, $data)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $interview_model = new Default_Model_Interviewdetails();
     $user_model = new Default_Model_Usermanagement();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $form->round_status->setRequired(false);
     $form->interview_feedback->setRequired(false);
     $cand_status = $this->_getParam('cand_status', null);
     $interview_status = $this->_getParam('interview_status', null);
     $flag = 'true';
     if ($interview_status == 'On hold' && $cand_status != 'On hold') {
         $msgarray['statusErr'] = 'Since the interview status is onhold, the candidate status should be onhold.';
         $flag = 'false';
     }
     if ($interview_status == 'Completed' && ($cand_status != 'Disqualified' && $cand_status != 'Shortlisted')) {
         $msgarray['statusErr'] = 'Since interview status is completed, the candidate status can be either disqualified or shortlisted.';
         $flag = 'false';
     }
     if ($interview_status == 'In process' && ($cand_status == 'Disqualified' || $cand_status == 'Shortlisted')) {
         $msgarray['statusErr'] = 'Since the interview status is in process, the candidate cannot be shortlisted or disqualified.';
         $flag = 'false';
     }
     if ($form->isValid($this->_request->getPost()) && $flag != 'false') {
         $id = $this->_getParam('id', null);
         $requisition_id = $this->_getParam('req_id', null);
         $candidate_id = $this->_getParam('candidate_name', null);
         $interviewer_ids = $this->_getParam('interviewer_id', null);
         $interview_panel = implode(",", $interviewer_ids);
         $interviewer_id = 0;
         foreach ($interviewer_ids as $interview) {
             $interviewer_id = $interview;
             break;
         }
         $int_location = $this->_getParam('int_location', null);
         $country = $this->_getParam('country', null);
         $state = $this->_getParam('state', null);
         $city = $this->_getParam('city', null);
         $interview_mode = $this->_getParam('interview_mode', null);
         $interview_type_details = $this->_getParam('interview_Type_Details', null);
         $interview_time = $this->_getParam('interview_time', null);
         $interview_date = $this->_getParam('interview_date', null);
         $interview_round = $this->_getParam('interview_round', null);
         if (!isset($candidate_id)) {
             $candidate_id = $data['id'];
         }
         if (empty($data)) {
             $getExistingCandidateRecord = $interview_model->getCandidateInInterviewProcess(trim($candidate_id));
             if ($getExistingCandidateRecord > 0) {
                 $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview already scheduled for this candidate.');
                 $this->_redirect('/scheduleinterviews');
             }
         }
         if (empty($data)) {
             $idata = array('req_id' => $requisition_id, 'candidate_id' => trim($candidate_id), 'interview_status' => trim($interview_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $idata['interview_status'] = 'In process';
             $iwhere = "";
             $actionflag = 1;
             $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere);
             if ($id == '') {
                 $tableid = $iresult;
             }
             if ($iresult != '') {
                 $irdata = array('interview_id' => $iresult, 'req_id' => $requisition_id, 'candidate_id' => $candidate_id, 'interviewer_id' => $interviewer_id, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date($interview_date, 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_type_details, 'interview_round_number' => 1, 'interview_round' => trim($interview_round), 'int_location' => trim($int_location), 'int_country' => trim(intval($country)), 'int_state' => trim(intval($state)), 'int_city' => trim(intval($city)), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel);
                 $ir_result = $interview_round_model->SaveorUpdateInterviewroundData($irdata, '');
                 $requisition_data = $requi_model->getRequisitionDataById($requisition_id);
                 $cand_data = $cand_model->getCandidateById($candidate_id);
                 $hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]);
                 $requisition_data = $requi_model->getrequisitiondetails($requisition_id);
                 $requesteremailaddress = $requi_model->getemployeeemailaddress($requisition_data["createdby"]);
                 $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($requisition_data["reporting_id"]);
                 $mail_arr = array('HR' => $hrgroupemail["groupEmail"], $requesteremailaddress['userfullname'] => $requesteremailaddress['emailaddress'], $reportingmanageremailaddress['userfullname'] => $reportingmanageremailaddress['emailaddress']);
                 $loginuser_person_data = $user_model->getUserDataById($loginUserId);
                 $interview_panel = $interview_panel . "," . $loginUserId;
                 $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel);
                 /* $emailtemp = array();
                    $nametemp = array();
                    foreach ($interviewpanelnamesemailaddress as $row) {
                    array_push($emailtemp, $row['emailaddress']);
                    array_push($nametemp, $row['userfullname']);
                    }
                    $email = implode(";", $emailtemp);
                    $ename = implode(";", $nametemp); */
                 $cal_unique_id = $this->getCalendarUniqueID();
                 foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) {
                     $description = "Meeting From : " . $from_name . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n";
                     /* $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                                               $options['subject'] = APPLICATION_NAME . ': Interview schedule';
                                               $options['header'] = 'Interview schedule';
                                               $options['toEmail'] = $interviewpanelnamesemailaddress['emailaddress'];
                                               $options['toName'] = $interviewpanelnamesemailaddress['userfullname'];
                                               $options['message'] = $description;
                                               $options['location'] = $int_location;
                                               $options['interviewdate'] = $interview_date;
                                               $options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0);
                                               $options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600);
                     
                                               //Interview Calendar Invite will be send from login user account
                                               $options['fromEmail'] = trim($loginuser_person_data['emailaddress']);
                                               $options['fromName'] = $loginuser_person_data['userfullname'];
                                               $options['calUniqueID'] = $cal_unique_id;
                                               $options['method'] = 'REQUEST';
                     
                                               //sapp_Global::_sendCalendarEmail($options); */
                     $from_name = trim($loginuser_person_data['userfullname']);
                     $from_address = trim($loginuser_person_data['emailaddress']);
                     $to_name = trim($interviewpanelnamesemailaddress['userfullname']);
                     $to_address = trim($interviewpanelnamesemailaddress['emailaddress']);
                     $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600);
                     $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)));
                     $subject = APPLICATION_NAME . ': Interview schedule';
                     $location = $int_location;
                     $calRequest = 'REQUEST';
                     sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
                 }
                 // update Calendar Invite ID to DB
                 $where = "id = " . $ir_result;
                 $irdata = array('calendarinviteid' => $cal_unique_id);
                 $ir_result1 = $interview_round_model->SaveorUpdateInterviewroundData($irdata, $where);
                 $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = "id = " . $candidate_id;
                 $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where);
             }
         } else {
             $idata = array('interview_status' => trim($interview_status), 'isactive' => 1, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $iwhere = "id = " . $id;
             $tableid = $id;
             $actionflag = 2;
             $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere);
             $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($cand_status && $cand_status != '0') {
                 $candData['cand_status'] = $cand_status;
             }
             $where = "id = " . $candidate_id;
             $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where);
             //send email
             $currentInterviewData = $requi_model->getinterviewdetails($id);
             $requisition_data = $requi_model->getrequisitiondetails($currentInterviewData["req_id"]);
             $currentrequisition_data = $requi_model->getrequisitiondetails($currentInterviewData["req_id"]);
             $cand_data = $cand_model->getCandidateById($candidate_id);
             //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]);
             $requesteremailaddress = $requi_model->getemployeeemailaddress($requisition_data["createdby"]);
             $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($requisition_data["reporting_id"]);
             //HR Group
             $mail_arr[0]['name'] = 'HR';
             $mail_arr[0]['email'] = constant('REQ_HR_0');
             //Requester
             $mail_arr[1]['name'] = $requesteremailaddress['userfullname'];
             $mail_arr[1]['email'] = $requesteremailaddress['emailaddress'];
             //Reporting Manager
             $mail_arr[2]['name'] = $reportingmanageremailaddress['userfullname'];
             $mail_arr[2]['email'] = $reportingmanageremailaddress['emailaddress'];
             //Management Group
             $mail_arr[3]['name'] = 'Management';
             $mail_arr[3]['email'] = constant('REQ_MGMT_0');
             //Recruiter Panel
             $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($currentrequisition_data["requisition_code"]);
             $emailCnt = 4;
             foreach ($requisition_recruiters_data as $requisition_recruiters_data1) {
                 $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname'];
                 $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress'];
                 $emailCnt = $emailCnt + 1;
             }
             //Technical Panel
             $pnlIDS = implode(',', $requi_model->getRequisitionInterviewPanelIDs($currentInterviewData["req_id"]));
             $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($pnlIDS);
             foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress1) {
                 $mail_arr[$emailCnt]['name'] = $interviewpanelnamesemailaddress1['userfullname'];
                 $mail_arr[$emailCnt]['email'] = $interviewpanelnamesemailaddress1['emailaddress'];
                 $emailCnt = $emailCnt + 1;
             }
             for ($ii = 0; $ii < count($mail_arr); $ii++) {
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $mail_arr[$ii]['name'];
                 $this->view->type = 'InterviewSummary';
                 $this->view->requisition_data = $currentrequisition_data;
                 $this->view->candidate_details = $cand_data;
                 $this->view->round_data = $currentInterviewData;
                 $this->view->base_url = $base_url;
                 $text = $view->render('mailtemplates/requisition.phtml');
                 $options['subject'] = APPLICATION_NAME . ': Interview feedback';
                 //$options['header'] = 'Interview feedback';
                 $options['toEmail'] = $mail_arr[$ii]['email'];
                 $options['toName'] = $mail_arr[$ii]['name'];
                 $options['message'] = $text;
                 sapp_Global::_sendEmail($options, "interviewrounds_feedback", REQUISITIONMODULESENDEMAIL);
             }
         }
         $menumodel = new Default_Model_Menu();
         $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
         $objID = $objidArr[0]['id'];
         $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
         if ($id == '') {
             $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview scheduled successfully.');
         } else {
             $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview details updated successfully.');
         }
         $this->_redirect('/scheduleinterviews');
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 public function save($employeeform)
 {
     $emproleStr = '';
     $roleArr = array();
     $empgroupStr = '';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usersModel = new Default_Model_Usermanagement();
     $employeeModal = new Default_Model_Employee();
     $requimodel = new Default_Model_Requisition();
     $candidate_model = new Default_Model_Candidatedetails();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $unitid = '';
     $deptid = '';
     $errorflag = 'true';
     $msgarray = array();
     $id = $this->_request->getParam('id');
     $businessunit_id = $this->_request->getParam('businessunit_id', null);
     $department_id = $this->_request->getParam('department_id', null);
     $reporting_manager = $this->_request->getParam('reporting_manager', null);
     $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
     $position_id = $this->_request->getParam('position_id', null);
     $user_id = $this->_getParam('user_id', null);
     $prefix_id = $this->_getParam('prefix_id', null);
     $extension_number = $this->_getParam('extension_number', null);
     $office_number = $this->_request->getParam('office_number', null);
     $office_faxnumber = $this->_request->getParam('office_faxnumber', null);
     $date_of_joining = $this->_request->getParam('date_of_joining', null);
     $date_of_joining = sapp_Global::change_date($date_of_joining, 'database');
     $isvalidorgstartdate = $orgInfoModel->validateEmployeeJoiningDate($date_of_joining, $unitid, $deptid);
     if (!empty($isvalidorgstartdate)) {
         $msgarray['date_of_joining'] = 'Employee joining date should be greater than organization start date.';
         $errorflag = 'false';
     }
     if ($employeeform->isValid($this->_request->getPost()) && $errorflag == 'true') {
         $id = $this->_request->getParam('id');
         $emp_status_id = $this->_request->getParam('emp_status_id', null);
         $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
         $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
         $years_exp = $this->_request->getParam('years_exp');
         //FOR USER table
         $employeeId = $this->_getParam('employeeId', null);
         $modeofentry = $this->_getParam('modeofentry', null);
         $firstname = trim($this->_getParam('firstname', null));
         $lastname = trim($this->_getParam('lastname', null));
         $userfullname = $firstname . ' ' . $lastname;
         $emprole = $this->_getParam('emprole', null);
         //roleid_group_id
         if ($emprole != "") {
             $roleArr = explode('_', $emprole);
             if (!empty($roleArr)) {
                 $emproleStr = $roleArr[0];
                 $empgroupStr = $roleArr[0];
             }
         }
         $emailaddress = $this->_getParam('emailaddress', null);
         //end of user table
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $empstatusarray = array(8, 9, 10);
         $actionflag = '';
         $tableid = '';
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $emppassword = sapp_Global::generatePassword();
             $user_data = array('emprole' => $emproleStr, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => 0, 'userstatus' => 'old');
             if ($id != '') {
                 $where = array('user_id=?' => $user_id);
                 $actionflag = 2;
                 $user_where = "id = " . $user_id;
                 unset($user_data['candidatereferredby']);
                 unset($user_data['userstatus']);
                 unset($user_data['emppassword']);
                 unset($user_data['employeeId']);
                 unset($user_data['modeofentry']);
             } else {
                 $user_data['createdby'] = $loginUserId;
                 $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $user_data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
                 $user_where = '';
                 $identity_code_model = new Default_Model_Identitycodes();
                 $identity_codes = $identity_code_model->getIdentitycodesRecord();
                 $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
                 if ($emp_identity_code != '') {
                     $emp_id = $emp_identity_code . str_pad($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                 } else {
                     $emp_id = '';
                 }
                 $user_data['employeeId'] = $emp_id;
             }
             $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where);
             if ($id == '') {
                 $user_id = $user_status;
             }
             $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number != '' ? $extension_number : NULL, 'office_number' => $office_number != '' ? $office_number : NULL, 'office_faxnumber' => $office_faxnumber != '' ? $office_faxnumber : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id == '') {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
             }
             $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where);
             $statuswhere = array('id=?' => $user_id);
             if ($id != '') {
                 if (in_array($emp_status_id, $empstatusarray)) {
                     $isactivestatus = '';
                     if ($emp_status_id == 8) {
                         $isactivestatus = 2;
                     } else {
                         if ($emp_status_id == 9) {
                             $isactivestatus = 3;
                         } else {
                             if ($emp_status_id == 10) {
                                 $isactivestatus = 4;
                             }
                         }
                     }
                     $statusdata = array('isactive' => $isactivestatus);
                     $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                     $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                 } else {
                     $edata = $usersModel->getUserDataById($id);
                     $statusdata = array('isactive' => 1);
                     if ($edata['isactive'] != 0) {
                         if ($edata['emptemplock'] == 1) {
                             $statusdata = array('isactive' => 0);
                         }
                         $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                         $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                     }
                 }
             }
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully."));
             } else {
                 //start of mailing
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $userfullname;
                 $this->view->password = $emppassword;
                 $this->view->emp_id = $employeeId;
                 $this->view->base_url = $base_url;
                 $text = $view->render('mailtemplates/newpassword.phtml');
                 $options['subject'] = APPLICATION_NAME . ': Login Credentials';
                 $options['header'] = 'Greetings from Sentrifugo';
                 $options['toEmail'] = $emailaddress;
                 $options['toName'] = $this->view->emp_name;
                 $options['message'] = $text;
                 $result = sapp_Global::_sendEmail($options);
                 //end of mailing
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully."));
             }
             $menuidArr = $menumodel->getMenuObjID('/employee');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id);
             $trDb->commit();
             // Send email to employee when his details are edited by other user.
             $options['subject'] = APPLICATION_NAME . ': Employee details updated';
             $options['header'] = 'Employee details updated';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $userfullname;
             $options['message'] = 'Dear ' . $userfullname . ', your employee details are updated.';
             $options['cron'] = 'yes';
             if (!empty($id)) {
                 sapp_Global::_sendEmail($options);
             }
             $this->_redirect('myemployees/edit/id/' . $user_id);
         } catch (Exception $e) {
             $trDb->rollBack();
             $msgarray['employeeId'] = "Something went wrong, please try again later.";
             return $msgarray;
         }
     } else {
         $messages = $employeeform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') {
             $positionsmodel = new Default_Model_Positions();
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             $employeeform->position_id->clearMultiOptions();
             $employeeform->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistRes) {
                 $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname']));
             }
             if (isset($position_id) && $position_id != 0 && $position_id != '') {
                 $employeeform->setDefault('position_id', $position_id);
             }
         }
         return $msgarray;
     }
 }
 /**
  * 
  * @param type $form
  * @return type
  */
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $round_model = new Default_Model_Interviewrounddetails();
     $round_reschedule_model = new Default_Model_Interviewroundrescheduledetails();
     $intrvwModel = new Default_Model_Interviewdetails();
     $user_model = new Default_Model_Usermanagement();
     $cand_model = new Default_Model_Candidatedetails();
     $roundId = $this->getRequest()->getParam('id');
     $intrvwId = $this->getRequest()->getParam('unitId');
     if ($form->isValid($this->_request->getPost())) {
         $reqData = $intrvwModel->getReqByintrvwID($intrvwId);
         if (!empty($reqData)) {
             $reqId = $reqData['req_id'];
             $candid = $reqData['candidate_id'];
             $id = $this->getRequest()->getParam('id');
             $interviewrnd_id = $intrvwId;
             $interviewer_id1 = $this->getRequest()->getParam('interviewer_id');
             if (is_array($interviewer_id1)) {
                 $interview_id = $interviewer_id1[0];
             } else {
                 $interview_id = $interviewer_id1;
             }
             $interview_round = $this->getRequest()->getParam('interview_round');
             $interview_mode = $this->getRequest()->getParam('interview_mode');
             $interview_Type_Details = $this->getRequest()->getParam('interview_Type_Details');
             $int_location = $this->getRequest()->getParam('int_location');
             $interview_time = $this->getRequest()->getParam('interview_time');
             $interview_date = $this->getRequest()->getParam('interview_date');
             $interview_feedback = $this->getRequest()->getParam('interview_feedback');
             $interview_comments = $this->getRequest()->getParam('interview_comments');
             $round_status = $this->getRequest()->getParam('round_status', null);
             $hid_round_status = $this->getRequest()->getParam('hid_round_status', null);
             if (is_array($interviewer_id1)) {
                 $interview_panel = implode(",", $this->getRequest()->getParam('interviewer_id', null));
             } else {
                 $interview_id = $interviewer_id1;
             }
             if ($id != null) {
                 //get Feedback Matrix values from Request
                 $requisitionSkillMatrix = $round_model->getRequisitionSkillMatrix($id);
                 $currRowCount = 0;
                 foreach ($requisitionSkillMatrix as $skill) {
                     $unqCode = $skill['uniquecode'];
                     $skillSelValue = $this->getRequest()->getParam($unqCode, null);
                     if ($skillSelValue != null) {
                         $requisitionSkillMatrix[$currRowCount]['Rating'] = $skillSelValue;
                     }
                     $currRowCount++;
                 }
             }
             //check if Skill matrix is filled as per business logic
             $skillsmatrixvalidate = true;
             if ($round_status == "Schedule for next round" || $round_status == "Qualified" || $round_status == "Selected" || $round_status == "Disqualified") {
                 if ($interview_round == "Technical") {
                     foreach ($requisitionSkillMatrix as $skill) {
                         if ($skill['Category'] == "Technical" && ($skill['Rating'] <= 0 || $skill['Rating'] == null)) {
                             $skillsmatrixvalidate = false;
                             break;
                         }
                     }
                 }
                 /* else if ($interview_round == "Managerial") {
                    foreach ($requisitionSkillMatrix as $skill) {
                    if ($skill['Category'] == "Non-Technical" && ($skill['Rating'] <= 0 || $skill['Rating'] == null)) {
                    $skillsmatrixvalidate = false;
                    break;
                    }
                    }
                    } */
             }
             if ($skillsmatrixvalidate != true) {
                 $alertMsg = ($interview_round == "Managerial" ? 'Non-Technical' : 'Technical') . " Skill Rating is Mandatory...!";
                 echo '<script language="javascript">';
                 echo 'alert("' . $alertMsg . '")';
                 echo '</script>';
             } else {
                 // for Interview Reschedule & Cancellations
                 if ($round_status == "Re-Scheduled-Interviewer Request" || $round_status == "Re-Scheduled-Candidate Request" || $round_status == "Cancelled") {
                     $round_data = $round_model->getSingleRoundData($id);
                     $cand_data = $cand_model->getCandidateById($candid);
                     $requisition_data = $requi_model->getRequisitionDataById($reqId);
                     $interviewpanelnamesemailaddress = $requi_model->GetInterviewPanelMamesEmailaddress($round_data['interview_panel']);
                     $loginuser_person_data = $user_model->getUserDataById($loginUserId);
                     $data = array('interviewround_id' => $id, 'interview_id' => trim($intrvwId), 'req_id' => $reqId, 'candidate_id' => $candid, 'interview_location_old' => $round_data['int_location'], 'interview_round_old' => $round_data['interview_round'], 'interview_date_old' => $round_data['interview_date'], 'interview_time_old' => $round_data['interview_time'], 'interview_mode_old' => $round_data['interview_mode'], 'interview_mode_details_old' => $round_data['interview_mode_details'], 'interview_location' => $int_location, 'interview_round' => $interview_round, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_Type_Details, 'interview_feedback' => trim($interview_feedback), 'round_status' => trim($round_status), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"));
                     $result1 = $round_reschedule_model->SaveorUpdateInterviewroundData($data, "");
                     $intRound_where = array("id = " . $id);
                     if ($round_status == "Cancelled") {
                         $data_intRound = array('int_location' => $int_location, 'interview_round' => $interview_round, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_Type_Details, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 0);
                     } else {
                         $data_intRound = array('int_location' => $int_location, 'interview_round' => $interview_round, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_Type_Details, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel);
                     }
                     $result2 = $round_model->SaveorUpdateInterviewroundData($data_intRound, $intRound_where);
                     if ($result1 > 0 && $result2 == "update") {
                         //send Reschedule meeting invite
                         $emailtemp = array();
                         $nametemp = array();
                         foreach ($interviewpanelnamesemailaddress as $row) {
                             array_push($emailtemp, $row['emailaddress']);
                             array_push($nametemp, $row['userfullname']);
                         }
                         $email = implode(";", $emailtemp);
                         $ename = implode(";", $nametemp);
                         $cal_unique_id = $round_data['calendarinviteid'];
                         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $description = "Meeting From : " . $ename . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n";
                         //$view = $this->getHelper('ViewRenderer')->view;
                         //$this->view->emp_name = "Interviewer";
                         //$this->view->base_url = $base_url;
                         //$this->view->candidate_name = $cand_data['candidate_name'];
                         //$this->view->interview_type = $interview_mode;
                         //$this->view->interview_mode_details = $interview_Type_Details;
                         //$this->view->interview_location = $int_location;
                         //$this->view->interview_date = $interview_date;
                         //$this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                         //$this->view->requisition_code = $requisition_data['requisition_code'];
                         //$text = $view->render('mailtemplates/interviewrounds.phtml');
                         //$options['subject'] = APPLICATION_NAME . ': Interview schedule';
                         //$options['header'] = 'Interview schedule';
                         //$options['toEmail'] = $email;
                         //$options['toName'] = $ename;
                         //$options['message'] = $description;
                         //$options['location'] = $int_location;
                         //$options['interviewdate'] = $interview_date;
                         //$options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0);
                         //$options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600);
                         //Interview Calendar Invite will be send from login user account
                         //$options['fromEmail'] = $loginuser_person_data['emailaddress'];
                         //$options['fromName'] = $loginuser_person_data['userfullname'];
                         //$options['fromEmail'] = SUPERADMIN_EMAIL;
                         //$options['fromName'] = "*****@*****.**";
                         //$options['calUniqueID'] = $cal_unique_id;
                         $calRequest = 'REQUEST';
                         if ($round_status == "Cancelled") {
                             $calRequest = 'CANCEL';
                         }
                         $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel);
                         foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) {
                             //sapp_Global::_sendCalendarEmail($options);
                             $from_name = trim($loginuser_person_data['userfullname']);
                             $from_address = trim($loginuser_person_data['emailaddress']);
                             $to_name = trim($interviewpanelnamesemailaddress['userfullname']);
                             $to_address = trim($interviewpanelnamesemailaddress['emailaddress']);
                             $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600);
                             $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)));
                             $subject = APPLICATION_NAME . ': Interview schedule';
                             $location = $int_location;
                             sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
                         }
                         $irwhere = "id = " . $result1;
                         $irdata = array('calendarinviteid' => $cal_unique_id);
                         $interview_round_model = new Default_Model_Interviewrounddetails();
                         $ir_result1 = $interview_round_model->SaveorUpdateInterviewroundData($irdata, $irwhere);
                         $this->view->eventact = 'updated';
                         $actionflag = 1;
                         $menumodel = new Default_Model_Menu();
                         $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
                         $objID = $objidArr[0]['id'];
                         $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $intrvwId);
                         $close = 'close';
                         $this->view->popup = $close;
                         $this->view->ermsg = '';
                     }
                 } else {
                     $data = array('candidate_id' => $candid, 'req_id' => $reqId, 'interview_id' => trim($intrvwId), 'interviewer_id' => $interview_id, 'interview_mode' => trim($interview_mode), 'interview_mode_details' => $interview_Type_Details, 'int_location' => trim($int_location), 'int_country' => trim($this->_getParam('country', null)), 'int_state' => trim($this->_getParam('state', null)), 'int_city' => trim($this->_getParam('city', null)), 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_round' => trim($interview_round), 'interview_feedback' => trim($interview_feedback), 'interview_comments' => trim($interview_comments), 'round_status' => trim($round_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel);
                     if ($interviewrnd_id != null) {
                         $roundnumberData = $intrvwModel->getinterviewroundnumber($interviewrnd_id);
                         $roundnumber = $roundnumberData['interview_round_number'];
                     }
                     $data['interview_round_number'] = $roundnumber + 1;
                     $currentinterviewroundnumber = $roundnumber;
                     $where = "";
                     $actionflag = 1;
                     if ($id != '') {
                         //update skill matrix to DB
                         if ($round_status == "Schedule for next round" || $round_status == "Qualified" || $round_status == "Selected" || $round_status == "Disqualified") {
                             $skillupdateresult = $round_model->UpdateOrInsertCandidateSkillMatrix($requisitionSkillMatrix, $id, $intrvwId, $reqId, $candid, $loginUserId, $currentinterviewroundnumber);
                         }
                         unset($data['interview_panel']);
                         unset($data['createdby']);
                         unset($data['createdon']);
                         unset($data['isactive']);
                         unset($data['interview_round_number']);
                         $where = array("id = " . $id);
                         $tableid = $id;
                         $actionflag = 2;
                         if ($hid_round_status != '') {
                             $data = array();
                             $data['round_status'] = trim($round_status);
                         }
                     }
                     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) && $interviewer_id == $loginUserId) {
                         unset($data['interviewer_id']);
                         unset($data['interview_mode']);
                         unset($data['int_location']);
                         unset($data['int_country']);
                         unset($data['int_state']);
                         unset($data['int_city']);
                         unset($data['interview_time']);
                         unset($data['interview_date']);
                         unset($data['interview_round']);
                     }
                     $result = $round_model->SaveorUpdateInterviewroundData($data, $where);
                     //upadating invite calander id if interview round id is numeric
                     if (is_numeric($result)) {
                         //updating calendarinviteid column in main_interviewrounddetails tabel - start
                         $startTime = sapp_Global::add_time($interview_time, 'view', 0);
                         //$domain = 'deltaintech.com';
                         //$cal_unique_id = date("Ymd\TGis", strtotime($startTime)) . rand() . "@" . $domain;
                         $irwhere = "id = " . $result;
                         $irdata = array('calendarinviteid' => $cal_unique_id);
                         $interview_round_model1 = new Default_Model_Interviewrounddetails();
                         $ir_result1 = $interview_round_model1->SaveorUpdateInterviewroundData($irdata, $irwhere);
                     }
                     //upadating invite calander id if interview round id is numeric - End
                     if ($id == '') {
                         //start of mailing
                         $requisition_data = $requi_model->getRequisitionDataById($reqId);
                         $cand_data = $cand_model->getCandidateById($candid);
                         /* $report_person_data = $user_model->getUserDataById($interviewer_id);
                            $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "",
                            $report_person_data['userfullname'] => $report_person_data['emailaddress']
                            ); */
                         $report_person_data = $user_model->getUserDataById($interviewer_id);
                         $currentrequisition_data = $requi_model->getrequisitiondetails($reqId);
                         $requesteremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["createdby"]);
                         $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["reporting_id"]);
                         $hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]);
                         $mail_arr = array('HR' => $hrgroupemail["groupEmail"], $report_person_data['userfullname'] => $report_person_data['emailaddress'], $requesteremailaddress['userfullname'] => $requesteremailaddress['emailaddress'], $reportingmanageremailaddress['userfullname'] => $reportingmanageremailaddress['emailaddress']);
                         //foreach ($mail_arr as $ename => $email) {
                         //$base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $description = "Meeting From : " . $ename . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n";
                         //$view = $this->getHelper('ViewRenderer')->view;
                         //$this->view->emp_name = $ename;
                         //$this->view->base_url = $base_url;
                         //$this->view->candidate_name = $cand_data['candidate_name'];
                         //$this->view->interview_type = $interview_mode;
                         //$interview_Type_Details
                         //$this->view->interview_location = $int_location;
                         //$this->view->interview_date = $interview_date;
                         //$this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                         //$this->view->requisition_code = $requisition_data['requisition_code'];
                         //$text = $view->render('mailtemplates/interviewrounds.phtml');
                         //$options['subject'] = APPLICATION_NAME . ': Interview schedule';
                         //$options['header'] = 'Interview schedule';
                         //$options['toEmail'] = $email;
                         //$options['toName'] = $ename;
                         //$options['message'] = $description;
                         ////$options['cron'] = 'yes';
                         //additional properties for Calendar invite -------------------START
                         //$options['interviewdate'] = $interview_date;
                         //$options['location'] = $int_location;
                         //$options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0);
                         //$options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600);
                         //$options['calUniqueID'] = $cal_unique_id;
                         //additional properties for Calendar invite -------------------END
                         //sapp_Global::_sendCalendarEmail($options);
                         $loginuser_person_data = $user_model->getUserDataById($loginUserId);
                         $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel);
                         foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) {
                             $cal_unique_id = $this->getCalendarUniqueID();
                             $from_name = trim($loginuser_person_data['userfullname']);
                             $from_address = trim($loginuser_person_data['emailaddress']);
                             $to_name = trim($interviewpanelnamesemailaddress['userfullname']);
                             $to_address = trim($interviewpanelnamesemailaddress['emailaddress']);
                             $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600);
                             $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)));
                             $subject = APPLICATION_NAME . ': Interview schedule';
                             $location = $int_location;
                             $calRequest = 'REQUEST';
                             sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
                         }
                         //}
                         //end of mailing
                         $tableid = $result;
                         $this->view->eventact = 'scheduled';
                     } else {
                         if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == MANAGEMENT_GROUP) {
                             $requisition_data = $requi_model->getRequisitionDataById($reqId);
                             $requisition_data_View = $requi_model->getReqDataForView($reqId);
                             $cand_data = $cand_model->getCandidateById($candid);
                             $round_data = $round_model->getSingleRoundData($id);
                             $report_person_data = $user_model->getUserDataById($interviewer_id);
                             $currentrequisition_data = $requi_model->getrequisitiondetails($reqId);
                             $requesteremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["createdby"]);
                             $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["reporting_id"]);
                             //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]);
                             //HR Group
                             $mail_arr[0]['name'] = 'HR';
                             $mail_arr[0]['email'] = constant('REQ_HR_0');
                             //Requester
                             $mail_arr[1]['name'] = $requesteremailaddress['userfullname'];
                             $mail_arr[1]['email'] = $requesteremailaddress['emailaddress'];
                             //Reporting Manager
                             $mail_arr[2]['name'] = $reportingmanageremailaddress['userfullname'];
                             $mail_arr[2]['email'] = $reportingmanageremailaddress['emailaddress'];
                             //Management Group
                             $mail_arr[3]['name'] = 'Management';
                             $mail_arr[3]['email'] = constant('REQ_MGMT_0');
                             //Recruiter Panel
                             $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($currentrequisition_data["requisition_code"]);
                             $emailCnt = 4;
                             foreach ($requisition_recruiters_data as $requisition_recruiters_data1) {
                                 $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname'];
                                 $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress'];
                                 $emailCnt = $emailCnt + 1;
                             }
                             //Technical Panel
                             $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($round_data['interview_panel']);
                             foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress1) {
                                 $mail_arr[$emailCnt]['name'] = $interviewpanelnamesemailaddress1['userfullname'];
                                 $mail_arr[$emailCnt]['email'] = $interviewpanelnamesemailaddress1['emailaddress'];
                                 $emailCnt = $emailCnt + 1;
                             }
                             for ($ii = 0; $ii < count($mail_arr); $ii++) {
                                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                                 $view = $this->getHelper('ViewRenderer')->view;
                                 $this->view->emp_name = $mail_arr[$ii]['name'];
                                 $this->view->type = 'InterviewFeedback';
                                 $this->view->requisition_data = $requisition_data_View[0];
                                 $this->view->candidate_details = $cand_data;
                                 $this->view->round_data = $round_data;
                                 $this->view->base_url = $base_url;
                                 $text = $view->render('mailtemplates/requisition.phtml');
                                 $options['subject'] = APPLICATION_NAME . ': Interview feedback';
                                 //$options['header'] = 'Interview feedback';
                                 $options['toEmail'] = $mail_arr[$ii]['email'];
                                 $options['toName'] = $mail_arr[$ii]['name'];
                                 $options['message'] = $text;
                                 sapp_Global::_sendEmail($options, "interviewrounds_feedback", REQUISITIONMODULESENDEMAIL);
                             }
                         }
                         $tableid = $id;
                         $this->view->eventact = 'updated';
                     }
                     $menumodel = new Default_Model_Menu();
                     $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
                     $objID = $objidArr[0]['id'];
                     $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $intrvwId);
                     $close = 'close';
                     $this->view->popup = $close;
                     $this->view->ermsg = '';
                 }
             }
         } else {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }