/**
  * This action is used to delete candidate and their interview round data.
  * @parameters
  * @param objid    =   id of candidate.
  * 
  * @return   =   success/failure message 
  */
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $messages['msgtype'] = "";
     $actionflag = 3;
     if ($id) {
         $cand_model = new Default_Model_Candidatedetails();
         $cand_work_model = new Default_Model_Candidateworkdetails();
         $interview_model = new Default_Model_Interviewdetails();
         $interview_round_model = new Default_Model_Interviewrounddetails();
         $menumodel = new Default_Model_Menu();
         $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = array('id=?' => $id);
         $Id = $cand_model->SaveorUpdateCandidateData($data, $where);
         if ($Id == 'update') {
             $cand_work_data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $cand_work_where = "cand_id = " . $id;
             $cand_work_model->SaveorUpdateCandidateWorkData($cand_work_data, $cand_work_where);
             $interview_data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $interview_where = "candidate_id = " . $id;
             $interview_model->SaveorUpdateInterviewData($interview_data, $interview_where);
             $interview_round_data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $interview_round_where = "candidate_id = " . $id;
             $interview_round_model->SaveorUpdateInterviewroundData($interview_round_data, $interview_round_where);
             $objidArr = $menumodel->getMenuObjID('/candidatedetails');
             $objID = $objidArr[0]['id'];
             $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $id);
             $messages['message'] = 'Candidate deleted successfully.';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'Candidate cannot be deleted.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Candidate cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }
 /**
  * 
  */
 public function candidatepopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $req_model = new Default_Model_Requisition();
     $jobtitleModel = new Default_Model_Jobtitles();
     $cand_model = new Default_Model_Candidatedetails();
     $candwork_model = new Default_Model_Candidateworkdetails();
     $country_model = new Default_Model_Countries();
     $role_model = new Default_Model_Roles();
     $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;
     }
     $id = $this->getRequest()->getParam('cand_id');
     $form = new Default_Form_Candidatedetails();
     $req_data = array();
     $jobtitle = '';
     $req_data['jobtitlename'] = '';
     try {
         $candidateData = $cand_model->getcandidateData($id);
         $req_data = $req_model->getRequisitionDataById($candidateData['requisition_id']);
         $req_data['cand_resume'] = !empty($candidateData['cand_resume']) ? $candidateData['cand_resume'] : '';
         $req_data['rec_id'] = $id;
         $jobttlArr = $jobtitleModel->getsingleJobTitleData($req_data['jobtitle']);
         if (!empty($jobttlArr) && $jobttlArr != 'norows') {
             $jobtitle = $jobttlArr[0]['jobtitlename'];
             $req_data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
         }
         $req_options = array();
         $req_options[$req_data['id']] = $req_data['requisition_code'];
         try {
             $candidateworkData = $candwork_model->getcandidateworkData($id);
             $countryId = $candidateData['country'];
             $stateId = $candidateData['state'];
             $cityId = $candidateData['city'];
             if ($countryId && $stateId) {
                 $statesmodel = new Default_Model_States();
                 $citiesmodel = new Default_Model_Cities();
                 $statesData = $statesmodel->getStatesList($countryId);
                 $citiesData = $citiesmodel->getCitiesList($stateId);
                 foreach ($statesData as $res) {
                     $form->state->addMultiOption($res['id'], utf8_encode($res['state_name']));
                 }
                 foreach ($citiesData as $res) {
                     $form->city->addMultiOption($res['id'], utf8_encode($res['city_name']));
                 }
                 $form->setDefault('country', $countryId);
                 $form->setDefault('state', $stateId);
                 $form->setDefault('city', $cityId);
                 $form->setDefault('job_title', $jobtitle);
             }
             $countrieslistArr = $country_model->getTotalCountriesList();
             if (sizeof($countrieslistArr) > 0) {
                 $form->country->addMultiOption('0', 'Select Country');
                 foreach ($countrieslistArr as $countrieslistres) {
                     $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                 }
             } else {
                 $msgarray['country'] = 'Countries not configured yet';
             }
             $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
             if ($id) {
                 $form->submit->setLabel('Update');
                 $form->populate($candidateworkData);
                 $form->populate($candidateData);
             }
             $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");
                     }
                 }
             }
             $previ_data = sapp_Global::_checkprivileges(CANDIDATEDETAILS, $login_group_id, $login_role_id, 'edit');
             $this->view->form = $form;
             $this->view->previ_data = $previ_data;
             $this->view->workdata = $candidateworkData;
             $this->view->ermsg = '';
             $this->view->req_data = $req_data;
             $objName = 'candidatedetails';
             $this->view->id = $id;
             $this->view->controllername = $objName;
         } catch (Exception $e) {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }