@php $totalPayDays = 0; $totalNetSalary = 0; $totalEarningDerived = []; $dateWiseTotalPresent = []; foreach ($dateList as $date) { $dateWiseTotalPresent[$date] = 0; } $totalDeductionDerived = []; $totalEarningDerivedTotal = 0; $totalDeductionDerivedTotal = 0; $earningDerivedTotalArr = array_fill(0, count($earningDerivedComponents), 0); $deductionDerivedTotalArr = array_fill(0, count($deductionDerivedComponents), 0); @endphp
@php $totalCol = 17 + count($earningDerivedComponents) + count($deductionDerivedComponents) + count($dateList) ; @endphp @foreach ($earningDerivedComponents as $component) @endforeach @foreach ($deductionDerivedComponents as $component) @endforeach @foreach ($dateList as $date) @endforeach @for ($i = 0; $i < $totalCol; $i++) @endfor @foreach ($employees as $index => $employee) @php $dayCount = 0; $slipLogs = []; $earningDerivedTotal = 0; $deductionDerivedTotal = 0; $totalEarningDerived = []; $totalDeductionDerived = []; $attendanceSummary = $employee->attendanceSummary ->pluck('status', 'attendance_date') ->toArray(); $attendanceDayCount = $employee->attendanceSummary ->pluck('day_count', 'attendance_date') ->toArray(); $ctc = isset($employee->salarySlip->ctc_for_month) && $employee->salarySlip->ctc_for_month ? $employee->salarySlip->ctc_for_month : 0; $totalPayDays += $dayCount; if ( isset($employee->salarySlip->slipLogs) && !empty($employee->salarySlip->slipLogs) ) { $slipLogs = $employee->salarySlip->slipLogs->pluck( 'calculate_salary', 'type_id', ); } @endphp @foreach ($dateList as $index => $date) @php if ( isset($attendanceSummary[$date]) && isset($attendanceDayCount[$date]) ) { $dateWiseTotalPresent[$date] += $attendanceDayCount[$date]; $dayCount += $attendanceDayCount[$date]; } @endphp @endforeach @foreach ($earningDerivedComponents as $component) @php $earningDerived = isset($slipLogs[$component->id]) && $slipLogs[$component->id] ? round($slipLogs[$component->id], 2) : 0; $earningDerivedTotalArr[$component->id] = (isset($earningDerivedTotalArr[$component->id]) ? round($earningDerivedTotalArr[$component->id]) : 0) + $earningDerived; $earningDerivedTotal += $earningDerived; @endphp @endforeach @foreach ($deductionDerivedComponents as $component) @php $deductionDerived = isset($slipLogs[$component->id]) && $slipLogs[$component->id] ? $slipLogs[$component->id] : 0; $deductionDerivedTotalArr[$component->id] = ($deductionDerivedTotalArr[$component->id] ?? 0) + $deductionDerived; $deductionDerivedTotal += $deductionDerived; @endphp @endforeach @php $totalEarningDerivedTotal += $earningDerivedTotal; $totalDeductionDerivedTotal += $deductionDerivedTotal; $netSalary = $employee->salarySlip->net_salary ?? 0; $totalNetSalary += $netSalary; @endphp @endforeach @foreach ($dateList as $index => $date) @endforeach @foreach ($earningDerivedComponents as $component) @endforeach @foreach ($deductionDerivedComponents as $component) @endforeach