public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $round_model = new Default_Model_Interviewrounddetails();
     $intrvwModel = new Default_Model_Interviewdetails();
     $user_model = new Default_Model_Usermanagement();
     $cand_model = new Default_Model_Candidatedetails();
     $intrvwId = $this->getRequest()->getParam('unitId');
     if ($form->isValid($this->_request->getPost())) {
         $reqData = $intrvwModel->getReqByintrvwID($intrvwId);
         if (!empty($reqData)) {
             $reqId = $reqData['req_id'];
             $candid = $reqData['candidate_id'];
             $id = $this->getRequest()->getParam('id');
             $interview_id = $intrvwId;
             $interviewer_id = $this->getRequest()->getParam('interviewer_id');
             $interview_round = $this->getRequest()->getParam('interview_round');
             $interview_mode = $this->getRequest()->getParam('interview_mode');
             $int_location = $this->getRequest()->getParam('int_location');
             $interview_time = $this->getRequest()->getParam('interview_time');
             $interview_date = $this->getRequest()->getParam('interview_date');
             $interview_feedback = $this->getRequest()->getParam('interview_feedback');
             $interview_comments = $this->getRequest()->getParam('interview_comments');
             $round_status = $this->getRequest()->getParam('round_status', null);
             $hid_round_status = $this->getRequest()->getParam('hid_round_status', null);
             $data = array('candidate_id' => $candid, 'req_id' => $reqId, 'interview_id' => trim($intrvwId), 'interviewer_id' => trim($interviewer_id), 'interview_mode' => trim($interview_mode), 'int_location' => trim($int_location), 'int_country' => trim($this->_getParam('country', null)), 'int_state' => trim($this->_getParam('state', null)), 'int_city' => trim($this->_getParam('city', null)), 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date(trim($interview_date), 'database'), 'interview_round' => trim($interview_round), 'interview_feedback' => trim($interview_feedback), 'interview_comments' => trim($interview_comments), 'round_status' => trim($round_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $roundnumberData = $intrvwModel->getinterviewroundnumber($interview_id);
             $roundnumber = $roundnumberData['interview_round_number'];
             $data['interview_round_number'] = $roundnumber + 1;
             $where = "";
             $actionflag = 1;
             if ($id != '') {
                 unset($data['createdby']);
                 unset($data['createdon']);
                 unset($data['isactive']);
                 unset($data['interview_round_number']);
                 $where = array("id = " . $id);
                 $tableid = $id;
                 $actionflag = 2;
                 if ($hid_round_status != '') {
                     $data = array();
                     $data['round_status'] = trim($round_status);
                 }
             }
             if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) && $interviewer_id == $loginUserId) {
                 unset($data['interviewer_id']);
                 unset($data['interview_mode']);
                 unset($data['int_location']);
                 unset($data['int_country']);
                 unset($data['int_state']);
                 unset($data['int_city']);
                 unset($data['interview_time']);
                 unset($data['interview_date']);
                 unset($data['interview_round']);
             }
             $result = $round_model->SaveorUpdateInterviewroundData($data, $where);
             if ($id == '') {
                 //start of mailing
                 $requisition_data = $requi_model->getRequisitionDataById($reqId);
                 $cand_data = $cand_model->getCandidateById($candid);
                 $report_person_data = $user_model->getUserDataById($interviewer_id);
                 $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
                 foreach ($mail_arr as $ename => $email) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $ename;
                     $this->view->base_url = $base_url;
                     $this->view->candidate_name = $cand_data['candidate_name'];
                     $this->view->interview_type = $interview_mode;
                     $this->view->interview_location = $int_location;
                     $this->view->interview_date = $interview_date;
                     $this->view->interview_time = sapp_Global::change_time($interview_time, 'view');
                     $this->view->requisition_code = $requisition_data['requisition_code'];
                     $text = $view->render('mailtemplates/interviewrounds.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Interview schedule';
                     $options['header'] = 'Interview schedule';
                     $options['toEmail'] = $email;
                     $options['toName'] = $ename;
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     sapp_Global::_sendEmail($options);
                 }
                 //end of mailing
                 $tableid = $result;
                 $this->view->eventact = 'scheduled';
             } else {
                 if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == MANAGEMENT_GROUP) {
                     $requisition_data = $requi_model->getRequisitionDataById($reqId);
                     $cand_data = $cand_model->getCandidateById($candid);
                     $round_data = $round_model->getSingleRoundData($id);
                     $report_person_data = $user_model->getUserDataById($loginUserId);
                     $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
                     foreach ($mail_arr as $ename => $email) {
                         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $view = $this->getHelper('ViewRenderer')->view;
                         $this->view->emp_name = $ename;
                         $this->view->base_url = $base_url;
                         $this->view->candidate_name = $cand_data['candidate_name'];
                         $this->view->interview_type = $round_data['interview_mode'];
                         $this->view->interview_location = $round_data['int_location'];
                         $this->view->interview_date = sapp_Global::change_date($round_data['interview_date'], 'view');
                         $this->view->interview_time = sapp_Global::change_time($round_data['interview_time'], 'view');
                         $this->view->interview_feedback = $interview_feedback;
                         $this->view->interview_comments = $interview_comments;
                         $this->view->round_status = $round_status;
                         $this->view->reporting_person = $report_person_data['userfullname'];
                         $text = $view->render('mailtemplates/interviewrounds_feedback.phtml');
                         $options['subject'] = APPLICATION_NAME . ': Interview feedback';
                         $options['header'] = 'Interview feedback';
                         $options['toEmail'] = $email;
                         $options['toName'] = $ename;
                         $options['message'] = $text;
                         $options['cron'] = 'yes';
                         sapp_Global::_sendEmail($options);
                     }
                 }
                 $tableid = $id;
                 $this->view->eventact = 'updated';
             }
             $menumodel = new Default_Model_Menu();
             $objidArr = $menumodel->getMenuObjID('/scheduleinterviews');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $intrvwId);
             $close = 'close';
             $this->view->popup = $close;
             $this->view->ermsg = '';
         } else {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 /**
  * 
  * @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;
     }
 }