/** * * @param type $form * @param type $data * @return type */ public function save($form, $data) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $cand_model = new Default_Model_Candidatedetails(); $requi_model = new Default_Model_Requisition(); $interview_model = new Default_Model_Interviewdetails(); $user_model = new Default_Model_Usermanagement(); $interview_round_model = new Default_Model_Interviewrounddetails(); $form->round_status->setRequired(false); $form->interview_feedback->setRequired(false); $cand_status = $this->_getParam('cand_status', null); $interview_status = $this->_getParam('interview_status', null); $flag = 'true'; if ($interview_status == 'On hold' && $cand_status != 'On hold') { $msgarray['statusErr'] = 'Since the interview status is onhold, the candidate status should be onhold.'; $flag = 'false'; } if ($interview_status == 'Completed' && ($cand_status != 'Disqualified' && $cand_status != 'Shortlisted')) { $msgarray['statusErr'] = 'Since interview status is completed, the candidate status can be either disqualified or shortlisted.'; $flag = 'false'; } if ($interview_status == 'In process' && ($cand_status == 'Disqualified' || $cand_status == 'Shortlisted')) { $msgarray['statusErr'] = 'Since the interview status is in process, the candidate cannot be shortlisted or disqualified.'; $flag = 'false'; } if ($form->isValid($this->_request->getPost()) && $flag != 'false') { $id = $this->_getParam('id', null); $requisition_id = $this->_getParam('req_id', null); $candidate_id = $this->_getParam('candidate_name', null); $interviewer_ids = $this->_getParam('interviewer_id', null); $interview_panel = implode(",", $interviewer_ids); $interviewer_id = 0; foreach ($interviewer_ids as $interview) { $interviewer_id = $interview; break; } $int_location = $this->_getParam('int_location', null); $country = $this->_getParam('country', null); $state = $this->_getParam('state', null); $city = $this->_getParam('city', null); $interview_mode = $this->_getParam('interview_mode', null); $interview_type_details = $this->_getParam('interview_Type_Details', null); $interview_time = $this->_getParam('interview_time', null); $interview_date = $this->_getParam('interview_date', null); $interview_round = $this->_getParam('interview_round', null); if (!isset($candidate_id)) { $candidate_id = $data['id']; } if (empty($data)) { $getExistingCandidateRecord = $interview_model->getCandidateInInterviewProcess(trim($candidate_id)); if ($getExistingCandidateRecord > 0) { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview already scheduled for this candidate.'); $this->_redirect('/scheduleinterviews'); } } if (empty($data)) { $idata = array('req_id' => $requisition_id, 'candidate_id' => trim($candidate_id), 'interview_status' => trim($interview_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s")); $idata['interview_status'] = 'In process'; $iwhere = ""; $actionflag = 1; $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere); if ($id == '') { $tableid = $iresult; } if ($iresult != '') { $irdata = array('interview_id' => $iresult, 'req_id' => $requisition_id, 'candidate_id' => $candidate_id, 'interviewer_id' => $interviewer_id, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date($interview_date, 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_type_details, 'interview_round_number' => 1, 'interview_round' => trim($interview_round), 'int_location' => trim($int_location), 'int_country' => trim(intval($country)), 'int_state' => trim(intval($state)), 'int_city' => trim(intval($city)), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel); $ir_result = $interview_round_model->SaveorUpdateInterviewroundData($irdata, ''); $requisition_data = $requi_model->getRequisitionDataById($requisition_id); $cand_data = $cand_model->getCandidateById($candidate_id); $hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]); $requisition_data = $requi_model->getrequisitiondetails($requisition_id); $requesteremailaddress = $requi_model->getemployeeemailaddress($requisition_data["createdby"]); $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($requisition_data["reporting_id"]); $mail_arr = array('HR' => $hrgroupemail["groupEmail"], $requesteremailaddress['userfullname'] => $requesteremailaddress['emailaddress'], $reportingmanageremailaddress['userfullname'] => $reportingmanageremailaddress['emailaddress']); $loginuser_person_data = $user_model->getUserDataById($loginUserId); $interview_panel = $interview_panel . "," . $loginUserId; $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel); /* $emailtemp = array(); $nametemp = array(); foreach ($interviewpanelnamesemailaddress as $row) { array_push($emailtemp, $row['emailaddress']); array_push($nametemp, $row['userfullname']); } $email = implode(";", $emailtemp); $ename = implode(";", $nametemp); */ $cal_unique_id = $this->getCalendarUniqueID(); foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) { $description = "Meeting From : " . $from_name . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n"; /* $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $options['subject'] = APPLICATION_NAME . ': Interview schedule'; $options['header'] = 'Interview schedule'; $options['toEmail'] = $interviewpanelnamesemailaddress['emailaddress']; $options['toName'] = $interviewpanelnamesemailaddress['userfullname']; $options['message'] = $description; $options['location'] = $int_location; $options['interviewdate'] = $interview_date; $options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0); $options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600); //Interview Calendar Invite will be send from login user account $options['fromEmail'] = trim($loginuser_person_data['emailaddress']); $options['fromName'] = $loginuser_person_data['userfullname']; $options['calUniqueID'] = $cal_unique_id; $options['method'] = 'REQUEST'; //sapp_Global::_sendCalendarEmail($options); */ $from_name = trim($loginuser_person_data['userfullname']); $from_address = trim($loginuser_person_data['emailaddress']); $to_name = trim($interviewpanelnamesemailaddress['userfullname']); $to_address = trim($interviewpanelnamesemailaddress['emailaddress']); $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600); $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time))); $subject = APPLICATION_NAME . ': Interview schedule'; $location = $int_location; $calRequest = 'REQUEST'; sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id); } // update Calendar Invite ID to DB $where = "id = " . $ir_result; $irdata = array('calendarinviteid' => $cal_unique_id); $ir_result1 = $interview_round_model->SaveorUpdateInterviewroundData($irdata, $where); $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = "id = " . $candidate_id; $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where); } } else { $idata = array('interview_status' => trim($interview_status), 'isactive' => 1, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $iwhere = "id = " . $id; $tableid = $id; $actionflag = 2; $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere); $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($cand_status && $cand_status != '0') { $candData['cand_status'] = $cand_status; } $where = "id = " . $candidate_id; $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where); //send email $currentInterviewData = $requi_model->getinterviewdetails($id); $requisition_data = $requi_model->getrequisitiondetails($currentInterviewData["req_id"]); $currentrequisition_data = $requi_model->getrequisitiondetails($currentInterviewData["req_id"]); $cand_data = $cand_model->getCandidateById($candidate_id); //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]); $requesteremailaddress = $requi_model->getemployeeemailaddress($requisition_data["createdby"]); $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($requisition_data["reporting_id"]); //HR Group $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = constant('REQ_HR_0'); //Requester $mail_arr[1]['name'] = $requesteremailaddress['userfullname']; $mail_arr[1]['email'] = $requesteremailaddress['emailaddress']; //Reporting Manager $mail_arr[2]['name'] = $reportingmanageremailaddress['userfullname']; $mail_arr[2]['email'] = $reportingmanageremailaddress['emailaddress']; //Management Group $mail_arr[3]['name'] = 'Management'; $mail_arr[3]['email'] = constant('REQ_MGMT_0'); //Recruiter Panel $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($currentrequisition_data["requisition_code"]); $emailCnt = 4; foreach ($requisition_recruiters_data as $requisition_recruiters_data1) { $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname']; $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress']; $emailCnt = $emailCnt + 1; } //Technical Panel $pnlIDS = implode(',', $requi_model->getRequisitionInterviewPanelIDs($currentInterviewData["req_id"])); $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($pnlIDS); foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress1) { $mail_arr[$emailCnt]['name'] = $interviewpanelnamesemailaddress1['userfullname']; $mail_arr[$emailCnt]['email'] = $interviewpanelnamesemailaddress1['emailaddress']; $emailCnt = $emailCnt + 1; } for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->type = 'InterviewSummary'; $this->view->requisition_data = $currentrequisition_data; $this->view->candidate_details = $cand_data; $this->view->round_data = $currentInterviewData; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/requisition.phtml'); $options['subject'] = APPLICATION_NAME . ': Interview feedback'; //$options['header'] = 'Interview feedback'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; sapp_Global::_sendEmail($options, "interviewrounds_feedback", REQUISITIONMODULESENDEMAIL); } } $menumodel = new Default_Model_Menu(); $objidArr = $menumodel->getMenuObjID('/scheduleinterviews'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($id == '') { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview scheduled successfully.'); } else { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview details updated successfully.'); } $this->_redirect('/scheduleinterviews'); } else { $messages = $form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
public function save($form, $data) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $cand_model = new Default_Model_Candidatedetails(); $requi_model = new Default_Model_Requisition(); $interview_model = new Default_Model_Interviewdetails(); $user_model = new Default_Model_Usermanagement(); $interview_round_model = new Default_Model_Interviewrounddetails(); $cand_status = $this->_getParam('cand_status', null); $interview_status = $this->_getParam('interview_status', null); $flag = 'true'; if ($interview_status == 'On hold' && $cand_status != 'On hold') { $msgarray['statusErr'] = 'Since the interview status is onhold, the candidate status should be onhold.'; $flag = 'false'; } if ($interview_status == 'Completed' && ($cand_status != 'Disqualified' && $cand_status != 'Shortlisted')) { $msgarray['statusErr'] = 'Since interview status is completed, the candidate status can be either disqualified or shortlisted.'; $flag = 'false'; } if ($interview_status == 'In process' && ($cand_status == 'Disqualified' || $cand_status == 'Shortlisted')) { $msgarray['statusErr'] = 'Since the interview status is in process, the candidate cannot be shortlisted or disqualified.'; $flag = 'false'; } if ($form->isValid($this->_request->getPost()) && $flag != 'false') { $id = $this->_getParam('id', null); $requisition_id = $this->_getParam('req_id', null); $candidate_id = $this->_getParam('candidate_name', null); $interviewer_id = $this->_getParam('interviewer_id', null); $int_location = $this->_getParam('int_location', null); $country = $this->_getParam('country', null); $state = $this->_getParam('state', null); $city = $this->_getParam('city', null); $interview_mode = $this->_getParam('interview_mode', null); $interview_time = $this->_getParam('interview_time', null); $interview_date = $this->_getParam('interview_date', null); $interview_round = $this->_getParam('interview_round', null); if (!isset($candidate_id)) { $candidate_id = $data['id']; } if (empty($data)) { $getExistingCandidateRecord = $interview_model->getCandidateInInterviewProcess(trim($candidate_id)); if ($getExistingCandidateRecord > 0) { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview already scheduled for this candidate.'); $this->_redirect('/scheduleinterviews'); } } if (empty($data)) { $idata = array('req_id' => $requisition_id, 'candidate_id' => trim($candidate_id), 'interview_status' => trim($interview_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s")); $idata['interview_status'] = 'In process'; $iwhere = ""; $actionflag = 1; $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere); if ($id == '') { $tableid = $iresult; } if ($iresult != '') { $irdata = array('interview_id' => $iresult, 'req_id' => $requisition_id, 'candidate_id' => $candidate_id, 'interviewer_id' => $interviewer_id, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date($interview_date, 'database'), 'interview_mode' => $interview_mode, 'interview_round_number' => 1, 'interview_round' => trim($interview_round), 'int_location' => trim($int_location), 'int_country' => trim(intval($country)), 'int_state' => trim(intval($state)), 'int_city' => trim(intval($city)), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s")); $ir_result = $interview_round_model->SaveorUpdateInterviewroundData($irdata, ''); $requisition_data = $requi_model->getRequisitionDataById($requisition_id); $cand_data = $cand_model->getCandidateById($candidate_id); $report_person_data = $user_model->getUserDataById($interviewer_id); $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']); foreach ($mail_arr as $ename => $email) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $ename; $this->view->base_url = $base_url; $this->view->candidate_name = $cand_data['candidate_name']; $this->view->interview_type = $interview_mode; $this->view->interview_location = $int_location; $this->view->interview_date = $interview_date; $this->view->interview_time = sapp_Global::change_time($interview_time, 'view'); $this->view->requisition_code = $requisition_data['requisition_code']; $text = $view->render('mailtemplates/interviewrounds.phtml'); $options['subject'] = APPLICATION_NAME . ': Interview schedule'; $options['header'] = 'Interview schedule'; $options['toEmail'] = $email; $options['toName'] = $ename; $options['message'] = $text; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = "id = " . $candidate_id; $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where); } } else { $idata = array('interview_status' => trim($interview_status), 'isactive' => 1, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $iwhere = "id = " . $id; $tableid = $id; $actionflag = 2; $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere); $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($cand_status && $cand_status != '0') { $candData['cand_status'] = $cand_status; } $where = "id = " . $candidate_id; $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where); } $menumodel = new Default_Model_Menu(); $objidArr = $menumodel->getMenuObjID('/scheduleinterviews'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($id == '') { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview scheduled successfully.'); } else { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview details updated successfully.'); } $this->_redirect('/scheduleinterviews'); } else { $messages = $form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }