@extends('layouts.header_admin') @section('css') @endsection @section('content')
@if(count($employees) > 0) @if($rates != null)
@csrf
@if(!empty($rates) && $rates->daily > 0) @endif @if($rates->specialholiday != "undefined" && $rates->specialholiday > 0) @endif @if($rates->holiday != "undefined" && $rates->holiday > 0) @endif @if($rates->nightshift != "undefined" && $rates->nightshift > 0) @endif @php $c = 1; @endphp @foreach($employees as $key => $employee) @php $day_works = 0; $working_hours = 0; $hours_tardy = 0; $overtime = 0; $special_holiday = 0; $legal_holiday = 0; $night_diff = 0; $basic_pay = 0; @endphp @foreach($date_range as $date) @php $holi = $holidays->pluck('holiday_date'); $holiday = $holidays->where('holiday_date',$date)->first(); if($holiday != null) { if($holiday->holiday_type == "Special Holiday") { $special_holiday = $special_holiday+1; } else { $legal_holiday = $legal_holiday+1; } } $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) && ($time_out != null)) { $day_works = $day_works+1; $working = get_working_hours($time_out->time,$time_in->time); if($rates->late != null) { $working = 8; } if($working > 8) { $working_hours = $working_hours + 8; } else { $working_hours = $working_hours + $working; } if($schedule != null) { if($rates->late == 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 @php if(count($employee->rate) >0) { $rate_d = ($employee->rate)->first(); $rate_employee = $rate_d->daily; } else { $rate_employee = $rate; } $basic_pay = ($rate_employee/8)*$working_hours; $tardy_amount = ($rate_employee/8/60)*$hours_tardy; $overtime_amount = ($rate_employee*1.25)*$overtime; $nightdiff_amount = ($rate_employee*.1)*$night_diff; $special_holiday_amount = ($rate_employee * .3) * $special_holiday; $legal_holiday_amount = $legal_holiday * $rate_employee; $gross_pay = $basic_pay - $tardy_amount + $overtime_amount + $nightdiff_amount +$special_holiday_amount +$legal_holiday_amount; $other_income_non_tax = 0; $sss = 0; $philhealth = 0; $pagibig = 0; $sss_er = 0; if($basic_pay >= 1) { $sssData = $sssTable->where('from_range','<=',$gross_pay)->where('to_range', '>=', $gross_pay)->first(); if($sssData != null) { $sss = $sssData->ee; $sss_er = $sssData->er; } if($rates->gross_pay != 0) { $philhealth = ((($rate_employee*313*.04)/12)/2); $philhealth = 200; $pagibig = 200.00; } else { $philhealth = ((($rate_employee*313*.05)/12)/2); $philhealth = $rates->philhealth; $pagibig = $rates->pagibig; } } $total_deduction = $sss + $philhealth + $pagibig; $net = $gross_pay - $total_deduction + $other_income_non_tax; @endphp @if($working_hours > 0) @if(!empty($rates) && $rates->daily > 0) @endif @if($rates->specialholiday != "undefined" && $rates->specialholiday > 0) @endif @if($rates->holiday != "undefined" && $rates->holiday > 0) @endif @if($rates->nightshift != "undefined" && $rates->nightshift > 0) @endif @endif @endforeach
{{$storeData}}
Payroll Period of {{date('M d, Y',strtotime($from))}} to {{date('M d, Y',strtotime($to))}} @if(count($employees) >0)
Holidays
@foreach($holidays as $holiday) {{$holiday->holiday_name}} - {{date('M d',strtotime($holiday->holiday_date))}} - {{$holiday->holiday_type}}
@endforeach
@endif
# Employee NameDaily Rate Daily Rate/Hour Days Work Hours Work Basic Pay Hours Tardy Hours Tardy Basic Overtime Amount OvertimeSpecial holiday Amount Special holidayLegal holiday Amount Legal HolidayNight Diff Amount Night DiffGross Pay Other Income Non Taxable SSS Contribution NHIP Contribution HDMF Contribution Other Deductions Total Deductions NET PAY ATM
{{$c++}} {{$employee->emp_name}}{{number_format($rate_employee,2)}} {{number_format($rate_employee/8,2)}} {{number_format($day_works,2)}} {{number_format($working_hours,2)}} {{number_format($basic_pay,2)}} {{number_format($hours_tardy,2)}} {{number_format($tardy_amount,2)}} {{number_format($overtime,2)}} {{number_format($overtime_amount,2)}} {{number_format($special_holiday,2)}} {{number_format($special_holiday_amount,2)}} {{number_format($legal_holiday,2)}} {{number_format($legal_holiday_amount,2)}} {{number_format($night_diff,2)}} {{number_format($nightdiff_amount,2)}} {{number_format($gross_pay,2)}} {{number_format($other_income_non_tax,2)}} {{number_format($sss,2)}} {{number_format($philhealth,2)}} {{number_format($pagibig,2)}} 0.00 {{number_format($total_deduction,2)}} {{number_format($net,2)}}
@else
No rates found for {{$storeData}}
Please click {{$storeData}}, select store then set rates.
@endif @endif
@php function get_working_hours($timeout,$timein) { return round((((strtotime($timeout) - strtotime($timein)))/3600),2); } 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 @endsection @section('js') @endsection