/**
  * This action is used for adding/updating data.
  * @parameters
  * @param $id  =  id of candidate (optional)
  * 
  * @return Zend_Form.
  */
 public function editAction()
 {
     $cand_model = new Default_Model_Candidatedetails();
     $requi_model = new Default_Model_Requisition();
     $interview_model = new Default_Model_Interviewdetails();
     $interview_round_model = new Default_Model_Interviewrounddetails();
     $jobtitleModel = new Default_Model_Jobtitles();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $id = $this->getRequest()->getParam('id');
     $intId = $id;
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $previousroundstatus = '';
     $cancel_name = "Cancel";
     $form = new Default_Form_Interviewrounds();
     $form->setAction(DOMAIN . 'scheduleinterviews/edit/id/' . $id);
     $form->id->setValue($id);
     $submitButon = $form->getElement("submit");
     $submitButon->setAttrib('style', 'display:none;');
     $form->removeElement('req_id');
     $form->removeElement('candidate_name');
     $form->removeElement('interviewer_id');
     $form->removeElement('interview_mode');
     $form->removeElement('int_location');
     $form->removeElement('country');
     $form->removeElement('state');
     $form->removeElement('city');
     $form->removeElement('interview_time');
     $form->removeElement('interview_date');
     $form->removeElement('interview_round');
     $data = array();
     $jobtitle = '';
     $interviewData = array();
     try {
         if ($id > 0 && is_numeric($id)) {
             $interviewData = $interview_model->getSingleInterviewData($intId);
             $reqstatusArray = array('On hold', 'Closed', 'Complete');
             $previousroundstatus = $interview_model->getinterviewroundnumber($intId);
             $previousroundstatus = $previousroundstatus['round_status'];
             $data = $interview_model->getCandidateDetailsById($intId);
             if (!empty($data) && $data['interview_status'] != 'Requisition Closed/Completed' && $data['interview_status'] != 'Completed' && !in_array($data['req_status'], $reqstatusArray)) {
                 if ($data['interview_status'] == 'On hold' && ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP)) {
                     $this->view->ermsg = 'nodata';
                 } else {
                     $data['jobtitlename'] = '';
                     $round_count = $interview_round_model->getRoundCnt($data['id'], $id);
                     $jobttlArr = $jobtitleModel->getsingleJobTitleData($data['jobtitle']);
                     if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                         $jobtitle = $jobttlArr[0]['jobtitlename'];
                         $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
                     }
                     $irData = $this->interviewRoundsGrid($id, $interviewData['interview_status']);
                     $this->view->dataArray = $irData[0];
                     $form->setDefault('interview_status', $interviewData['interview_status']);
                     $cand_arr = array();
                     if ($interviewData['interview_status'] == 'In process') {
                         $cand_arr['Scheduled'] = 'Scheduled';
                     } elseif ($interviewData['interview_status'] == 'Completed') {
                         $cand_arr['Disqualified'] = 'Disqualified';
                         $cand_arr['Shortlisted'] = 'Shortlisted';
                     } elseif ($interviewData['interview_status'] == 'On hold') {
                         $cand_arr['On hold'] = 'On hold';
                     }
                     $form->cand_status->clearMultiOptions();
                     $form->cand_status->addMultiOptions(array('' => 'Select status') + $cand_arr);
                     $form->setDefault('cand_status', $data['cand_status']);
                     $this->view->form = $form;
                     $this->view->data = $data;
                     $this->view->id = $id;
                     $this->view->round_count = $round_count;
                     if ($this->getRequest()->getPost()) {
                         $result = $this->save($form, $data);
                         $this->view->msgarray = $result;
                         $this->view->messages = $result;
                     }
                     $this->view->ermsg = '';
                     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP || $interviewData['interview_status'] == 'Completed') {
                         $form->removeElement('submit');
                         $cancel_name = "Back";
                         $elements = $form->getElements();
                         if (count($elements) > 0) {
                             foreach ($elements as $key => $element) {
                                 if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                                     $element->setAttrib("disabled", "disabled");
                                 }
                             }
                         }
                         if ($interviewData['interview_status'] == 'Completed') {
                             $this->view->ermsg = 'interviewcompleted';
                         }
                     }
                 }
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } else {
             $this->view->ermsg = 'nodata';
         }
         $this->view->interview_status = $interviewData['interview_status'];
         $this->view->previousroundstatus = $previousroundstatus;
         $this->view->loginuserGroup = $loginuserGroup;
         $this->view->cancel_name = $cancel_name;
     } catch (EXception $e) {
         $this->view->ermsg = 'nodata';
     }
 }
 public function viewpopupAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     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();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $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();
     $elements = $ir_form->getElements();
     //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 (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     $intData = $intrvwModel->getReqByintrvwID($intId);
     $roundData = $interview_round_model->getSingleRoundData($roundId);
     $this->view->ermsg = '';
     $edit_flag = 'no';
     if ($roundData['interviewer_id'] == $loginUserId) {
         $edit_flag = 'yes';
     }
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '' || $loginuserGroup == EMPLOYEE_GROUP || $loginuserGroup == SYSTEMADMIN_GROUP) {
         $countryId = $roundData['int_country'];
         $stateId = $roundData['int_state'];
         $cityId = $roundData['int_city'];
         $country_name = '';
         $state_name = '';
         $city_name = '';
         if ($countryId && $stateId) {
             $statesmodel = new Default_Model_States();
             $citiesmodel = new Default_Model_Cities();
             $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;
                 }
             }
             $statesData = $statesmodel->getBasicStatesList($countryId);
             $citiesData = $citiesmodel->getBasicCitiesList($stateId);
             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'];
                 }
             }
             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'];
                 }
             }
         }
         $interviewer_data = $user_model->getUserDataById($roundData['interviewer_id']);
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($interviewer_data['jobtitle_id']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = ', ' . $jobttlArr[0]['jobtitlename'];
             $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $ir_form->interviewer_id->addMultiOptions(array('' => $interviewer_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);
         $this->view->form = $ir_form;
         $this->view->intId = $intId;
         $this->view->deptid = $deptid;
         $this->view->roundId = $roundId;
         $this->view->ermsg = '';
         $this->view->country_name = $country_name;
         $this->view->state_name = $state_name;
         $this->view->city_name = $city_name;
         $this->view->edit_flag = $edit_flag;
     } else {
         $this->view->ermsg = 'nodata';
     }
 }