Пример #1
0
 /**
  * Display leave information
  *
  * @param boolean $admin Show admin view or ess user view
  * @param Exception $exception Exception class (used to display any errors from previous apply/assign)
  */
 public function displayLeaveInfo($admin = false, $exception = null)
 {
     $authorizeObj = $this->authorize;
     if ($admin) {
         if ($authorizeObj->getIsAdmin() == 'Yes') {
             $empObj = new EmpInfo();
             $tmpObjs[0] = array(true);
         } else {
             if ($authorizeObj->isSupervisor()) {
                 $empRepToObj = new EmpRepTo();
                 $tmpObjs[0] = $empRepToObj->getEmpSubDetails($authorizeObj->getEmployeeId());
             }
         }
         $roles = array(authorize::AUTHORIZE_ROLE_ADMIN, authorize::AUTHORIZE_ROLE_SUPERVISOR);
         $role = $authorizeObj->firstRole($roles);
         $previousLeave = null;
         if (isset($_GET['id'])) {
             $leaveObj = new Leave();
             $previousLeaves = $leaveObj->retrieveLeave($_GET['id']);
             $previousLeave = $previousLeaves[0];
             if ($authorizeObj->getIsAdmin() != 'Yes' && $authorizeObj->isSupervisor() && !$authorizeObj->isTheSupervisor($previousLeave->getEmployeeId())) {
                 $previousLeave = null;
             }
         }
         $this->setId($_SESSION['empID']);
         $tmpObj = new LeaveType();
         $tmpObjs[1] = $tmpObj->fetchLeaveTypes();
         $tmpObjs[2] = $role;
         $tmpObjs[3] = $previousLeave;
         $tmpObjs['allEmpWorkshits'] = Workshift::getWorkshiftForAllEmployees();
     } else {
         $this->setId($_SESSION['empID']);
         $tmpObj = new LeaveQuota();
         $tmpObj->setYear(date('Y'));
         $tmpObjs[1] = $tmpObj->fetchLeaveQuota($this->getId());
         $workShift = Workshift::getWorkshiftForEmployee($this->getId());
         $shiftLength = isset($workShift) ? $workShift->getHoursPerDay() : Leave::LEAVE_LENGTH_FULL_DAY;
         $tmpObjs['shiftLength'] = $shiftLength;
     }
     $this->setObjLeave($tmpObjs);
     $path = "/templates/leave/leaveApply.php";
     if (!empty($exception)) {
         $tmpObjs['exception'] = $exception;
     }
     $template = new TemplateMerger($tmpObjs, $path);
     $template->display();
 }