/**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     $positions = Positions::all();
     $shifts = Shifts::all();
     $data = array('positions_all' => $positions, 'shifts' => $shifts);
     return view('auth.register')->with($data);
 }
 public function addSchedule(Request $request)
 {
     $shifts = Shifts::all();
     foreach ($shifts as $shift) {
         if (strtotime($shift->shift_from) == strtotime($request->input('shift_from'))) {
             if (strtotime($shift->shift_to) == strtotime($request->input('shift_to'))) {
                 $status = "Error: Schedule is already been in the database.";
                 break;
             } else {
                 $status = "Success!";
             }
         } else {
             $status = "Success!";
         }
     }
     if ($status == "Success!") {
         $result = Shifts::create(['shift_from' => $request->input('shift_from'), 'shift_to' => $request->input('shift_to')]);
         if ($result) {
             $status = "Success!";
         } else {
             $status = "Failed!";
         }
     }
     return redirect('/accounts')->with('status', $status);
 }
 public function viewForm($type, $id)
 {
     $inboxNotif = $this->inboxNotif();
     $profileImage = $this->getImage();
     $positions = $this->position();
     $approvalNotif = $this->approvalNotif();
     $count = $this->forms();
     $dataFirst = array('inboxNotif' => $inboxNotif, 'profileImage' => $profileImage, 'positions' => $positions, 'approvalNotif' => $approvalNotif, 'count' => $count);
     if ($type == 1) {
         $contents = ExitPass::where('id', $id)->get();
         $user_position = Auth::user()->position_id;
         $empDepartment = Positions::find($user_position)->departments;
         $HRs = DB::table("positions")->join('users', 'users.position_id', '=', 'positions.id')->where('positions.department_id', 1)->get();
         $Supervisors = User::where('permissioners', 1)->get();
         $PMs = User::where('permissioners', 2)->get();
         $CompanyReps = User::where('permissioners', 3)->get();
         $dataSecond = array('title' => "Edit Exit Pass", 'contents' => $contents, 'HRs' => $HRs, 'Supervisors' => $Supervisors, 'PMs' => $PMs, 'CompanyReps' => $CompanyReps, 'empDepartment' => $empDepartment);
         $data = array_merge($dataFirst, $dataSecond);
         return view('user.inboxExitApproval')->with($data);
     } elseif ($type == 2) {
         $contents = Leaves::where('id', $id)->get();
         $user_position = Auth::user()->position_id;
         $empDepartment = Positions::find($user_position)->departments;
         $HRs = DB::table("positions")->join('users', 'users.position_id', '=', 'positions.id')->where('positions.department_id', 1)->get();
         $Supervisors = User::where('permissioners', 1)->get();
         $dataSecond = array('title' => "Edit Request for Leave of Absence", 'contents' => $contents, 'HRs' => $HRs, 'Supervisors' => $Supervisors, 'empDepartment' => $empDepartment);
         $data = array_merge($dataFirst, $dataSecond);
         return view('user.inboxLeaveApproval')->with($data);
     } elseif ($type == 3) {
         $contents = Change::where('id', $id)->get();
         $user_position = Auth::user()->position_id;
         $empDepartment = Positions::find($user_position)->departments;
         $permissioners = User::where('permissioners', '!=', 0)->get();
         $HRs = DB::table("positions")->join('users', 'users.position_id', '=', 'positions.id')->where('positions.department_id', 1)->get();
         $Supervisors = User::where('permissioners', 1)->get();
         $PMs = User::where('permissioners', 2)->get();
         $CompanyReps = User::where('permissioners', 3)->get();
         $currentShift = Shifts::where('id', Auth::user()->shift_id)->get();
         $shifts = Shifts::all();
         foreach ($currentShift as $cur) {
             $currentShift = date('h:i A', strtotime($cur->shift_from)) . ' to ' . date('h:i A', strtotime($cur->shift_to));
         }
         $dataSecond = array('title' => "Edit Change Schedule", 'contents' => $contents, 'permissioners' => $permissioners, 'HRs' => $HRs, 'Supervisors' => $Supervisors, 'PMs' => $PMs, 'CompanyReps' => $CompanyReps, 'empDepartment' => $empDepartment, 'currentShift' => $currentShift, 'shifts' => $shifts);
         $data = array_merge($dataFirst, $dataSecond);
         return view('user.inboxChangeApproval')->with($data);
     } elseif ($type == 4) {
         $contents = Overtime::where('id', $id)->get();
         $user_position = Auth::user()->position_id;
         $empDepartment = Positions::find($user_position)->departments;
         $Supervisors = User::where('permissioners', 1)->get();
         $dateTime = DateTimeOvertime::where('overtime_id', $id)->get();
         $shift = Shifts::find(Auth::user()->shift_id);
         $var = 0;
         $dataSecond = array('title' => "Edit Overtime Authorization", 'contents' => $contents, 'empDepartment' => $empDepartment, 'Supervisors' => $Supervisors, 'dateTime' => $dateTime, 'var' => $var, 'shift' => $shift);
         $data = array_merge($dataFirst, $dataSecond);
         // dd($data);
         return view('user.inboxOverApproval')->with($data);
     } else {
         $status = "Nothing to Show.";
         return redirect('inbox')->with('status', $status);
     }
 }
 public function changeSchedule()
 {
     $inboxNotif = $this->inboxNotif();
     $approvalNotif = $this->approvalNotif();
     $profileImage = $this->getImage();
     $positions = $this->position();
     $id = Auth::user()->position_id;
     $permissioners = User::where('permissioners', '!=', 0)->get();
     $user_position = Auth::user()->position_id;
     $empDepartment = Positions::find($user_position)->departments;
     $HRs = DB::table("positions")->join('users', 'users.position_id', '=', 'positions.id')->where('positions.department_id', 1)->get();
     $Supervisors = User::where('permissioners', 1)->get();
     $PMs = User::where('permissioners', 2)->get();
     $CompanyReps = User::where('permissioners', 3)->get();
     $currentShift = Shifts::where('id', Auth::user()->shift_id)->get();
     foreach ($currentShift as $cur) {
         $currentShift = date('h:i A', strtotime($cur->shift_from)) . ' to ' . date('h:i A', strtotime($cur->shift_to));
     }
     $shifts = Shifts::all();
     $count = $this->forms();
     $data = array('title' => 'Change Schedule', 'positions' => $positions, 'HRs' => $HRs, 'Supervisors' => $Supervisors, 'PMs' => $PMs, 'CompanyReps' => $CompanyReps, 'permissioners' => $permissioners, 'profileImage' => $profileImage, 'inboxNotif' => $inboxNotif, 'approvalNotif' => $approvalNotif, 'empDepartment' => $empDepartment, 'shifts' => $shifts, 'currentShift' => $currentShift, 'count' => $count);
     return view('changeSchedule')->with($data);
 }