public function multipleresumeAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginUserId = trim($loginUserId);
     }
     $priv_check = sapp_Global::_checkprivileges(CANDIDATEDETAILS, '', $auth->getStorage()->read()->emprole, 'add');
     if ($priv_check == 'Yes') {
         $msgarray = $req_options = array();
         $form = new Default_Form_Multipleresume();
         $form->setAction(DOMAIN . 'candidatedetails/multipleresume');
         // To show list of requisitions to user
         $req_model = new Default_Model_Requisition();
         $req_data = $req_model->getRequisitionsForCV("'Approved','In process'");
         foreach ($req_data as $req) {
             $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
         }
         if (count($req_options) == 0) {
             $msgarray['requisition_id'] = "No active requisitions are found.";
         }
         $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
         $form_post_status = $this->_request->getPost();
         if ($form_post_status) {
             $candidate_firstname = $this->_getParam('candidate_firstname', null);
             $candidate_lastname = $this->_getParam('candidate_lastname', null);
             $cand_resumes = $this->_getParam('cand_resume', null);
             if ($form->isValid($form_post_status)) {
                 $cand_details_model = new Default_Model_Candidatedetails();
                 $requisition_id = $this->_getParam('requisition_id', null);
                 $cand_status = $this->_getParam('cand_status', null);
                 $req_records = $cand_details_model->getcountofrecords($requisition_id);
                 $curr_date = gmdate("Y-m-d H:i:s");
                 if (empty($req_records)) {
                     $rdata = array('req_status' => 'In process', 'modifiedby' => $loginUserId, 'modifiedon' => $curr_date);
                     $rwhere = ' id = ' . $requisition_id;
                     $req_model->SaveorUpdateRequisitionData($rdata, $rwhere);
                 }
                 // To insert records in a single query
                 $records = array();
                 foreach ($candidate_firstname as $key => $candidate_fname) {
                     $cfull_name = $candidate_fname . ' ' . $candidate_lastname[$key];
                     $records[] = "({$requisition_id}, '{$candidate_fname}','{$candidate_lastname[$key]}','{$cfull_name}', '{$cand_resumes[$key]}', '{$cand_status}', 1, {$loginUserId}, {$loginUserId}, '{$curr_date}', '{$curr_date}')";
                 }
                 $data_fields = array('requisition_id', 'candidate_firstname', 'candidate_lastname', 'candidate_name', 'cand_resume', 'cand_status', 'isactive', 'createdby', 'modifiedby', 'createddate', 'modifieddate');
                 $last_insert_id = $cand_details_model->insertMultipleRecords($data_fields, $records);
                 // Log status to Log manager and redirect to Resource Pooling list page.
                 if ($last_insert_id != '') {
                     $menumodel = new Default_Model_Menu();
                     $objidArr = $menumodel->getMenuObjID('/candidatedetails');
                     $objID = $objidArr[0]['id'];
                     $log_status = sapp_Global::logManager($objID, 1, $loginUserId, $last_insert_id);
                     //$this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Candidate details added successfully.');
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Candidate details added successfully."));
                     $this->_redirect('/candidatedetails');
                 }
             } else {
                 // To handle server validation, when Javascript is disabled
                 $messages = $form->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                 }
                 $form->setDefault('candidate_firstname', $candidate_firstname[0]);
                 $form->setDefault('cand_resume', '');
             }
         }
         $this->view->form = $form;
         $this->view->msgarray = $msgarray;
     } else {
         $this->_redirect('error');
     }
 }
 /**
  * This action is used to delete requisition.
  * @parameters
  * @param objid    =   id of requisition.
  *
  * @return  {String} =   success/failure message
  */
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $actionflag = 3;
     if ($id) {
         $requi_model = new Default_Model_Requisition();
         $menumodel = new Default_Model_Menu();
         $data = array('isactive' => 0, 'modifiedon' => gmdate("Y-m-d H:i:s"));
         $where = array('id=?' => $id);
         $req_status = $requi_model->getRequisitionForEdit($id, $loginUserId);
         if ($req_status['aflag'] == 'creator') {
             $Id = $requi_model->SaveorUpdateRequisitionData($data, $where);
         } else {
             $Id = "not deleted";
         }
         if ($Id == 'update') {
             $menuidArr = $menumodel->getMenuObjID('/requisition');
             $menuID = $menuidArr[0]['id'];
             sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
             $messages['message'] = 'Requisition deleted successfully.';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'Requisition cannot be deleted.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Requisition cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
Esempio n. 3
0
 public function save($employeeform)
 {
     $emproleStr = '';
     $roleArr = array();
     $empgroupStr = '';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usersModel = new Default_Model_Usermanagement();
     $employeeModal = new Default_Model_Employee();
     $requimodel = new Default_Model_Requisition();
     $candidate_model = new Default_Model_Candidatedetails();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $unitid = '';
     $deptid = '';
     $errorflag = 'true';
     $msgarray = array();
     $id = $this->_request->getParam('id');
     $businessunit_id = $this->_request->getParam('businessunit_id', null);
     $department_id = $this->_request->getParam('department_id', null);
     $reporting_manager = $this->_request->getParam('reporting_manager', null);
     $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
     $position_id = $this->_request->getParam('position_id', null);
     $user_id = $this->_getParam('user_id', null);
     $prefix_id = $this->_getParam('prefix_id', null);
     $extension_number = $this->_getParam('extension_number', null);
     $office_number = $this->_request->getParam('office_number', null);
     $office_faxnumber = $this->_request->getParam('office_faxnumber', null);
     $date_of_joining = $this->_request->getParam('date_of_joining', null);
     $date_of_joining = sapp_Global::change_date($date_of_joining, 'database');
     $isvalidorgstartdate = $orgInfoModel->validateEmployeeJoiningDate($date_of_joining, $unitid, $deptid);
     if (!empty($isvalidorgstartdate)) {
         $msgarray['date_of_joining'] = 'Employee joining date should be greater than organization start date.';
         $errorflag = 'false';
     }
     if ($id) {
         $data = $employeeModal->getsingleEmployeeData($id);
         if (!empty($data) && $data[0]['is_orghead'] == 1) {
             $reporting_manager = $this->_request->getParam('reporting_manager', '0');
         }
     }
     if ($employeeform->isValid($this->_request->getPost()) && $errorflag == 'true') {
         $id = $this->_request->getParam('id');
         $emp_status_id = $this->_request->getParam('emp_status_id', null);
         $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
         $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
         $years_exp = $this->_request->getParam('years_exp');
         //FOR USER table
         $employeeId = $this->_getParam('employeeId', null);
         $modeofentry = $this->_getParam('modeofentry', null);
         $hid_modeofentry = $this->_getParam('hid_modeofentry', null);
         $other_modeofentry = $this->_getParam('other_modeofentry', null);
         $firstname = trim($this->_getParam('firstname', null));
         $lastname = trim($this->_getParam('lastname', null));
         $userfullname = $firstname . ' ' . $lastname;
         $candidatereferredby = $this->_getParam('candidatereferredby', null);
         $rccandidatename = $this->_getParam('rccandidatename', null);
         $emprole = $this->_getParam('emprole', null);
         //roleid_group_id
         if ($emprole != "") {
             $roleArr = explode('_', $emprole);
             if (!empty($roleArr)) {
                 $emproleStr = $roleArr[0];
                 $empgroupStr = $roleArr[0];
             }
         }
         $emailaddress = $this->_getParam('emailaddress', null);
         $tmp_name = $this->_request->getParam('tmp_emp_name', null);
         $act_inact = $this->_request->getParam("act_inact", null);
         //end of user table
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $empstatusarray = array(8, 9, 10);
         $actionflag = '';
         $tableid = '';
         if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') {
             $candidate_key = 'userfullname';
             $candidate_value = $userfullname;
             $emp_name = $userfullname;
             $candidate_flag = 'no';
         } else {
             $candidate_key = 'rccandidatename';
             $candidate_value = $rccandidatename;
             $emp_name = $tmp_name;
             $candidate_flag = 'yes';
         }
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $emppassword = sapp_Global::generatePassword();
             $user_data = array('emprole' => $emproleStr, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry);
             if ($id != '') {
                 $where = array('user_id=?' => $user_id);
                 $actionflag = 2;
                 $user_where = "id = " . $user_id;
                 unset($user_data['candidatereferredby']);
                 unset($user_data['userstatus']);
                 unset($user_data['emppassword']);
                 unset($user_data['employeeId']);
                 unset($user_data['modeofentry']);
                 unset($user_data['other_modeofentry']);
             } else {
                 $user_data['createdby'] = $loginUserId;
                 $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $user_data['isactive'] = 1;
                 if ($modeofentry != 'Direct') {
                     $user_data['userfullname'] = $emp_name;
                 }
                 $where = '';
                 $actionflag = 1;
                 $user_where = '';
                 $identity_code_model = new Default_Model_Identitycodes();
                 $identity_codes = $identity_code_model->getIdentitycodesRecord();
                 $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
                 if ($emp_identity_code != '') {
                     $emp_id = $emp_identity_code . str_pad($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                 } else {
                     $emp_id = '';
                 }
                 $user_data['employeeId'] = $emp_id;
             }
             $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where);
             if ($id == '') {
                 $user_id = $user_status;
             }
             $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number != '' ? $extension_number : NULL, 'office_number' => $office_number != '' ? $office_number : NULL, 'office_faxnumber' => $office_faxnumber != '' ? $office_faxnumber : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id == '') {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
             }
             $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where);
             $statuswhere = array('id=?' => $user_id);
             if ($id != '') {
                 if (in_array($emp_status_id, $empstatusarray)) {
                     $isactivestatus = '';
                     if ($emp_status_id == 8) {
                         $isactivestatus = 2;
                     } else {
                         if ($emp_status_id == 9) {
                             $isactivestatus = 3;
                         } else {
                             if ($emp_status_id == 10) {
                                 $isactivestatus = 4;
                             }
                         }
                     }
                     $statusdata = array('isactive' => $isactivestatus);
                     $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                     $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                 } else {
                     $edata = $usersModel->getUserDataById($id);
                     $statusdata = array('isactive' => 1);
                     if ($edata['isactive'] != 0) {
                         if ($edata['emptemplock'] == 1) {
                             $statusdata = array('isactive' => 0);
                         }
                         $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                         $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                     }
                 }
             }
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully."));
             } else {
                 //start of mailing
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $emp_name;
                 $this->view->password = $emppassword;
                 $this->view->emp_id = $employeeId;
                 $this->view->base_url = $base_url;
                 $text = $view->render('mailtemplates/newpassword.phtml');
                 $options['subject'] = APPLICATION_NAME . ': Login Credentials';
                 $options['header'] = 'Greetings from Sentrifugo';
                 $options['toEmail'] = $emailaddress;
                 $options['toName'] = $this->view->emp_name;
                 $options['message'] = $text;
                 $result = sapp_Global::_sendEmail($options);
                 //end of mailing
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully."));
                 //incrementing requisition id
                 if ($candidate_flag == 'yes') {
                     $cand_data = $candidate_model->getCandidateById($rccandidatename);
                     $candidate_model->SaveorUpdateCandidateData(array('cand_status' => 'Recruited', 'modifieddate' => gmdate("Y-m-d H:i:s")), " id = " . $rccandidatename);
                     $reqData = $requimodel->incrementfilledpositions($cand_data['requisition_id']);
                     if ($reqData['req_no_positions'] == $reqData['filled_positions']) {
                         $req_status = '6';
                         $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"));
                         $where = "id = " . $cand_data['requisition_id'];
                         $result = $requimodel->SaveorUpdateRequisitionData($data, $where);
                         $requimodel->change_to_requisition_closed($cand_data['requisition_id']);
                         $this->send_requi_mail($cand_data['requisition_id'], $requimodel, $usersModel, $loginUserId);
                     }
                 }
             }
             $menuidArr = $menumodel->getMenuObjID('/employee');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id);
             if ($act_inact == 1) {
                 if ($user_data['isactive'] == 1) {
                 } else {
                 }
             }
             $trDb->commit();
             // Send email to employee when his details are edited by other user.
             $options['subject'] = APPLICATION_NAME . ': Employee details updated';
             $options['header'] = 'Employee details updated';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $userfullname;
             $options['message'] = 'Dear ' . $userfullname . ', your employee details are updated.';
             $options['cron'] = 'yes';
             if (!empty($id)) {
                 sapp_Global::_sendEmail($options);
             }
             $this->_redirect('employee/edit/id/' . $user_id);
         } catch (Exception $e) {
             $trDb->rollBack();
             $msgarray['employeeId'] = "Something went wrong, please try again later.";
             return $msgarray;
         }
     } else {
         $messages = $employeeform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         if (isset($businessunit_id) && $businessunit_id != '') {
             $departmentsmodel = new Default_Model_Departments();
             $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id);
             $employeeform->department_id->clearMultiOptions();
             $employeeform->reporting_manager->clearMultiOptions();
             $employeeform->department_id->addMultiOption('', 'Select Department');
             foreach ($departmentlistArr as $departmentlistresult) {
                 $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname']));
             }
             if (isset($department_id) && $department_id != 0 && $department_id != '') {
                 $employeeform->setDefault('department_id', $department_id);
             }
         }
         if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') {
             $positionsmodel = new Default_Model_Positions();
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             $employeeform->position_id->clearMultiOptions();
             $employeeform->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistRes) {
                 $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname']));
             }
             if (isset($position_id) && $position_id != 0 && $position_id != '') {
                 $employeeform->setDefault('position_id', $position_id);
             }
         }
         return $msgarray;
     }
 }
 public function save($requisitionform, $data)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $req_status = $this->_getParam('req_status', null);
     $flag = 'true';
     if ($requisitionform->isValid($this->_request->getPost()) && $flag != 'false') {
         $id = $this->_getParam('id', null);
         $req_status = $this->_getParam('req_status', null);
         $onboard_date = $this->_getParam('onboard_date', null);
         $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"));
         if ($onboard_date != '') {
             $data = $data + array('onboard_date' => sapp_Global::change_date($onboard_date, 'database'));
         }
         $where = "id = " . $id;
         $result = $requi_model->SaveorUpdateRequisitionData($data, $where);
         $tableid = $id;
         $actionflag = 2;
         if ($result != '') {
             if ($req_status == 'Complete' || $req_status == 'Closed') {
                 $requi_model->change_to_requisition_closed($id);
                 $requisition_data = $requi_model->getReqDataForView($id);
                 $requisition_data = $requisition_data[0];
                 $report_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                 $closed_person_data = $user_model->getUserDataById($loginUserId);
                 $mail_arr[0]['name'] = 'HR';
                 $requisition_data['businessunit_id'];
                 $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "";
                 $mail_arr[0]['type'] = 'HR';
                 $mail_arr[1]['name'] = 'Management';
                 $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : "";
                 $mail_arr[1]['type'] = 'Management';
                 $mail_arr[2]['name'] = $report_person_data['userfullname'];
                 $mail_arr[2]['email'] = $report_person_data['emailaddress'];
                 $mail_arr[2]['type'] = 'Raise';
                 for ($ii = 0; $ii < count($mail_arr); $ii++) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $mail_arr[$ii]['name'];
                     $this->view->base_url = $base_url;
                     $this->view->type = $mail_arr[$ii]['type'];
                     $this->view->requisition_code = $requisition_data['requisition_code'];
                     $this->view->req_status = $status = strtolower($req_status == 'Complete' ? "Completed" : $req_status);
                     $this->view->raised_name = $report_person_data['userfullname'];
                     $this->view->approver_str = $closed_person_data['userfullname'];
                     $text = $view->render('mailtemplates/changedrequisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Requisition is ' . $status;
                     $options['header'] = 'Requisition is ' . $status;
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     sapp_Global::_sendEmail($options);
                 }
             }
             $menumodel = new Default_Model_Menu();
             $objidArr = $menumodel->getMenuObjID('/approvedrequisitions');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
             if ($id != '') {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition updated successfully."));
             } else {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition added successfully."));
             }
             $this->_redirect('/approvedrequisitions');
         }
     } else {
         $messages = $requisitionform->getMessages();
         $msgarray = array();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }