/**
  * 
  */
 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';
     }
 }
 /**
  * This action is used for adding data.    
  * @return Zend_Form.
  */
 public function addAction()
 {
     $req_model = new Default_Model_Requisition();
     $cand_model = new Default_Model_Candidatedetails();
     $cand_work_model = new Default_Model_Candidateworkdetails();
     $countriesModel = new Default_Model_Countries();
     $auth = Zend_Auth::getInstance();
     $msgarray = array();
     $popConfigPermission = array();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     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');
     }
     $req_data = $req_model->getRequisitionsForCV("'Approved','In process'");
     $req_options = array();
     foreach ($req_data as $req) {
         $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
     }
     if (count($req_options) == 0) {
         $msgarray['requisition_id'] = "No approved requisitions.";
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $form = new Default_Form_Candidatedetails();
     $form->setAction(DOMAIN . 'candidatedetails/add');
     $countrieslistArr = $countriesModel->getTotalCountriesList();
     if (sizeof($countrieslistArr) > 0) {
         $form->country->addMultiOption('', 'Select Country');
         foreach ($countrieslistArr as $countrieslistres) {
             $form->country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
         }
     } else {
         $msgarray['country'] = 'Countries are not configured yet';
     }
     $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
     if (isset($_POST['country']) && $_POST['country'] != '') {
         $statesmodel = new Default_Model_States();
         $statesmodeldata = $statesmodel->getStatesList(intval($_POST['country']));
         $st_opt = array();
         if (count($statesmodeldata) > 0) {
             foreach ($statesmodeldata as $dstate) {
                 $st_opt[$dstate['id'] . '!@#' . $dstate['state_name']] = $dstate['state_name'];
             }
         }
         $form->state->addMultiOptions(array('' => 'Select State') + $st_opt);
     }
     if (isset($_POST['state']) && $_POST['state'] != '') {
         $citiesmodel = new Default_Model_Cities();
         $citiesmodeldata = $citiesmodel->getCitiesList(intval($_POST['state']));
         $ct_opt = array();
         if (count($citiesmodeldata) > 0) {
             foreach ($citiesmodeldata as $dcity) {
                 $ct_opt[$dcity['id'] . '!@#' . $dcity['city_name']] = $dcity['city_name'];
             }
         }
         $form->city->addMultiOptions(array('' => 'Select City') + $ct_opt);
     }
     $data = array();
     $data['cand_resume'] = $this->_getParam('cand_resume');
     $data['selected_option'] = $this->_getParam('selected_option');
     $this->view->form = $form;
     $this->view->data = $data;
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->msgarray = $msgarray;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($form);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
 }
 /**
  * This action is used for adding data.    
  * @return Zend_Form.
  */
 public function addAction()
 {
     $req_model = new Default_Model_Requisition();
     $cand_model = new Default_Model_Candidatedetails();
     $cand_work_model = new Default_Model_Candidateworkdetails();
     $countriesModel = new Default_Model_Countries();
     $profiles = new Default_Model_Profiles();
     $auth = Zend_Auth::getInstance();
     $msgarray = array();
     $popConfigPermission = array();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $req_data = $req_model->getRequisitionsForCV("'Approved','In process'");
     $req_options = array();
     foreach ($req_data as $req) {
         if (strlen(trim($req['technology'])) > 0) {
             $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'] . ' - ' . $req['technology'];
         } else {
             $req_options[$req['id']] = $req['requisition_code'] . ' - ' . $req['jobtitlename'];
         }
     }
     if (count($req_options) == 0) {
         $msgarray['requisition_id'] = "No approved requisitions.";
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $form = new Default_Form_Candidatedetails();
     $form->setAction(DOMAIN . 'candidatedetails/add');
     $form->requisition_id->addMultiOptions(array('' => 'Select Requisition ID') + $req_options);
     $data = array();
     $data['cand_resume'] = $this->_getParam('cand_resume');
     $data['selected_option'] = $this->_getParam('selected_option');
     $this->view->form = $form;
     $this->view->data = $data;
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->msgarray = $msgarray;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($form);
         $this->view->msgarray = $result;
         $this->view->messages = $result;
     }
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }