/**
  * 
  * @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;
     }
 }
Exemplo n.º 2
0
 /**
  * Send Emails
  * @param type $RequisitionCode
  * @param type $action
  */
 public function requisition_cvupload_emails($requisition_id, $action, $candDetails)
 {
     $user_model = new Default_Model_Usermanagement();
     $requi_model = new Default_Model_Requisition();
     #$identity_code_model = new Default_Model_Identitycodes();
     #$candiate_model = new Default_Model_Candidatedetails();
     //Requisition Summary Data
     $requisition_data = $requi_model->getrequisitiondetails($requisition_id);
     if (isset($requisition_data)) {
         $reqDetails = sprintf("%s-%s-%s (%s)", $requisition_data['businessunit_name'], $requisition_data['department_name'], $requisition_data['jobtitle_name'], $requisition_data['requisition_code']);
         $RequisitionCode = $requisition_data["requisition_code"];
         $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($RequisitionCode);
         //HRExecutive Details
         $hrexecutive_person_data = $user_model->getUserDataById($requisition_data["hrexecutive_id"]);
         //Requester Details
         $Raisedby_person_data = $user_model->getUserDataById($requisition_data["createdby"]);
         //Reporting Manager Details
         $Reportedto_person_data = $user_model->getUserDataById($requisition_data["reporting_id"]);
         //HR Group
         $mail_arr[0]['name'] = 'HR';
         $mail_arr[0]['email'] = constant('REQ_HR_0');
         $mail_arr[0]['type'] = 'CandidateCV';
         //Requester
         $mail_arr[1]['name'] = $Raisedby_person_data['userfullname'];
         $mail_arr[1]['email'] = $Raisedby_person_data['emailaddress'];
         $mail_arr[1]['type'] = 'CandidateCV';
         //HR Executive
         $mail_arr[2]['name'] = $hrexecutive_person_data['userfullname'];
         $mail_arr[2]['email'] = $hrexecutive_person_data['emailaddress'];
         $mail_arr[2]['type'] = 'CandidateCV';
         //Reporting Manager
         $mail_arr[3]['name'] = $Reportedto_person_data['userfullname'];
         $mail_arr[3]['email'] = $Reportedto_person_data['emailaddress'];
         $mail_arr[3]['type'] = 'CandidateCV';
         //Management Group
         $mail_arr[4]['name'] = 'Management';
         $mail_arr[4]['email'] = constant('REQ_MGMT_0');
         $mail_arr[4]['type'] = 'CandidateCV';
         $emailCnt = 5;
         foreach ($requisition_recruiters_data as $requisition_recruiters_data1) {
             $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname'];
             $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress'];
             $mail_arr[$emailCnt]['type'] = 'CandidateCV';
             $emailCnt = $emailCnt + 1;
         }
         $appr_str = $hrexecutive_person_data['userfullname'];
         $jobtitle_name = $requisition_data["jobtitle_name"];
         for ($ii = 0; $ii < count($mail_arr); $ii++) {
             $subjMsg = 'Uploaded CV modified for requisition.';
             if ($action == "New") {
                 $subjMsg = 'New CV uploaded to requisition.';
             }
             if ($action == "Update") {
                 $subjMsg = 'Uploaded CV modified for requisition.';
             }
             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
             $view = $this->getHelper('ViewRenderer')->view;
             $this->view->emp_name = $mail_arr[$ii]['name'];
             $this->view->subjMsg = $subjMsg;
             $this->view->base_url = $base_url;
             $this->view->type = $mail_arr[$ii]['type'];
             $this->view->requisition_details = $reqDetails;
             $this->view->candidate_details = $candDetails;
             $text = $view->render('mailtemplates/requisition.phtml');
             $options['subject'] = APPLICATION_NAME . ':' . $subjMsg;
             $options['header'] = 'Requisition Status';
             $options['toEmail'] = $mail_arr[$ii]['email'];
             $options['toName'] = $mail_arr[$ii]['name'];
             $options['message'] = $text;
             $options['cron'] = 'yes';
             if ($options['toEmail'] != '') {
                 sapp_Global::_sendEmail($options, "requisition", REQUISITIONMODULESENDEMAIL);
             }
         }
     }
 }
 /**
  * 
  * @param type $form
  * @return type
  */
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $round_model = new Default_Model_Interviewrounddetails();
     $round_reschedule_model = new Default_Model_Interviewroundrescheduledetails();
     $intrvwModel = new Default_Model_Interviewdetails();
     $user_model = new Default_Model_Usermanagement();
     $cand_model = new Default_Model_Candidatedetails();
     $roundId = $this->getRequest()->getParam('id');
     $intrvwId = $this->getRequest()->getParam('unitId');
     if ($form->isValid($this->_request->getPost())) {
         $reqData = $intrvwModel->getReqByintrvwID($intrvwId);
         if (!empty($reqData)) {
             $reqId = $reqData['req_id'];
             $candid = $reqData['candidate_id'];
             $id = $this->getRequest()->getParam('id');
             $interviewrnd_id = $intrvwId;
             $interviewer_id1 = $this->getRequest()->getParam('interviewer_id');
             if (is_array($interviewer_id1)) {
                 $interview_id = $interviewer_id1[0];
             } else {
                 $interview_id = $interviewer_id1;
             }
             $interview_round = $this->getRequest()->getParam('interview_round');
             $interview_mode = $this->getRequest()->getParam('interview_mode');
             $interview_Type_Details = $this->getRequest()->getParam('interview_Type_Details');
             $int_location = $this->getRequest()->getParam('int_location');
             $interview_time = $this->getRequest()->getParam('interview_time');
             $interview_date = $this->getRequest()->getParam('interview_date');
             $interview_feedback = $this->getRequest()->getParam('interview_feedback');
             $interview_comments = $this->getRequest()->getParam('interview_comments');
             $round_status = $this->getRequest()->getParam('round_status', null);
             $hid_round_status = $this->getRequest()->getParam('hid_round_status', null);
             if (is_array($interviewer_id1)) {
                 $interview_panel = implode(",", $this->getRequest()->getParam('interviewer_id', null));
             } else {
                 $interview_id = $interviewer_id1;
             }
             if ($id != null) {
                 //get Feedback Matrix values from Request
                 $requisitionSkillMatrix = $round_model->getRequisitionSkillMatrix($id);
                 $currRowCount = 0;
                 foreach ($requisitionSkillMatrix as $skill) {
                     $unqCode = $skill['uniquecode'];
                     $skillSelValue = $this->getRequest()->getParam($unqCode, null);
                     if ($skillSelValue != null) {
                         $requisitionSkillMatrix[$currRowCount]['Rating'] = $skillSelValue;
                     }
                     $currRowCount++;
                 }
             }
             //check if Skill matrix is filled as per business logic
             $skillsmatrixvalidate = true;
             if ($round_status == "Schedule for next round" || $round_status == "Qualified" || $round_status == "Selected" || $round_status == "Disqualified") {
                 if ($interview_round == "Technical") {
                     foreach ($requisitionSkillMatrix as $skill) {
                         if ($skill['Category'] == "Technical" && ($skill['Rating'] <= 0 || $skill['Rating'] == null)) {
                             $skillsmatrixvalidate = false;
                             break;
                         }
                     }
                 }
                 /* else if ($interview_round == "Managerial") {
                    foreach ($requisitionSkillMatrix as $skill) {
                    if ($skill['Category'] == "Non-Technical" && ($skill['Rating'] <= 0 || $skill['Rating'] == null)) {
                    $skillsmatrixvalidate = false;
                    break;
                    }
                    }
                    } */
             }
             if ($skillsmatrixvalidate != true) {
                 $alertMsg = ($interview_round == "Managerial" ? 'Non-Technical' : 'Technical') . " Skill Rating is Mandatory...!";
                 echo '<script language="javascript">';
                 echo 'alert("' . $alertMsg . '")';
                 echo '</script>';
             } else {
                 // for Interview Reschedule & Cancellations
                 if ($round_status == "Re-Scheduled-Interviewer Request" || $round_status == "Re-Scheduled-Candidate Request" || $round_status == "Cancelled") {
                     $round_data = $round_model->getSingleRoundData($id);
                     $cand_data = $cand_model->getCandidateById($candid);
                     $requisition_data = $requi_model->getRequisitionDataById($reqId);
                     $interviewpanelnamesemailaddress = $requi_model->GetInterviewPanelMamesEmailaddress($round_data['interview_panel']);
                     $loginuser_person_data = $user_model->getUserDataById($loginUserId);
                     $data = array('interviewround_id' => $id, 'interview_id' => trim($intrvwId), 'req_id' => $reqId, 'candidate_id' => $candid, 'interview_location_old' => $round_data['int_location'], 'interview_round_old' => $round_data['interview_round'], 'interview_date_old' => $round_data['interview_date'], 'interview_time_old' => $round_data['interview_time'], 'interview_mode_old' => $round_data['interview_mode'], 'interview_mode_details_old' => $round_data['interview_mode_details'], 'interview_location' => $int_location, 'interview_round' => $interview_round, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_Type_Details, 'interview_feedback' => trim($interview_feedback), 'round_status' => trim($round_status), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"));
                     $result1 = $round_reschedule_model->SaveorUpdateInterviewroundData($data, "");
                     $intRound_where = array("id = " . $id);
                     if ($round_status == "Cancelled") {
                         $data_intRound = array('int_location' => $int_location, 'interview_round' => $interview_round, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_Type_Details, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 0);
                     } else {
                         $data_intRound = array('int_location' => $int_location, 'interview_round' => $interview_round, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_Type_Details, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel);
                     }
                     $result2 = $round_model->SaveorUpdateInterviewroundData($data_intRound, $intRound_where);
                     if ($result1 > 0 && $result2 == "update") {
                         //send Reschedule meeting invite
                         $emailtemp = array();
                         $nametemp = array();
                         foreach ($interviewpanelnamesemailaddress as $row) {
                             array_push($emailtemp, $row['emailaddress']);
                             array_push($nametemp, $row['userfullname']);
                         }
                         $email = implode(";", $emailtemp);
                         $ename = implode(";", $nametemp);
                         $cal_unique_id = $round_data['calendarinviteid'];
                         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $description = "Meeting From : " . $ename . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n";
                         //$view = $this->getHelper('ViewRenderer')->view;
                         //$this->view->emp_name = "Interviewer";
                         //$this->view->base_url = $base_url;
                         //$this->view->candidate_name = $cand_data['candidate_name'];
                         //$this->view->interview_type = $interview_mode;
                         //$this->view->interview_mode_details = $interview_Type_Details;
                         //$this->view->interview_location = $int_location;
                         //$this->view->interview_date = $interview_date;
                         //$this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                         //$this->view->requisition_code = $requisition_data['requisition_code'];
                         //$text = $view->render('mailtemplates/interviewrounds.phtml');
                         //$options['subject'] = APPLICATION_NAME . ': Interview schedule';
                         //$options['header'] = 'Interview schedule';
                         //$options['toEmail'] = $email;
                         //$options['toName'] = $ename;
                         //$options['message'] = $description;
                         //$options['location'] = $int_location;
                         //$options['interviewdate'] = $interview_date;
                         //$options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0);
                         //$options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600);
                         //Interview Calendar Invite will be send from login user account
                         //$options['fromEmail'] = $loginuser_person_data['emailaddress'];
                         //$options['fromName'] = $loginuser_person_data['userfullname'];
                         //$options['fromEmail'] = SUPERADMIN_EMAIL;
                         //$options['fromName'] = "*****@*****.**";
                         //$options['calUniqueID'] = $cal_unique_id;
                         $calRequest = 'REQUEST';
                         if ($round_status == "Cancelled") {
                             $calRequest = 'CANCEL';
                         }
                         $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel);
                         foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) {
                             //sapp_Global::_sendCalendarEmail($options);
                             $from_name = trim($loginuser_person_data['userfullname']);
                             $from_address = trim($loginuser_person_data['emailaddress']);
                             $to_name = trim($interviewpanelnamesemailaddress['userfullname']);
                             $to_address = trim($interviewpanelnamesemailaddress['emailaddress']);
                             $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600);
                             $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)));
                             $subject = APPLICATION_NAME . ': Interview schedule';
                             $location = $int_location;
                             sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
                         }
                         $irwhere = "id = " . $result1;
                         $irdata = array('calendarinviteid' => $cal_unique_id);
                         $interview_round_model = new Default_Model_Interviewrounddetails();
                         $ir_result1 = $interview_round_model->SaveorUpdateInterviewroundData($irdata, $irwhere);
                         $this->view->eventact = 'updated';
                         $actionflag = 1;
                         $menumodel = new Default_Model_Menu();
                         $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
                         $objID = $objidArr[0]['id'];
                         $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $intrvwId);
                         $close = 'close';
                         $this->view->popup = $close;
                         $this->view->ermsg = '';
                     }
                 } else {
                     $data = array('candidate_id' => $candid, 'req_id' => $reqId, 'interview_id' => trim($intrvwId), 'interviewer_id' => $interview_id, 'interview_mode' => trim($interview_mode), 'interview_mode_details' => $interview_Type_Details, 'int_location' => trim($int_location), 'int_country' => trim($this->_getParam('country', null)), 'int_state' => trim($this->_getParam('state', null)), 'int_city' => trim($this->_getParam('city', null)), 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_round' => trim($interview_round), 'interview_feedback' => trim($interview_feedback), 'interview_comments' => trim($interview_comments), 'round_status' => trim($round_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel);
                     if ($interviewrnd_id != null) {
                         $roundnumberData = $intrvwModel->getinterviewroundnumber($interviewrnd_id);
                         $roundnumber = $roundnumberData['interview_round_number'];
                     }
                     $data['interview_round_number'] = $roundnumber + 1;
                     $currentinterviewroundnumber = $roundnumber;
                     $where = "";
                     $actionflag = 1;
                     if ($id != '') {
                         //update skill matrix to DB
                         if ($round_status == "Schedule for next round" || $round_status == "Qualified" || $round_status == "Selected" || $round_status == "Disqualified") {
                             $skillupdateresult = $round_model->UpdateOrInsertCandidateSkillMatrix($requisitionSkillMatrix, $id, $intrvwId, $reqId, $candid, $loginUserId, $currentinterviewroundnumber);
                         }
                         unset($data['interview_panel']);
                         unset($data['createdby']);
                         unset($data['createdon']);
                         unset($data['isactive']);
                         unset($data['interview_round_number']);
                         $where = array("id = " . $id);
                         $tableid = $id;
                         $actionflag = 2;
                         if ($hid_round_status != '') {
                             $data = array();
                             $data['round_status'] = trim($round_status);
                         }
                     }
                     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) && $interviewer_id == $loginUserId) {
                         unset($data['interviewer_id']);
                         unset($data['interview_mode']);
                         unset($data['int_location']);
                         unset($data['int_country']);
                         unset($data['int_state']);
                         unset($data['int_city']);
                         unset($data['interview_time']);
                         unset($data['interview_date']);
                         unset($data['interview_round']);
                     }
                     $result = $round_model->SaveorUpdateInterviewroundData($data, $where);
                     //upadating invite calander id if interview round id is numeric
                     if (is_numeric($result)) {
                         //updating calendarinviteid column in main_interviewrounddetails tabel - start
                         $startTime = sapp_Global::add_time($interview_time, 'view', 0);
                         //$domain = 'deltaintech.com';
                         //$cal_unique_id = date("Ymd\TGis", strtotime($startTime)) . rand() . "@" . $domain;
                         $irwhere = "id = " . $result;
                         $irdata = array('calendarinviteid' => $cal_unique_id);
                         $interview_round_model1 = new Default_Model_Interviewrounddetails();
                         $ir_result1 = $interview_round_model1->SaveorUpdateInterviewroundData($irdata, $irwhere);
                     }
                     //upadating invite calander id if interview round id is numeric - End
                     if ($id == '') {
                         //start of mailing
                         $requisition_data = $requi_model->getRequisitionDataById($reqId);
                         $cand_data = $cand_model->getCandidateById($candid);
                         /* $report_person_data = $user_model->getUserDataById($interviewer_id);
                            $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "",
                            $report_person_data['userfullname'] => $report_person_data['emailaddress']
                            ); */
                         $report_person_data = $user_model->getUserDataById($interviewer_id);
                         $currentrequisition_data = $requi_model->getrequisitiondetails($reqId);
                         $requesteremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["createdby"]);
                         $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["reporting_id"]);
                         $hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]);
                         $mail_arr = array('HR' => $hrgroupemail["groupEmail"], $report_person_data['userfullname'] => $report_person_data['emailaddress'], $requesteremailaddress['userfullname'] => $requesteremailaddress['emailaddress'], $reportingmanageremailaddress['userfullname'] => $reportingmanageremailaddress['emailaddress']);
                         //foreach ($mail_arr as $ename => $email) {
                         //$base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $description = "Meeting From : " . $ename . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n";
                         //$view = $this->getHelper('ViewRenderer')->view;
                         //$this->view->emp_name = $ename;
                         //$this->view->base_url = $base_url;
                         //$this->view->candidate_name = $cand_data['candidate_name'];
                         //$this->view->interview_type = $interview_mode;
                         //$interview_Type_Details
                         //$this->view->interview_location = $int_location;
                         //$this->view->interview_date = $interview_date;
                         //$this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                         //$this->view->requisition_code = $requisition_data['requisition_code'];
                         //$text = $view->render('mailtemplates/interviewrounds.phtml');
                         //$options['subject'] = APPLICATION_NAME . ': Interview schedule';
                         //$options['header'] = 'Interview schedule';
                         //$options['toEmail'] = $email;
                         //$options['toName'] = $ename;
                         //$options['message'] = $description;
                         ////$options['cron'] = 'yes';
                         //additional properties for Calendar invite -------------------START
                         //$options['interviewdate'] = $interview_date;
                         //$options['location'] = $int_location;
                         //$options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0);
                         //$options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600);
                         //$options['calUniqueID'] = $cal_unique_id;
                         //additional properties for Calendar invite -------------------END
                         //sapp_Global::_sendCalendarEmail($options);
                         $loginuser_person_data = $user_model->getUserDataById($loginUserId);
                         $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel);
                         foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) {
                             $cal_unique_id = $this->getCalendarUniqueID();
                             $from_name = trim($loginuser_person_data['userfullname']);
                             $from_address = trim($loginuser_person_data['emailaddress']);
                             $to_name = trim($interviewpanelnamesemailaddress['userfullname']);
                             $to_address = trim($interviewpanelnamesemailaddress['emailaddress']);
                             $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600);
                             $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)));
                             $subject = APPLICATION_NAME . ': Interview schedule';
                             $location = $int_location;
                             $calRequest = 'REQUEST';
                             sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
                         }
                         //}
                         //end of mailing
                         $tableid = $result;
                         $this->view->eventact = 'scheduled';
                     } else {
                         if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == MANAGEMENT_GROUP) {
                             $requisition_data = $requi_model->getRequisitionDataById($reqId);
                             $requisition_data_View = $requi_model->getReqDataForView($reqId);
                             $cand_data = $cand_model->getCandidateById($candid);
                             $round_data = $round_model->getSingleRoundData($id);
                             $report_person_data = $user_model->getUserDataById($interviewer_id);
                             $currentrequisition_data = $requi_model->getrequisitiondetails($reqId);
                             $requesteremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["createdby"]);
                             $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($currentrequisition_data["reporting_id"]);
                             //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]);
                             //HR Group
                             $mail_arr[0]['name'] = 'HR';
                             $mail_arr[0]['email'] = constant('REQ_HR_0');
                             //Requester
                             $mail_arr[1]['name'] = $requesteremailaddress['userfullname'];
                             $mail_arr[1]['email'] = $requesteremailaddress['emailaddress'];
                             //Reporting Manager
                             $mail_arr[2]['name'] = $reportingmanageremailaddress['userfullname'];
                             $mail_arr[2]['email'] = $reportingmanageremailaddress['emailaddress'];
                             //Management Group
                             $mail_arr[3]['name'] = 'Management';
                             $mail_arr[3]['email'] = constant('REQ_MGMT_0');
                             //Recruiter Panel
                             $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($currentrequisition_data["requisition_code"]);
                             $emailCnt = 4;
                             foreach ($requisition_recruiters_data as $requisition_recruiters_data1) {
                                 $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname'];
                                 $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress'];
                                 $emailCnt = $emailCnt + 1;
                             }
                             //Technical Panel
                             $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($round_data['interview_panel']);
                             foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress1) {
                                 $mail_arr[$emailCnt]['name'] = $interviewpanelnamesemailaddress1['userfullname'];
                                 $mail_arr[$emailCnt]['email'] = $interviewpanelnamesemailaddress1['emailaddress'];
                                 $emailCnt = $emailCnt + 1;
                             }
                             for ($ii = 0; $ii < count($mail_arr); $ii++) {
                                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                                 $view = $this->getHelper('ViewRenderer')->view;
                                 $this->view->emp_name = $mail_arr[$ii]['name'];
                                 $this->view->type = 'InterviewFeedback';
                                 $this->view->requisition_data = $requisition_data_View[0];
                                 $this->view->candidate_details = $cand_data;
                                 $this->view->round_data = $round_data;
                                 $this->view->base_url = $base_url;
                                 $text = $view->render('mailtemplates/requisition.phtml');
                                 $options['subject'] = APPLICATION_NAME . ': Interview feedback';
                                 //$options['header'] = 'Interview feedback';
                                 $options['toEmail'] = $mail_arr[$ii]['email'];
                                 $options['toName'] = $mail_arr[$ii]['name'];
                                 $options['message'] = $text;
                                 sapp_Global::_sendEmail($options, "interviewrounds_feedback", REQUISITIONMODULESENDEMAIL);
                             }
                         }
                         $tableid = $id;
                         $this->view->eventact = 'updated';
                     }
                     $menumodel = new Default_Model_Menu();
                     $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
                     $objID = $objidArr[0]['id'];
                     $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $intrvwId);
                     $close = 'close';
                     $this->view->popup = $close;
                     $this->view->ermsg = '';
                 }
             }
         } else {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }