Exemplo n.º 1
0
 /**
  * This action is used for viewing data.
  * @parameters
  * @param id  =  id of requisition
  *
  * @return Zend_Form.
  */
 public function viewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $requi_model = new Default_Model_Requisition();
     $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;
     }
     $ju_name = array();
     try {
         if (is_numeric($id) && $id > 0) {
             $id = abs($id);
             $getempId = $requi_model->getrequisitionDataonid($id);
             if (!empty($getempId['billable_empname'])) {
                 $getdatampname = $requi_model->getEmployeeNameonId($getempId['billable_empname']);
             }
             $data = $requi_model->getReqDataForView($id);
             $dataskills = $requi_model->getReqSkillsDataForView($id);
             $app1_name = $app2_name = $app3_name = '';
             if (count($data) > 0 && $data[0]['req_status'] == 'Initiated') {
                 $data = $data[0];
                 $auth = Zend_Auth::getInstance();
                 if ($auth->hasIdentity()) {
                     $loginUserId = $auth->getStorage()->read()->id;
                     $loginuserRole = $auth->getStorage()->read()->emprole;
                     $loginuserGroup = $auth->getStorage()->read()->group_id;
                 }
                 $data['jobtitlename'] = '';
                 $data['businessunit_name'] = $data['businessunit_name'];
                 $data['dept_name'] = $data['department_name'];
                 $data['titlename'] = $data['jobtitle_name'];
                 $data['posname'] = $data['position_name'];
                 $data['empttype'] = $data['emp_type_name'];
                 $data['mngrname'] = $data['reporting_manager_name'];
                 $data['raisedby'] = $data['createdby_name'];
                 $data['app1_name'] = $data['approver1_name'];
                 if ($data['approver2'] != '') {
                     $data['app2_name'] = $data['approver2_name'];
                 } else {
                     $data['app2_name'] = 'No Approver';
                 }
                 if ($data['approver3'] != '') {
                     $data['app3_name'] = $data['approver3_name'];
                 } else {
                     $data['app3_name'] = 'No Approver';
                 }
                 if (count($dataskills) > 0) {
                     $data['technicalskillids'] = $dataskills['TechnicalSkillIds'];
                     $data['technicalskillnames'] = $dataskills['TechnicalSkills'];
                     $data['nontechnicalskillids'] = $dataskills['NonTechnicalSkillIds'];
                     $data['nontechnicalskillnames'] = $dataskills['NonTechnicalSkills'];
                 }
                 foreach ($data as $key => $val) {
                     if ($key == 'jdfilename') {
                         if (isset($val)) {
                             $data[$key] = "<a href='" . DOMAIN . 'requisition/download/id/' . $id . "'>View Job Description file.</a>";
                         } else {
                             $data[$key] = "--No Job Description file exists...";
                         }
                     } else {
                         $data[$key] = htmlentities($val, ENT_QUOTES, "UTF-8");
                     }
                 }
                 $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                 $previ_data = sapp_Global::_checkprivileges(REQUISITION, $login_group_id, $login_role_id, 'edit');
                 $this->view->previ_data = $previ_data;
                 $this->view->data = $data;
                 $this->view->getempId = $getempId;
                 $this->view->getdatampname = $getdatampname;
                 $this->view->id = $id;
                 $this->view->controllername = "requisition";
                 $this->view->ermsg = '';
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }