/**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $user = $this->user;
     $travelOrderCount = 0;
     $regularLeaveCount = 0;
     $specialLeaveCount = 0;
     if ($user->employee && $user->employee->canApproveRegularLeave()) {
         $regularLeaveCount = $user->employee->regular_leave_recommending_approvals->merge($user->employee->regular_leave_approved_by)->count();
     }
     if ($user->employee && $user->employee->canApproveSpecialLeave()) {
         $specialLeaveCount = $user->employee->special_leave_recommending_approvals->merge($user->employee->special_leave_approved_by)->count();
     }
     if ($user->isAdmin()) {
         $regularLeaveCount = EmployeeLeave::approved()->count();
         $specialLeaveCount = EmployeeSpecialLeave::approved()->count();
     }
     if ($user->employee && $user->employee->canApproveTravelOrder()) {
         if ($user->isFinanceDirector()) {
             $travelOrderCount = TravelOrder::recommended()->count();
         } else {
             $travelOrderCount = $user->employee->travel_order_recommending_approvals->merge($user->employee->travel_order_approved_by)->count();
         }
     }
     $view->with(compact('user', 'regularLeaveCount', 'specialLeaveCount', 'travelOrderCount'));
 }
Exemple #2
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (auth()->user()->employee) {
         $stats = collect();
         $sessions = $this->session->getActiveUsers();
         $stats->push(['title' => 'System users', 'class' => 'info', 'icon' => 'users', 'number' => User::count(), 'description' => 'Registered user account in the system', 'url' => '/employee']);
         $stats->push(['title' => 'User with PDS', 'class' => 'success', 'icon' => 'user', 'number' => round(Employee::count() / User::count() * 100, 0) . '%', 'description' => Employee::count() . ' employees with Personal Data Sheet', 'url' => '/employee']);
         $stats->push(['title' => 'Leave Request', 'class' => 'danger', 'icon' => 'thumbs-o-up', 'number' => EmployeeLeave::approved()->count(), 'description' => '<i class="fa fa-thumbs-o-up"></i>&nbsp;' . EmployeeLeave::count() . ' Total filed leaves', 'url' => 'leave']);
         $stats->push(['title' => 'Upcoming Trainings', 'class' => 'warning', 'icon' => 'calendar', 'number' => Training::where('start', '>', Carbon::today())->count(), 'description' => '<i class="fa fa-calendar"></i>&nbsp; ' . Training::count() . ' Trainings & Seminar', 'url' => '/calendar']);
         $view->with(compact('stats', 'sessions'));
     }
 }
 public function index()
 {
     $employee = auth()->user()->employee;
     if ($employee->canApproveRegularLeave()) {
         if ($employee->user->isAdmin()) {
             $employee_leaves = EmployeeLeave::approved()->get();
         } else {
             $employee_leaves = $employee->regular_leave_recommending_approvals->merge($employee->regular_leave_approved_by);
         }
         return view('leaves.regular.employee_leaves')->with(compact('employee_leaves'));
     }
     abort(403);
 }
 public function approvedSickLeaves()
 {
     return EmployeeLeave::approved()->sick()->get();
 }