public function addAction()
 {
     $req_model = new Default_Model_Requisition();
     $candsmodel = new Default_Model_Candidatedetails();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginUserGroup = $auth->getStorage()->read()->group_id;
     }
     $popConfigPermission = array();
     if (sapp_Global::_checkprivileges(COUNTRIES, $loginUserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'country');
     }
     if (sapp_Global::_checkprivileges(STATES, $loginUserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'state');
     }
     if (sapp_Global::_checkprivileges(CITIES, $loginUserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'city');
     }
     $managerStr = '';
     $messages = array();
     $inter_options = array();
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $form = new Default_Form_Interviewrounds();
     $form->setAction(BASE_URL . 'scheduleinterviews/add');
     $form->id->setValue($id);
     $form->removeElement('cand_status');
     $form->removeElement('interview_status');
     $form->submit->setLabel('Save');
     $data = array();
     $req_data = $req_model->getReqForInterviews();
     $req_options = array();
     foreach ($req_data as $req) {
         $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
     }
     $form->req_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
     if (count($req_options) == 0) {
         $messages['req_id'] = "No approved requisitions.";
         $messages['candidate_name'] = "Candidates are not added yet.";
         $messages['interviewer_id'] = "Interviewers are not added yet.";
     }
     if (count($form->country->getMultiOptions()) == 1) {
         $messages['country'] = "Countries are not configured yet.";
         $messages['state'] = "States are not configured yet.";
         $messages['city'] = "Cities are not configured yet.";
     }
     if (isset($_POST['req_id']) && $_POST['req_id'] != '') {
         $candsData = $candsmodel->getnotscheduledcandidateData($_POST['req_id']);
         $cand_data_opt = array();
         if (count($candsData) > 0) {
             foreach ($candsData as $cand) {
                 $cand_data_opt[$cand['id']] = $cand['candidate_name'];
             }
         }
         $form->candidate_name->addMultiOptions(array('' => 'Select Candidate') + $cand_data_opt);
         if (isset($req['department_id'])) {
             $repmanData = $req_model->getReportingmanagers($loginUserGroup, $loginUserId, '', $req['department_id'], 'interviewer');
             $managers_data_opt = array();
             if (!empty($repmanData)) {
                 foreach ($repmanData as $rep) {
                     $inter_options[] = array('id' => $rep['id'], 'name' => $rep['name'], 'profileimg' => $rep['profileimg']);
                 }
             }
         } else {
             $managerStr = "nomanagers";
         }
     }
     if (isset($_POST['country']) && $_POST['country'] != '') {
         $statesmodel = new Default_Model_States();
         $statesmodeldata = $statesmodel->getBasicStatesList(intval($_POST['country']));
         $st_opt = array();
         if (count($statesmodeldata) > 0) {
             foreach ($statesmodeldata as $dstate) {
                 $st_opt[$dstate['state_id_org']] = $dstate['state'];
             }
         }
         $form->state->addMultiOptions(array('' => 'Select State') + $st_opt);
     }
     if (isset($_POST['state']) && $_POST['state'] != '') {
         $citiesmodel = new Default_Model_Cities();
         $citiesmodeldata = $citiesmodel->getBasicCitiesList(intval($_POST['state']));
         $ct_opt = array();
         if (count($citiesmodeldata) > 0) {
             foreach ($citiesmodeldata as $dcity) {
                 $ct_opt[$dcity['city_org_id']] = $dcity['city'];
             }
         }
         $form->city->addMultiOptions(array('' => 'Select City') + $ct_opt);
     }
     $this->view->form = $form;
     $this->view->round_count = 0;
     $this->view->messages = $messages;
     $this->view->inter_options = $inter_options;
     $this->view->popConfigPermission = $popConfigPermission;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($form, $data);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
 }
Ejemplo n.º 2
0
 /**
  * This function is used for ajax call to get reporting managers based on  department
  * @parameters	department id.
  * @return Array of managers in json format.
  */
 public function getempreportingmanagersAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('getempreportingmanagers', 'html')->initContext();
     $form = new Default_Form_Requisition();
     $dept_id = $this->_getParam('id', null);
     $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 ($dept_id != '') {
         if ($loginuserGroup == '') {
             $reportingManagerData = $requi_model->getReportingmanagers('', $loginUserId, '', $dept_id, 'requisition');
         } else {
             $reportingManagerData = $requi_model->getReportingmanagers('', '', '', $dept_id, 'requisition');
         }
         //for hr,management
         if (empty($reportingManagerData)) {
             $flag = 'true';
         } else {
             $flag = 'false';
         }
     }
     $this->view->RMdata = $reportingManagerData;
     $this->view->reqform = $form;
     $this->view->flag = $flag;
 }
 public function editpopupAction()
 {
     $auth = Zend_Auth::getInstance();
     $inter_options = array();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
     }
     $editpermission = 'No';
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $intrvwModel = new Default_Model_Interviewdetails();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $user_model = new Default_Model_Usermanagement();
     $cancel_name = 'Cancel';
     $auth = Zend_Auth::getInstance();
     $jobtitle = '';
     $deptid = $this->getRequest()->getParam('deptid');
     if ($deptid == '') {
         $deptid = $this->getRequest()->getParam('deptidform');
     }
     $intId = $this->getRequest()->getParam('unitId');
     $roundId = $this->getRequest()->getParam('id');
     $ir_form = new Default_Form_Interviewrounds();
     $ir_form->setAttrib('action', BASE_URL . 'interviewrounds/editpopup/unitId/' . $intId . '/id/' . $roundId);
     $intData = $intrvwModel->getReqByintrvwID($intId);
     $ir_form->removeElement('req_id');
     $ir_form->removeElement('candidate_name');
     $ir_form->removeElement('interview_status');
     $ir_form->removeElement('cand_status');
     $roundData = $interview_round_model->getSingleRoundData($roundId);
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP) {
         $editpermission = sapp_Global::_checkprivileges(SCHEDULEINTERVIEWS, $loginuserGroup, $loginuserRole, 'edit');
     }
     if ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '' || $editpermission == 'Yes') {
         $countryId = $roundData['int_country'];
         if (isset($_POST['country'])) {
             $countryId = $_POST['country'];
         }
         $stateId = $roundData['int_state'];
         if (isset($_POST['state'])) {
             $stateId = $_POST['state'];
         }
         $cityId = $roundData['int_city'];
         if (isset($_POST['city'])) {
             $cityId = $_POST['city'];
         }
         $country_name = '';
         $state_name = '';
         $city_name = '';
         $countryModal = new Default_Model_Countries();
         $countriesData = $countryModal->fetchAll('isactive=1', 'country');
         foreach ($countriesData as $cdata) {
             if ($roundData['int_country'] == $cdata['country_id_org']) {
                 $country_name = $cdata['country'];
                 break;
             }
         }
         $ir_form->setDefault('country', $countryId);
         if ($countryId != '') {
             $statesmodel = new Default_Model_States();
             $statesData = $statesmodel->getBasicStatesList($countryId);
             foreach ($statesData as $res) {
                 $ir_form->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                 if ($roundData['int_state'] == $res['state_id_org']) {
                     $state_name = $res['state'];
                 }
             }
         }
         if ($stateId != '') {
             $citiesmodel = new Default_Model_Cities();
             $citiesData = $citiesmodel->getBasicCitiesList($stateId);
             foreach ($citiesData as $res) {
                 $ir_form->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                 if ($roundData['int_city'] == $res['city_org_id']) {
                     $city_name = $res['city'];
                 }
             }
             $ir_form->setDefault('state', $stateId);
             $ir_form->setDefault('city', $cityId);
         }
         $interviewer_data = $requi_model->getReportingmanagers('', $loginUserId, '', $deptid, 'interviewer');
         $inter_options = $interviewer_data;
         $inter_data = $user_model->getUserDataById($roundData['interviewer_id']);
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($inter_data['jobtitle_id']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = ', ' . $jobttlArr[0]['jobtitlename'];
             $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $roundData['interviewer_name'] = $inter_data['userfullname'] . $jobtitle;
         $roundData['interview_date'] = sapp_Global::change_date($roundData['interview_date'], 'view');
         $roundData['interview_time'] = sapp_Global::change_time($roundData['interview_time'], 'view');
         $ir_form->populate($roundData);
         // giving only for hr,management and super admin
         if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
             $ir_form->round_status->addMultiOptions(array('Decision pending' => 'Decision pending', 'On hold' => 'On hold'));
         }
         if ($roundData['round_status'] != '') {
             $ir_form->round_status->setValue($roundData['round_status']);
         }
         $future_rcnt = $interview_round_model->getFutureRoundCnt($roundData['interview_id'], $roundData['interview_round_number']);
         if ($roundData['round_status'] != '') {
             if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) && $loginUserId == $roundData['interviewer_id']) {
                 $elements = $ir_form->getElements();
                 if (count($elements) > 0) {
                     foreach ($elements as $key => $element) {
                         if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                             $element->setAttrib("disabled", "disabled");
                         }
                     }
                 }
                 $ir_form->removeElement('submit');
                 $cancel_name = 'Close';
             } else {
                 if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
                     $elements = $ir_form->getElements();
                     if (count($elements) > 0) {
                         if ($future_rcnt == 0) {
                             foreach ($elements as $key => $element) {
                                 if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments" && $key != "round_status" && $key != "submit") {
                                     $element->setAttrib("disabled", "disabled");
                                 }
                             }
                         } else {
                             foreach ($elements as $key => $element) {
                                 if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                     $element->setAttrib("disabled", "disabled");
                                 }
                             }
                             $ir_form->removeElement('submit');
                             $cancel_name = 'Close';
                         }
                     }
                 }
             }
         } else {
             if ($roundData['interviewer_id'] != $loginUserId && ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP)) {
                 $elements = $ir_form->getElements();
                 if (count($elements) > 0) {
                     foreach ($elements as $key => $element) {
                         if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                             $element->setAttrib("disabled", "disabled");
                         }
                     }
                 }
                 $ir_form->removeElement('submit');
                 $cancel_name = 'Close';
             }
         }
         $this->view->deptid = $deptid;
         $this->view->data = $roundData;
         $this->view->interviewer_data = $interviewer_data;
         $this->view->country_name = $country_name;
         $this->view->state_name = $state_name;
         $this->view->city_name = $city_name;
         $this->view->cancel_name = $cancel_name;
         $this->view->form = $ir_form;
         $this->view->inter_options = $inter_options;
         if ($this->getRequest()->getPost()) {
             $result = $this->save($ir_form);
             $this->view->msgarray = $result;
             $this->view->messages = $result;
         }
         $this->view->ermsg = '';
     } else {
         $this->view->ermsg = 'nodata';
     }
     $this->view->loginuserGroup = $loginuserGroup;
     $this->view->loginUserId = $loginUserId;
 }