@extends('layouts.header_admin') @section('css') @endsection @section('content') @if(session()->has('message'))
{{ session()->get('message') }}
@endif
{{-- New Laborer --}}
@foreach($employees as $employee) @php $day_works = 0; $working_hours = 0; $hours_tardy = 0; $overtime = 0; $special_holiday = 0; $legal_holiday = 0; $night_diff = 0; @endphp @foreach($date_range as $index => $date) @php $time_in = (($employee->attendances)->where('status','time-in')->where('date',$date))->first(); $time_out = (($employee->attendances)->where('status','time-out')->where('date', $date))->first(); $schedule = (($employee->schedules)->where('date',$date))->first(); if($time_in != null) { $day_works = $day_works+1; }; if(($time_in != null) && ($time_out != null)) { $working = get_working_hours($time_out->time,$time_in->time); if($working > 8) { $working_hours = $working_hours + 8; } else { $working_hours = $working_hours + $working; } if($schedule != null) { $late = get_late($schedule,$time_in->time); $hours_tardy = $hours_tardy+$late; $night_difference = night_difference(strtotime($time_in->time),strtotime($time_out->time),$schedule); $night_diff = $night_diff+$night_difference; } } @endphp @endforeach @if($working_hours > 0) @endif @endforeach
Employee Name Days Work Hours Work Hours Tardy Overtime Special holiday Legal holiday Night Diff
{{$employee->emp_name}} {{number_format($day_works,2)}} {{$working_hours}} {{$hours_tardy}} {{$overtime}} {{$special_holiday}} {{$legal_holiday}} {{$night_diff}}
@foreach($employees as $employee) @include('users.view_attedances') @endforeach {{--

Employees

@foreach($employees as $employee) @foreach($date_range as $date) @php $time_in = (($employee->attendances)->where('status','time-in')->where('date',$date))->first(); $time_out = (($employee->attendances)->where('status','time-out')->where('date',$date))->first(); $schedule = (($schedules)->where('emp_id',$employee->_id)->where('date',$date))->first(); @endphp @endforeach
{{$employee->emp_id}} - {{$employee->emp_name}}
Date Schedule Time In Time Out Working Hrs Lates Undertime Overtime Night Diff
{{date('M d, Y - l',strtotime($date))}} {{($schedule != null) ? date('h:i a',strtotime($schedule->time_in)). "-".date('h:i a',strtotime($schedule->time_out))." Working Hrs : ".$schedule->total_hours : "No Schedule"}} {{($time_in != null) ? date('h:i a',strtotime($time_in->time)) : ""}} {{($time_out != null) ? date('h:i a',strtotime($time_out->time)) : ""}} {{(($time_in != null) && ($time_out != null) ) ? get_working_hours($time_out->time,$time_in->time)." hrs" : "0.00 hrs" }} {{((($time_in != null) && ($time_out != null) && ($schedule != null)) ) ? get_late($schedule,$time_in->time)." hrs" : "0.00 hrs" }} 0.00 0.00 {{((($time_in != null) && ($time_out != null) && ($schedule != null)) ) ? night_difference(strtotime($time_in->time),strtotime($time_out->time),$schedule)." hrs" : "0.00 hrs"}}
@endforeach
--}} @endsection @php function get_working_hours($timeout,$timein) { return round((((strtotime($timeout) - strtotime($timein)))/3600)); } function get_late($schedule,$timein) { $startTime = new DateTime($timein); $timeInTimeOnly = $startTime->format('H:i:s'); $endTime = new DateTime($schedule->time_in); $ScheduledtimeInTimeOnly = $endTime->format('H:i:s'); $formattedDateTimeIn = new DateTime($timeInTimeOnly); if ($timeInTimeOnly > $ScheduledtimeInTimeOnly) { $interval = $formattedDateTimeIn->diff(new DateTime ($ScheduledtimeInTimeOnly)); $hours = $interval->h; $minutes = $interval->i; $lateMinutes = $hours * 60 + $minutes; } else { $lateMinutes = 0; } return $lateMinutes; } function night_difference($start_work,$end_work,$schedule) { $startTime = new DateTime($schedule->time_in); $startTimeTimeOnly = $startTime->format('H:i:s'); $start_night = mktime('22','00','00',date('m',$start_work),date('d',$start_work),date('Y',$start_work)); $end_night = mktime('06','00','00',date('m',$start_work),date('d',$start_work) + 1,date('Y',$start_work)); if($startTime <= new DateTime("22:00:00")){ return 0; } else { if($start_work >= $start_night && $start_work <= $end_night) { if($end_work >= $end_night) { return ($end_night - $start_work) / 3600; } else { return ($end_work - $start_work) / 3600; } } elseif($end_work >= $start_night && $end_work <= $end_night) { if($start_work <= $start_night) { return ($end_work - $start_night) / 3600; } else { return ($end_work - $start_work) / 3600; } } else { if($start_work < $start_night && $end_work > $end_night) { return ($end_night - $start_night) / 3600; } return 0; } } } @endphp @section('js') @endsection