@php $totalColspan = 16 + (isset($dateList) ? count($dateList) : 0) + (isset($leaveTypes) ? count($leaveTypes) : 0); $totalLeaveCounts = []; $totalWeekoff = 0; $totalAbsentDays = 0; $totalHdDays = 0; $totalCoDays = 0; $totalPhDays = 0; $totalScoDays = 0; $totalPaidDays = 0; $totalPresentWorkDays = 0; $totalPresentDays = array_fill(0, count($dateList), 0); @endphp
@if (!empty($contractorName)) @endif @if (!empty($locationName)) @endif @if (!empty($employeeType)) @endif @if (!empty($status)) @endif @if (!empty($departmentName)) @endif @if(!$showColumns) @endif @if($showColumns) @endif @foreach ($dateList as $date) @endforeach @if(!$showColumns) @endif @foreach ($leaveTypes as $leaveType) @endforeach @if($showColumns) @endif @foreach ($totalEmployees as $key => $employee) @php $payrollProcess = new \App\Lib\Services\PayrollProcess(); $attendanceData = $payrollProcess->getPayrollAttendanceData($organization, $employee, $month, $year); $atSummary = $employee->getAttendanceSummaryList($month, $year); $leavesData = $payrollProcess->getMonthlyLeaves($employee, $month, $year); $present = @$attendanceData['present']; $absent = @$attendanceData['absent']; $weekOff = @$attendanceData['weekOffs']; $totalHd = @$attendanceData['halfDays']; $totalCo = @$attendanceData['compensations']; $totalPh = @$attendanceData['holidays']; $totalSco = @$attendanceData['scoDays']; $payDay = @$attendanceData['totalPaidDays']; $totalMonthlyHrs = @$attendanceData['payableHours']; $totalMonthlyOvertime = @$attendanceData['totalOvertime']; $pow = @$attendanceData['pow']; $poh = @$attendanceData['poh']; $totalPaidDay = ($payDay + $totalCo + $totalSco) - ($totalPh + $totalHd); // Accumulate totals $totalHdDays += $totalHd; $totalCoDays += $totalCo; $totalPhDays += $totalPh; $totalScoDays += $totalSco; $totalAbsentDays += $absent; $totalPresentWorkDays += $present; $totalPaidDays += $totalPaidDay; $totalWeekoff += $weekOff; @endphp @if(!$showColumns) @endif @if($showColumns) @endif @foreach ($dateList as $index => $date) @php $attendance = $atSummary[$date] ?? null; $st = $attendance->status ?? '--'; if ($st === 'P') { $totalPresentDays[$index]++; } @endphp @endforeach @if(!$showColumns) @endif @foreach ($leaveTypes as $leaveType) @php $leaveDetail = $employee->leaves->flatMap->leaveDetail->firstWhere('leave_type_id', $leaveType->id) ?? null; if ($leaveDetail) { $totalLeaveCounts[$leaveType->id] = ($totalLeaveCounts[$leaveType->id] ?? 0) + $leaveDetail->total_leave_count; } @endphp @endforeach @if($showColumns) @endif @endforeach @foreach ($totalPresentDays as $presentCount) @endforeach @if(!$showColumns) @endif @foreach ($leaveTypes as $leaveType) @endforeach