Esempio n. 1
0
 public function view()
 {
     if (!$this->loadData()) {
         $this->_uses[$this->modeltype]->authorisationPolicy();
         if (!$this->loadData()) {
             $this->dataError($this->_no_access_msg);
             sendBack();
         }
         // User can only view other peoples data
         $restrict_inserts = $readonly = TRUE;
     }
     $employee = $this->_uses[$this->modeltype];
     $idfield = $employee->idField;
     $idvalue = $employee->{$idfield};
     // Do not allow the user to update their own details
     if ($idvalue == $employee->user_person_id) {
         $restrict_inserts = TRUE;
     }
     /* Get the details from the Person table*/
     $this->view->set('person', $employee->person);
     $this->view->set('holidays', $employee->getHolidayTotals());
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['view_all'] = array('tag' => 'view_all', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index'));
     $sidebarlist['new_employee'] = array('tag' => 'new_employee', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new'));
     $sidebar->addList('actions', $sidebarlist);
     $sidebarlist = array();
     $sidebarlist[$employee->employee] = array('tag' => $employee->employee, 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', $idfield => $idvalue));
     if (!$readonly) {
         $sidebarlist['edit_employee'] = array('tag' => 'Edit Employee Details', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', $idfield => $idvalue));
         $sidebarlist['edit_personal'] = array('tag' => 'Edit Personal Details', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit_personal', $idfield => $idvalue));
         $sidebarlist['edit_work'] = array('tag' => 'Edit Work Contact Details', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit_work', $idfield => $idvalue));
         if (is_null($employee->finished_date)) {
             $sidebarlist['make_leaver'] = array('tag' => 'Leaver', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'leaver', $idfield => $idvalue));
         }
     }
     $sidebar->addList('currently_viewing', $sidebarlist);
     $sidebarlist = array();
     $sidebarlist['expenses'] = array('tag' => 'View Expenses', 'link' => array('modules' => $this->_modules, 'controller' => 'expenses', 'action' => 'viewemployee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'expenses', 'action' => 'new', 'employee_id' => $idvalue));
     $sidebarlist['expenses_for_payment'] = array('tag' => 'Expenses Awaiting Authorisation', 'link' => array('modules' => $this->_modules, 'controller' => 'expenses', 'action' => 'viewemployee', 'employee_id' => $idvalue, 'status' => Expense::statusAwaitingAuthorisation()));
     $sidebarlist['make_payment'] = array('tag' => 'Make Payment', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'make_payment', 'employee_id' => $idvalue));
     $sidebarlist['allocate_expenses'] = array('tag' => 'Allocate Expenses to Payments', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'allocate', 'employee_id' => $idvalue));
     if ($restrict_inserts) {
         $sidebarlist['holidayentitlement'] = array('tag' => 'Holiday Entitlement', 'link' => array('modules' => $this->_modules, 'controller' => 'holidayentitlements', 'action' => 'viewemployee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['holidayentitlement'] = array('tag' => 'Holiday Entitlement', 'link' => array('modules' => $this->_modules, 'controller' => 'holidayentitlements', 'action' => 'viewemployee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'holidayentitlements', 'action' => 'new', 'employee_id' => $idvalue));
     }
     $sidebarlist['holidayrequest'] = array('tag' => 'Holiday Request', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'viewholidayrequests', 'employee_id' => $employee->id), 'new' => array('modules' => $this->_modules, 'controller' => 'holidayrequests', 'action' => 'new', 'employee_id' => $idvalue));
     $sidebarlist['trainingplan'] = array('tag' => 'Training Plan', 'link' => array('modules' => $this->_modules, 'controller' => 'employeetrainingplans', 'action' => 'viewemployeetrainingplans', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeetrainingplans', 'action' => 'new', 'employee_id' => $idvalue));
     if ($restrict_inserts) {
         $sidebarlist['employeerates'] = array('tag' => 'Pay Rates', 'link' => array('modules' => $this->_modules, 'controller' => 'employeerates', 'action' => 'view_employee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['employeerates'] = array('tag' => 'Pay Rates', 'link' => array('modules' => $this->_modules, 'controller' => 'employeerates', 'action' => 'view_employee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeerates', 'action' => 'new', 'employee_id' => $idvalue));
     }
     if ($restrict_inserts) {
         $sidebarlist['employeecontractdetails'] = array('tag' => 'Contract Details', 'link' => array('modules' => $this->_modules, 'controller' => 'employeecontractdetails', 'action' => 'viewemployee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['employeecontractdetails'] = array('tag' => 'Contract Details', 'link' => array('modules' => $this->_modules, 'controller' => 'employeecontractdetails', 'action' => 'viewemployee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeecontractdetails', 'action' => 'new', 'employee_id' => $idvalue));
     }
     $week_dates = $this->getWeekDates();
     $sidebarlist['hours'] = array('tag' => 'Timesheet Hours', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view_hours_summary', 'person_id' => $employee->person_id, 'start_date' => $week_dates['week_start_date'], 'end_date' => $week_dates['week_end_date']), 'new' => array('modules' => $this->_modules, 'controller' => 'hours', 'action' => 'new', 'person_id' => $employee->person_id, 'start_date' => $week_dates['week_start_date'], 'end_date' => $week_dates['week_end_date']));
     if ($restrict_inserts) {
         $sidebarlist['payhistory'] = array('tag' => 'Pay History', 'link' => array('modules' => $this->_modules, 'controller' => 'employeepayhistorys', 'action' => 'view_employee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['payhistory'] = array('tag' => 'Pay History', 'link' => array('modules' => $this->_modules, 'controller' => 'employeepayhistorys', 'action' => 'view_employee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeepayhistorys', 'action' => 'new', 'employee_id' => $idvalue));
     }
     $sidebar->addList('related_items', $sidebarlist);
     $authoriser = DataObjectFactory::Factory('HRAuthoriser');
     foreach ($authoriser->getTypesForEmployee($idvalue) as $authorisation_type) {
         $array[] = $authoriser->getEnum('authorisation_type', $authorisation_type);
     }
     if (!empty($array)) {
         $this->view->set('can_authorise', implode(',', $array));
     }
     $this->view->set('expense_authorisers', implode(',', $this->_templateobject->expense_model()->getAuthorisersByName($idvalue)));
     $this->view->set('holiday_authorisers', implode(',', $this->_templateobject->holiday_model()->getAuthorisersByName($idvalue)));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }