public function downloadSummaryPerEmployee(Employee $employee)
 {
     $leaves = $employee->employee_leaves()->certified()->orderBy('start_date', 'desc')->get();
     if ($leaves->isEmpty()) {
         flash()->warning('Employee has no regular leave yet.');
         return redirect()->back();
     }
     write_form(new \DNSCHumanResource\FormWriters\WriteEmployeeRegularLeaveSummary($leaves));
 }
 public function store(Request $request, Employee $employee)
 {
     // dd($request->all());
     if ($request->isMethod('PUT')) {
         $employee->approval_heirarchy->update($this->getApproval($request));
         flash()->success($employee->full_name . ' approval heirarchy was already saved and updated.');
     } else {
         $employee->approval_heirarchy()->create($this->getApproval($request));
         flash()->success($employee->full_name . ' approval heirarchy was already set.');
     }
     return redirect()->back();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $employee = Employee::findOrFail($id);
     $leaveCredits = $employee->leave_credit()->update($request->leave_credit);
     $accumulatedLeaves = $employee->accumulated_leave()->update($request->accumulated_leave);
     return response()->json(['leave_credit' => $employee->leave_credit, 'accumulated_leave' => $employee->accumulated_leave], 200);
 }
Ejemplo n.º 4
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($department_head) {
         $department_head->notifications()->create(['sent_to' => Employee::find($department_head->employee_id)->user->id, 'sent_by' => auth()->user()->id, 'subject' => 'New designation', 'message' => trans('notification.department_head-created', ['department' => $department_head->department->name, 'name' => auth()->user()->employee->fullName()]), 'icon' => 'institution', 'color' => 'warning']);
     });
 }
Ejemplo n.º 5
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     foreach (Employee::with('leave_credit')->get() as $employee) {
         $utility = $employee->utility;
         $employee->leave_credit->update(['force_leave' => $utility->can_file_force_leave ? 5 : 0, 'special_leave' => $utility->can_file_special_leave ? 3 : 0]);
     }
     $this->info('Leave credits successfully reset!');
 }
Ejemplo n.º 6
0
 public function show($id)
 {
     $training = Training::whereId($id)->with('employees.user')->firstOrFail();
     $employees = Employee::all()->map(function ($value) {
         return ['value' => $value->id, 'text' => $value->full_name];
     });
     $participants = $training->employees->keyBy('id')->keys();
     return response()->json(compact('training', 'employees', 'participants'), 200);
 }
Ejemplo n.º 7
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'));
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $id)
 {
     $employee = Employee::findOrFail($id);
     if ($employee) {
         $rating = $employee->personnel_performance;
         if ($rating) {
             $this->update($request, $rating);
         } else {
             $employee->personnel_performance()->create($request->all());
         }
         return response($employee->personnel_performance, 200);
     }
     return response('Error occured!', 500);
 }
 public function notifications()
 {
     $notifications = auth()->user()->notifications()->unread()->get();
     $user_notifications = collect();
     foreach ($notifications as $notification) {
         $user_notifications->push(['subject' => $notification->subject, 'message' => $notification->message, 'object_type' => $notification->object_type, 'object_id' => value(function () use($notification) {
             if ($notification->object_type == 'employee') {
                 return Employee::find($notification->object_id)->user->username;
             } else {
                 return $notification->object_id;
             }
         }), 'created_at' => $notification->created_at]);
     }
     return $user_notifications;
 }
Ejemplo n.º 10
0
 /**
  * @param Request $request
  */
 public function store(Request $request)
 {
     if ($this->validator($request->all())->fails()) {
         flash()->error('You have missing fields.');
         return redirect()->back();
     }
     $training = Training::create($request->all());
     if ($training) {
         if (is_array($request->participants)) {
             foreach ($request->input('participants') as $participant) {
                 try {
                     if ($participant == 'all') {
                         foreach (Employee::all() as $employee) {
                             TrainingParticipant::create(['training_id' => $training->id, 'employee_id' => $employee->id]);
                             // $training->employees()->attach($employee->id);
                         }
                         break;
                     } elseif (is_object(json_decode($participant))) {
                         $participant = json_decode($participant);
                         foreach (Department::find($participant->id)->users as $user) {
                             TrainingParticipant::create(['training_id' => $training->id, 'employee_id' => $user->employee->id]);
                             // $training->employees()->attach($user->employee->id);
                         }
                     } else {
                         TrainingParticipant::create(['training_id' => $training->id, 'employee_id' => $participant]);
                         // $training->employees()->attach($participant);
                     }
                 } catch (QueryException $ex) {
                 }
             }
         }
         flash()->success('Successfully added the trainings and seminar.');
     } else {
         flash()->error('Oopss! Something went wrong.');
     }
     return redirect()->back();
 }
 public function downloadSummaryPerEmployee(Employee $employee)
 {
     $leaves = $employee->employee_special_leaves()->certified()->orderBy('date_from', 'desc')->get();
     if ($leaves->isEmpty()) {
         flash()->warning('Special leave summary is empty.');
         return redirect()->back();
     }
     write_form(new \DNSCHumanResource\FormWriters\WriteEmployeeSpecialLeaveSummary($leaves));
 }
Ejemplo n.º 12
0
 public function forEmployeeIncludedInPds(Employee $employee)
 {
     return $employee->trainings()->includedInPds()->finishedTrainings()->get()->merge($employee->employee_training_programs);
 }
Ejemplo n.º 13
0
 public function downloadSummaryPerEmployee(Request $request, Employee $employee)
 {
     $travels = $employee->travel_orders()->certified()->get();
     if ($travels->isEmpty()) {
         flash()->warning('You have no certified travel orders yet.');
         return redirect()->back();
     }
     write_form(new \DNSCHumanResource\FormWriters\WriteEmployeeTravelOrderSummary($travels));
 }
Ejemplo n.º 14
0
 public function birthdays(Request $request)
 {
     $employees = Employee::whereBirthday(Carbon::today());
     return response()->json($employees, 200);
 }