public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     $role_datap = array();
     $empGroup = "";
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserUnitID = $auth->getStorage()->read()->businessunit_id;
         $loginuserDeptID = $auth->getStorage()->read()->department_id;
     }
     $id = (int) $this->getRequest()->getParam('id');
     $id = abs($id);
     if ($id == '') {
         $id = $loginUserId;
     }
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $employeeform = new Default_Form_Myteamemployee();
     try {
         if ($id != '' && is_numeric($id) && $id > 0 && $id != $loginUserId) {
             $employeeModal = new Default_Model_Employee();
             $usersModel = new Default_Model_Users();
             $employmentstatusModel = new Default_Model_Employmentstatus();
             $busineesUnitModel = new Default_Model_Businessunits();
             $deptModel = new Default_Model_Departments();
             $role_model = new Default_Model_Roles();
             $user_model = new Default_Model_Usermanagement();
             $candidate_model = new Default_Model_Candidatedetails();
             $jobtitlesModel = new Default_Model_Jobtitles();
             $positionsmodel = new Default_Model_Positions();
             $prefixModel = new Default_Model_Prefix();
             $data = array();
             $empDeptId = "";
             $empRoleId = "";
             $data = $employeeModal->getsingleEmployeeData($id);
             if ($data == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 if (!empty($data)) {
                     $this->view->rowexist = "rows";
                     $employeeform->submit->setLabel('Update');
                     $data = $data[0];
                     /* Earlier code to fetch employee details */
                     $employeeData = $employeeModal->getsingleEmployeeData($id);
                     $roles_arr = $role_model->getRolesListByGroupID(EMPLOYEE_GROUP);
                     if (sizeof($roles_arr) > 0) {
                         $employeeform->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
                     }
                     $employmentStatusData = $employmentstatusModel->getempstatuslist();
                     if (sizeof($employmentStatusData) > 0) {
                         $employeeform->emp_status_id->addMultiOption('', 'Select Employment Status');
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $businessunitData = $busineesUnitModel->getDeparmentList();
                     if (sizeof($businessunitData) > 0) {
                         foreach ($businessunitData as $businessunitres) {
                             if ($businessunitres['id'] == $loginuserUnitID) {
                                 $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']);
                             }
                         }
                     }
                     $departmentsData = $deptModel->getDepartmentList($data['businessunit_id']);
                     if (sizeof($departmentsData) > 0) {
                         foreach ($departmentsData as $departmentsres) {
                             if ($departmentsres['id'] == $loginuserDeptID) {
                                 $employeeform->department_id->addMultiOption($departmentsres['id'], $departmentsres['deptname']);
                             }
                         }
                     }
                     $jobtitleData = $jobtitlesModel->getJobTitleList();
                     if (sizeof($jobtitleData) > 0) {
                         $employeeform->jobtitle_id->addMultiOption('', 'Select Job Title');
                         foreach ($jobtitleData as $jobtitleres) {
                             $employeeform->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
                         }
                     }
                     $positionlistArr = $positionsmodel->getPositionList($data['jobtitle_id']);
                     if (sizeof($positionlistArr) > 0) {
                         $employeeform->position_id->addMultiOption('', 'Select Position');
                         foreach ($positionlistArr as $positionlistres) {
                             $employeeform->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                         }
                     }
                     $prefixData = $prefixModel->getPrefixList();
                     if (!empty($prefixData)) {
                         foreach ($prefixData as $prefixres) {
                             $employeeform->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
                         }
                     }
                     $userData = $usersModel->getUserDetails($loginUserId);
                     if (count($userData) > 0) {
                         $employeeform->reporting_manager->addMultiOption($userData[0]['id'], $userData[0]['userfullname']);
                     }
                     $employeeform->populate($data);
                     $employeeform->setDefault('user_id', $data['user_id']);
                     $employeeform->setDefault('emp_status_id', $data['emp_status_id']);
                     $employeeform->setDefault('businessunit_id', $data['businessunit_id']);
                     $employeeform->setDefault('jobtitle_id', $data['jobtitle_id']);
                     $employeeform->setDefault('department_id', $data['department_id']);
                     $employeeform->setDefault('position_id', $data['position_id']);
                     $employeeform->setDefault('prefix_id', $data['prefix_id']);
                     $date_of_joining = sapp_Global::change_date($data['date_of_joining'], 'view');
                     $employeeform->date_of_joining->setValue($date_of_joining);
                     if ($data['date_of_leaving'] != '' && $data['date_of_leaving'] != '0000-00-00') {
                         $date_of_leaving = sapp_Global::change_date($data['date_of_leaving'], 'view');
                         $employeeform->date_of_leaving->setValue($date_of_leaving);
                     }
                     $role_data = $role_model->getRoleDataById($data['emprole']);
                     $employeeform->emprole->setValue($data['emprole'] . "_" . $role_data['group_id']);
                     $employeeform->setAttrib('action', DOMAIN . 'myemployees/edit/id/' . $id);
                     $this->view->id = $id;
                     $this->view->form = $employeeform;
                     $this->view->employeedata = !empty($employeeData) ? $employeeData[0] : "";
                     $this->view->messages = $this->_helper->flashMessenger->getMessages();
                     $this->view->data = $data;
                 }
             }
         } else {
             $this->view->rowexist = "norows";
         }
         if ($this->getRequest()->getPost()) {
             $result = $this->save($employeeform);
             $this->view->msgarray = $result;
             $employeeform->modeofentry->setValue($data['modeofentry']);
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
 }
Esempio n. 2
0
 public function addpopupAction()
 {
     $emptyFlag = NULL;
     $msgarray = array();
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $jobtitleid = $this->_request->getParam('jobtitleid');
     $visible = true;
     $controllername = 'positions';
     $positionsform = new Default_Form_positions();
     $positionsmodel = new Default_Model_Positions();
     $jobtitlesmodel = new Default_Model_Jobtitles();
     if ($jobtitleid == null) {
         $jobtitleidmodeldata = $jobtitlesmodel->getJobTitleList();
         if (!empty($jobtitleidmodeldata)) {
             foreach ($jobtitleidmodeldata as $jobtitleidres) {
                 $positionsform->jobtitleid->addMultiOption($jobtitleidres['id'], utf8_encode($jobtitleidres['jobtitlename']));
                 $this->view->notdisplayposition = 0;
             }
         } else {
             $msgarray['jobtitleid'] = 'Job titles are not configured yet.';
             $emptyFlag++;
         }
         $this->view->emptyFlag = $emptyFlag;
     } else {
         $jobtitleidres = $jobtitlesmodel->getsingleJobTitleData($jobtitleid);
         $positionsform->jobtitleid->addMultiOption($jobtitleidres[0]['id'], utf8_encode($jobtitleidres[0]['jobtitlename']));
         $positionsform->setDefault('jobtitleid', $jobtitleid);
         $this->view->notdisplayposition = $jobtitleid;
     }
     $positionsform->setAction(BASE_URL . 'positions/addpopup');
     if ($this->getRequest()->getPost()) {
         if ($positionsform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $positionname = $this->_request->getParam('positionname');
             $jobtitleidpop = $this->_request->getParam('jobtitleid');
             $description = $this->_request->getParam('description');
             $displayposition = $this->_request->getParam('display');
             $date = new Zend_Date();
             $menumodel = new Default_Model_Menu();
             $actionflag = '';
             $tableid = '';
             $data = array('positionname' => trim($positionname), 'jobtitleid' => $jobtitleidpop, 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
             }
             $Id = $positionsmodel->SaveorUpdatePositionData($data, $where);
             $tableid = $Id;
             $menuidArr = $menumodel->getMenuObjID('/positions');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $opt = '';
             if ($displayposition == '0') {
                 $this->view->positionlistArr = $opt;
             } else {
                 $positionlistArr = $positionsmodel->getPositionList($displayposition);
                 foreach ($positionlistArr as $record) {
                     $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['positionname']);
                 }
                 $this->view->positionlistArr = $opt;
             }
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $positionsform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->controllername = $controllername;
     $this->view->form = $positionsform;
     $this->view->ermsg = '';
     $this->view->disableselect = $visible;
 }
 /**
  * This action is used for adding/updating data.
  * @parameters
  * @param $id  =  id of candidate (optional)
  * 
  * @return Zend_Form.
  */
 public function editAction()
 {
     $req_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $cand_model = new Default_Model_Candidatedetails();
     $candwork_model = new Default_Model_Candidateworkdetails();
     $country_model = new Default_Model_Countries();
     $role_model = new Default_Model_Roles();
     $auth = Zend_Auth::getInstance();
     $data = array();
     $jobtitle = '';
     $req_data['jobtitlename'] = '';
     $popConfigPermission = array();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'country');
     }
     if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'state');
     }
     if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'city');
     }
     $id = trim($this->getRequest()->getParam('id'));
     if (is_numeric($id) && $id > 0) {
         try {
             $candidateData = $cand_model->getcandidateData($id);
             $form = new Default_Form_Candidatedetails($candidateData['requisition_id']);
             $form->setAction(DOMAIN . 'candidatedetails/edit/id/' . $id);
             $statsflag = 'false';
             if (count($candidateData) > 0) {
                 try {
                     $candidateworkData = $candwork_model->getcandidateworkData($id);
                     $req_data = $req_model->getRequisitionDataById($candidateData['requisition_id']);
                     // To show it on edit view
                     $data['cand_resume'] = isset($candidateData['cand_resume']) ? $candidateData['cand_resume'] : NULL;
                     $data['rec_id'] = isset($id) ? $id : NULL;
                     $data['selected_option'] = $this->_getParam('selected_option');
                     $req_data['jobtitlename'] = '';
                     $jobttlArr = $jobtitleModel->getsingleJobTitleData($req_data['jobtitle']);
                     if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                         $jobtitle = $jobttlArr[0]['jobtitlename'];
                         $req_data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
                     }
                     if (($req_data['req_status'] == 'Closed' || $req_data['req_status'] == 'On hold' || $req_data['req_status'] == 'Complete') && ($candidateData['cand_status'] == 'Requisition Closed/Completed' || $candidateData['cand_status'] == 'On hold' || $candidateData['cand_status'] == 'Not Scheduled')) {
                         //|| $candidateData['cand_status'] == 'Rejected' || $candidateData['cand_status'] == 'Disqualified'
                         $statsflag = 'true';
                         $reqforcv_data = $req_model->getRequisitionsForCV("'Approved','In process'");
                         $req_options = array();
                         foreach ($reqforcv_data as $req) {
                             $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
                         }
                         $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
                         $form->cand_status->addMultiOption('', 'Select Status');
                         $form->cand_status->addMultiOption('Not Scheduled', 'Not Scheduled');
                     }
                     $countryId = $candidateData['country'];
                     if (isset($_POST['country'])) {
                         $countryId = $_POST['country'];
                     }
                     $stateId = $candidateData['state'];
                     if (isset($_POST['state'])) {
                         $stateId = $_POST['state'];
                     }
                     $cityId = $candidateData['city'];
                     if (isset($_POST['city'])) {
                         $cityId = $_POST['city'];
                     }
                     if ($countryId != '') {
                         $statesmodel = new Default_Model_States();
                         $statesData = $statesmodel->getStatesList($countryId);
                         foreach ($statesData as $res) {
                             $form->state->addMultiOption($res['id'], utf8_encode($res['state_name']));
                         }
                         $form->setDefault('country', $countryId);
                     }
                     if ($stateId != '') {
                         $citiesmodel = new Default_Model_Cities();
                         $citiesData = $citiesmodel->getCitiesList($stateId);
                         foreach ($citiesData as $res) {
                             $form->city->addMultiOption($res['id'], utf8_encode($res['city_name']));
                         }
                         $form->setDefault('state', $stateId);
                     }
                     $form->setDefault('city', $cityId);
                     $form->setDefault('job_title', $jobtitle);
                     $countrieslistArr = $country_model->getTotalCountriesList();
                     if (sizeof($countrieslistArr) > 0) {
                         $form->country->addMultiOption('', 'Select Country');
                         foreach ($countrieslistArr as $countrieslistres) {
                             $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                         }
                     } else {
                         $msgarray['country'] = 'Countries are not configured yet';
                     }
                     $data['requisition_code'] = $req_data['requisition_code'];
                     $data['requisition_id'] = $req_data['id'];
                     $data['jobtitlename'] = $req_data['jobtitlename'];
                     if ($id) {
                         $form->submit->setLabel('Update');
                         foreach ($candidateData as $key => $val) {
                             $candidateData[$key] = htmlentities(addslashes($val), ENT_QUOTES, "UTF-8");
                         }
                         $form->populate($candidateworkData);
                         $form->populate($candidateData);
                     }
                     $this->view->candidate_data = $candidateData;
                     $this->view->form = $form;
                     $this->view->workdata = $candidateworkData;
                     $this->view->data = $data;
                     $this->view->popConfigPermission = $popConfigPermission;
                     $this->view->statsflag = $statsflag;
                     $this->view->ermsg = '';
                     if ($this->getRequest()->getPost()) {
                         $result = $this->save($form);
                         $this->view->msgarray = $result;
                         $this->view->messages = $result;
                     }
                 } catch (Exception $e) {
                     $this->view->ermsg = 'nodata';
                 }
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $this->view->ermsg = 'nodata';
     }
 }
Esempio n. 4
0
 /**
  * This function returns candidates and interviewers based on a particular requisition code.
  * @param integer $req_id          = id of requisition
  * @param integer $loginUserGroup  = id of group
  * @param integer $loginUserId     = id of logged user
  * @return array  Array of candidate options and interviewers options.
  */
 public function getcandidates_forinterview($req_id, $loginUserGroup, $loginUserId)
 {
     $jobtitleModel = new Default_Model_Jobtitles();
     $candsmodel = new Default_Model_Candidatedetails();
     $reqData = $this->getRequisitionDataById($req_id);
     $candsData = $candsmodel->getnotscheduledcandidateData($req_id);
     $candStr = '';
     $jobttlArr = array();
     $jobtitle = '';
     $managerStr = "";
     if (!empty($candsData)) {
         foreach ($candsData as $cand) {
             $candStr .= sapp_Global::selectOptionBuilder($cand['id'], $cand['candidate_name']);
         }
     } else {
         $candStr = "nocandidates";
     }
     if (!empty($reqData)) {
         $reqData['jobtitlename'] = '';
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($reqData['jobtitle']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = $jobttlArr[0]['jobtitlename'];
             $reqData['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $repmanData = $this->getReportingmanagers($loginUserGroup, $loginUserId, '', $reqData['department_id'], 'interviewer');
         if (!empty($repmanData)) {
             foreach ($repmanData as $rep) {
                 $managerStr .= sapp_Global::selectOptionBuilder($rep['id'], $rep['name'], $rep['profileimg']);
             }
         } else {
             $managerStr = "nomanagers";
         }
     }
     return array('candidates' => $candStr, 'managers' => $managerStr, 'jobtitle' => $jobtitle);
 }
 public function indexAction()
 {
     $editPrivilege = "";
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $loginUserId;
     $data = array();
     $tabName = "employee";
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $employeeform = new Default_Form_employee();
     try {
         if ($id != '' && $id > 0) {
             $employeeModal = new Default_Model_Employee();
             $usersModel = new Default_Model_Users();
             $employmentstatusModel = new Default_Model_Employmentstatus();
             $busineesUnitModel = new Default_Model_Businessunits();
             $deptModel = new Default_Model_Departments();
             $role_model = new Default_Model_Roles();
             $user_model = new Default_Model_Usermanagement();
             $candidate_model = new Default_Model_Candidatedetails();
             $jobtitlesModel = new Default_Model_Jobtitles();
             $positionsmodel = new Default_Model_Positions();
             $prefix_model = new Default_Model_Prefix();
             $data = $employeeModal->getsingleEmployeeData($id);
             if ($data == 'norows') {
                 $this->view->rowexist = "norows";
                 $this->view->empdata = "";
             } else {
                 if (!empty($data)) {
                     $this->view->rowexist = "rows";
                     $this->view->empdata = $data;
                     $elements = $employeeform->getElements();
                     if (count($elements) > 0) {
                         foreach ($elements as $key => $element) {
                             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                 $element->setAttrib("disabled", "disabled");
                             }
                         }
                     }
                     $employeeform->removeElement("submit");
                     $data = $data[0];
                     if ($loginUserId == SUPERADMIN) {
                         //If login user is superAdmin..... role is 'Super Admin'.
                         $employeeform->emprole->addMultiOption('superAdmin', 'Super Admin');
                     } else {
                         $roles_arr = $role_model->getRolesDataByID($data['emprole']);
                         if (sizeof($roles_arr) > 0) {
                             $employeeform->emprole->addMultiOption($roles_arr[0]['id'] . '_' . $roles_arr[0]['group_id'], utf8_encode($roles_arr[0]['rolename']));
                         }
                     }
                     $prefix_data = $prefix_model->getsinglePrefixData($data['prefix_id']);
                     if ($prefix_data != 'norows') {
                         $prefix_data = $prefix_data[0];
                         $employeeform->prefix_id->addMultiOption($prefix_data['id'], $prefix_data['prefix']);
                     }
                     $referedby_options = $user_model->getRefferedByForUsers();
                     /* Code for reporting manager dropdown */
                     $reportingManagerData = $usersModel->getUserDetailsByID($data['reporting_manager']);
                     if (!empty($reportingManagerData)) {
                         $employeeform->reporting_manager->addMultiOption($reportingManagerData[0]['id'], $reportingManagerData[0]['userfullname']);
                     }
                     $employmentStatusData = $employmentstatusModel->getempstatuslist();
                     if (sizeof($employmentStatusData) > 0) {
                         $employeeform->emp_status_id->addMultiOption('', 'Select a Employment Status');
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $businessunitData = $busineesUnitModel->getDeparmentList();
                     if (sizeof($businessunitData) > 0) {
                         $employeeform->businessunit_id->addMultiOption('0', 'No Business Unit');
                         foreach ($businessunitData as $businessunitres) {
                             $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']);
                         }
                     }
                     $departmentsData = $deptModel->getDepartmentList($data['businessunit_id']);
                     if (sizeof($departmentsData) > 0) {
                         $employeeform->department_id->addMultiOption('', 'Select a Department');
                         foreach ($departmentsData as $departmentsres) {
                             $employeeform->department_id->addMultiOption($departmentsres['id'], $departmentsres['deptname']);
                         }
                     }
                     $jobtitleData = $jobtitlesModel->getJobTitleList();
                     if (sizeof($jobtitleData) > 0) {
                         $employeeform->jobtitle_id->addMultiOption('', 'Select a Job Title');
                         foreach ($jobtitleData as $jobtitleres) {
                             $employeeform->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
                         }
                     }
                     $positionlistArr = $positionsmodel->getPositionList($data['jobtitle_id']);
                     if (sizeof($positionlistArr) > 0) {
                         $employeeform->position_id->addMultiOption('', 'Select a Position');
                         foreach ($positionlistArr as $positionlistres) {
                             $employeeform->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                         }
                     }
                     $employeeform->populate($data);
                     $employeeform->setDefault('user_id', $data['user_id']);
                     $employeeform->setDefault('emp_status_id', $data['emp_status_id']);
                     $employeeform->setDefault('businessunit_id', $data['businessunit_id']);
                     $employeeform->setDefault('jobtitle_id', $data['jobtitle_id']);
                     $employeeform->setDefault('department_id', $data['department_id']);
                     $employeeform->setDefault('position_id', $data['position_id']);
                     if ($data['date_of_joining'] != '' && $data['date_of_joining'] != '0000-00-00') {
                         $date_of_joining = sapp_Global::change_date($data['date_of_joining'], 'view');
                         $employeeform->date_of_joining->setValue($date_of_joining);
                     }
                     if ($data['date_of_leaving'] != '' && $data['date_of_leaving'] != '0000-00-00') {
                         $date_of_leaving = sapp_Global::change_date($data['date_of_leaving'], 'view');
                         $employeeform->date_of_leaving->setValue($date_of_leaving);
                     }
                     if ($data['modeofentry'] != 'Direct') {
                         $employeeform->rccandidatename->setValue($data['userfullname']);
                     }
                     if (sizeof($referedby_options) > 0 && $data['candidatereferredby'] != '' && $data['candidatereferredby'] != 0) {
                         $employeeform->candidatereferredby->setValue($referedby_options[$data['candidatereferredby']]);
                     }
                     $employeeform->setAttrib('action', DOMAIN . 'mydetails/edit/');
                     $this->view->id = $id;
                     $this->view->form = $employeeform;
                     $this->view->employeedata = !empty($data) ? $data : "";
                     $this->view->messages = $this->_helper->flashMessenger->getMessages();
                     $this->view->empdata = $data;
                     $this->view->editPrivilege = $this->mydetailsobjPrivileges;
                 }
             }
         } else {
             $this->view->rowexist = "norows";
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
     if ($this->getRequest()->getPost()) {
         $result = $this->save($employeeform, $tabName);
         $this->view->msgarray = $result;
     }
 }
Esempio n. 6
0
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $messages['msgtype'] = '';
     $messages['flagtype'] = '';
     $actionflag = 3;
     if ($id) {
         $jobtitlesmodel = new Default_Model_Jobtitles();
         $positionsModel = new Default_Model_Positions();
         $menumodel = new Default_Model_Menu();
         $data = array('isactive' => 0, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = array('id=?' => $id);
         $job_data = $jobtitlesmodel->getsingleJobTitleData($id);
         $Id = $jobtitlesmodel->SaveorUpdateJobTitleData($data, $where);
         if ($Id == 'update') {
             $positionData = array('isactive' => 0, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $positionsWhere = array('jobtitleid=?' => $id);
             $positionsModel->SaveorUpdatePositionData($positionData, $positionsWhere);
             sapp_Global::send_configuration_mail("Job Titles", $job_data[0]['jobtitlename']);
             $menuidArr = $menumodel->getMenuObjID('/jobtitles');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
             $messages['message'] = 'Job title deleted successfully.';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'Job title cannot be deleted.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Job title cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
Esempio n. 7
0
 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;
 }
 /**
  * This action is used for adding/updating data.
  * @parameters
  * @param $id  =  id of candidate (optional)
  * 
  * @return Zend_Form.
  */
 public function editAction()
 {
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $interview_model = new Default_Model_Interviewdetails();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $jobtitleModel = new Default_Model_Jobtitles();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $id = $this->getRequest()->getParam('id');
     $intId = $id;
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $previousroundstatus = '';
     $cancel_name = "Cancel";
     $form = new Default_Form_Interviewrounds();
     $form->setAction(DOMAIN . 'scheduleinterviews/edit/id/' . $id);
     $form->id->setValue($id);
     $submitButon = $form->getElement("submit");
     $submitButon->setAttrib('style', 'display:none;');
     $form->removeElement('req_id');
     $form->removeElement('candidate_name');
     $form->removeElement('interviewer_id');
     $form->removeElement('interview_mode');
     $form->removeElement('int_location');
     $form->removeElement('country');
     $form->removeElement('state');
     $form->removeElement('city');
     $form->removeElement('interview_time');
     $form->removeElement('interview_date');
     $form->removeElement('interview_round');
     $data = array();
     $jobtitle = '';
     $interviewData = array();
     try {
         if ($id > 0 && is_numeric($id)) {
             $interviewData = $interview_model->getSingleInterviewData($intId);
             $reqstatusArray = array('On hold', 'Closed', 'Complete');
             $previousroundstatus = $interview_model->getinterviewroundnumber($intId);
             $previousroundstatus = $previousroundstatus['round_status'];
             $data = $interview_model->getCandidateDetailsById($intId);
             if (!empty($data) && $data['interview_status'] != 'Requisition Closed/Completed' && $data['interview_status'] != 'Completed' && !in_array($data['req_status'], $reqstatusArray)) {
                 if ($data['interview_status'] == 'On hold' && ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP)) {
                     $this->view->ermsg = 'nodata';
                 } else {
                     $data['jobtitlename'] = '';
                     $round_count = $interview_round_model->getRoundCnt($data['id'], $id);
                     $jobttlArr = $jobtitleModel->getsingleJobTitleData($data['jobtitle']);
                     if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                         $jobtitle = $jobttlArr[0]['jobtitlename'];
                         $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
                     }
                     $irData = $this->interviewRoundsGrid($id, $interviewData['interview_status']);
                     $this->view->dataArray = $irData[0];
                     $form->setDefault('interview_status', $interviewData['interview_status']);
                     $cand_arr = array();
                     if ($interviewData['interview_status'] == 'In process') {
                         $cand_arr['Scheduled'] = 'Scheduled';
                     } elseif ($interviewData['interview_status'] == 'Completed') {
                         $cand_arr['Disqualified'] = 'Disqualified';
                         $cand_arr['Shortlisted'] = 'Shortlisted';
                     } elseif ($interviewData['interview_status'] == 'On hold') {
                         $cand_arr['On hold'] = 'On hold';
                     }
                     $form->cand_status->clearMultiOptions();
                     $form->cand_status->addMultiOptions(array('' => 'Select status') + $cand_arr);
                     $form->setDefault('cand_status', $data['cand_status']);
                     $this->view->form = $form;
                     $this->view->data = $data;
                     $this->view->id = $id;
                     $this->view->round_count = $round_count;
                     if ($this->getRequest()->getPost()) {
                         $result = $this->save($form, $data);
                         $this->view->msgarray = $result;
                         $this->view->messages = $result;
                     }
                     $this->view->ermsg = '';
                     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $interviewData['interview_status'] == 'Completed') {
                         $form->removeElement('submit');
                         $cancel_name = "Back";
                         $elements = $form->getElements();
                         if (count($elements) > 0) {
                             foreach ($elements as $key => $element) {
                                 if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                     $element->setAttrib("disabled", "disabled");
                                 }
                             }
                         }
                         if ($interviewData['interview_status'] == 'Completed') {
                             $this->view->ermsg = 'interviewcompleted';
                         }
                     }
                 }
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } else {
             $this->view->ermsg = 'nodata';
         }
         $this->view->interview_status = $interviewData['interview_status'];
         $this->view->previousroundstatus = $previousroundstatus;
         $this->view->loginuserGroup = $loginuserGroup;
         $this->view->cancel_name = $cancel_name;
     } catch (EXception $e) {
         $this->view->ermsg = 'nodata';
     }
 }
 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;
     }
 }
Esempio n. 10
0
 /**
  * 
  * @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;
     }
 }
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $data = array();
     $jobtitle = '';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $form = new Default_Form_Requisition();
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $jobtitleModel = new Default_Model_Jobtitles();
     $form->setAttrib('action', BASE_URL . 'approvedrequisitions/edit/id/' . $id);
     $form->submit->setLabel('Update');
     $elements = $form->getElements();
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments" && $key != "submit" && $key != 'req_status' && $key != 'onboard_date') {
                 $form->removeElement($key);
             }
         }
     }
     try {
         if ($id > 0 && is_numeric($id)) {
             $data = $requi_model->getRequisitionDataById($id);
             if (count($data) > 0 && $data['req_status'] != 'Initiated' && $data['req_status'] != 'Rejected') {
                 $data['jobtitlename'] = '';
                 $business_units_list = $requi_model->getBusinessUnitsList($data['businessunit_id']);
                 $data['businessunit_name'] = $business_units_list['unitname'];
                 $departments_list = $requi_model->getDepartmentList($data['businessunit_id'], $data['department_id']);
                 $data['dept_name'] = $departments_list['deptname'];
                 $job_data = $requi_model->getJobTitleList($data['jobtitle']);
                 $data['titlename'] = $job_data['jobtitlename'];
                 $pos_data = $requi_model->getPositionOptions($data['jobtitle'], $data['position_id']);
                 $data['posname'] = $pos_data['positionname'];
                 $emptype_options = $requi_model->getEmpStatusOptions($data['emp_type']);
                 $data['empttype'] = $emptype_options['employemnt_status'];
                 $report_manager_options = $user_model->getUserDataById($data['reporting_id']);
                 $data['mngrname'] = $report_manager_options['userfullname'];
                 $raisedby = $requi_model->getrequisitioncreatername($data['createdby']);
                 $data['raisedby'] = $raisedby['userfullname'];
                 $app1_data = $user_model->getUserDataById($data['approver1']);
                 $data['app1_name'] = $app1_data['userfullname'];
                 if ($data['approver2'] != '') {
                     $app2_data = $user_model->getUserDataById($data['approver2']);
                     $data['app2_name'] = $app2_data['userfullname'];
                 } else {
                     $data['app2_name'] = 'No Approver';
                 }
                 if ($data['approver3'] != '') {
                     $app3_data = $user_model->getUserDataById($data['approver3']);
                     $data['app3_name'] = $app3_data['userfullname'];
                 } else {
                     $data['app3_name'] = 'No Approver';
                 }
                 $jobttlArr = $jobtitleModel->getsingleJobTitleData($data['jobtitle']);
                 if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                     $jobtitle = $jobttlArr[0]['jobtitlename'];
                     $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
                 }
                 foreach ($data as $key => $val) {
                     $data[$key] = htmlentities($val, ENT_QUOTES, "UTF-8");
                 }
                 $onboard_date_org = $data['onboard_date'];
                 $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                 if ($data['req_status'] == 'Approved') {
                     $form->req_status->addMultiOptions(array('Approved' => 'Approved', 'Closed' => 'Closed', 'On hold' => 'On hold', 'Complete' => 'Complete'));
                 } else {
                     if ($data['req_status'] == 'Complete') {
                         $form->req_status->addMultiOptions(array('Complete' => 'Complete'));
                         $form->req_status->setAttrib('disabled', 'disabled');
                         $form->removeElement('submit');
                     } else {
                         $form->req_status->addMultiOptions(array('' => 'Select status', 'Closed' => 'Closed', 'On hold' => 'On hold', 'Complete' => 'Complete', 'In process' => 'In process'));
                     }
                 }
                 $form->req_status->setRequired(true);
                 $form->req_status->addValidator('NotEmpty', false, array('messages' => 'Please select option.'));
                 $form->populate($data);
                 $form->setDefault('req_status', $data['req_status']);
                 $this->view->data = $data;
                 $this->view->loginuserGroup = $loginuserGroup;
                 $this->view->form = $form;
                 $this->view->id = $id;
                 $this->view->edit_duedate = 'no';
                 if ($onboard_date_org < date('Y-m-d') && ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '')) {
                     $this->view->edit_duedate = 'yes';
                 } else {
                     $form->removeElement('onboard_date');
                 }
                 $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                 $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'c.createddate';
                 $perPage = $this->_getParam('per_page', 10);
                 $pageNo = $this->_getParam('page', 1);
                 $searchQuery = '';
                 $searchArray = array();
                 $tablecontent = '';
                 /** search from grid - START **/
                 $searchData = $this->_getParam('searchData');
                 if ($searchData != '' && $searchData != 'undefined') {
                     $searchValues = json_decode($searchData);
                     if (count($searchValues) > 0) {
                         foreach ($searchValues as $key => $val) {
                             $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                             $searchArray[$key] = $val;
                         }
                         $searchQuery = rtrim($searchQuery, " AND");
                     }
                 }
                 /** search from grid - END **/
                 $objName = 'apprreqcandidates';
                 $tableFields = array('action' => 'Action', 'candidate_name' => 'Candidate Name', 'cand_status' => 'Candidate Status');
                 $candidate_model = new Default_Model_Candidatedetails();
                 $tablecontent = $candidate_model->getCandidatesData_requisition($sort, $by, $pageNo, $perPage, $searchQuery, $id);
                 $cand_status_opt = array('' => 'All', 'Shortlisted' => 'Shortlisted', 'Selected' => 'Selected', 'Rejected' => 'Rejected', 'On hold' => 'On hold', 'Disqualified' => 'Disqualified', 'Scheduled' => 'Scheduled', 'Not Scheduled' => 'Not Scheduled', 'Recruited' => 'Recruited', 'Requisition Closed/Completed' => 'Requisition Closed/Completed');
                 $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'formgrid' => 'true', 'searchArray' => $searchArray, 'menuName' => 'Candidate details', 'call' => '', 'search_filters' => array('cand_status' => array('type' => 'select', 'filter_data' => $cand_status_opt)));
                 array_push($data, $dataTmp);
                 $this->view->dataArray = $dataTmp;
                 if ($this->getRequest()->getPost()) {
                     $result = $this->save($form, $data);
                     $this->view->msgarray = $result;
                     $this->view->messages = $result;
                 }
                 $this->view->nodata = '';
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 public function editpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $userid = $this->getRequest()->getParam('unitId');
     if ($id == '') {
         $id = $loginUserId;
     }
     // For open the form in popup...
     $empjobhistoryform = new Default_Form_empjobhistory();
     $empjobhistoryModel = new Default_Model_Empjobhistory();
     $employeeModel = new Default_Model_Employee();
     $positionModel = new Default_Model_Positions();
     $departmentModel = new Default_Model_Departments();
     $jobtitleModel = new Default_Model_Jobtitles();
     $clientsModel = new Timemanagement_Model_Clients();
     if ($id) {
         $employeeArr = $employeeModel->getActiveEmployeeData($userid);
         if (!empty($employeeArr)) {
             if (isset($employeeArr[0]['businessunit_id']) && $employeeArr[0]['businessunit_id'] != '') {
                 $departmentArr = $departmentModel->getDepartmentList($employeeArr[0]['businessunit_id']);
                 if (!empty($departmentArr)) {
                     $empjobhistoryform->department->addMultiOption('', 'Select Department');
                     foreach ($departmentArr as $departmentres) {
                         $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']);
                     }
                 }
             } else {
                 $departmentArr = $departmentModel->getTotalDepartmentList();
                 if (!empty($departmentArr)) {
                     $empjobhistoryform->department->addMultiOption('', 'Select Department');
                     foreach ($departmentArr as $departmentres) {
                         $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']);
                     }
                 }
             }
         }
         $positionArr = $positionModel->getTotalPositionList();
         if (!empty($positionArr)) {
             $empjobhistoryform->positionheld->addMultiOption('', 'Select Position');
             foreach ($positionArr as $positionres) {
                 $empjobhistoryform->positionheld->addMultiOption($positionres['id'], $positionres['positionname']);
             }
         }
         $jobtitleArr = $jobtitleModel->getJobTitleList();
         if (!empty($jobtitleArr)) {
             $empjobhistoryform->jobtitleid->addMultiOption('', 'Select Job Title');
             foreach ($jobtitleArr as $jobtitleres) {
                 $empjobhistoryform->jobtitleid->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
             }
         }
         $clientsArr = $clientsModel->getActiveClientsData();
         if (!empty($clientsArr)) {
             $empjobhistoryform->client->addMultiOption('', 'Select a Client');
             foreach ($clientsArr as $clientsres) {
                 $empjobhistoryform->client->addMultiOption($clientsres['id'], $clientsres['client_name']);
             }
         }
         $data = $empjobhistoryModel->getsingleEmpJobHistoryData($id);
         if (!empty($data)) {
             $empjobhistoryform->populate($data[0]);
             $empjobhistoryform->setDefault('department', $data[0]['department']);
             $empjobhistoryform->setDefault('positionheld', $data[0]['positionheld']);
             $empjobhistoryform->setDefault('jobtitleid', $data[0]['jobtitleid']);
             $empjobhistoryform->setDefault('client', $data[0]['client_id']);
             if (isset($data[0]['start_date']) && $data[0]['start_date'] != '') {
                 $start_date = sapp_Global::change_date($data[0]['start_date'], 'view');
                 $empjobhistoryform->start_date->setValue($start_date);
             }
             if (isset($data[0]['end_date']) && $data[0]['end_date'] != '') {
                 $end_date = sapp_Global::change_date($data[0]['end_date'], 'view');
                 $empjobhistoryform->end_date->setValue($end_date);
             }
         }
     }
     $empjobhistoryform->setAttrib('action', BASE_URL . 'empjobhistory/editpopup/unitId/' . $userid);
     $this->view->form = $empjobhistoryform;
     $this->view->controllername = 'empjobhistory';
     if ($this->getRequest()->getPost()) {
         $result = $this->save($empjobhistoryform, $userid);
         $this->view->msgarray = $result;
     }
 }
 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 viewpopupAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $intrvwModel = new Default_Model_Interviewdetails();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $user_model = new Default_Model_Usermanagement();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $jobtitle = '';
     $deptid = $this->getRequest()->getParam('deptid');
     if ($deptid == '') {
         $deptid = $this->getRequest()->getParam('deptidform');
     }
     $intId = $this->getRequest()->getParam('unitId');
     $roundId = $this->getRequest()->getParam('id');
     $ir_form = new Default_Form_Interviewrounds();
     $elements = $ir_form->getElements();
     //giving only for hr,management and super admin
     if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
         $ir_form->round_status->addMultiOptions(array('Decision pending' => 'Decision pending', 'On hold' => 'On hold'));
     }
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     $intData = $intrvwModel->getReqByintrvwID($intId);
     $roundData = $interview_round_model->getSingleRoundData($roundId);
     $this->view->ermsg = '';
     $edit_flag = 'no';
     if ($roundData['interviewer_id'] == $loginUserId) {
         $edit_flag = 'yes';
     }
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '' || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP) {
         $countryId = $roundData['int_country'];
         $stateId = $roundData['int_state'];
         $cityId = $roundData['int_city'];
         $country_name = '';
         $state_name = '';
         $city_name = '';
         if ($countryId && $stateId) {
             $statesmodel = new Default_Model_States();
             $citiesmodel = new Default_Model_Cities();
             $countryModal = new Default_Model_Countries();
             $countriesData = $countryModal->fetchAll('isactive=1', 'country');
             foreach ($countriesData as $cdata) {
                 if ($roundData['int_country'] == $cdata['country_id_org']) {
                     $country_name = $cdata['country'];
                     break;
                 }
             }
             $statesData = $statesmodel->getBasicStatesList($countryId);
             $citiesData = $citiesmodel->getBasicCitiesList($stateId);
             foreach ($statesData as $res) {
                 $ir_form->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                 if ($roundData['int_state'] == $res['state_id_org']) {
                     $state_name = $res['state'];
                 }
             }
             foreach ($citiesData as $res) {
                 $ir_form->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                 if ($roundData['int_city'] == $res['city_org_id']) {
                     $city_name = $res['city'];
                 }
             }
         }
         $interviewer_data = $user_model->getUserDataById($roundData['interviewer_id']);
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($interviewer_data['jobtitle_id']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = ', ' . $jobttlArr[0]['jobtitlename'];
             $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $ir_form->interviewer_id->addMultiOptions(array('' => $interviewer_data['userfullname'] . $jobtitle));
         $roundData['interview_date'] = sapp_Global::change_date($roundData['interview_date'], 'view');
         $roundData['interview_time'] = sapp_Global::change_time($roundData['interview_time'], 'view');
         $ir_form->populate($roundData);
         $this->view->form = $ir_form;
         $this->view->intId = $intId;
         $this->view->deptid = $deptid;
         $this->view->roundId = $roundId;
         $this->view->ermsg = '';
         $this->view->country_name = $country_name;
         $this->view->state_name = $state_name;
         $this->view->city_name = $city_name;
         $this->view->edit_flag = $edit_flag;
     } else {
         $this->view->ermsg = 'nodata';
     }
 }
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $candidatesmodel = new Default_Model_Shortlistedcandidates();
     $requi_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $intrvwroundsData = array();
     $intrvwData = array();
     $jobtitle = '';
     try {
         $candidateData = $candidatesmodel->getcandidateData($id);
         $cand_status = $candidateData['cand_status'];
         $req_id = $candidateData['requisition_id'];
         try {
             $requisitionData = $requi_model->getRequisitionDataById($req_id);
             $requisitionData['jobtitlename'] = '';
             $jobttlArr = $jobtitleModel->getsingleJobTitleData($requisitionData['jobtitle']);
             if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                 $jobtitle = $jobttlArr[0]['jobtitlename'];
                 $requisitionData['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
             }
             $intrvwData = $candidatesmodel->getinterviewData($requisitionData['id'], $candidateData['id']);
             if (!empty($intrvwData)) {
                 $intrvwroundsData = $candidatesmodel->getinterviewrounds($intrvwData['id'], $requisitionData['id'], $candidateData['id']);
                 $intrvwroundsSkillSetData = $candidatesmodel->getinterviewroundskillsetsummary($intrvwroundsData[0]['interview_round_number'], $requisitionData['id'], $candidateData['id']);
                 $intrvwroundsSkillSetDataSummary = $tLeaveCardData01 = sapp_Global::_convertArrayToHTMLTable("leavecardtablegrid", "", $intrvwroundsSkillSetData);
                 $this->view->intrvwroundsSkillSetDataSummary = $intrvwroundsSkillSetDataSummary;
                 $this->view->candidateData = $candidateData;
                 $this->view->requisitionData = $requisitionData;
                 $this->view->intrvwrounds = $intrvwroundsData;
                 $this->view->intrvwData = $intrvwData;
                 $this->view->ermsg = '';
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->loginuserGroup = $loginuserGroup;
 }
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $candidatesmodel = new Default_Model_Shortlistedcandidates();
     $requi_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $intrvwroundsData = array();
     $intrvwData = array();
     $jobtitle = '';
     try {
         $candidateData = $candidatesmodel->getcandidateData($id);
         $cand_status = $candidateData['cand_status'];
         $req_id = $candidateData['requisition_id'];
         try {
             $requisitionData = $requi_model->getRequisitionDataById($req_id);
             $requisitionData['jobtitlename'] = '';
             $jobttlArr = $jobtitleModel->getsingleJobTitleData($requisitionData['jobtitle']);
             if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                 $jobtitle = $jobttlArr[0]['jobtitlename'];
                 $requisitionData['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
             }
             $intrvwData = $candidatesmodel->getinterviewData($requisitionData['id'], $candidateData['id']);
             if (!empty($intrvwData) && ($cand_status == 'Shortlisted' || $cand_status == 'Selected' || $cand_status == 'Rejected')) {
                 $intrvwroundsData = $candidatesmodel->getinterviewrounds($intrvwData['id'], $requisitionData['id'], $candidateData['id']);
                 $this->view->candidateData = $candidateData;
                 $this->view->requisitionData = $requisitionData;
                 $this->view->intrvwrounds = $intrvwroundsData;
                 $this->view->intrvwData = $intrvwData;
                 $this->view->ermsg = '';
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->loginuserGroup = $loginuserGroup;
 }