/**
  * 
  */
 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;
     }
     $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(DOMAIN . '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 (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');
             #$requi_number = $_POST['req_id'];
             $repmanData = $req_model->getRequisitionInterviewPanel($_POST['req_id']);
             $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";
         }
     }
     $this->view->form = $form;
     $this->view->round_count = 0;
     $this->view->messages = $messages;
     $this->view->inter_options = $inter_options;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($form, $data);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
 }
 /**
  * 
  */
 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', DOMAIN . '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);
     $ipreporting_ids = explode(",", $roundData['interview_panel']);
     $interview_type_detail = $roundData['interview_mode_details'];
     if ($roundData['interview_mode'] != '' && $roundData['interview_mode'] == "Phone" || $roundData['interview_mode'] == "Skype") {
         $ir_form->interview_Type_Details->setValue($roundData['interview_mode_details']);
     }
     if ($roundData['round_status'] == "Schedule for next round" || $roundData['round_status'] == "Qualified" || $roundData['round_status'] == "Selected" || $roundData['round_status'] == "Disqualified") {
         $requisitionSkillMatrix = $interview_round_model->getSubmittedRequisitionSkillMatrix($roundData['id'], $roundData['interview_round_number']);
         $requisitionSkillMatrix_tabel = $this->ArrayToGenericGrid("Feedback Matrix", $requisitionSkillMatrix);
     } else {
         $requisitionSkillMatrix = $interview_round_model->getRequisitionSkillMatrix($roundId);
         $requisitionSkillMatrix_tabel = $this->ConvertArrayToGrid("Feedback Matrix", $requisitionSkillMatrix);
     }
     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');
         if ($loginuserGroup == 3) {
             $interviewer_data = $requi_model->getRequisitionInterviewPanel($roundData['req_id']);
         } else {
             $interviewer_data = $requi_model->getInterviewRoundPanel($roundData['interview_panel']);
         }
         $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 {
             $interview_panel = $roundData['interview_panel'];
             $str = substr_count($interview_panel, $loginUserId) > 0;
             if ($str != true && ($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;
         $this->view->requisitionSkillMatrix_tabel = $requisitionSkillMatrix_tabel;
         $this->view->ipreporting_ids = $ipreporting_ids;
         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;
 }