Route::get('/employee/servertime', array('before' => 'auth', 'as' => 'updateServerTime', 'uses' => 'EmployeesController@updateServerTime')); Route::get('/employee/serverdatetime', array('before' => 'auth', 'as' => 'getServerDateTime', 'uses' => 'EmployeesController@getServerDateTime')); Route::get('/employee/clocking', array('before' => 'auth', 'as' => 'employeeTimesheet', 'uses' => 'EmployeesController@showEmployeeTimesheet')); Route::post('/employee/clocking', array('as' => 'timeClocking', 'uses' => function () { $data = Input::all(); echo Session::put('timeclocking', $data['timeclocking']); $workShift = new Workshift(); $getWorkShift = $workShift->getWorkShiftByEmployeeId(Auth::user()->employee_id); $todayDate = date('Y-m-d'); $holiday = new Holiday(); $getHolidayByDate = $holiday->getHolidayByDate($todayDate); //var_dump($employeeClocking); //$employeeId = Auth::user()->employee_id; //$workShift = DB::table('work_shift')->where('employee_id', $employeeId)->get(); $timesheet = new Timesheet(); $getTimesheetById = $timesheet->getTimesheetById(Auth::user()->employee_id, date('Y-m-d')); $schedule = new Schedule(); $hasSchedule = $schedule->checkSchedule(Auth::user()->employee_id, date('Y-m-d')); $getSchedule = $schedule->getSchedule(Auth::user()->employee_id, date('Y-m-d')); //Deduction Model $deduction = new Deduction(); $hasNightShiftStartTimeThreshold = true; $nightShiftStartTimeThreshold = 5; //It should be bigger; //get schedule //Check if there is assign schedule today //if ( $hasSchedule && strtotime($getSchedule[0]->start_time) !== strtotime('00:00:00')) { if ($hasSchedule && strtotime($getSchedule[0]->start_time) !== '') { $hasTodaySchedule = true; } else { //check workShift table default schedule if no schedule in the schedule table
public function showAdminEmployeeTimesheet() { $employeeId = Session::get('userEmployeeId'); //$employeeId = Auth::user()->employee_id; $currentDate = date('Y-m-d'); $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); $workShift = new Workshift(); $employeeWorkShift = $workShift->getWorkShiftByEmployeeId($employeeId); $timesheet = new Timesheet(); $employeeTimesheet = $timesheet->getAllRows($employeeId); $getTimesheetById = $timesheet->getTimesheetById($employeeId, $currentDate); $timesheetPerMonth = $timesheet->getTimesheetPerMonth($employeeId, Session::get('dayDateArr')); $schedule = new Schedule(); $checkSchedule = $schedule->checkSchedule($employeeId, $currentDate); $getSchedule = $schedule->getSchedule($employeeId, $currentDate); //Admin view return View::make('employees.admin.clocking', ['employeeInfo' => $employeeInfo, 'employeeWorkShift' => $employeeWorkShift, 'employeeTimesheet' => $employeeTimesheet, 'getTimesheetById' => $getTimesheetById, 'timesheetPerMonth' => $timesheetPerMonth]); }