public function getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $statusid, $a1, $a2, $a3)
 {
     $searchQuery = '';
     $searchArray = array();
     $data = array();
     $requi_model = new Default_Model_Requisition();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if ($searchData != '' && $searchData != 'undefined') {
         $searchValues = json_decode($searchData);
         if (count($searchValues) > 0) {
             foreach ($searchValues as $key => $val) {
                 if ($key == 'onboard_date' || $key == 'r.createdon') {
                     $searchQuery .= " date(" . $key . ")  = '" . sapp_Global::change_date($val, 'database') . "' AND ";
                 } else {
                     $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                 }
                 $searchArray[$key] = $val;
             }
             $searchQuery = rtrim($searchQuery, " AND");
         }
     }
     $objName = 'rejectedrequisitions';
     $tableFields = array('action' => 'Action', 'requisition_code' => 'Requisition Code', 'jobtitle_name' => 'Job Title', 'createdby_name' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'req_no_positions' => 'No. of Positions', 'filled_positions' => 'Filled Positions', 'r.createdon' => 'Raised On', 'onboard_date' => 'Due Date');
     $tablecontent = $requi_model->getRequisitionData($sort, $by, $pageNo, $perPage, $searchQuery, $loginUserId, $loginuserGroup, 3);
     $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'add' => 'add', 'searchArray' => $searchArray, 'menuName' => 'Rejected Requisitions', 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => array('r.createdon' => array('type' => 'datepicker'), 'onboard_date' => array('type' => 'datepicker')));
     return $dataTmp;
 }
 /**
  * This action is called on onchange of requisition select box in schedule interviews.
  */
 public function getcandidatesAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginUserGroup = $auth->getStorage()->read()->group_id;
     }
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('getcandidates', 'json')->initContext();
     $req_model = new Default_Model_Requisition();
     $req_id = $this->_request->getParam('req_id');
     $cdata = $req_model->getcandidates_forinterview($req_id, $loginUserGroup, $loginUserId);
     $this->_helper->json($cdata);
 }
 public function save($requisitionform, $data)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $req_status = $this->_getParam('req_status', null);
     $flag = 'true';
     if ($requisitionform->isValid($this->_request->getPost()) && $flag != 'false') {
         $id = $this->_getParam('id', null);
         $req_status = $this->_getParam('req_status', null);
         $onboard_date = $this->_getParam('onboard_date', null);
         $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"));
         if ($onboard_date != '') {
             $data = $data + array('onboard_date' => sapp_Global::change_date($onboard_date, 'database'));
         }
         $where = "id = " . $id;
         $result = $requi_model->SaveorUpdateRequisitionData($data, $where);
         $tableid = $id;
         $actionflag = 2;
         if ($result != '') {
             if ($req_status == 'Complete' || $req_status == 'Closed') {
                 $requi_model->change_to_requisition_closed($id);
                 $requisition_data = $requi_model->getReqDataForView($id);
                 $requisition_data = $requisition_data[0];
                 $report_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                 $closed_person_data = $user_model->getUserDataById($loginUserId);
                 $mail_arr[0]['name'] = 'HR';
                 $requisition_data['businessunit_id'];
                 $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "";
                 $mail_arr[0]['type'] = 'HR';
                 $mail_arr[1]['name'] = 'Management';
                 $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : "";
                 $mail_arr[1]['type'] = 'Management';
                 $mail_arr[2]['name'] = $report_person_data['userfullname'];
                 $mail_arr[2]['email'] = $report_person_data['emailaddress'];
                 $mail_arr[2]['type'] = 'Raise';
                 for ($ii = 0; $ii < count($mail_arr); $ii++) {
                     $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                     $view = $this->getHelper('ViewRenderer')->view;
                     $this->view->emp_name = $mail_arr[$ii]['name'];
                     $this->view->base_url = $base_url;
                     $this->view->type = $mail_arr[$ii]['type'];
                     $this->view->requisition_code = $requisition_data['requisition_code'];
                     $this->view->req_status = $status = strtolower($req_status == 'Complete' ? "Completed" : $req_status);
                     $this->view->raised_name = $report_person_data['userfullname'];
                     $this->view->approver_str = $closed_person_data['userfullname'];
                     $text = $view->render('mailtemplates/changedrequisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ': Requisition is ' . $status;
                     $options['header'] = 'Requisition is ' . $status;
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     $options['cron'] = 'yes';
                     sapp_Global::_sendEmail($options);
                 }
             }
             $menumodel = new Default_Model_Menu();
             $objidArr = $menumodel->getMenuObjID('/approvedrequisitions');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
             if ($id != '') {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition updated successfully."));
             } else {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition added successfully."));
             }
             $this->_redirect('/approvedrequisitions');
         }
     } else {
         $messages = $requisitionform->getMessages();
         $msgarray = array();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 /**
  * This function acts as a service for adding a interview.
  * @param array $params_arr  = array of parameters
  * @return array  Array of results.
  */
 public function addinterview($params_arr)
 {
     $result = array();
     $status = 0;
     $message = "No access to add interview.";
     if (isset($params_arr['role_id']) && $params_arr['role_id'] != '' && isset($params_arr['group_id']) && $params_arr['group_id'] != '' && isset($params_arr['userid']) && $params_arr['userid'] != '') {
         $role_id = $params_arr['role_id'];
         $group_id = $params_arr['group_id'];
         $userid = $params_arr['userid'];
         if ($role_id == SUPERADMINROLE || $group_id == MANAGEMENT_GROUP || $group_id == HR_GROUP) {
             $privilege_flag = sapp_Global::_checkprivileges(SCHEDULEINTERVIEWS, $group_id, $role_id, 'add');
             if ($privilege_flag == 'Yes') {
                 $status = 1;
                 $message = "success";
                 $req_model = new Default_Model_Requisition();
                 $countryModal = new Default_Model_Countries();
                 $req_data = $req_model->getReqForInterviews();
                 $req_options = $requisition_options = array();
                 $countries_options = $cntry_options = array();
                 foreach ($req_data as $req) {
                     $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
                 }
                 $requisition_options = array('' => 'Select Requisition ID') + $req_options;
                 $countriesData = $countryModal->fetchAll('isactive=1', 'country');
                 foreach ($countriesData->toArray() as $data) {
                     $cntry_options[trim($data['country_id_org'])] = $data['country'];
                 }
                 $countries_options = array('' => 'Select country') + $cntry_options;
                 $interview_type_options = array('' => 'Select Interview Type', 'In person' => 'In person', 'Phone' => 'Phone', 'Video conference' => 'Video conference');
                 if (empty($req_options) && count($req_options) == 0) {
                     $status = 0;
                     $message = "No approved requisitions.";
                 } else {
                     if (empty($cntry_options) && count($cntry_options) == 0) {
                         $status = 0;
                         $message = "Countries are not configured yet.";
                     } else {
                         $result['req_id'] = $requisition_options;
                         $result['country'] = $countries_options;
                         $result['interview_mode'] = $interview_type_options;
                     }
                 }
             }
         }
     }
     return array('status' => $status, 'message' => $message, 'result' => $result);
 }
 public function multipleresumeAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginUserId = trim($loginUserId);
     }
     $priv_check = sapp_Global::_checkprivileges(CANDIDATEDETAILS, '', $auth->getStorage()->read()->emprole, 'add');
     if ($priv_check == 'Yes') {
         $msgarray = $req_options = array();
         $form = new Default_Form_Multipleresume();
         $form->setAction(DOMAIN . 'candidatedetails/multipleresume');
         // To show list of requisitions to user
         $req_model = new Default_Model_Requisition();
         $req_data = $req_model->getRequisitionsForCV("'Approved','In process'");
         foreach ($req_data as $req) {
             $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
         }
         if (count($req_options) == 0) {
             $msgarray['requisition_id'] = "No active requisitions are found.";
         }
         $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
         $form_post_status = $this->_request->getPost();
         if ($form_post_status) {
             $candidate_firstname = $this->_getParam('candidate_firstname', null);
             $candidate_lastname = $this->_getParam('candidate_lastname', null);
             $cand_resumes = $this->_getParam('cand_resume', null);
             if ($form->isValid($form_post_status)) {
                 $cand_details_model = new Default_Model_Candidatedetails();
                 $requisition_id = $this->_getParam('requisition_id', null);
                 $cand_status = $this->_getParam('cand_status', null);
                 $req_records = $cand_details_model->getcountofrecords($requisition_id);
                 $curr_date = gmdate("Y-m-d H:i:s");
                 if (empty($req_records)) {
                     $rdata = array('req_status' => 'In process', 'modifiedby' => $loginUserId, 'modifiedon' => $curr_date);
                     $rwhere = ' id = ' . $requisition_id;
                     $req_model->SaveorUpdateRequisitionData($rdata, $rwhere);
                 }
                 // To insert records in a single query
                 $records = array();
                 foreach ($candidate_firstname as $key => $candidate_fname) {
                     $cfull_name = $candidate_fname . ' ' . $candidate_lastname[$key];
                     $records[] = "({$requisition_id}, '{$candidate_fname}','{$candidate_lastname[$key]}','{$cfull_name}', '{$cand_resumes[$key]}', '{$cand_status}', 1, {$loginUserId}, {$loginUserId}, '{$curr_date}', '{$curr_date}')";
                 }
                 $data_fields = array('requisition_id', 'candidate_firstname', 'candidate_lastname', 'candidate_name', 'cand_resume', 'cand_status', 'isactive', 'createdby', 'modifiedby', 'createddate', 'modifieddate');
                 $last_insert_id = $cand_details_model->insertMultipleRecords($data_fields, $records);
                 // Log status to Log manager and redirect to Resource Pooling list page.
                 if ($last_insert_id != '') {
                     $menumodel = new Default_Model_Menu();
                     $objidArr = $menumodel->getMenuObjID('/candidatedetails');
                     $objID = $objidArr[0]['id'];
                     $log_status = sapp_Global::logManager($objID, 1, $loginUserId, $last_insert_id);
                     //$this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Candidate details added successfully.');
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Candidate details added successfully."));
                     $this->_redirect('/candidatedetails');
                 }
             } else {
                 // To handle server validation, when Javascript is disabled
                 $messages = $form->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                 }
                 $form->setDefault('candidate_firstname', $candidate_firstname[0]);
                 $form->setDefault('cand_resume', '');
             }
         }
         $this->view->form = $form;
         $this->view->msgarray = $msgarray;
     } else {
         $this->_redirect('error');
     }
 }
 /**
  * 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);
             }
         }
     }
 }
 public function save($employeeform)
 {
     $emproleStr = '';
     $roleArr = array();
     $empgroupStr = '';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usersModel = new Default_Model_Usermanagement();
     $employeeModal = new Default_Model_Employee();
     $requimodel = new Default_Model_Requisition();
     $candidate_model = new Default_Model_Candidatedetails();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $unitid = '';
     $deptid = '';
     $errorflag = 'true';
     $msgarray = array();
     $id = $this->_request->getParam('id');
     $businessunit_id = $this->_request->getParam('businessunit_id', null);
     $department_id = $this->_request->getParam('department_id', null);
     $reporting_manager = $this->_request->getParam('reporting_manager', null);
     $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
     $position_id = $this->_request->getParam('position_id', null);
     $user_id = $this->_getParam('user_id', null);
     $prefix_id = $this->_getParam('prefix_id', null);
     $extension_number = $this->_getParam('extension_number', null);
     $office_number = $this->_request->getParam('office_number', null);
     $office_faxnumber = $this->_request->getParam('office_faxnumber', null);
     $date_of_joining = $this->_request->getParam('date_of_joining', null);
     $date_of_joining = sapp_Global::change_date($date_of_joining, 'database');
     $isvalidorgstartdate = $orgInfoModel->validateEmployeeJoiningDate($date_of_joining, $unitid, $deptid);
     if (!empty($isvalidorgstartdate)) {
         $msgarray['date_of_joining'] = 'Employee joining date should be greater than organization start date.';
         $errorflag = 'false';
     }
     if ($id) {
         $data = $employeeModal->getsingleEmployeeData($id);
         if (!empty($data) && $data[0]['is_orghead'] == 1) {
             $reporting_manager = $this->_request->getParam('reporting_manager', '0');
         }
     }
     if ($employeeform->isValid($this->_request->getPost()) && $errorflag == 'true') {
         $id = $this->_request->getParam('id');
         $emp_status_id = $this->_request->getParam('emp_status_id', null);
         $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
         $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
         $years_exp = $this->_request->getParam('years_exp');
         //FOR USER table
         $employeeId = $this->_getParam('employeeId', null);
         $modeofentry = $this->_getParam('modeofentry', null);
         $hid_modeofentry = $this->_getParam('hid_modeofentry', null);
         $other_modeofentry = $this->_getParam('other_modeofentry', null);
         $firstname = trim($this->_getParam('firstname', null));
         $lastname = trim($this->_getParam('lastname', null));
         $userfullname = $firstname . ' ' . $lastname;
         $candidatereferredby = $this->_getParam('candidatereferredby', null);
         $rccandidatename = $this->_getParam('rccandidatename', null);
         $emprole = $this->_getParam('emprole', null);
         //roleid_group_id
         if ($emprole != "") {
             $roleArr = explode('_', $emprole);
             if (!empty($roleArr)) {
                 $emproleStr = $roleArr[0];
                 $empgroupStr = $roleArr[0];
             }
         }
         $emailaddress = $this->_getParam('emailaddress', null);
         $tmp_name = $this->_request->getParam('tmp_emp_name', null);
         $act_inact = $this->_request->getParam("act_inact", null);
         //end of user table
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $empstatusarray = array(8, 9, 10);
         $actionflag = '';
         $tableid = '';
         if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') {
             $candidate_key = 'userfullname';
             $candidate_value = $userfullname;
             $emp_name = $userfullname;
             $candidate_flag = 'no';
         } else {
             $candidate_key = 'rccandidatename';
             $candidate_value = $rccandidatename;
             $emp_name = $tmp_name;
             $candidate_flag = 'yes';
         }
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $emppassword = sapp_Global::generatePassword();
             $user_data = array('emprole' => $emproleStr, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry);
             if ($id != '') {
                 $where = array('user_id=?' => $user_id);
                 $actionflag = 2;
                 $user_where = "id = " . $user_id;
                 unset($user_data['candidatereferredby']);
                 unset($user_data['userstatus']);
                 unset($user_data['emppassword']);
                 unset($user_data['employeeId']);
                 unset($user_data['modeofentry']);
                 unset($user_data['other_modeofentry']);
             } else {
                 $user_data['createdby'] = $loginUserId;
                 $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $user_data['isactive'] = 1;
                 if ($modeofentry != 'Direct') {
                     $user_data['userfullname'] = $emp_name;
                 }
                 $where = '';
                 $actionflag = 1;
                 $user_where = '';
                 $identity_code_model = new Default_Model_Identitycodes();
                 $identity_codes = $identity_code_model->getIdentitycodesRecord();
                 $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
                 if ($emp_identity_code != '') {
                     $emp_id = $emp_identity_code . str_pad($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                 } else {
                     $emp_id = '';
                 }
                 $user_data['employeeId'] = $emp_id;
             }
             $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where);
             if ($id == '') {
                 $user_id = $user_status;
             }
             $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number != '' ? $extension_number : NULL, 'office_number' => $office_number != '' ? $office_number : NULL, 'office_faxnumber' => $office_faxnumber != '' ? $office_faxnumber : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id == '') {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
             }
             $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where);
             $statuswhere = array('id=?' => $user_id);
             if ($id != '') {
                 if (in_array($emp_status_id, $empstatusarray)) {
                     $isactivestatus = '';
                     if ($emp_status_id == 8) {
                         $isactivestatus = 2;
                     } else {
                         if ($emp_status_id == 9) {
                             $isactivestatus = 3;
                         } else {
                             if ($emp_status_id == 10) {
                                 $isactivestatus = 4;
                             }
                         }
                     }
                     $statusdata = array('isactive' => $isactivestatus);
                     $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                     $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                 } else {
                     $edata = $usersModel->getUserDataById($id);
                     $statusdata = array('isactive' => 1);
                     if ($edata['isactive'] != 0) {
                         if ($edata['emptemplock'] == 1) {
                             $statusdata = array('isactive' => 0);
                         }
                         $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                         $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                     }
                 }
             }
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully."));
             } else {
                 //start of mailing
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $emp_name;
                 $this->view->password = $emppassword;
                 $this->view->emp_id = $employeeId;
                 $this->view->base_url = $base_url;
                 $text = $view->render('mailtemplates/newpassword.phtml');
                 $options['subject'] = APPLICATION_NAME . ': Login Credentials';
                 $options['header'] = 'Greetings from Sentrifugo';
                 $options['toEmail'] = $emailaddress;
                 $options['toName'] = $this->view->emp_name;
                 $options['message'] = $text;
                 $result = sapp_Global::_sendEmail($options);
                 //end of mailing
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully."));
                 //incrementing requisition id
                 if ($candidate_flag == 'yes') {
                     $cand_data = $candidate_model->getCandidateById($rccandidatename);
                     $candidate_model->SaveorUpdateCandidateData(array('cand_status' => 'Recruited', 'modifieddate' => gmdate("Y-m-d H:i:s")), " id = " . $rccandidatename);
                     $reqData = $requimodel->incrementfilledpositions($cand_data['requisition_id']);
                     if ($reqData['req_no_positions'] == $reqData['filled_positions']) {
                         $req_status = '6';
                         $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"));
                         $where = "id = " . $cand_data['requisition_id'];
                         $result = $requimodel->SaveorUpdateRequisitionData($data, $where);
                         $requimodel->change_to_requisition_closed($cand_data['requisition_id']);
                         $this->send_requi_mail($cand_data['requisition_id'], $requimodel, $usersModel, $loginUserId);
                     }
                 }
             }
             $menuidArr = $menumodel->getMenuObjID('/employee');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id);
             if ($act_inact == 1) {
                 if ($user_data['isactive'] == 1) {
                 } else {
                 }
             }
             $trDb->commit();
             // Send email to employee when his details are edited by other user.
             $options['subject'] = APPLICATION_NAME . ': Employee details updated';
             $options['header'] = 'Employee details updated';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $userfullname;
             $options['message'] = 'Dear ' . $userfullname . ', your employee details are updated.';
             $options['cron'] = 'yes';
             if (!empty($id)) {
                 sapp_Global::_sendEmail($options);
             }
             $this->_redirect('employee/edit/id/' . $user_id);
         } catch (Exception $e) {
             $trDb->rollBack();
             $msgarray['employeeId'] = "Something went wrong, please try again later.";
             return $msgarray;
         }
     } else {
         $messages = $employeeform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         if (isset($businessunit_id) && $businessunit_id != '') {
             $departmentsmodel = new Default_Model_Departments();
             $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id);
             $employeeform->department_id->clearMultiOptions();
             $employeeform->reporting_manager->clearMultiOptions();
             $employeeform->department_id->addMultiOption('', 'Select Department');
             foreach ($departmentlistArr as $departmentlistresult) {
                 $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname']));
             }
             if (isset($department_id) && $department_id != 0 && $department_id != '') {
                 $employeeform->setDefault('department_id', $department_id);
             }
         }
         if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') {
             $positionsmodel = new Default_Model_Positions();
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             $employeeform->position_id->clearMultiOptions();
             $employeeform->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistRes) {
                 $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname']));
             }
             if (isset($position_id) && $position_id != 0 && $position_id != '') {
                 $employeeform->setDefault('position_id', $position_id);
             }
         }
         return $msgarray;
     }
 }
 public function requisitionstatusreportAction()
 {
     try {
         $norec_arr = array();
         $form = new Default_Form_Requisitionsstatusreport();
         $requi_model = new Default_Model_Requisition();
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $job_data = $requi_model->getJobTitleList();
         if (count($job_data) == 0) {
             $norec_arr['jobtitle'] = "Job titles are not configured yet.";
         }
         $form->jobtitle->addMultiOptions(array('' => 'Select Job Title') + $job_data);
         // Requisiton's Raised in limit from  past 10 years to next two years
         $raised_in_years1 = range(date('Y', strtotime('-10 years')), date('Y', strtotime('+2 years')));
         $raised_in_years2 = array_combine($raised_in_years1, $raised_in_years1);
         $form->createdon->addMultiOptions(array('' => 'Select Requisition Year'));
         $form->createdon->addMultiOptions($raised_in_years2);
         $columns_array = array('requisition_code' => 'Requisition Code', 'job_title' => 'Job title', 'req_status' => 'Requisition Status', 'created_by' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'approver1' => 'Approver -1', 'appstatus1' => 'Status', 'req_no_positions' => 'No.of positions', 'selected_members' => 'Filled positions', 'created_on' => 'Raised On', 'onboard_date' => 'Due Date');
         $mandatory_array = array('requisition_code' => 'Requisition Code', 'job_title' => 'Job title', 'req_status' => 'Requisition Status', 'created_by' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'approver1' => 'Approver -1', 'appstatus1' => 'Status', 'req_no_positions' => 'No.of positions', 'selected_members' => 'Filled positions', 'created_on' => 'Raised On', 'onboard_date' => 'Due Date');
         $this->view->columns_array = $columns_array;
         $this->view->form = $form;
         $this->view->messages = $norec_arr;
     } catch (Exception $e) {
         exit($e->getMessage());
     }
 }
 public function getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $statusid, $a1, $a2, $a3)
 {
     $searchQuery = '';
     $searchArray = array();
     $data = array();
     $requi_model = new Default_Model_Requisition();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if ($searchData != '' && $searchData != 'undefined') {
         $searchValues = json_decode($searchData);
         if (count($searchValues) > 0) {
             foreach ($searchValues as $key => $val) {
                 if ($key == 'onboard_date' || $key == 'r.createdon') {
                     $searchQuery .= " date(" . $key . ") = '" . sapp_Global::change_date($val, 'database') . "' AND ";
                 } else {
                     $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                 }
                 $searchArray[$key] = $val;
             }
             $searchQuery = rtrim($searchQuery, " AND");
         }
     }
     $sarray = array('Approved' => 2, 'Closed' => 4, 'On hold' => 5, 'Complete' => 6, 'In process' => 7);
     if ($statusid != '' && is_numeric($statusid)) {
         if ($statusid == 1) {
             $queryflag = 'Approved';
         }
         if ($statusid == 2) {
             $queryflag = 'Approved';
         } else {
             if ($statusid == 4) {
                 $queryflag = 'Closed';
             } else {
                 if ($statusid == 5) {
                     $queryflag = 'On hold';
                 } else {
                     if ($statusid == 6) {
                         $queryflag = 'Complete';
                     } else {
                         if ($statusid == 7) {
                             $queryflag = 'In process';
                         }
                     }
                 }
             }
         }
         $statusidstring = sapp_Global::_encrypt($statusid);
     } else {
         $statusid = 2;
         $queryflag = 'Approved';
         $statusidstring = sapp_Global::_encrypt('2');
     }
     $objName = 'approvedrequisitions';
     $tableFields = array('action' => 'Action', 'requisition_code' => 'Requisition Code', 'jobtitle_name' => 'Job Title', 'createdby_name' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'req_no_positions' => 'No. of Positions', 'filled_positions' => 'Filled Positions', 'r.createdon' => 'Raised On', 'onboard_date' => 'Due Date');
     $search_filters = array('r.createdon' => array('type' => 'datepicker'), 'onboard_date' => array('type' => 'datepicker'));
     if ($dashboardcall == 'Yes') {
         $tableFields['req_status'] = "Status";
         $search_filters['req_status'] = array('type' => 'select', 'filter_data' => array('Approved' => 'Approved', 'Closed' => 'Closed', 'On hold' => 'On hold', 'Complete' => 'Complete', 'In process' => 'In process'));
         $statusid = 2;
         $queryflag = 'Approved';
         $statusidstring = sapp_Global::_encrypt('2');
         if (isset($searchArray['req_status'])) {
             $queryflag = $searchArray['req_status'];
             $statusidstring = sapp_Global::_encrypt($sarray[$queryflag]);
             $statusid = $sarray[$queryflag];
         }
     }
     $tablecontent = $requi_model->getRequisitionData($sort, $by, $pageNo, $perPage, $searchQuery, $loginUserId, $loginuserGroup, 2, $queryflag);
     $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'add' => 'add', 'searchArray' => $searchArray, 'menuName' => 'Approved Requisitions', 'formgrid' => 'true', 'unitId' => $statusidstring, 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => $search_filters);
     if (($statusid == 4 || $statusid == 6) && ($loginuserGroup == HR_GROUP || $loginuserGroup == '')) {
         $dataTmp = $dataTmp + array('defined_actions' => array('view'));
     }
     return $dataTmp;
 }
 /**
  * 
  * @param array $data
  * @param type $requisition_code
  * @param type $hrExecutiveID
  */
 public function hrexecutive_to_requisition_emails($data, $requisition_code, $hrExecutiveID)
 {
     $user_model = new Default_Model_Usermanagement();
     $requi_model = new Default_Model_Requisition();
     $identity_code_model = new Default_Model_Identitycodes();
     //for requisition code
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : "";
     if ($irequistion_code != '') {
         $req_id = $requi_model->getMaxReqCode($irequistion_code . "/");
     } else {
         $req_id = '';
     }
     $data['requisition_code'] = $req_id;
     //end of requisition code
     $Raisedby_person_data = $user_model->getUserDataById($data['createdby']);
     $business_unit = $data['businessunit_id'];
     //HR Group
     $mail_arr[0]['name'] = 'HR';
     $mail_arr[0]['email'] = constant('REQ_HR_0');
     $mail_arr[0]['type'] = 'HR';
     //Management Group
     $mail_arr[1]['name'] = 'Management';
     $mail_arr[1]['email'] = constant('REQ_MGMT_0');
     $mail_arr[1]['type'] = 'Management';
     //Requester
     $mail_arr[2]['name'] = $Raisedby_person_data['userfullname'];
     $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress'];
     $mail_arr[2]['type'] = 'Raise';
     $currEmailCount = 3;
     foreach ($hrExecutiveID as $ipid) {
         $hrexecutive_person_data = $user_model->getUserDataById($ipid);
         $mail_arr[$currEmailCount]['name'] = $hrexecutive_person_data['userfullname'];
         $mail_arr[$currEmailCount]['email'] = $hrexecutive_person_data['emailaddress'];
         $mail_arr[$currEmailCount]['type'] = 'HRExecutive';
         $currEmailCount = $currEmailCount + 1;
     }
     #$appr_str = $hrexecutive_person_data['userfullname'];
     $appr_str = $Raisedby_person_data['userfullname'];
     for ($ii = 0; $ii < count($mail_arr); $ii++) {
         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
         $view = $this->getHelper('ViewRenderer')->view;
         $this->view->emp_name = $mail_arr[$ii]['name'];
         $this->view->base_url = $base_url;
         $this->view->type = $mail_arr[$ii]['type'];
         $this->view->jobtitle = "";
         //Job doesnt require for this emails
         $this->view->requisition_code = $requisition_code;
         $this->view->approver_str = $appr_str;
         $this->view->raised_name = $Raisedby_person_data['userfullname'];
         $text = $view->render('mailtemplates/requisition.phtml');
         $options['subject'] = APPLICATION_NAME . ':' . $requisition_code . '-Recruiter allocated for requisition.';
         $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);
         }
     }
 }
 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;
     }
 }
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $candidatesmodel = new Default_Model_Shortlistedcandidates();
     $cand_model = new Default_Model_Candidatedetails();
     $requimodel = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     if ($form->isValid($this->_request->getPost())) {
         $id = $this->getRequest()->getParam('id');
         $status = $this->getRequest()->getParam('selectionstatus');
         $txtReason = $this->getRequest()->getParam('txtReason');
         $txtJoiningDate = $this->getRequest()->getParam('txtJoiningDate');
         $candidateData = $candidatesmodel->getcandidateData($id);
         $req_id = $candidateData['requisition_id'];
         $selsctionopt = array('0' => 'Select status', '1' => 'Selected', '2' => 'Rejected', '3' => 'Offered', '4' => 'Offer Accepted', '5' => 'Joined', '6' => 'On Hold', '7' => 'Offer Declined', '8' => 'Yet to offer');
         //validation
         if ($status == "4" && $txtJoiningDate == "") {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("failure" => "Joining Date required."));
             $messages = $form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             return $msgarray;
         } else {
             if (($status == "7" || $status == "2" || $status == "6" || $status == "8") && $txtReason == "") {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("failure" => "Comments required."));
                 $messages = $form->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                 }
                 return $msgarray;
             } else {
                 if ($txtReason == '' && $txtJoiningDate == '') {
                     $data = array('cand_status' => $selsctionopt[$status], 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 } else {
                     if ($txtReason == '' && $txtJoiningDate != '') {
                         $data = array('cand_status' => $selsctionopt[$status], 'joiningdate' => sapp_Global::change_date(trim($txtJoiningDate), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     } else {
                         if ($txtReason != '' && $txtJoiningDate == '') {
                             $data = array('cand_status' => $selsctionopt[$status], 'comments' => $txtReason, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         } else {
                             $data = array('cand_status' => $selsctionopt[$status], 'comments' => $txtReason, 'joiningdate' => sapp_Global::change_date(trim($txtJoiningDate), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         }
                     }
                 }
                 $where = "id = " . $id;
                 $result = $candidatesmodel->SaveorUpdateCandidateDetails($data, $where);
                 //if (($status == '1' || $status == 'Selected' ) && ($result != '')) {
                 //increment selected members count
                 $requimodel->incrementselected_members($req_id);
                 //start of mailing
                 $cand_data = $cand_model->getCandidateById($id);
                 $requisition_data = $requimodel->getRequisitionDataById($req_id);
                 $requisition_data_view = $requimodel->getReqDataForView($req_id);
                 $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']);
                 $requester_person_data = $user_model->getUserDataById($requisition_data['createdby']);
                 /* $mail_arr = array(
                    'HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "",
                    'Management' => defined("REQ_MGMT_" . $requisition_data['businessunit_id']) ? constant("REQ_MGMT_" . $requisition_data['businessunit_id']) : "",
                    $report_person_data['userfullname'] => $report_person_data['emailaddress']
                    );
                    $cstat_arr = array(
                    '0' => 'Select status',
                    '1' => 'Selected',
                    '2' => 'Rejected'
                    ); */
                 //HR Group
                 $mail_arr[0]['name'] = 'HR';
                 $mail_arr[0]['email'] = constant('REQ_HR_0');
                 $mail_arr[0]['type'] = 'CandidateFinalChange';
                 //Requester
                 $mail_arr[1]['name'] = $requester_person_data['userfullname'];
                 $mail_arr[1]['email'] = $requester_person_data['emailaddress'];
                 $mail_arr[1]['type'] = 'CandidateFinalChange';
                 //Management Group
                 $mail_arr[2]['name'] = 'Management';
                 $mail_arr[2]['email'] = constant('REQ_MGMT_0');
                 $mail_arr[2]['type'] = 'CandidateFinalChange';
                 //Reporting Manager
                 $mail_arr[3]['name'] = $report_person_data['userfullname'];
                 $mail_arr[3]['email'] = $report_person_data['emailaddress'];
                 $mail_arr[3]['type'] = 'CandidateFinalChange';
                 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 = $mail_arr[$ii]['type'];
                     $this->view->base_url = $base_url;
                     $this->view->requisition_data = $requisition_data_view[0];
                     $this->view->candidate_details = $cand_data;
                     $text = $view->render('mailtemplates/requisition.phtml');
                     $options['subject'] = APPLICATION_NAME . ':Candidate ' . $cand_data['cand_status'];
                     $options['header'] = 'Candidate ' . $cstat_arr[$status];
                     $options['toEmail'] = $mail_arr[$ii]['email'];
                     $options['toName'] = $mail_arr[$ii]['name'];
                     $options['message'] = $text;
                     sapp_Global::_sendEmail($options, "selectedcandidates", REQUISITIONMODULESENDEMAIL);
                 }
                 //end of mailing
                 //}
                 $actionflag = 2;
                 $tableid = $id;
                 $menumodel = new Default_Model_Menu();
                 $objidArr = $menumodel->getMenuObjID('/shortlistedcandidates');
                 $objID = $objidArr[0]['id'];
                 $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Request updated successfully."));
                 $this->_redirect('/shortlistedcandidates');
             }
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 public function save($form)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $candidatesmodel = new Default_Model_Shortlistedcandidates();
     $cand_model = new Default_Model_Candidatedetails();
     $requimodel = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     if ($form->isValid($this->_request->getPost())) {
         $id = $this->getRequest()->getParam('id');
         $status = $this->getRequest()->getParam('selectionstatus');
         $candidateData = $candidatesmodel->getcandidateData($id);
         $req_id = $candidateData['requisition_id'];
         $data = array('cand_status' => trim($status), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = "id = " . $id;
         $result = $candidatesmodel->SaveorUpdateCandidateDetails($data, $where);
         if (($status == '2' || $status == 'Selected') && $result != '') {
             //increment selected members count
             $requimodel->incrementselected_members($req_id);
             //start of mailing
             $cand_data = $cand_model->getCandidateById($id);
             $requisition_data = $requimodel->getRequisitionDataById($req_id);
             $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']);
             $mail_arr = array('HR' => defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : "", 'Management' => defined("REQ_MGMT_" . $requisition_data['businessunit_id']) ? constant("REQ_MGMT_" . $requisition_data['businessunit_id']) : "", $report_person_data['userfullname'] => $report_person_data['emailaddress']);
             $cstat_arr = array('0' => 'Select status', '2' => 'Selected', '3' => 'Rejected');
             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->requisition_code = $requisition_data['requisition_code'];
                 $this->view->candidate_name = $cand_data['candidate_name'];
                 $this->view->status = $cstat_arr[$status];
                 $text = $view->render('mailtemplates/selectedcandidates.phtml');
                 $options['subject'] = APPLICATION_NAME . ': Candidate ' . $cstat_arr[$status];
                 $options['header'] = 'Candidate ' . $cstat_arr[$status];
                 $options['toEmail'] = $email;
                 $options['toName'] = $ename;
                 $options['message'] = $text;
                 $options['cron'] = 'yes';
                 sapp_Global::_sendEmail($options);
             }
             //end of mailing
         }
         $actionflag = 2;
         $tableid = $id;
         $menumodel = new Default_Model_Menu();
         $objidArr = $menumodel->getMenuObjID('/shortlistedcandidates');
         $objID = $objidArr[0]['id'];
         $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid);
         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Request updated successfully."));
         $this->_redirect('/shortlistedcandidates');
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 public function getapproversAction()
 {
     $report_id = $this->_getParam('report_id', null);
     $dept_id = $this->_getParam('dept_id', null);
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $approver1_val = $this->_getParam('approver1_val', 0);
     $approver2_val = $this->_getParam('approver2_val', 0);
     $requi_model = new Default_Model_Requisition();
     $options = $requi_model->getapprovers($report_id, $dept_id);
     if ($approver1_val == '0') {
         $opt_str = sapp_Global::selectOptionBuilder('', 'Select Approver -1');
     } else {
         if ($approver2_val == '0') {
             $opt_str = sapp_Global::selectOptionBuilder('', 'Select Approver -2');
         } else {
             $opt_str = sapp_Global::selectOptionBuilder('', 'Select Approver -3');
         }
     }
     if (count($options) > 0) {
         foreach ($options as $opt) {
             if ($approver1_val != $opt['id'] && $approver2_val != $opt['id'] && $loginUserId != $opt['id']) {
                 $opt_str .= sapp_Global::selectOptionBuilder($opt['id'], ucwords($opt['name']), $opt['profileimg']);
             }
         }
     }
     $this->_helper->_json(array('options' => $opt_str));
 }
 /**
  * 
  * @param type $sort
  * @param type $by
  * @param type $perPage
  * @param type $pageNo
  * @param type $searchData
  * @param type $call
  * @param type $dashboardcall
  * @param type $statusid
  * @param type $a1
  * @param type $a2
  * @param type $a3
  * @return type
  */
 public function getMyGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $statusid, $a1, $a2, $a3)
 {
     $searchQuery = '';
     $searchArray = array();
     $data = array();
     $requi_model = new Default_Model_Requisition();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $sarray = array('Approved' => 2, 'Closed' => 3, 'Closed' => 4, 'On hold' => 5, 'In process' => 7);
     $objName = 'myactiverequisitions';
     $tableFields = array('action' => 'Action', 'requisition_code' => 'Requisition Code', 'jobtitle_name' => 'Job Title', 'createdby_name' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'r.createdon' => 'Raised On', 'onboard_date' => 'Due Date', 'hrexecutive_name' => 'Recruit panel');
     $tablecontent = $requi_model->getMyRequisitionData($sort, $by, $pageNo, $perPage, $searchQuery, $loginUserId, $loginuserGroup, 2, $queryflag);
     $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'add' => 'add', 'searchArray' => $searchArray, 'menuName' => 'Requisitions Assigned to Me', 'formgrid' => 'true', 'unitId' => $statusidstring, 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => $search_filters);
     return $dataTmp;
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $messages['message'] = '';
     $id = $this->getRequest()->getParam('id', null);
     $projectsModel = new Default_Model_Createprojects();
     $requi_model = new Default_Model_Requisition();
     $usersModel = new Default_Model_Users();
     $where = "";
     $actionflag = 1;
     $form = new Default_Form_createprojects();
     $form->setAttrib('action', DOMAIN . 'createprojects/edit/id/' . $id);
     $this->view->business_units_list = $requi_model->getBusinessUnits();
     try {
         if ($id > 0 && is_numeric($id)) {
             //update code
             $where = "";
             $actionflag = 2;
             $id = abs($id);
             $projectdata = $projectsModel->getProjectDataByID($id);
             $form->submit->setLabel('Update Project');
             $this->view->loginuserGroup = $loginuserGroup;
             $this->view->form = $form;
             $this->view->isEdit = "1";
             $this->view->data = $projectdata;
             $this->view->BUUsers = $usersModel->getAllActiveUsersByBU($projectdata['businessunit']);
             $this->view->TrackingCodes = $projectsModel->getTrackingCodesByCategory($projectdata['category']);
             if ($this->getRequest()->getPost()) {
                 $trDb = Zend_Db_Table::getDefaultAdapter();
                 // starting transaction
                 $trDb->beginTransaction();
                 try {
                     $bFlag = true;
                     //$tprojectCategory = $this->_getParam('projectCategory', null);
                     $tprojectCategory = PROJECTCATEGORYID;
                     $tProjectName = $this->_getParam('ProjectName', null);
                     $tProjectDescription = $this->_getParam('ProjectDescription', null);
                     $tprojectStatus = $this->_getParam('projectStatus', null);
                     $tprojectBU = $this->_getParam('projectBU', null);
                     $tprojectPrimaryLead = $this->_getParam('projectPrimaryLead', null);
                     $tprojectSecondaryLead = $this->_getParam('projectSecondaryLead', null);
                     $tprojectEffort = $this->_getParam('ProjectEffort', null);
                     $tprojectStartDate = $this->_getParam('projectStartDate', null);
                     $tprojectEndDate = $this->_getParam('projectEndDate', null);
                     $tprojectStartDate1 = sapp_Global::change_date(trim($tprojectStartDate), 'database');
                     $tprojectEndDate1 = sapp_Global::change_date(trim($tprojectEndDate), 'database');
                     $tprojectStartDate2 = sapp_Global::change_date(trim($projectdata['startdate']), 'database');
                     $tprojectEndDate2 = sapp_Global::change_date(trim($projectdata['enddate']), 'database');
                     //get tracking codes for edits
                     $ttrackingcodestartdate = $this->_getParam('trackingcodestartdate', null);
                     $ttrackingcodeenddate = $this->_getParam('trackingcodeenddate', null);
                     $ttrackingcodeeffort = $this->_getParam('trackingcodeeffort', null);
                     if ($tprojectStartDate2 != $tprojectStartDate1 && ($ttrackingcodestartdate <= 0 || $ttrackingcodestartdate == '')) {
                         //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned Start Date."));
                         $validationMsg['message'] = 'Tracking code due to change in Project Planned Start Date.';
                         $validationMsg['msgtype'] = 'error';
                         $this->view->validationMsg = $validationMsg;
                         $bFlag = false;
                     } else {
                         if ($tprojectEndDate2 != $tprojectEndDate1 && ($ttrackingcodeenddate <= 0 || $ttrackingcodeenddate == '')) {
                             //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned End Date."));
                             $validationMsg['message'] = 'Tracking code due to change in Project Planned End Date.';
                             $validationMsg['msgtype'] = 'error';
                             $this->view->validationMsg = $validationMsg;
                             $bFlag = false;
                         } else {
                             if ($projectdata['effort'] != $tprojectEffort && ($ttrackingcodeeffort <= 0 || $ttrackingcodeeffort == '')) {
                                 //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned Effort."));
                                 $validationMsg['message'] = 'Tracking code due to change in Project Planned Effort.';
                                 $validationMsg['msgtype'] = 'error';
                                 $this->view->validationMsg = $validationMsg;
                                 $bFlag = false;
                             } else {
                                 if (strlen(trim($tProjectName)) <= 0) {
                                     $validationMsg['message'] = 'Project name cannot be empty.';
                                     $validationMsg['msgtype'] = 'error';
                                     $this->view->validationMsg = $validationMsg;
                                     $bFlag = false;
                                 } else {
                                     if (strlen(trim($tProjectDescription)) <= 0) {
                                         $validationMsg['message'] = 'Project description cannot be empty.';
                                         $validationMsg['msgtype'] = 'error';
                                         $this->view->validationMsg = $validationMsg;
                                         $bFlag = false;
                                     } else {
                                         if (strlen(trim($tprojectStartDate)) <= 0) {
                                             $validationMsg['message'] = 'Project planned start date cannot be empty.';
                                             $validationMsg['msgtype'] = 'error';
                                             $this->view->validationMsg = $validationMsg;
                                             $bFlag = false;
                                         } else {
                                             if (strlen(trim($tprojectEndDate)) <= 0) {
                                                 $validationMsg['message'] = 'Project planned end date cannot be empty.';
                                                 $validationMsg['msgtype'] = 'error';
                                                 $this->view->validationMsg = $validationMsg;
                                                 $bFlag = false;
                                             } else {
                                                 if ($tprojectBU <= 0) {
                                                     $validationMsg['message'] = 'Please select project business unit.';
                                                     $validationMsg['msgtype'] = 'error';
                                                     $this->view->validationMsg = $validationMsg;
                                                     $bFlag = false;
                                                 } else {
                                                     if ($tprojectPrimaryLead <= 0) {
                                                         $validationMsg['message'] = 'Project primary lead cannot be empty.';
                                                         $validationMsg['msgtype'] = 'error';
                                                         $this->view->validationMsg = $validationMsg;
                                                         $bFlag = false;
                                                     } else {
                                                         if ($tprojectSecondaryLead <= 0) {
                                                             $validationMsg['message'] = 'Project secondary lead cannot be empty.';
                                                             $validationMsg['msgtype'] = 'error';
                                                             $this->view->validationMsg = $validationMsg;
                                                             $bFlag = false;
                                                         } else {
                                                             if (strlen(trim($tprojectEffort)) <= 0) {
                                                                 $validationMsg['message'] = 'Project planned effort cannot be empty.';
                                                                 $validationMsg['msgtype'] = 'error';
                                                                 $this->view->validationMsg = $validationMsg;
                                                                 $bFlag = false;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($bFlag) {
                         $mpolicydata = array('category' => trim($tprojectCategory), 'projectname' => trim($tProjectName), 'description' => trim($tProjectDescription), 'status' => trim($tprojectStatus), 'effort' => trim($tprojectEffort), 'startdate' => $tprojectStartDate1, 'enddate' => $tprojectEndDate1, 'businessunit' => trim($tprojectBU), 'primarylead' => trim($tprojectPrimaryLead), 'secondarylead' => trim($tprojectSecondaryLead), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         $where = array('id = ?' => $id);
                         $Id = $projectsModel->SaveorUpdatePolicyData($mpolicydata, $where);
                         if ($projectdata['startdate'] != $tprojectStartDate1 || $projectdata['enddate'] != $tprojectEndDate1 || $projectdata['effort'] != $tprojectEffort) {
                             $projectslogModel = new Default_Model_Createprojectslog();
                             $mprojectlogdata = array('projectid' => trim($projectdata['id']), 'startdatetrackingcodeid' => trim($ttrackingcodestartdate), 'enddatetrackingcodeid' => trim($ttrackingcodeenddate), 'efforttrackingcodeid' => trim($ttrackingcodeeffort), 'effortold' => trim($projectdata['effort']), 'startdateold' => $tprojectStartDate2, 'enddateold' => $projectdata['enddate'], 'effortnew' => $tprojectEndDate2, 'startdatenew' => $tprojectStartDate1, 'enddatenew' => $tprojectEndDate1, 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"));
                             $where = "";
                             $Id = $projectslogModel->SaveorUpdateData($mprojectlogdata, $where);
                         }
                         //if ($Id == 'update') {
                         $menuID = -999;
                         sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Project details successfully updated."));
                         /* } else {
                            $this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Error while updating project details."));
                            } */
                         $trDb->commit();
                         $this->_redirect('/createprojects');
                     }
                 } catch (Exception $e) {
                     $trDb->rollBack();
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
                     $this->_redirect('/createprojects');
                 }
             }
         } else {
             //Insert code
             $actionflag = 1;
             if ($this->getRequest()->getPost()) {
                 #$result = $this->save($form, $policydata);
                 $trDb = Zend_Db_Table::getDefaultAdapter();
                 // starting transaction
                 $trDb->beginTransaction();
                 try {
                     $bFlag = true;
                     $tprojectCategory = PROJECTCATEGORYID;
                     $tProjectName = $this->_getParam('ProjectName', null);
                     $tProjectDescription = $this->_getParam('ProjectDescription', null);
                     $tprojectStartDate = $this->_getParam('projectStartDate', null);
                     $tprojectEndDate = $this->_getParam('projectEndDate', null);
                     $tprojectStatus = $this->_getParam('projectStatus', null);
                     $tprojectBU = $this->_getParam('projectBU', null);
                     $tprojectPrimaryLead = $this->_getParam('projectPrimaryLead', null);
                     $tprojectSecondaryLead = $this->_getParam('projectSecondaryLead', null);
                     $tprojectEffort = $this->_getParam('ProjectEffort', null);
                     $tprojectStartDate1 = sapp_Global::change_date(trim($tprojectStartDate), 'database');
                     $tprojectEndDate1 = sapp_Global::change_date(trim($tprojectEndDate), 'database');
                     if (strlen(trim($tProjectName)) <= 0) {
                         $validationMsg['message'] = 'Project name cannot be empty.';
                         $validationMsg['msgtype'] = 'error';
                         $this->view->validationMsg = $validationMsg;
                         $bFlag = false;
                     } else {
                         if (strlen(trim($tProjectDescription)) <= 0) {
                             $validationMsg['message'] = 'Project description cannot be empty.';
                             $validationMsg['msgtype'] = 'error';
                             $this->view->validationMsg = $validationMsg;
                             $bFlag = false;
                         } else {
                             if (strlen(trim($tprojectStartDate)) <= 0) {
                                 $validationMsg['message'] = 'Project planned start date cannot be empty.';
                                 $validationMsg['msgtype'] = 'error';
                                 $this->view->validationMsg = $validationMsg;
                                 $bFlag = false;
                             } else {
                                 if (strlen(trim($tprojectEndDate)) <= 0) {
                                     $validationMsg['message'] = 'Project planned end date cannot be empty.';
                                     $validationMsg['msgtype'] = 'error';
                                     $this->view->validationMsg = $validationMsg;
                                     $bFlag = false;
                                 } else {
                                     if ($tprojectBU <= 0) {
                                         $validationMsg['message'] = 'Please select project business unit.';
                                         $validationMsg['msgtype'] = 'error';
                                         $this->view->validationMsg = $validationMsg;
                                         $bFlag = false;
                                     } else {
                                         if ($tprojectPrimaryLead <= 0) {
                                             $validationMsg['message'] = 'Project primary lead cannot be empty.';
                                             $validationMsg['msgtype'] = 'error';
                                             $this->view->validationMsg = $validationMsg;
                                             $bFlag = false;
                                         } else {
                                             if ($tprojectSecondaryLead <= 0) {
                                                 $validationMsg['message'] = 'Project secondary lead cannot be empty.';
                                                 $validationMsg['msgtype'] = 'error';
                                                 $this->view->validationMsg = $validationMsg;
                                                 $bFlag = false;
                                             } else {
                                                 if (strlen(trim($tprojectEffort)) <= 0) {
                                                     $validationMsg['message'] = 'Project planned effort cannot be empty.';
                                                     $validationMsg['msgtype'] = 'error';
                                                     $this->view->validationMsg = $validationMsg;
                                                     $bFlag = false;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($bFlag) {
                         $mpolicydata = array('category' => trim($tprojectCategory), 'projectname' => trim($tProjectName), 'description' => trim($tProjectDescription), 'status' => trim($tprojectStatus), 'effort' => trim($tprojectEffort), 'startdate' => sapp_Global::change_date(trim($tprojectStartDate), 'database'), 'enddate' => sapp_Global::change_date(trim($tprojectEndDate), 'database'), 'businessunit' => trim($tprojectBU), 'primarylead' => trim($tprojectPrimaryLead), 'secondarylead' => trim($tprojectSecondaryLead), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         $Id = $projectsModel->SaveorUpdatePolicyData($mpolicydata, $where);
                         if ($Id > 0 && is_numeric($Id)) {
                             $menuID = -999;
                             sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Project details successfully added."));
                         } else {
                             $this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Error while adding project details."));
                         }
                         $trDb->commit();
                         $this->_redirect('/createprojects');
                     }
                 } catch (Exception $e) {
                     $trDb->rollBack();
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
                     $this->_redirect('/createprojects');
                 }
             }
             $mdata = array('category' => PROJECTCATEGORYID, 'projectname' => trim($tProjectName), 'description' => trim($tProjectDescription), 'status' => trim($tprojectStatus), 'effort' => trim($tprojectEffort), 'startdate' => $tprojectStartDate1, 'enddate' => $tprojectEndDate1, 'businessunit' => trim($tprojectBU), 'primarylead' => trim($tprojectPrimaryLead), 'secondarylead' => trim($tprojectSecondaryLead));
             $buUsers = array();
             if ($tprojectBU > 0) {
                 $buUsers = $usersModel->getAllActiveUsersByBU($tprojectBU);
             }
             $this->view->BUUsers = $buUsers;
             $form->submit->setLabel('Add Project');
             $this->view->loginuserGroup = $loginuserGroup;
             $this->view->form = $form;
             $this->view->data = $mdata;
             $this->view->isEdit = "0";
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
 public function addpopupAction()
 {
     $screenFlag = "";
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     if ($this->getRequest()->getParam('screenflag')) {
         $screenFlag = $this->getRequest()->getParam('screenflag');
     }
     $boxid = $this->_getParam('boxid', null);
     $fromcontroller = $this->_getParam('fromcontroller', null);
     $msgarray = array();
     $controllername = 'employmentstatus';
     $employmentstatusform = new Default_Form_employmentstatus();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $employmentstatusform->setAction(BASE_URL . 'employmentstatus/addpopup');
     $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
     $newarr = array();
     $empstatusstr = '';
     if (!empty($activeEmploymentStatusArr)) {
         for ($i = 0; $i < sizeof($activeEmploymentStatusArr); $i++) {
             $newarr1[] = $activeEmploymentStatusArr[$i]['workcodename'];
         }
         if ($screenFlag == 'add') {
             array_push($newarr1, 8, 9, 10);
         }
         $empstatusstr = implode(",", $newarr1);
     }
     if ($empstatusstr != '') {
         $statusArr = $employmentstatusmodel->getStatuslist($empstatusstr);
     } else {
         $statusArr = $employmentstatusmodel->getCompleteStatuslist();
     }
     if (!empty($statusArr)) {
         $employmentstatusform->workcodename->addMultiOption('', 'Select Work Code');
         for ($i = 0; $i < sizeof($statusArr); $i++) {
             if ($fromcontroller == 'requisition') {
                 if (!in_array($statusArr[$i]['id'], array(5, 7, 8, 9, 10))) {
                     $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
                 }
             } else {
                 $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
             }
         }
     }
     $this->view->statusArr = $statusArr;
     $this->view->ermsg = '';
     if ($this->getRequest()->getPost()) {
         if ($employmentstatusform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $workcode = $this->_request->getParam('workcode');
             $workcodename = $this->_request->getParam('workcodename');
             $default_leaves = $this->_request->getParam('default_leaves');
             $description = $this->_request->getParam('description');
             $screenFlag = $this->getRequest()->getParam('screenflag');
             $date = new Zend_Date();
             $actionflag = '';
             $tableid = '';
             $data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
             }
             $Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($data, $where);
             $tableid = $Id;
             $menuID = EMPLOYMENTSTATUS;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
             if (isset($_POST['fromcontroller']) && $_POST['fromcontroller'] != '') {
                 $fromcontroller = $_POST['fromcontroller'];
             }
             if (isset($_POST['boxid']) && $_POST['boxid'] != '') {
                 $boxid = $_POST['boxid'];
             }
         } else {
             $messages = $employmentstatusform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $opt = '';
     if ($fromcontroller == '') {
         if ($screenFlag == 'edit') {
             $empstatusData = $employmentstatusmodel->getempstatuslist();
         }
         if ($screenFlag == 'add') {
             $empstatusData = $employmentstatusmodel->getempstatusActivelist();
         }
         if (!empty($empstatusData)) {
             foreach ($empstatusData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['workcodename'], $record['statusname']);
             }
         }
     } else {
         if ($fromcontroller == 'requisition') {
             $requi_model = new Default_Model_Requisition();
             $empstatusData = $requi_model->getStatusOptionsForRequi();
             foreach ($empstatusData as $stat_id => $stat_name) {
                 $opt .= sapp_Global::selectOptionBuilder($stat_id, $stat_name);
             }
         }
     }
     $this->view->empstatusData = $opt;
     $this->view->screenFlag = $screenFlag;
     $this->view->controllername = $controllername;
     $this->view->form = $employmentstatusform;
     $this->view->ermsg = '';
     $this->view->boxid = $boxid;
     $this->view->fromcontroller = $fromcontroller;
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $messages['message'] = '';
     $id = $this->getRequest()->getParam('id', null);
     $taskAllocationModel = new Default_Model_Tasksallocation();
     $activityModel = new Default_Model_Createactivities();
     $requi_model = new Default_Model_Requisition();
     $usersModel = new Default_Model_Users();
     $currentUserSummary = $usersModel->getEmployeeSummaryByID($loginUserId);
     $where = "";
     $actionflag = 1;
     $form = new Default_Form_createprojects();
     $form->setAttrib('action', DOMAIN . 'tasksallocation/edit/id/' . $id);
     //$this->view->activeprojects = $taskAllocationModel->getActiveProjects();
     $this->view->activeprojects = $taskAllocationModel->getActiveProjectsForUser($currentUserSummary['businessunit_id'], $loginUserId, $loginuserGroup);
     $this->view->projectCategories = $taskAllocationModel->getProjectCategories();
     $this->view->business_units_list = $requi_model->getBusinessUnits();
     $this->view->allusers = array();
     //$this->view->allusers = $usersModel->getAllActiveUsers();
     $form->submit->setLabel('Allocate Task Activities');
     $this->view->loginuserGroup = $loginuserGroup;
     $this->view->form = $form;
     if ($this->getRequest()->getPost()) {
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         $tprojectSelected = $this->_getParam('projectSelected', null);
         $ttaskSelected = $this->_getParam('taskSelected', null);
         $ActivitiesForTasks = $taskAllocationModel->getTaskActivityDetails($ttaskSelected);
         $ttaskallocationdelete = $this->_getParam('taskallocationdelete', null);
         $ttaskallocationactivitys = $this->_getParam('taskallocationactivity', null);
         $ttaskallocationresource = $this->_getParam('taskallocationresource', null);
         $ttaskallocationstartdate = $this->_getParam('taskallocationstartdate', null);
         $ttaskallocationenddate = $this->_getParam('taskallocationenddate', null);
         $ttaskallocationeffort = $this->_getParam('taskallocationeffort', null);
         $ttaskallocationrowid = $this->_getParam('taskallocationrowid', null);
         $resCurPos = 0;
         foreach ($ttaskallocationactivitys as $ttaskallocationactivity) {
             $varCurrAction = "0";
             $currRowID = $ttaskallocationrowid[$resCurPos];
             $allocID = $this->getIDbyActivity($ActivitiesForTasks, $ttaskallocationactivity);
             if (is_numeric($currRowID)) {
                 if ($currRowID > 0) {
                     //for Update
                     $mpolicydata = array('taskactivityid' => trim($allocID), 'resourceid' => trim($ttaskallocationresource[$resCurPos]), 'effort' => trim($ttaskallocationeffort[$resCurPos]), 'startdate' => sapp_Global::change_date(trim($ttaskallocationstartdate[$resCurPos]), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskallocationenddate[$resCurPos]), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     $where = array('id=?' => $currRowID);
                     $varCurrAction = $taskAllocationModel->SaveorUpdateData($mpolicydata, $where);
                 }
             }
             if ($varCurrAction == "0") {
                 //for Insert
                 $mpolicydata = array('taskactivityid' => trim($allocID), 'resourceid' => trim($ttaskallocationresource[$resCurPos]), 'status' => trim('5'), 'effort' => trim($ttaskallocationeffort[$resCurPos]), 'startdate' => sapp_Global::change_date(trim($ttaskallocationstartdate[$resCurPos]), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskallocationenddate[$resCurPos]), 'database'), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 $where = "";
                 $Id = $taskAllocationModel->SaveorUpdateData($mpolicydata, $where);
             }
             $resCurPos = $resCurPos + 1;
         }
         //for Soft Delete
         foreach ($ttaskallocationdelete as $ttaskallocationdelete1) {
             $isRecordForDelete = $ttaskallocationdelete[$resCurPos];
             if (is_numeric($ttaskallocationdelete1)) {
                 if ($ttaskallocationdelete1 > 0) {
                     $mpolicydata = array('isactive' => '0', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     $where = array('id=?' => $ttaskallocationdelete1);
                     $varCurrAction = $taskAllocationModel->SaveorUpdateData($mpolicydata, $where);
                 }
             }
         }
         $menuID = -999;
         sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Task successfully allocated."));
         $trDb->commit();
         $this->_redirect('/tasksallocation');
     }
 }
 /**
  * 
  */
 public function requisitionhistoryreportdetailAction()
 {
     $id = $this->getRequest()->getParam('id');
     $requi_model = new Default_Model_Requisition();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $login_group_id = $auth->getStorage()->read()->group_id;
         $login_role_id = $auth->getStorage()->read()->emprole;
     }
     $ju_name = array();
     try {
         if (is_numeric($id) && $id > 0) {
             $id = abs($id);
             $data = $requi_model->getReqDataForView($id);
             $app1_name = $app2_name = $app3_name = '';
             if (count($data) > 0) {
                 $data = $data[0];
                 $auth = Zend_Auth::getInstance();
                 if ($auth->hasIdentity()) {
                     $loginUserId = $auth->getStorage()->read()->id;
                     $loginuserRole = $auth->getStorage()->read()->emprole;
                     $loginuserGroup = $auth->getStorage()->read()->group_id;
                 }
                 $data['jobtitlename'] = '';
                 $data['businessunit_name'] = $data['businessunit_name'];
                 $data['dept_name'] = $data['department_name'];
                 $data['titlename'] = $data['jobtitle_name'];
                 $data['posname'] = $data['position_name'];
                 $data['empttype'] = $data['emp_type_name'];
                 $data['mngrname'] = $data['reporting_manager_name'];
                 $data['raisedby'] = $data['createdby_name'];
                 $data['app1_name'] = $data['approver1_name'];
                 foreach ($data as $key => $val) {
                     if ($key == 'jdfilename') {
                         if (isset($val)) {
                             $data[$key] = "<a href='" . DOMAIN . 'requisition/download/id/' . $id . "'>View Job Description file.</a>";
                         } else {
                             $data[$key] = "--No Job Description file exists...";
                         }
                     } else {
                         $data[$key] = htmlentities($val, ENT_QUOTES, "UTF-8");
                     }
                 }
                 $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                 $previ_data = sapp_Global::_checkprivileges(REQUISITION, $login_group_id, $login_role_id, 'edit');
                 $this->view->previ_data = $previ_data;
                 $this->view->data = $data;
                 $this->view->id = $id;
                 $this->view->controllername = "requisition";
                 $this->view->ermsg = '';
                 //grid data
                 $this->view->dataArrayapprovalgrid = $this->requisitionhistoryreportdetail_ApprovalsGrid($id);
                 $this->view->dataArrayhrexecutivegrid = $this->requisitionhistoryreportdetail_HRExecutiveGrid($id);
                 $this->view->dataArraycvgrid = $this->requisitionhistoryreportdetail_CVManagementGrid($id);
                 $this->view->dataArrayinterviewgrid = $this->requisitionhistoryreportdetail_InterviewGrid($id);
                 $this->view->dataArrayrequisitionemailsgrid = $this->requisitionhistoryreportdetail_RequisitionEmailsGrid($id);
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $requi_model = new Default_Model_Requisition();
     $data = array();
     try {
         if ($id > 0 && is_numeric($id)) {
             $data = $requi_model->getReqDataForView($id);
             if (count($data) > 0 && $data[0]['req_status'] == 'Rejected') {
                 $data = $data[0];
                 $auth = Zend_Auth::getInstance();
                 if ($auth->hasIdentity()) {
                     $loginUserId = $auth->getStorage()->read()->id;
                     $loginuserRole = $auth->getStorage()->read()->emprole;
                     $loginuserGroup = $auth->getStorage()->read()->group_id;
                 }
                 $data['jobtitlename'] = '';
                 $data['businessunit_name'] = $data['businessunit_name'];
                 $data['dept_name'] = $data['department_name'];
                 $data['titlename'] = $data['jobtitle_name'];
                 $data['posname'] = $data['position_name'];
                 $data['empttype'] = $data['emp_type_name'];
                 $data['mngrname'] = $data['reporting_manager_name'];
                 $data['raisedby'] = $data['createdby_name'];
                 $data['app1_name'] = $data['approver1_name'];
                 if ($data['approver2'] != '') {
                     $data['app2_name'] = $data['approver2_name'];
                 } else {
                     $data['app2_name'] = 'No Approver';
                 }
                 if ($data['approver3'] != '') {
                     $data['app3_name'] = $data['approver3_name'];
                 } else {
                     $data['app3_name'] = 'No Approver';
                 }
                 foreach ($data as $key => $val) {
                     $data[$key] = htmlentities($val, ENT_QUOTES, "UTF-8");
                 }
                 $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                 //start of candidate details
                 $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                 $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'c.createddate';
                 $perPage = $this->_getParam('per_page', 10);
                 $pageNo = $this->_getParam('page', 1);
                 $searchQuery = '';
                 $searchArray = array();
                 $tablecontent = '';
                 /** search from grid - START **/
                 $searchData = $this->_getParam('searchData');
                 if ($searchData != '' && $searchData != 'undefined') {
                     $searchValues = json_decode($searchData);
                     if (count($searchValues) > 0) {
                         foreach ($searchValues as $key => $val) {
                             $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                             $searchArray[$key] = $val;
                         }
                         $searchQuery = rtrim($searchQuery, " AND");
                     }
                 }
                 /** search from grid - END **/
                 $objName = 'apprreqcandidates';
                 $tableFields = array('action' => 'Action', 'candidate_name' => 'Candidate Name', 'cand_status' => 'Candidate Status');
                 $candidate_model = new Default_Model_Candidatedetails();
                 $tablecontent = $candidate_model->getCandidatesData_requisition($sort, $by, $pageNo, $perPage, $searchQuery, $id);
                 $cand_status_opt = array('' => 'All', 'Shortlisted' => 'Shortlisted', 'Selected' => 'Selected', 'Rejected' => 'Rejected', 'On hold' => 'On hold', 'Disqualified' => 'Disqualified', 'Scheduled' => 'Scheduled', 'Not Scheduled' => 'Not Scheduled', 'Recruited' => 'Recruited', 'Requisition Closed/Completed' => 'Requisition Closed/Completed');
                 $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'formgrid' => 'true', 'searchArray' => $searchArray, 'menuName' => 'Candidate details', 'call' => '', 'search_filters' => array('cand_status' => array('type' => 'select', 'filter_data' => $cand_status_opt)));
                 array_push($data, $dataTmp);
                 $this->view->dataArray = $dataTmp;
                 //end of candidate details
                 $this->view->data = $data;
                 $this->view->loginuserGroup = $loginuserGroup;
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 public function sendInvite($invitepanel, $loginUserId, $meetingdate, $meetingstarttime, $meetingendtime, $Id, $meetingnotes, $meetingtitle)
 {
     $cal_unique_id = $this->getCalendarUniqueID();
     $user_model = new Default_Model_Usermanagement();
     $requi_model = new Default_Model_Requisition();
     $meetingroomModel = new Default_Model_Meetingroom();
     $loginuser_person_data = $user_model->getUserDataById($loginUserId);
     $invitepanel = $invitepanel . "," . $loginUserId;
     $invitepanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($invitepanel);
     foreach ($invitepanelnamesemailaddresss as $invitepanelnamesemailaddress) {
         $description = trim($meetingnotes);
         $from_name = trim($loginuser_person_data['userfullname']);
         $from_address = trim($loginuser_person_data['emailaddress']);
         $to_name = trim($invitepanelnamesemailaddress['userfullname']);
         $to_address = trim($invitepanelnamesemailaddress['emailaddress']);
         $startTime = sapp_Global::_getMeetingScheduleTime(sapp_Global::change_date($meetingdate), sapp_Global::change_time(trim($meetingstarttime)));
         $endTime = sapp_Global::_getMeetingScheduleTime(sapp_Global::change_date($meetingdate), sapp_Global::change_time(trim($meetingendtime)));
         $subject = trim($meetingtitle);
         $location = "INDIA";
         $calRequest = 'REQUEST';
         sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id);
     }
     $where = "id = " . $Id;
     $irdata = array('calendarinviteid' => $cal_unique_id);
     $ir_result1 = $meetingroomModel->SaveorUpdateData($irdata, $where);
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $messages['message'] = '';
     $id = $this->getRequest()->getParam('id', null);
     $taskModel = new Default_Model_Createtasks();
     $currprojectsModel = new Default_Model_Createprojects();
     $activityModel = new Default_Model_Createactivities();
     $requi_model = new Default_Model_Requisition();
     $usersModel = new Default_Model_Users();
     $currentUserSummary = $usersModel->getEmployeeSummaryByID($loginUserId);
     $taskAllocationModel = new Default_Model_Tasksallocation();
     $where = "";
     $actionflag = 1;
     $form = new Default_Form_createprojects();
     $form->setAttrib('action', DOMAIN . 'createtasks/edit/id/' . $id);
     //$this->view->activeprojects = $taskModel->getActiveProjects();
     $this->view->activeprojects = $taskAllocationModel->getActiveProjectsForTasksForUser($currentUserSummary['businessunit_id'], $loginUserId, $loginuserGroup);
     $this->view->projectCategories = $taskModel->getProjectCategories();
     $this->view->business_units_list = $requi_model->getBusinessUnits();
     $this->view->allusers = array();
     //$this->view->allusers = $usersModel->getAllActiveUsers();
     try {
         if ($id > 0 && is_numeric($id)) {
             //update code
             $where = "";
             $actionflag = 2;
             $id = abs($id);
             $taskdata = $taskModel->getTaskDataByID($id);
             $Currprojectdata = $currprojectsModel->getProjectDataByID($taskdata['projectid']);
             $form->submit->setLabel('Update Task');
             $this->view->taskpagerefresh = '0';
             $this->view->TaskID = $id;
             $this->view->loginuserGroup = $loginuserGroup;
             $this->view->form = $form;
             $this->view->isEdit = "1";
             $this->view->data = $taskdata;
             $this->view->BUUsers = $usersModel->getAllActiveUsersByBU($Currprojectdata['businessunit']);
             $this->view->TrackingCodes = $currprojectsModel->getTrackingCodesByCategory($Currprojectdata['category']);
             if ($this->getRequest()->getPost()) {
                 $trDb = Zend_Db_Table::getDefaultAdapter();
                 // starting transaction
                 $trDb->beginTransaction();
                 try {
                     $bFlag = true;
                     //Task Details
                     $tprojectSelected = $this->_getParam('projectSelected', null);
                     $ttaskName = $this->_getParam('taskName', null);
                     $ttaskDescription = $this->_getParam('taskDescription', null);
                     $ttaskStartDate = $this->_getParam('taskStartDate', null);
                     $ttaskEndDate = $this->_getParam('taskEndDate', null);
                     $ttaskStatus = $this->_getParam('taskStatus', null);
                     $ttaskPrimaryLead = $this->_getParam('taskPrimaryLead', null);
                     $ttaskSecondaryLead = $this->_getParam('taskSecondaryLead', null);
                     $ttaskEffort = $this->_getParam('taskEffort', null);
                     //Task Activity Details
                     $tprjactivitytaskid = $this->_getParam('prjactivitytaskid', null);
                     $tprjactivityid = $this->_getParam('prjactivityid', null);
                     $tprjactivitysdate = $this->_getParam('prjactivitysdate', null);
                     $tprjactivityedate = $this->_getParam('prjactivityedate', null);
                     $tprjactivityeffort = $this->_getParam('prjactivityeffort', null);
                     $tprojectStartDate1 = sapp_Global::change_date(trim($ttaskStartDate), 'database');
                     $tprojectEndDate1 = sapp_Global::change_date(trim($ttaskEndDate), 'database');
                     $tprojectStartDate2 = sapp_Global::change_date(trim($taskdata['startdate']), 'database');
                     $tprojectEndDate2 = sapp_Global::change_date(trim($taskdata['enddate']), 'database');
                     //get tracking codes for edits
                     $ttrackingcodestartdate = $this->_getParam('trackingcodestartdate', null);
                     $ttrackingcodeenddate = $this->_getParam('trackingcodeenddate', null);
                     $ttrackingcodeeffort = $this->_getParam('trackingcodeenddate', null);
                     $mtaskactivitytrackingdata = array('startdate' => implode(',', $ttrackingcodestartdate), 'enddate' => implode(',', $ttrackingcodeenddate), 'effort' => implode(',', $ttrackingcodeeffort));
                     $this->view->taskactivitytrackingdata = $mtaskactivitytrackingdata;
                     $this->view->taskpagerefresh = '1';
                     if ($tprojectStartDate2 != $tprojectStartDate1 && ($ttrackingcodestartdate <= 0 || $ttrackingcodestartdate == '')) {
                         //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned Start Date."));
                         $validationMsg['message'] = 'Tracking code due to change in Task Planned Start Date.';
                         $validationMsg['msgtype'] = 'error';
                         $this->view->validationMsg = $validationMsg;
                         $bFlag = false;
                     } else {
                         if ($tprojectEndDate2 != $tprojectEndDate1 && ($ttrackingcodeenddate <= 0 || $ttrackingcodeenddate == '')) {
                             //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned End Date."));
                             $validationMsg['message'] = 'Tracking code due to change in Task Planned End Date.';
                             $validationMsg['msgtype'] = 'error';
                             $this->view->validationMsg = $validationMsg;
                             $bFlag = false;
                         } else {
                             if ($taskdata['effort'] != $ttaskEffort && ($ttrackingcodeeffort <= 0 || $ttrackingcodeeffort == '')) {
                                 //$this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Tracking code due to change in Project Planned Effort."));
                                 $validationMsg['message'] = 'Tracking code due to change in Task Planned Effort.';
                                 $validationMsg['msgtype'] = 'error';
                                 $this->view->validationMsg = $validationMsg;
                                 $bFlag = false;
                             } else {
                                 if ($tprojectSelected <= 0) {
                                     $validationMsg['message'] = 'Please select project.';
                                     $validationMsg['msgtype'] = 'error';
                                     $this->view->validationMsg = $validationMsg;
                                     $bFlag = false;
                                 } else {
                                     if (strlen(trim($ttaskName)) <= 0) {
                                         $validationMsg['message'] = 'Task name cannot be empty.';
                                         $validationMsg['msgtype'] = 'error';
                                         $this->view->validationMsg = $validationMsg;
                                         $bFlag = false;
                                     } else {
                                         if (strlen(trim($ttaskDescription)) <= 0) {
                                             $validationMsg['message'] = 'Task description cannot be empty.';
                                             $validationMsg['msgtype'] = 'error';
                                             $this->view->validationMsg = $validationMsg;
                                             $bFlag = false;
                                         } else {
                                             if (strlen(trim($ttaskStartDate)) <= 0) {
                                                 $validationMsg['message'] = 'Task startdate cannot be empty.';
                                                 $validationMsg['msgtype'] = 'error';
                                                 $this->view->validationMsg = $validationMsg;
                                                 $bFlag = false;
                                             } else {
                                                 if (strlen(trim($ttaskEndDate)) <= 0) {
                                                     $validationMsg['message'] = 'Task enddate cannot be empty.';
                                                     $validationMsg['msgtype'] = 'error';
                                                     $this->view->validationMsg = $validationMsg;
                                                     $bFlag = false;
                                                 } else {
                                                     if (strlen(trim($ttaskEffort)) <= 0) {
                                                         $validationMsg['message'] = 'Task effort cannot be empty.';
                                                         $validationMsg['msgtype'] = 'error';
                                                         $this->view->validationMsg = $validationMsg;
                                                         $bFlag = false;
                                                     } else {
                                                         if ($ttaskPrimaryLead <= 0) {
                                                             $validationMsg['message'] = 'Please select primary lead.';
                                                             $validationMsg['msgtype'] = 'error';
                                                             $this->view->validationMsg = $validationMsg;
                                                             $bFlag = false;
                                                         } else {
                                                             if ($ttaskSecondaryLead <= 0) {
                                                                 $validationMsg['message'] = 'Please select secondary lead.';
                                                                 $validationMsg['msgtype'] = 'error';
                                                                 $this->view->validationMsg = $validationMsg;
                                                                 $bFlag = false;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($bFlag) {
                         $mpolicydata = array('projectid' => trim($tprojectSelected), 'taskname' => trim($ttaskName), 'description' => trim($ttaskDescription), 'status' => trim($ttaskStatus), 'effort' => trim($ttaskEffort), 'startdate' => sapp_Global::change_date(trim($ttaskStartDate), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskEndDate), 'database'), 'primarylead' => trim($ttaskPrimaryLead), 'secondarylead' => trim($ttaskSecondaryLead), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                         $where = array('id=?' => $id);
                         $Id = $taskModel->SaveorUpdateData($mpolicydata, $where);
                         if ($tprojectStartDate2 != $tprojectStartDate1 || $tprojectEndDate2 != $tprojectEndDate1 || $taskdata['effort'] != $ttaskEffort) {
                             $taskslogModel = new Default_Model_Createtaskslog();
                             $mprojectlogdata = array('taskid' => trim($taskdata['id']), 'startdatetrackingcodeid' => trim($ttrackingcodestartdate), 'enddatetrackingcodeid' => trim($ttrackingcodeenddate), 'efforttrackingcodeid' => trim($ttrackingcodeeffort), 'effortold' => trim($taskdata['effort']), 'startdateold' => $tprojectStartDate2, 'enddateold' => $tprojectEndDate2, 'effortnew' => $ttaskEffort, 'startdatenew' => $tprojectStartDate1, 'enddatenew' => $tprojectEndDate1, 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"));
                             $where = "";
                             $Id = $taskslogModel->SaveorUpdateData($mprojectlogdata, $where);
                         }
                         //update Task Activities
                         $currRow = 0;
                         foreach ($tprjactivityid as $tprjactid) {
                             $mactivitydata = array('effort' => trim($tprjactivityeffort[$currRow]), 'startdate' => sapp_Global::change_date(trim($tprjactivitysdate[$currRow]), 'database'), 'enddate' => sapp_Global::change_date(trim($tprjactivityedate[$currRow]), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                             $where = array('id=?' => $tprjactivitytaskid[$currRow]);
                             $Id1 = $activityModel->SaveorUpdateData($mactivitydata, $where);
                             $currRow = $currRow + 1;
                         }
                         $menuID = -999;
                         sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Task details successfully modified."));
                         $trDb->commit();
                         $this->_redirect('/createtasks');
                     }
                 } catch (Exception $e) {
                     $trDb->rollBack();
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
                     $this->_redirect('/createtasks');
                 }
             }
         } else {
             //Insert code
             $actionflag = 1;
             if ($this->getRequest()->getPost()) {
                 #$result = $this->save($form, $policydata);
                 $trDb = Zend_Db_Table::getDefaultAdapter();
                 // starting transaction
                 $trDb->beginTransaction();
                 try {
                     $bFlag = true;
                     //Task Details
                     $tprojectSelected = $this->_getParam('projectSelected', null);
                     $ttaskName = $this->_getParam('taskName', null);
                     $ttaskDescription = $this->_getParam('taskDescription', null);
                     $ttaskStartDate = $this->_getParam('taskStartDate', null);
                     $ttaskEndDate = $this->_getParam('taskEndDate', null);
                     $ttaskStatus = $this->_getParam('taskStatus', null);
                     $ttaskPrimaryLead = $this->_getParam('taskPrimaryLead', null);
                     $ttaskSecondaryLead = $this->_getParam('taskSecondaryLead', null);
                     $ttaskEffort = $this->_getParam('taskEffort', null);
                     //Task Activity Details
                     $tprjactivityid = $this->_getParam('prjactivityid', null);
                     $tprjactivitysdate = $this->_getParam('prjactivitysdate', null);
                     $tprjactivityedate = $this->_getParam('prjactivityedate', null);
                     $tprjactivityeffort = $this->_getParam('prjactivityeffort', null);
                     $tprjactivitysdate1 = implode(',', $tprjactivitysdate);
                     $mtaskactivitytrackingdata = array('startdate' => implode(',', $tprjactivitysdate), 'enddate' => implode(',', $tprjactivityedate), 'effort' => implode(',', $tprjactivityeffort));
                     $this->view->taskactivitytrackingdata = $mtaskactivitytrackingdata;
                     $this->view->taskpagerefresh = '1';
                     if ($tprojectSelected <= 0) {
                         $validationMsg['message'] = 'Please select project.';
                         $validationMsg['msgtype'] = 'error';
                         $this->view->validationMsg = $validationMsg;
                         $bFlag = false;
                     } else {
                         if (strlen(trim($ttaskName)) <= 0) {
                             $validationMsg['message'] = 'Task name cannot be empty.';
                             $validationMsg['msgtype'] = 'error';
                             $this->view->validationMsg = $validationMsg;
                             $bFlag = false;
                         } else {
                             if (strlen(trim($ttaskDescription)) <= 0) {
                                 $validationMsg['message'] = 'Task description cannot be empty.';
                                 $validationMsg['msgtype'] = 'error';
                                 $this->view->validationMsg = $validationMsg;
                                 $bFlag = false;
                             } else {
                                 if (strlen(trim($ttaskStartDate)) <= 0) {
                                     $validationMsg['message'] = 'Task startdate cannot be empty.';
                                     $validationMsg['msgtype'] = 'error';
                                     $this->view->validationMsg = $validationMsg;
                                     $bFlag = false;
                                 } else {
                                     if (strlen(trim($ttaskEndDate)) <= 0) {
                                         $validationMsg['message'] = 'Task enddate cannot be empty.';
                                         $validationMsg['msgtype'] = 'error';
                                         $this->view->validationMsg = $validationMsg;
                                         $bFlag = false;
                                     } else {
                                         if (strlen(trim($ttaskEffort)) <= 0) {
                                             $validationMsg['message'] = 'Task effort cannot be empty.';
                                             $validationMsg['msgtype'] = 'error';
                                             $this->view->validationMsg = $validationMsg;
                                             $bFlag = false;
                                         } else {
                                             if ($ttaskPrimaryLead <= 0) {
                                                 $validationMsg['message'] = 'Please select primary lead.';
                                                 $validationMsg['msgtype'] = 'error';
                                                 $this->view->validationMsg = $validationMsg;
                                                 $bFlag = false;
                                             } else {
                                                 if ($ttaskSecondaryLead <= 0) {
                                                     $validationMsg['message'] = 'Please select secondary lead.';
                                                     $validationMsg['msgtype'] = 'error';
                                                     $this->view->validationMsg = $validationMsg;
                                                     $bFlag = false;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $mpolicydata = array('projectid' => trim($tprojectSelected), 'taskname' => trim($ttaskName), 'description' => trim($ttaskDescription), 'status' => trim($ttaskStatus), 'effort' => trim($ttaskEffort), 'startdate' => sapp_Global::change_date(trim($ttaskStartDate), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskEndDate), 'database'), 'primarylead' => trim($ttaskPrimaryLead), 'secondarylead' => trim($ttaskSecondaryLead), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                     if ($bFlag) {
                         $Id = $taskModel->SaveorUpdateData($mpolicydata, $where);
                         if ($Id > 0 && is_numeric($Id)) {
                             //Insert Task Activities
                             $currRow = 0;
                             foreach ($tprjactivityid as $tprjactid) {
                                 $mactivitydata = array('taskid' => trim($Id), 'activityid' => trim($tprjactid), 'status' => trim($ttaskStatus), 'effort' => trim($tprjactivityeffort[$currRow]), 'startdate' => sapp_Global::change_date(trim($tprjactivitysdate[$currRow]), 'database'), 'enddate' => sapp_Global::change_date(trim($tprjactivityedate[$currRow]), 'database'), 'primarylead' => trim($ttaskPrimaryLead), 'secondarylead' => trim($ttaskSecondaryLead), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s"));
                                 $currRow = $currRow + 1;
                                 $Id1 = $activityModel->SaveorUpdateData($mactivitydata, $where);
                             }
                             $menuID = -999;
                             sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Project details successfully added."));
                         } else {
                             $this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Error while adding project details."));
                         }
                         $trDb->commit();
                         $this->_redirect('/createtasks');
                     }
                 } catch (Exception $e) {
                     $trDb->rollBack();
                     $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later."));
                     $this->_redirect('/createtasks');
                 }
             }
             if ($tprojectSelected > 0) {
                 $Currprojectdata = $currprojectsModel->getProjectDataByID($tprojectSelected);
                 $this->view->BUUsers = $usersModel->getAllActiveUsersByBU($Currprojectdata['businessunit']);
             }
             $form->submit->setLabel('Add Task');
             $this->view->loginuserGroup = $loginuserGroup;
             $this->view->TaskID = "0";
             $this->view->form = $form;
             $this->view->isEdit = "0";
             $this->view->data = $mpolicydata;
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 /**
  * 
  */
 public function downloadAction()
 {
     $requi_details_model = new Default_Model_Requisition();
     $result = $requi_details_model->getRequisitionJDFileName($this->_getParam('id'));
     if (!empty($result['jdfilename'])) {
         $status = array();
         $file = BASE_PATH . '/uploads/jobdescriptions/' . $result['jdfilename'];
         $status = sapp_Global::downloadFile($file);
         if (!empty($status['message'])) {
             $this->_helper->FlashMessenger()->setNamespace('success')->addMessage($status['message']);
         }
     }
     $this->_redirect('requisition/index');
 }
 /**
  * 
  * Show analytics of employees reporting to manager 
  */
 public function employeereportAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserRole == SUPERADMINROLE) {
         $norec_arr = array();
         $form = new Default_Form_Employeereport();
         $requi_model = new Default_Model_Requisition();
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $role_model = new Default_Model_Roles();
         $departmentsmodel = new Default_Model_Departments();
         $bu_model = new Default_Model_Businessunits();
         $roles_arr = $role_model->getRolesList_EMP();
         $job_data = $requi_model->getJobTitleList();
         $employmentStatusData = $employmentstatusModel->getempstatuslist();
         if (count($job_data) == 0) {
             $norec_arr['jobtitle_id'] = "Job titles are not configured yet.";
             $norec_arr['position_id'] = "Positions are not configured yet.";
         }
         if (count($employmentStatusData) == 0) {
             $norec_arr['emp_status_id'] = "Employment status is not configured yet.";
         }
         $form->jobtitle_id->addMultiOptions(array('' => 'Select Job Title') + $job_data);
         if (count($employmentStatusData) > 0) {
             $form->emp_status_id->addMultiOption('', 'Select Employment Status');
             foreach ($employmentStatusData as $employmentStatusres) {
                 $form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
             }
         }
         if (sizeof($roles_arr) > 0) {
             $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
         } else {
             $norec_arr['emprole'] = 'Roles are not added yet.';
         }
         $bu_arr = $bu_model->getBU_report();
         if (!empty($bu_arr)) {
             foreach ($bu_arr as $bu) {
                 $form->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
             }
         } else {
             $norec_arr['businessunit_id'] = 'Business Units are not added yet.';
         }
         // Show count of employees reporting to manager
         // Get employees data reporting to manager
         $myEmployees_model = new Default_Model_Myemployees();
         $employee_model = new Default_Model_Employee();
         //$this->_helper->layout->setLayout("analyticslayout");
         $this->view->count_emp_reporting = $employee_model->getCountEmpReporting($myEmployees_model->getLoginUserId());
         $this->view->form = $form;
         $this->view->messages = $norec_arr;
         $this->view->ermsg = '';
     } else {
         $this->render('error/error.phtml');
     }
 }
 /**
  * 
  * @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;
     }
 }