示例#1
0
function getUnderTimeHours($clockingIn, $clockingOut, $shiftStart, $shiftEnd)
{
    $employeeId = Session::get('userEmployeeId');
    $userId = Session::get('userId');
    $setting = new Setting();
    $employeeSetting = $setting->getEmployeeSettingByEmployeeId($employeeId);
    //$interval = getDateTimeDiffInterval($clockingOut, $shiftStart);
    $interval = getDateTimeDiffInterval($clockingOut, $clockingIn);
    $hh = (int) $interval->format('%h');
    $mm = (int) $interval->format('%i');
    $ss = (int) $interval->format('%s');
    $underTimeHours = getTimeToDecimalHours($hh, $mm, $ss);
    //number_format($hours, 2);
    return number_format($underTimeHours, 2);
}
         //return dd($getUserEmployee);*/
    //return View::make('admin.newschedule', ['employeeInfo' => $employeeInfo, 'getUserEmployee' => $getUserEmployee]);
    return View::make('admin.newschedule', ['employeeInfo' => $employeeInfo, 'newEmployeeId' => $newEmployeeId]);
}));
Route::post('/admin/user/new/schedule/', array('as' => 'adminProcessUserNewSchedule', 'uses' => function () {
    $data = Input::all();
    $rules = array('start_time' => 'required', 'end_time' => 'required', 'rest_day' => 'required');
    $validator = Validator::make($data, $rules);
    if ($validator->fails()) {
        $messages = $validator->messages();
        return Redirect::to('/admin/user/new/' . $data['new_employee_id'] . '/schedule/')->withErrors($validator);
        //return  Redirect::route('adminProcessUserNewSchedule')->withErrors($validator);
    } else {
        echo $startTime = date('H:i:s', strtotime(Input::get('start_time') . ' ' . Input::get('start_ampm')));
        echo $endTime = date('H:i:s', strtotime(Input::get('end_time') . ' ' . Input::get('end_ampm')));
        $interval = getDateTimeDiffInterval($startTime, $endTime);
        $hh = (int) $interval->format('%h');
        $mm = (int) $interval->format('%i');
        $ss = (int) $interval->format('%s');
        echo $hoursPerDay = (double) getTimeToDecimalHours($hh, $mm, $ss);
        DB::table('work_shift')->insert(array('employee_id' => (int) $data['new_employee_id'], 'rest_day' => strtolower($data["rest_day"]), 'hours_per_day' => $hoursPerDay, 'start_time' => $startTime, 'end_time' => $endTime));
        //return Redirect::to('/admin/user/new/schedule/');
        return Redirect::route('adminDashboard');
    }
}));
Route::get('/admin/user/{employeeId}/edit', array('as' => 'adminUserDelete', 'uses' => function ($employeeId) {
    //return $employeeId;
    /*
    //$employeeId = Auth::user()->employee_id;
    //$employeeId = Session::get('userEmployeeId');	
    //$userId = Session::get('userId');
            ?>
</td>
								<td><?php 
            echo $clockingStatus;
            ?>
</td>
								</tr>
							
							<?php 
        } elseif (!empty($getWorkShiftByDayOfTheWeek)) {
            ?>

								<?php 
            $scheduled['start_time'] = $getWorkShiftByDayOfTheWeek[0]->start_time;
            $scheduled['end_time'] = $getWorkShiftByDayOfTheWeek[0]->end_time;
            $interval = getDateTimeDiffInterval($scheduled['start_time'], $scheduled['end_time']);
            $days = $interval->format('%a');
            $days = (int) $days;
            if ($days !== 0) {
                $hhToDays = $days * 24;
                $hh = (int) $hhToDays;
            } else {
                $hh = (int) $interval->format('%h');
            }
            $mm = (int) $interval->format('%i');
            $ss = (int) $interval->format('%s');
            $totalHours = number_format(getTimeToDecimalHours($hh, $mm, $ss) - $breakTime, 2);
            //number_format($hours, 2);
            ?>

								<tr>