@once @endonce @php $detailRows = is_array($detailRows ?? null) ? $detailRows : []; $detailOtColumns = is_array($detailOtColumns ?? null) ? $detailOtColumns : []; $detailProfil = $detailProfil ?? $profil ?? null; $publicView = (bool) ($publicView ?? false); $paymentView = !$publicView && request()->query('view') === 'payment'; $hidePaymentModeButton = (bool) ($hidePaymentModeButton ?? false); $paymentHourlyRate = (float) ($paymentHourlyRate ?? 0); $paymentOvertimeRate = (float) ($paymentOvertimeRate ?? 0); $segmentView = request()->query('view', 'segment') !== 'legacy'; $segmentAutoOtEnabled = collect($detailRows)->contains(fn ($row) => (bool) ($row['auto_ot_without_spl'] ?? false)); $dayTypeLabelResolver = static fn (string $dayType): string => match ($dayType) { 'holiday_special' => 'Holiday Special', 'holiday' => 'Holiday', 'weekend' => 'Weekend', default => 'Workday', }; $specialPaymentModeLabelResolver = static fn (?string $mode): string => match (strtolower(trim((string) $mode))) { 'payroll' => 'Gabung Payroll', 'separate' => 'Bayar Terpisah', default => '-', }; $emergencyBaselineLabelResolver = static fn (?string $mode): string => match (strtolower(trim((string) $mode))) { 'after_normal_shift' => 'Setelah jam normal selesai', 'after_normal_or_existing_ot' => 'Setelah jam normal / OT existing selesai', default => trim((string) $mode) !== '' ? trim((string) $mode) : '-', }; $emergencyMultiplierLabelResolver = static fn (?string $profile): string => match (strtolower(trim((string) $profile))) { 'default' => 'Default Emergency x2', default => trim((string) $profile) !== '' ? trim((string) $profile) : '-', }; $workTargetBonusSourceLabelResolver = static fn (?string $source): string => match (strtolower(trim((string) $source))) { 'manual_override' => 'Override manual', 'remaining_target' => 'Sisa target aktual', default => trim((string) $source) !== '' ? trim((string) $source) : '-', }; $dayTypeRowClassResolver = static fn (string $dayType): string => match ($dayType) { 'holiday_special' => 'row-holiday-special', 'holiday' => 'row-holiday', 'weekend' => 'row-weekend', default => '', }; $isHolidayLikeDayType = static fn (string $dayType): bool => in_array($dayType, ['holiday', 'holiday_special'], true); $sumPlannedHours = 0.0; $sumActualEffectiveDisplay = 0.0; $sumNormalHours = 0.0; $sumHk = 0.0; $prorataPeriodWorkdayHk = 0; $prorataAbsentWorkdayHk = 0; $prorataHolidayWeekday = 0; $prorataCuti = 0; $prorataSakit = 0; $payableLeaveDays = 0; $payableLeaveHours = 0.0; $prorataIzin = 0; $prorataAlpha = 0; $realizedRecognizedHours = 0.0; $realizedTargetHours = 0.0; $jamTdkMasuk = 0.0; $sumOvertime = 0.0; $sumWeightedOvertime = 0.0; $otTotals = []; $sumOvertimeBefore = 0.0; $sumOvertimeBeforeWeighted = 0.0; $sumOvertimeAfter = 0.0; $sumNoRest1Hours = 0.0; $sumNoRest2Hours = 0.0; $detailPayrollBasis = is_array($payrollBasis ?? null) ? $payrollBasis : []; $isDailySalaryOverride = (bool) ($isDailySalaryOverride ?? false); $detailPayrollSettings = is_array($detailProfil?->payroll_settings ?? null) ? (array) $detailProfil->payroll_settings : []; $isProrataSalary = (bool) ($detailPayrollSettings['prorata_salary'] ?? false); $hkHoursPerDay = (float) ($detailPayrollBasis['hours_per_day'] ?? ($detailProfil->jam_per_hari ?? 8)); $hkBaseHours = (float) ($detailPayrollBasis['monthly_hour_base'] ?? (((float) ($detailProfil->hk_basis ?? 21)) * $hkHoursPerDay)); $hkBasis = $hkHoursPerDay > 0 ? ($hkBaseHours / $hkHoursPerDay) : (float) ($detailProfil->hk_basis ?? 21); $basisProfileLabel = trim((string) ($detailPayrollBasis['profil_gaji_code'] ?? '') . ' - ' . (string) ($detailPayrollBasis['profil_gaji_name'] ?? ''), ' -'); $fmt = function ($v) { return number_format((float) $v, 2, ',', '.'); }; $prorateSummaryLabel = $isProrataSalary ? 'HK Efektif Payroll Periode' : ($isDailySalaryOverride ? 'Prorate Hari' : 'Proyeksi Jam Masuk Normal Periode (' . $fmt($hkBaseHours) . ' - Total Jam Kurang Periode)'); $prorateSmallLabel = $isProrataSalary ? 'HK periode prorata' : ($isDailySalaryOverride ? 'Prorate hari' : 'Jam normal'); $resolveAttendanceDayCredit = static fn (array $detailRow, float $hkHoursPerDay, $profil): array => \App\Modules\AttendanceReview\Services\AttendanceDayCreditResolver::resolve($detailRow, $profil, $hkHoursPerDay); $realizedCutoffDate = \Carbon\Carbon::today(config('app.timezone'))->subDay()->toDateString(); $isRosterDetail = collect($detailRows)->contains(fn ($row) => in_array(strtolower(trim((string) ($row['schedule_badge_label'] ?? ''))), ['shift', 'off', 'belum ada shift'], true)); // Use the same payable gate as payroll: approved SPL or the matching auto-OT rule. $isOvertimeAuthorized = static function (array $row, string $segment): bool { return (bool) ($row['spl_approved'] ?? false) || (bool) ($row['auto_overtime_' . $segment] ?? $row['auto_ot_without_spl'] ?? false); }; $isNoRestAuthorized = static function (array $row, string $segment): bool { return (bool) ($row['spl_approved'] ?? false) || (bool) ($row['auto_no_rest_' . $segment] ?? false); }; $payrollEligibleDetailRows = $paymentView ? collect($detailRows)->filter(fn ($row) => (bool) ($row['is_approved'] ?? false) || (bool) ($row['leave_is_payable'] ?? false))->values()->all() : $detailRows; foreach ($payrollEligibleDetailRows as $row) { $sumPlannedHours += (float) ($row['planned_hours'] ?? 0); $summaryDayType = (string) ($row['day_type'] ?? 'workday'); $summaryIn = trim((string) ($row['in_time'] ?? '-')); $summaryOut = trim((string) ($row['out_time'] ?? '-')); $summaryHasActual = $summaryIn !== '' && $summaryIn !== '-' && $summaryOut !== '' && $summaryOut !== '-'; $summaryPlannedSpan = 0.0; if (in_array($summaryDayType, ['holiday', 'holiday_special', 'weekend'], true) && ($row['planned_in_time'] ?? '-') !== '-' && ($row['planned_out_time'] ?? '-') !== '-') { $summaryPlannedSpan = (float) (strtotime((string) $row['planned_out_time']) - strtotime((string) $row['planned_in_time'])) / 3600; if ($summaryPlannedSpan < 0) $summaryPlannedSpan += 24; } $summarySourceHours = $summaryDayType === 'weekend' && $summaryPlannedSpan > 0 ? $summaryPlannedSpan : (in_array($summaryDayType, ['holiday', 'holiday_special', 'weekend'], true) && (float) ($row['overtime_hours_gross'] ?? 0) > 0 ? (float) $row['overtime_hours_gross'] : (float) ($row['actual_hours'] ?? 0)); $sumActualEffectiveDisplay += max(0.0, $summarySourceHours - (($summaryHasActual && $summarySourceHours > 0) ? (float) ($row['break_hours'] ?? 0) : 0.0)); $sumNormalHours += (float) ($row['normal_hours'] ?? 0); $rowSpecialCode = strtolower((string) ($row['special_overtime_code'] ?? '')); $rowSpecialMode = strtolower((string) ($row['special_overtime_mode'] ?? '')); $isCarryBonusRow = $rowSpecialCode === 'continues_work_day' && str_contains($rowSpecialMode, 'carry'); if (!$isCarryBonusRow) { $beforeHoursRow = $isOvertimeAuthorized((array) $row, 'before') ? max(0.0, (float) ($row['overtime_before_hours'] ?? 0)) : 0.0; $beforeWeightedRow = $isOvertimeAuthorized((array) $row, 'before') ? max(0.0, (float) ($row['overtime_before_weighted_hours'] ?? 0)) : 0.0; $afterHoursRow = $isOvertimeAuthorized((array) $row, 'after') ? max(0.0, (float) ($row['overtime_after_hours'] ?? 0)) : 0.0; $afterWeightedRow = $isOvertimeAuthorized((array) $row, 'after') ? max(0.0, (float) ($row['overtime_after_weighted_hours'] ?? 0)) : 0.0; $noRest1Row = $isNoRestAuthorized((array) $row, '1') ? max(0.0, (float) ($row['no_rest_normal_included_minutes'] ?? 0) / 60) : 0.0; $noRest2Row = $isNoRestAuthorized((array) $row, '2') ? max(0.0, (float) ($row['no_rest_skip_break_minutes'] ?? 0) / 60) : 0.0; $sumOvertime += $beforeHoursRow + $afterHoursRow + $noRest1Row + $noRest2Row; $sumWeightedOvertime += $beforeWeightedRow + $afterWeightedRow + $noRest1Row + $noRest2Row; $sumOvertimeAfter += $afterHoursRow; $sumOvertimeBefore += $beforeHoursRow; $sumOvertimeBeforeWeighted += $beforeWeightedRow; $sumNoRest1Hours += $noRest1Row; $sumNoRest2Hours += $noRest2Row; } if (!empty($row['ot_dynamic']) && is_array($row['ot_dynamic'])) { foreach ($row['ot_dynamic'] as $k => $v) { if (!isset($otTotals[$k])) { $otTotals[$k] = 0.0; } $otTotals[$k] += (float) $v; } } $dayCredit = $resolveAttendanceDayCredit((array) $row, $hkHoursPerDay, $detailProfil); $rowSpecialCode = strtolower((string) ($row['special_overtime_code'] ?? '')); $rowSpecialMode = strtolower((string) ($row['special_overtime_mode'] ?? '')); $isCarryBonusRow = $rowSpecialCode === 'continues_work_day' && str_contains($rowSpecialMode, 'carry'); $rowHkFlag = $isCarryBonusRow ? 1 : (int) ($dayCredit['hk_flag'] ?? 0); $rowHkValue = $isCarryBonusRow ? 1.0 : (float) ($dayCredit['hk_value'] ?? $rowHkFlag); $sumHk += $isProrataSalary ? $rowHkValue : $rowHkFlag; if ($isProrataSalary && (string) ($row['day_type'] ?? 'workday') === 'workday') { $prorataPeriodWorkdayHk++; if ($rowHkFlag !== 1) { $prorataAbsentWorkdayHk++; } } $rowText = strtolower((string) ($row['leave_tag_label'] ?? '') . ' ' . (string) ($row['reason'] ?? '')); if ((bool) ($row['leave_is_payable'] ?? false)) { $payableLeaveDays++; $payableLeaveHours += max(0.0, (float) ($row['planned_hours'] ?? 0)); } if ($isProrataSalary && in_array((string) ($row['day_type'] ?? ''), ['holiday', 'holiday_special'], true) && !in_array(strtolower((string) ($row['day_name'] ?? '')), ['sabtu', 'minggu', 'saturday', 'sunday'], true)) { $prorataHolidayWeekday++; } if ($isProrataSalary && str_contains($rowText, 'cuti')) $prorataCuti++; if ($isProrataSalary && str_contains($rowText, 'sakit')) $prorataSakit++; if ($isProrataSalary && str_contains($rowText, 'izin')) $prorataIzin++; if ($isProrataSalary && (string) ($row['day_type'] ?? '') === 'workday' && (int) ($dayCredit['hk_flag'] ?? 0) !== 1 && !str_contains($rowText, 'cuti') && !str_contains($rowText, 'sakit') && !str_contains($rowText, 'izin')) $prorataAlpha++; if ((string) ($row['work_date'] ?? '') <= $realizedCutoffDate && (int) ($dayCredit['hk_flag'] ?? 0) === 1) { $realizedTargetHours += $hkHoursPerDay; $realizedRecognizedHours += min($hkHoursPerDay, max(0.0, (float) ($dayCredit['recognized_hours'] ?? 0))); } } $totalJamHk = $hkBaseHours; $deficitRows = []; foreach ($detailRows as $row) { $dayCredit = $resolveAttendanceDayCredit((array) $row, $hkHoursPerDay, $detailProfil); if ((int) ($dayCredit['hk_flag'] ?? 0) !== 1 && (float) ($dayCredit['deficit_hours'] ?? 0) <= 0) { continue; } $normalHours = max(0.0, (float) ($dayCredit['recognized_hours'] ?? 0)); $deficitHours = max(0.0, (float) ($dayCredit['deficit_hours'] ?? 0)); if ($deficitHours <= 0) { continue; } $deficitRows[] = [ 'work_date' => (string) ($row['work_date'] ?? '-'), 'day_name' => (string) ($row['day_name'] ?? '-'), 'day_type' => (string) ($row['day_type'] ?? 'workday'), 'leave_tag_label' => (string) ($row['leave_tag_label'] ?? ''), 'normal_hours' => $normalHours, 'deficit_hours' => $deficitHours, 'reason' => (string) ($row['reason'] ?? '-') . (!empty($dayCredit['special_bonus']) ? ' | Bonus HK ContinuesNextDay' : ''), ]; } if ($isProrataSalary && $isRosterDetail) { $rosterOnRows = collect($detailRows)->filter(function ($row): bool { $badge = strtolower(trim((string) ($row['schedule_badge_label'] ?? ''))); return $badge === 'shift' && (float) ($row['planned_hours'] ?? 0) > 0; }); $prorataPeriodWorkdayHk = $rosterOnRows->count(); $hkBasis = (float) $prorataPeriodWorkdayHk; $hkBaseHours = (float) $rosterOnRows->sum(fn ($row) => (float) ($row['planned_hours'] ?? 0)); $hkHoursPerDay = $hkBasis > 0 ? $hkBaseHours / $hkBasis : $hkHoursPerDay; } elseif ($isProrataSalary && $prorataPeriodWorkdayHk > 0) { // Regular employees use calendar workdays; roster employees use scheduled ON days above. $hkBasis = (float) $prorataPeriodWorkdayHk; $hkBaseHours = $hkBasis * $hkHoursPerDay; } $prorataEffectiveBasis = $hkBasis; if ($isProrataSalary) { // Keep the period basis intact; effective HK is shown separately after absence deductions. $prorataEffectiveBasis = $hkBasis; $hkBaseHours = $hkBasis * $hkHoursPerDay; } $totalDeficitHours = collect($deficitRows)->sum('deficit_hours'); $jamTdkMasuk = max(0.0, $totalDeficitHours); $jamMasukNormal = max(0.0, $hkBaseHours - $jamTdkMasuk); $hkMasuk = $isProrataSalary ? max(0.0, (float) $sumHk) : ($hkHoursPerDay > 0 ? $jamMasukNormal / $hkHoursPerDay : 0); if ($isProrataSalary) { $jamMasukNormal = $hkMasuk * $hkHoursPerDay; } $realizedHk = $hkHoursPerDay > 0 ? $realizedRecognizedHours / $hkHoursPerDay : 0; $realizedTargetHk = $hkHoursPerDay > 0 ? $realizedTargetHours / $hkHoursPerDay : 0; $scheduleCounts = collect($detailRows)->countBy(function ($row) { $badge = strtolower(trim((string) ($row['schedule_badge_label'] ?? ''))); return $badge === 'belum ada shift' ? 'waiting' : ($badge === 'off' ? 'off' : 'scheduled'); }); $usesRosterShift = collect($detailRows)->contains(function ($row) { return strtolower(trim((string) ($row['schedule_badge_label'] ?? ''))) === 'shift'; }); $rosterComplete = $usesRosterShift && (int) ($scheduleCounts['waiting'] ?? 0) === 0 && ((int) ($scheduleCounts['scheduled'] ?? 0) + (int) ($scheduleCounts['off'] ?? 0)) === count($detailRows); // NoRest hanya jam break yang benar-benar diberi rule NoRest, bukan sisa OT segment. $noRest1Hours = round($sumNoRest1Hours, 2); $noRest2Hours = round($sumNoRest2Hours, 2); $noRestHours = $noRest1Hours + $noRest2Hours; $afterRawHours = max(0.0, $sumOvertime - $sumOvertimeBefore - $noRestHours); $beforeMultiplier = $sumOvertimeBefore > 0 ? $sumOvertimeBeforeWeighted / $sumOvertimeBefore : 0.0; $afterWeighted = max(0.0, $sumWeightedOvertime - $sumOvertimeBeforeWeighted - $noRestHours); $afterMultiplier = $afterRawHours > 0 ? $afterWeighted / $afterRawHours : 0.0; $totalMultiplier = $sumOvertime > 0 ? $sumWeightedOvertime / $sumOvertime : 0.0; $multiplierLabel = static fn (float $value): string => $value > 0 ? 'x' . number_format($value, 2, ',', '.') : 'x0'; $segmentOtColumns = collect($detailOtColumns)->map(function (array $column) use ($multiplierLabel) { $multiplier = (float) ($column['multiplier'] ?? 0); $key = (string) ($column['key'] ?? $multiplier); $label = trim((string) ($column['label'] ?? '')); if ($label === '') { $label = 'x' . rtrim(rtrim(number_format($multiplier, 2, ',', ''), '0'), ','); } return ['key' => $key, 'multiplier' => $multiplier, 'label' => $multiplierLabel($multiplier)]; })->values()->all(); $segmentTotalBuckets = []; foreach ($segmentOtColumns as $column) { $segmentTotalBuckets[$column['key']] = (float) ($otTotals[$column['key']] ?? 0); } // Daily rounded buckets can differ a few minutes from raw OT total; reconcile on the closest active rule. $bucketDelta = $sumOvertime - array_sum($segmentTotalBuckets); if ($segmentOtColumns !== [] && abs($bucketDelta) > 0.0001) { usort($segmentOtColumns, fn ($left, $right) => abs($left['multiplier'] - $totalMultiplier) <=> abs($right['multiplier'] - $totalMultiplier)); $segmentTotalBuckets[$segmentOtColumns[0]['key']] = max(0.0, ($segmentTotalBuckets[$segmentOtColumns[0]['key']] ?? 0) + $bucketDelta); usort($segmentOtColumns, fn ($left, $right) => $left['multiplier'] <=> $right['multiplier']); } $segmentBeforeBuckets = array_fill_keys(array_column($segmentOtColumns, 'key'), 0.0); $segmentNoRestBuckets = array_fill_keys(array_column($segmentOtColumns, 'key'), 0.0); if ($sumOvertimeBefore > 0 && $segmentOtColumns !== []) { $beforeColumn = collect($segmentOtColumns)->sortBy(fn ($column) => abs($column['multiplier'] - $beforeMultiplier))->first(); $segmentBeforeBuckets[$beforeColumn['key']] = $sumOvertimeBefore; } // NoRest dibayar 1:1 sebagai jam lembur; tidak masuk bucket multiplier OVT Before/After. if ($noRestHours > 0 && $segmentOtColumns !== []) { $noRestColumn = collect($segmentOtColumns)->sortBy(fn ($column) => abs($column['multiplier']))->first(); $segmentTotalBuckets[$noRestColumn['key']] = max(0.0, ($segmentTotalBuckets[$noRestColumn['key']] ?? 0) - $noRestHours); } $segmentAfterBuckets = []; foreach ($segmentOtColumns as $column) { $key = $column['key']; $segmentAfterBuckets[$key] = max(0.0, ($segmentTotalBuckets[$key] ?? 0) - ($segmentBeforeBuckets[$key] ?? 0)); } // Buckets are display-only; total must use the engine's authorized weighted hours. $afterWeighted = round(max(0.0, $sumWeightedOvertime - $sumOvertimeBeforeWeighted - $noRestHours), 2); $ovtTotalWeighted = round($sumOvertimeBeforeWeighted + $afterWeighted, 2); $otCount = count($detailOtColumns); $remainingCols = 4 + $otCount; $totalDetailColumns = 11 + $otCount + ($segmentView ? 2 : 0); $summaryTailCols = max(1, $totalDetailColumns - 8); @endphp @if ($usesRosterShift)
Info jadwal: Perhitungan hanya berlaku setelah shift harian dibuat. {{ (int) ($scheduleCounts['waiting'] ?? 0) }} Menunggu Jadwal {{ (int) ($scheduleCounts['scheduled'] ?? 0) }} Shift Terjadwal {{ (int) ($scheduleCounts['off'] ?? 0) }} OFF
Tanggal Menunggu Jadwal belum dihitung sebagai HK, jam normal, lembur, atau kekurangan. Isi shift/OFF, lalu jalankan Rebuild Planning dan Run Deteksi.
@endif @if (empty($publicView)) @if (!$hidePaymentModeButton)
Mode Payment
@endif @endif
@if ($segmentView)@endif @if ($segmentView)@endif @foreach ($detailOtColumns as $otCol) @php $rawLabel = (string) ($otCol['label'] ?? ''); $multiplier = (float) ($otCol['multiplier'] ?? 0); $percentLabel = $multiplier > 0 ? rtrim(rtrim(number_format($multiplier * 100, 1, '.', ''), '0'), '.') . '%' : ''; $headerLabel = $rawLabel !== '' ? $rawLabel : ($percentLabel !== '' ? $percentLabel : 'x0'); @endphp @endforeach @forelse ($detailRows as $idx => $row) @php $dayType = (string) ($row['day_type'] ?? 'workday'); $dayClass = $dayTypeRowClassResolver($dayType); $dayLabel = $dayTypeLabelResolver($dayType); $scheduleBadgeType = (string) ($row['schedule_badge_type'] ?? 'normal'); $scheduleBadgeLabel = (string) ($row['schedule_badge_label'] ?? 'Normal'); $specialCodeBadge = strtolower((string) ($row['special_overtime_code'] ?? '')); $specialModeBadge = strtolower((string) ($row['special_overtime_mode'] ?? '')); $specialLabelBadge = strtolower((string) ($row['special_overtime_label'] ?? '')); $isTargetBadge = $specialCodeBadge === 'work_target' || str_contains($specialModeBadge, 'target') || str_contains($specialLabelBadge, 'target'); $targetBeforeHours = (float) ($row['overtime_before_hours'] ?? 0); $targetAfterHours = (float) ($row['overtime_after_hours'] ?? 0); $targetPayloadBadge = is_array($row['special_overtime_payload'] ?? null) ? $row['special_overtime_payload'] : []; $targetEndsNextDay = $isTargetBadge && substr((string) ($targetPayloadBadge['work_target_end_at'] ?? ''), 0, 10) > (string) ($row['work_date'] ?? ''); $isTargetCarry = $isTargetBadge && str_contains((string) ($row['work_target_execution_mode'] ?? $targetPayloadBadge['work_target_execution_mode'] ?? ''), 'target_carry'); $targetPreviousSplMissing = (bool) ($row['work_target_previous_spl_missing'] ?? $targetPayloadBadge['work_target_previous_spl_missing'] ?? false); $continuesTrace = is_array($row['continues_trace'] ?? null) ? $row['continues_trace'] : []; $traceModeBadge = strtolower((string) ($continuesTrace['mode'] ?? '')); $isContinuesBadge = $specialCodeBadge === 'continues_work_day' || str_contains($specialModeBadge, 'continues') || str_contains($specialLabelBadge, 'continues') || $traceModeBadge !== ''; $isCarryBadge = $isContinuesBadge && (str_contains($specialModeBadge, 'carry') || $traceModeBadge === 'carry'); $carryHasTargetFollowUpBadge = (bool) ($targetPayloadBadge['continues_carry_has_target_follow_up'] ?? false); $continuesTraceStatus = strtolower((string) ($continuesTrace['status'] ?? '')); $continuesTraceTitle = $continuesTraceStatus === 'approved' ? (trim((string) ($continuesTrace['erp_notrans'] ?? '')) ?: trim((string) ($continuesTrace['document_no'] ?? ''))) : ''; @endphp @if ($segmentView) @php $beforePlan = (string) ($row['planned_in_time'] ?? '-'); $beforeOtIn = (string) ($row['overtime_before_in_time'] ?? '-'); $beforeRawIn = (string) ($row['in_time_real'] ?? '-'); $beforeAllowed = (bool) ($row['spl_approved'] ?? false) || (bool) ($row['auto_ot_without_spl'] ?? false) || (bool) ($row['auto_overtime_before'] ?? false); $beforeExists = $beforeAllowed && $beforeOtIn !== '-' && $beforePlan !== '-' && strtotime($beforeOtIn) < strtotime($beforePlan); $afterPlan = (string) ($row['planned_out_time'] ?? '-'); $afterDisplayStart = (string) ($row['planned_in_time'] ?? '-'); $isWeekendAfter = (string) ($row['day_type'] ?? '') === 'weekend'; $afterOtOut = (string) ($row['overtime_after_out_time'] ?? $row['overtime_out_time'] ?? '-'); $afterAllowed = (bool) ($row['spl_approved'] ?? false) || (bool) ($row['auto_ot_without_spl'] ?? false) || (bool) ($row['auto_overtime_after'] ?? false); $afterExists = $afterAllowed && $afterOtOut !== '-' && $afterPlan !== '-' && (float) ($row['overtime_after_hours'] ?? 0) > 0; // Carry ditampilkan pada kolom OUT, bukan sebagai OVT After kedua. if ($isCarryBadge) $afterExists = false; @endphp @endif @if ($segmentView) @php $afterPlan = (string) ($row['planned_out_time'] ?? '-'); $afterOtOut = (string) ($row['overtime_after_out_time'] ?? $row['overtime_out_time'] ?? '-'); $afterOtOutClean = preg_replace('/\s*(?:\(\+1\)\s*)+$/', '', $afterOtOut) ?: $afterOtOut; $afterIsCrossDay = ! $isWeekendAfter && (float) ($row['overtime_after_hours'] ?? 0) > 0 && (str_contains($afterOtOut, '(+1)') || strtotime($afterPlan) <= strtotime((string) ($row['planned_in_time'] ?? '-')) || ($afterOtOut !== '-' && $afterPlan !== '-' && strtotime($afterOtOutClean) < strtotime($afterPlan))); $afterRawIn = (string) ($row['in_time_real'] ?? '-'); $afterRawOut = (string) ($row['out_time_real'] ?? '-'); $afterRawOutClean = preg_replace('/\s*(?:\(\+1\)\s*)+$/', '', $afterRawOut) ?: $afterRawOut; $targetBonusHoursDisplay = $isTargetBadge ? round((float) ($row['work_target_bonus_hours_calculated'] ?? ($targetPayloadBadge['work_target_bonus_hours_calculated'] ?? 0)), 2) : 0.0; $targetAfterActualHoursDisplay = (float) ($row['overtime_after_actual_hours'] ?? ($row['overtime_after_hours'] ?? 0)); $targetAfterTotalHoursDisplay = round($targetAfterActualHoursDisplay + $targetBonusHoursDisplay, 2); $targetEndDisplay = $isTargetBadge ? substr((string) ($targetPayloadBadge['work_target_end_at'] ?? ''), 11, 5) : ''; $targetStartDisplay = $isTargetBadge ? substr((string) ($row['work_target_start_at'] ?? $targetPayloadBadge['work_target_start_at'] ?? ''), 11, 5) : ''; $targetBonusEndDisplay = $isTargetBadge ? substr((string) ($targetPayloadBadge['work_target_bonus_end_at'] ?? ''), 11, 5) : ''; $targetBonusEndNextDay = $isTargetBadge && substr((string) ($targetPayloadBadge['work_target_bonus_end_at'] ?? ''), 0, 10) > substr((string) ($row['work_date'] ?? ''), 0, 10); $targetEndNextDay = $isTargetBadge && substr((string) ($targetPayloadBadge['work_target_end_at'] ?? ''), 0, 10) > substr((string) ($row['work_date'] ?? ''), 0, 10); $afterAllowed = (bool) ($row['spl_approved'] ?? false) || (bool) ($row['auto_ot_without_spl'] ?? false) || (bool) ($row['auto_overtime_after'] ?? false); $afterExists = $afterAllowed && $afterOtOut !== '-' && $afterPlan !== '-' && (float) ($row['overtime_after_hours'] ?? 0) > 0; if ($isCarryBadge) $afterExists = false; @endphp @endif @foreach ($detailOtColumns as $otCol) @endforeach @php $detailRemark = trim((string) ($row['reason'] ?? '')); if (strtolower($detailRemark) === 'normal') $detailRemark = ''; $detailMarkerGroups = []; $detailNotes = []; foreach (preg_split('/\r?\n/', $detailRemark) as $detailLine) { $detailLine = trim($detailLine); if ($detailLine === '') continue; if (preg_match('/^(NoRest 1|NoRest 2|Overtime|Target|Continues):\s*(.+)$/i', $detailLine, $matches)) { $detailMarker = $matches[1]; $detailMarkerGroups[$detailMarker] ??= []; $detailMarkerGroups[$detailMarker] = array_merge($detailMarkerGroups[$detailMarker], preg_split('/\s*,\s*/', trim($matches[2])) ?: []); continue; } if (preg_match('/No Trans:\s*([^|\n]+)/i', $detailLine, $matches)) { $detailMarkerGroups['Referensi'] ??= []; $reference = trim($matches[1]); $reference = preg_replace('/\s*(Window|Actual|Approved|Carry-over)\s*:.*$/i', '', $reference); $reference = rtrim($reference, " \t\n\r\0\x0B.,;:"); $detailMarkerGroups['Referensi'] = array_merge($detailMarkerGroups['Referensi'], preg_split('/\s*,\s*/', trim($reference)) ?: []); } if (preg_match('/^Carry-over\b/i', $detailLine)) { $detailMarkerGroups['Continues'] ??= []; continue; } if (preg_match('/^(SPL Approved|SPL)\b/i', $detailLine)) continue; if (preg_match('/^No Trans:/i', $detailLine)) continue; $detailNotes[] = $detailLine; } $weekendHasAttendance = (string) ($row['day_type'] ?? '') === 'weekend' && !in_array(trim((string) ($row['in_time'] ?? '-')), ['', '-'], true) && !in_array(trim((string) ($row['out_time'] ?? '-')), ['', '-'], true); if ($weekendHasAttendance && !(bool) ($row['spl_approved'] ?? false)) { $detailNotes[] = 'Hadir di weekend tanpa SPL'; } // No Trans belongs to the anchor work date; Carry H+1 is only its derived attendance result. if ($isContinuesBadge && !$isCarryBadge && $continuesTraceTitle !== '') { $detailMarkerGroups['Continues'] ??= []; $detailMarkerGroups['Continues'][] = $continuesTraceTitle; } if ($isCarryBadge) { unset($detailMarkerGroups['Continues']); } foreach ($detailMarkerGroups as $detailMarker => $detailReferences) { $detailMarkerGroups[$detailMarker] = array_values(array_unique(array_filter(array_map('trim', $detailReferences)))); } // Carry reason writes No Trans on the same sentence; attach it to Continues like other SPL markers. if (!empty($detailMarkerGroups['Referensi'])) { foreach (['NoRest 1', 'NoRest 2', 'Overtime', 'Target', 'Continues'] as $detailPrimaryMarker) { if (!array_key_exists($detailPrimaryMarker, $detailMarkerGroups)) continue; $detailMarkerGroups[$detailPrimaryMarker] = array_values(array_unique(array_filter(array_merge( $detailMarkerGroups[$detailPrimaryMarker], $detailMarkerGroups['Referensi'] )))); unset($detailMarkerGroups['Referensi']); break; } } @endphp @if ($paymentView) @php $beforeAuthorized = $isOvertimeAuthorized((array) $row, 'before'); $afterAuthorized = $isOvertimeAuthorized((array) $row, 'after'); $beforeWeighted = $beforeAuthorized ? (float) ($row['overtime_before_weighted_hours'] ?? 0) : 0.0; $afterWeighted = $afterAuthorized ? (float) ($row['overtime_after_weighted_hours'] ?? 0) : 0.0; if ($beforeAuthorized && $segmentView && $beforeWeighted <= 0 && !empty($row['overtime_before_dynamic'])) { foreach ($detailOtColumns as $otColumn) { $beforeWeighted += (float) ($row['overtime_before_dynamic'][$otColumn['key']] ?? 0) * (float) ($otColumn['multiplier'] ?? 0); } } if ($afterAuthorized && $segmentView && $afterWeighted <= 0 && !empty($row['overtime_after_dynamic'])) { foreach ($detailOtColumns as $otColumn) { $afterWeighted += (float) ($row['overtime_after_dynamic'][$otColumn['key']] ?? 0) * (float) ($otColumn['multiplier'] ?? 0); } } $paymentBefore = round($beforeWeighted * $paymentOvertimeRate, 2); $paymentNoRest1Hours = $isNoRestAuthorized((array) $row, '1') ? max(0.0, (float) ($row['no_rest_normal_included_minutes'] ?? 0) / 60) : 0.0; $paymentNoRest2Hours = ($isContinuesBadge && !$isCarryBadge) ? 0.0 : ($isNoRestAuthorized((array) $row, '2') ? max(0.0, (float) ($row['no_rest_skip_break_minutes'] ?? 0) / 60) : 0.0); $paymentNoRest1 = round($paymentNoRest1Hours * $paymentOvertimeRate, 2); $paymentNoRest2 = round($paymentNoRest2Hours * $paymentOvertimeRate, 2); $leaveLabel = strtolower((string) ($row['leave_tag_label'] ?? '')); $leaveReason = strtolower((string) ($row['reason'] ?? '')); $isApprovedLeave = (bool) ($row['leave_is_payable'] ?? false) && !str_contains($leaveLabel, 'terlambat') && !str_contains($leaveReason, 'izin terlambat'); $isAttendancePaymentEligible = (bool) ($row['is_approved'] ?? false) || $isApprovedLeave; $specialPaymentCode = strtolower((string) ($row['special_overtime_code'] ?? '')); $specialPaymentMode = strtolower((string) ($row['special_overtime_mode'] ?? '')); $isContinuesCarryPayment = $specialPaymentCode === 'continues_work_day' && str_contains($specialPaymentMode, 'carry'); $normalPaymentHours = $isContinuesCarryPayment ? (float) ($dayCredit['recognized_hours'] ?? $hkHoursPerDay) : ($isApprovedLeave ? (float) ($row['planned_hours'] ?? 0) : (float) ($row['normal_hours'] ?? 0)); $paymentNormal = round($normalPaymentHours * $paymentHourlyRate, 2); $paymentAfter = round($afterWeighted * $paymentOvertimeRate, 2); if (!$isAttendancePaymentEligible) { $paymentBefore = 0.0; $paymentNoRest1 = 0.0; $paymentNoRest2 = 0.0; $paymentNormal = 0.0; $paymentAfter = 0.0; } $paymentTotal = round($paymentBefore + $paymentNoRest1 + $paymentNoRest2 + $paymentNormal + $paymentAfter, 2); @endphp @if ($segmentView) @endif @if ($segmentView) @endif @endif @empty @endforelse @if (!empty($detailRows)) @if ($segmentView) @foreach ($detailOtColumns as $otCol) @endforeach @endif @if (!$segmentView) @if ($isProrataSalary && $usesRosterShift) @endif @if ($isProrataSalary) @else @endif @endif @if (!$segmentView) @foreach ($detailOtColumns as $otCol) @php $k = $otCol['key']; @endphp @endforeach @else @endif @endif
No. TanggalOVT Before
{{ $segmentAutoOtEnabled ? 'SPL / Auto OT' : 'SPL' }}
In No Rest 1 Out No Rest 2OVT After
{{ $segmentAutoOtEnabled ? 'SPL / Auto OT' : 'SPL' }}
Jam Normal (Plan) HK Jam Aktual / Efektif{{ $headerLabel }}Total Jam
Bobot Overtime
Status Penanda
{{ $idx + 1 }} {{ $row['work_date'] }} ({{ $row['day_name'] }}) @if (!empty($row['day_type_description']) && $row['day_type_description'] !== '-') - {{ $row['day_type_description'] }} @endif
{{ $dayLabel }} @if ($usesRosterShift && strtolower(trim($scheduleBadgeLabel)) === 'off') OFF @elseif ($usesRosterShift && empty($row['has_scheduled_shift'])) Tidak Lengkap @elseif (!$usesRosterShift) @if (strtolower(trim($scheduleBadgeLabel)) !== 'normal') {{ $scheduleBadgeLabel }} @endif @endif @if (!empty($row['leave_tag_label'])) {{ $row['leave_tag_label'] }} @endif @if ($isTargetBadge) {{ $isTargetCarry ? 'SPL Target' : 'Target' }} @if ($isTargetCarry) Continues Workdays H+1 Target Carry Bonus +4 Jam @endif @if ($targetPreviousSplMissing) SPL H-1 Belum Ada @endif @if ($targetBeforeHours > 0) OVT Before @endif @if ($isTargetCarry) Bonus Carry +4 Jam @elseif ((float) ($row['work_target_bonus_hours_calculated'] ?? ($row['special_overtime_payload']['work_target_bonus_hours_calculated'] ?? 0)) > 0) Bonus Target @endif @if ($targetEndsNextDay && !$isTargetCarry) H+1 @endif @elseif ($isContinuesBadge) @if ($isCarryBadge) Carry @if ($carryHasTargetFollowUpBadge) Bonus HK @endif H+1 @else Continues H+1 @endif @if ($continuesTraceStatus !== '' && $continuesTraceStatus !== 'approved') {{ strtoupper($continuesTraceStatus) }} @endif @else @if (!empty($row['special_overtime_label'])) {{ $row['special_overtime_label'] }} @endif @if (!empty($row['special_overtime_mode'])) {{ $row['special_overtime_mode'] }} @endif @endif
@if (!empty($row['applied_shift_code']))
@if (strtolower(trim((string) $row['applied_shift_code'])) === 'off') OFF @elseif ($usesRosterShift && !empty($row['has_scheduled_shift'])) {{ $row['applied_shift_code'] }} @else {{ $row['applied_shift_code'] }} @endif
@endif @if (!empty($row['has_face_image']))
@endif
@if ($beforeExists) @if ($isTargetBadge)Target OVT Before@endif {{ $beforeOtIn }} - {{ $beforePlan }} @if ($beforeRawIn !== '-' && $beforeRawIn !== '' && $beforeRawIn !== $beforeOtIn)
{{ $beforeRawIn }} (actual) - {{ $beforePlan }} @endif @endif
{{ ($segmentView && $beforeExists) ? $beforePlan : $row['in_time'] }} @if (!empty($row['fc_urgency_in']))
FC URGENCY Approved @elseif (!empty($row['fc_personal_in']))
FC Approved @endif @php $inEff = (string) ($row['in_time'] ?? '-'); $inShadow = (string) ($row['in_time_shadow'] ?? '-'); $inRaw = (string) ($row['in_time_real'] ?? '-'); $inReal = '-'; if ($inRaw !== '-' && $inRaw !== '') { $inReal = $inRaw; } elseif ($inShadow !== '-' && $inShadow !== '') { $inReal = $inShadow; } @endphp @if ($inReal !== '-' && empty($row['is_off_day']) && (! $segmentView || ! $beforeExists))
{{ $inReal }} (actual) @endif
{{ ((float) ($row['no_rest_normal_included_minutes'] ?? 0)) > 0 ? number_format(((float) ($row['no_rest_normal_included_minutes'] ?? 0)) / 60, 2, ',', '.') : '' }} @php $specialCodeView = strtolower((string) ($row['special_overtime_code'] ?? '')); $specialModeView = strtolower((string) ($row['special_overtime_mode'] ?? '')); $specialLabelView = strtolower((string) ($row['special_overtime_label'] ?? '')); $displayOutTime = (string) ($row['out_time'] ?? '-'); $displayOutTime = preg_replace('/\s*(?:\(\+1\)\s*)+$/', '', $displayOutTime) ?: $displayOutTime; @endphp @if ($segmentView && $isCarryBadge && $afterOtOut !== '-' && $afterPlan !== '-') {{ $displayOutTime }} @else {{ ($segmentView && $afterExists) ? $afterPlan : $displayOutTime }} @endif @if (!empty($row['fc_urgency_out']))
FC URGENCY Approved @elseif (!empty($row['fc_personal_out']))
FC Approved @endif @php $outEff = (string) ($row['out_time'] ?? '-'); $outShadow = (string) ($row['out_time_shadow'] ?? '-'); $outRaw = !empty($row['hide_cross_day_out']) ? '-' : (string) ($row['out_time_real'] ?? '-'); $outReal = '-'; if ($outRaw !== '-' && $outRaw !== '') { $outReal = $outRaw; } elseif ($outShadow !== '-' && $outShadow !== '') { $outReal = $outShadow; } @endphp @if ($outReal !== '-' && empty($row['is_off_day']) && (! $segmentView || ! $afterExists))
{{ $outReal }} (actual) @endif
@php $noRest2Minutes = (float) ($row['no_rest_skip_break_minutes'] ?? 0); if ($isContinuesBadge && !$isCarryBadge) { $noRest2Minutes = 0.0; } @endphp {{ $noRest2Minutes > 0 ? number_format($noRest2Minutes / 60, 2, ',', '.') : '' }} @if ($afterExists) @if ($isContinuesBadge && !$isCarryBadge)SPL@endif @if ($isTargetBadge) @if ($targetEndDisplay !== '') Target Jam {{ $targetEndDisplay }}{{ $targetEndNextDay ? ' (+1)' : '' }}
@endif OVT aktual: {{ $targetStartDisplay !== '' ? $targetStartDisplay : $afterPlan }} - {{ $afterRawOutClean !== '-' ? $afterRawOutClean : $afterOtOutClean }} @if ($targetBonusHoursDisplay > 0) Bonus Target: {{ $afterRawOutClean !== '-' ? $afterRawOutClean : $afterOtOutClean }} - {{ $targetBonusEndDisplay !== '' ? $targetBonusEndDisplay : $afterOtOutClean }} (+{{ number_format($targetBonusHoursDisplay, 2, ',', '.') }} jam) Batas pembulatan OUT: {{ $targetBonusEndDisplay !== '' ? $targetBonusEndDisplay : $afterOtOutClean }}{{ $targetBonusEndNextDay ? ' (+1)' : '' }} (profil OVT After) @endif @else {{ $isWeekendAfter ? $afterDisplayStart : $afterPlan }} - {{ $afterOtOutClean }}{{ $isContinuesBadge && !$isCarryBadge ? ' (+1)' : '' }} @endif @if ($isContinuesBadge && !$isCarryBadge)
Overtime Cutoff 24 Jam@endif @if (!$isTargetBadge && !$isContinuesBadge && $afterRawOut !== '-' && $afterRawOut !== '' && $afterRawOut !== $afterOtOut)
{{ $isWeekendAfter && $afterRawIn !== '-' ? $afterRawIn : $afterPlan }} - {{ $afterRawOut }} (actual) @endif @elseif ($isCarryBadge && $carryHasTargetFollowUpBadge) @php $carryTargetStartDisplay = substr((string) ($targetPayloadBadge['continues_carry_target_start'] ?? ''), 11, 5); $carryTargetEndDisplay = substr((string) ($targetPayloadBadge['continues_carry_target_end'] ?? ''), 11, 5); $carryTargetActualOutDisplay = trim((string) ($targetPayloadBadge['continues_carry_actual_out'] ?? '')); $carryTargetBonusEndDisplay = substr((string) ($targetPayloadBadge['continues_carry_overtime_end'] ?? ''), 11, 5); $carryTargetBonusHoursDisplay = (float) ($targetPayloadBadge['continues_carry_target_bonus_hours'] ?? 0); @endphp SPL Target Carry {{ $carryTargetStartDisplay ?: '-' }} - {{ $carryTargetEndDisplay ?: '-' }} Actual: {{ $carryTargetActualOutDisplay ?: '-' }} @if ($carryTargetBonusHoursDisplay > 0) Bonus: {{ $carryTargetActualOutDisplay ?: '-' }} - {{ $carryTargetBonusEndDisplay ?: '-' }} ({{ number_format($carryTargetBonusHoursDisplay, 2, ',', '.') }} jam) @endif @endif
{{ number_format((float) $row['planned_hours'], 2, ',', '.') }} @if (!empty($row['planned_in_time']) && !empty($row['planned_out_time']) && empty($row['is_off_day']))
{{ $row['planned_in_time'] }} - {{ $row['planned_out_time'] }} @endif
@php $dayType = (string) ($row['day_type'] ?? 'workday'); $dayCredit = $resolveAttendanceDayCredit((array) $row, $hkHoursPerDay, $detailProfil); $hkFlag = (int) ($dayCredit['hk_flag'] ?? 0); $hkValue = $isProrataSalary ? (float) ($dayCredit['hk_value'] ?? $hkFlag) : (float) $hkFlag; $specialCodeHk = strtolower((string) ($row['special_overtime_code'] ?? '')); $specialModeHk = strtolower((string) ($row['special_overtime_mode'] ?? '')); $specialLabelHk = strtolower((string) ($row['special_overtime_label'] ?? '')); $isContinuesVisual = $specialCodeHk === 'continues_work_day' || str_contains($specialModeHk, 'continues') || str_contains($specialLabelHk, 'special overtime'); $isContinuesCarryVisual = $isContinuesVisual && str_contains($specialModeHk, 'carry') && $hkFlag === 1; $hkDisplayValue = $isContinuesCarryVisual ? 1 : ($isProrataSalary ? $hkValue : $hkFlag); $hkDisplayHours = $isContinuesCarryVisual ? $hkHoursPerDay : ($isProrataSalary ? $hkValue * $hkHoursPerDay : $hkHoursPerDay); @endphp {{ $isContinuesCarryVisual ? 'Bonus HK' : $hkDisplayValue }} @if ($isContinuesCarryVisual) 1,00 HK ({{ $fmt($hkDisplayHours) }} jam) @elseif ($hkFlag === 1 && empty($row['is_off_day'])) ({{ $isProrataSalary ? $fmt($hkValue * $hkHoursPerDay) : $fmt($hkHoursPerDay) }} jam) @php $isAlphaWorkday = ($dayType === 'workday' && $hkFlag === 1 && (float) ($row['actual_hours'] ?? 0) <= 0 && empty($row['leave_tag_label']) && empty($dayCredit['special_bonus'])); @endphp @if ($isAlphaWorkday && !$isContinuesVisual)
HK 1 (Alpha)
@elseif (!empty($dayCredit['holiday_paid']))
Holiday dibayar: +{{ $fmt($dayCredit['recognized_hours'] ?? $hkHoursPerDay) }} jam
@if (!empty($dayCredit['pending_spl']))
Log hadir menunggu SPL; belum dihitung lembur
@endif @elseif (!empty($dayCredit['special_bonus']))
HK Bonus ContinuesNextDay
@endif @endif
@php $dayTypeValue = (string) ($row['day_type'] ?? 'workday'); $actualInTime = trim((string) ($row['in_time'] ?? '-')); $actualOutTime = trim((string) ($row['out_time'] ?? '-')); $hasActualInOut = $actualInTime !== '' && $actualInTime !== '-' && $actualOutTime !== '' && $actualOutTime !== '-'; $isHolidayWeekend = in_array($dayTypeValue, ['holiday', 'holiday_special', 'weekend'], true); $plannedSpanHours = 0.0; if ($isHolidayWeekend && ($row['planned_in_time'] ?? '-') !== '-' && ($row['planned_out_time'] ?? '-') !== '-') { $plannedSpanHours = (float) (strtotime((string) $row['planned_out_time']) - strtotime((string) $row['planned_in_time'])) / 3600; if ($plannedSpanHours < 0) $plannedSpanHours += 24; } $sourceHours = $dayTypeValue === 'weekend' && $plannedSpanHours > 0 ? $plannedSpanHours : ($isHolidayWeekend && (float) ($row['overtime_hours_gross'] ?? 0) > 0 ? (float) ($row['overtime_hours_gross'] ?? 0) : (float) ($row['actual_hours'] ?? 0)); $hasNormalBreakCut = (float) ($row['break_hours'] ?? 0) > 0 && $sourceHours > 0 && $hasActualInOut; $actualDisplayHours = $hasNormalBreakCut ? max(0, $sourceHours - (float) ($row['break_hours'] ?? 0)) : $sourceHours; $noRest1DisplayHours = $isNoRestAuthorized((array) $row, '1') ? max(0.0, (float) ($row['no_rest_normal_included_minutes'] ?? 0) / 60) : 0.0; $noRest2DisplayHours = $isNoRestAuthorized((array) $row, '2') ? max(0.0, (float) ($row['no_rest_skip_break_minutes'] ?? 0) / 60) : 0.0; $fixedCreditHours = strtolower(trim((string) ($row['credit_mode'] ?? ''))) === 'fixed' ? min((float) ($row['normal_hours'] ?? 0), $hkHoursPerDay) : 0.0; $specialPayload = is_array($row['special_overtime_payload'] ?? null) ? $row['special_overtime_payload'] : []; $specialCodeHours = strtolower((string) ($row['special_overtime_code'] ?? '')); $specialModeHours = strtolower((string) ($row['special_overtime_mode'] ?? '')); $isContinuesHours = $specialCodeHours === 'continues_work_day' || str_contains($specialModeHours, 'continues'); $continuesTargetCoverageHours = round((float) ($specialPayload['continues_target_coverage_hours'] ?? 0), 2); $continuesNextDayWorkHours = round((float) ($specialPayload['continues_next_day_work_hours'] ?? 0), 2); $continuesShortageHours = round((float) ($specialPayload['continues_effective_shortage_hours'] ?? ($specialPayload['continues_shortage_hours'] ?? 0)), 2); $continuesOriginalShortageHours = round((float) ($specialPayload['continues_original_shortage_hours'] ?? $continuesShortageHours), 2); $continuesEffectiveHours = round(max(0.0, $continuesNextDayWorkHours + $continuesShortageHours), 2); $continuesConversionMode = strtolower(trim((string) ($specialPayload['continues_conversion_mode'] ?? ''))); $continuesConversionLabel = $continuesConversionMode === 'bonus_hk' ? 'Bonus 1 HK' : ($continuesConversionMode === 'bonus_hours' ? 'Bonus Jam' : 'Bonus Continues'); $continuesCarryActualOut = trim((string) ($specialPayload['continues_carry_actual_out'] ?? '')); $continuesCarryTargetStart = substr((string) ($specialPayload['continues_carry_target_start'] ?? ''), 11, 5); $continuesCarryTargetEnd = substr((string) ($specialPayload['continues_carry_target_end'] ?? ''), 11, 5); $continuesCarryTargetBonusEnd = substr((string) ($specialPayload['continues_carry_overtime_end'] ?? ''), 11, 5); $continuesBonusCutoff = trim((string) ($specialPayload['continues_bonus_cutoff_time'] ?? '16:00')); $continuesBonusAwarded = (bool) ($specialPayload['continues_bonus_awarded'] ?? ($continuesShortageHours > 0)); $continuesCarryTargetHours = round((float) ($specialPayload['continues_carry_target_hours'] ?? 0), 2); $continuesCarryTargetBonusHours = round((float) ($specialPayload['continues_carry_target_bonus_hours'] ?? 0), 2); $continuesCarryIsWeekend = (bool) ($specialPayload['continues_carry_is_weekend'] ?? false); $isEmergencyHours = $specialCodeHours === 'emergency_on_call'; $emergencyBonusHours = round((float) ($specialPayload['emergency_bonus_hours'] ?? 0), 2); $emergencyBonusNominal = round((float) ($specialPayload['emergency_bonus_nominal'] ?? 0), 2); $emergencyBaselineLabel = $emergencyBaselineLabelResolver($specialPayload['emergency_baseline_mode'] ?? ''); $emergencyMultiplierLabel = $emergencyMultiplierLabelResolver($specialPayload['emergency_multiplier_profile'] ?? ''); $specialPaymentModeLabel = $specialPaymentModeLabelResolver($specialPayload['bonus_payment_mode'] ?? ''); $isTargetWorkHours = $specialCodeHours === 'work_target'; $isTargetCarryWork = $isTargetWorkHours && str_contains((string) ($row['work_target_execution_mode'] ?? $specialPayload['work_target_execution_mode'] ?? ''), 'target_carry'); $workTargetBonusHours = round((float) ($specialPayload['work_target_bonus_hours'] ?? 0), 2); $workTargetBonusCapHours = round((float) ($specialPayload['work_target_bonus_cap_hours'] ?? 0), 2); $workTargetMinimumActualHours = round((float) ($specialPayload['work_target_minimum_actual_hours'] ?? 0), 2); $workTargetCompletionRequired = (bool) ($specialPayload['work_target_completion_required'] ?? false); $workTargetBonusSourceLabel = $workTargetBonusSourceLabelResolver($specialPayload['work_target_bonus_source'] ?? ''); $workTargetCalculatedHours = round((float) ($row['work_target_bonus_hours_calculated'] ?? ($specialPayload['work_target_bonus_hours_calculated'] ?? 0)), 2); $workTargetCalculatedWeightedHours = round((float) ($row['work_target_bonus_weighted_hours'] ?? ($specialPayload['work_target_bonus_weighted_hours'] ?? 0)), 2); $workTargetMultiplierLabel = trim((string) ($row['work_target_bonus_multiplier_label'] ?? ($specialPayload['work_target_bonus_multiplier_label'] ?? ''))); $workTargetActualAfterHours = round((float) ($row['overtime_after_actual_hours'] ?? 0), 2); $workTargetActualAfterWeightedHours = round((float) ($row['overtime_after_actual_weighted_hours'] ?? 0), 2); @endphp @if ($isContinuesHours && str_contains($specialModeHours, 'carry')) @if ($continuesCarryIsWeekend && $continuesCarryTargetHours > 0) OVT Carry: {{ number_format($continuesCarryTargetHours, 2, ',', '.') }} jam
Carry: {{ $specialPayload['continues_carry_start_time'] ?? '-' }} - {{ $continuesCarryActualOut !== '' ? $continuesCarryActualOut : '-' }}
Bonus Target: {{ number_format($continuesCarryTargetBonusHours, 2, ',', '.') }} jam @else Carry Normal: {{ number_format($continuesNextDayWorkHours, 2, ',', '.') }} jam
Carry: {{ $specialPayload['continues_carry_start_time'] ?? '-' }} - {{ $continuesBonusCutoff }} @if (!empty($specialPayload['continues_carry_has_target_follow_up']))
OVT Target: {{ $continuesCarryTargetStart }} - {{ $continuesCarryTargetEnd }}
Actual: {{ $continuesCarryActualOut !== '' ? $continuesCarryActualOut : '-' }}
Bonus Carry: {{ number_format($continuesShortageHours, 2, ',', '.') }} jam
Bonus Target: {{ $continuesCarryActualOut !== '' ? $continuesCarryActualOut : '-' }} - {{ $continuesCarryTargetBonusEnd }} ({{ number_format($continuesCarryTargetBonusHours, 2, ',', '.') }} jam) @endif @endif @elseif ($isContinuesHours) @php $continuesActualHours = (float) ($row['actual_hours'] ?? $actualDisplayHours); $continuesRestHours = (float) ($row['break_hours'] ?? 0); $continuesEffectiveDisplayHours = max(0.0, $continuesActualHours - $continuesRestHours); @endphp
Aktual - Rest = Efektif
{{ number_format($continuesActualHours, 2, ',', '.') }} jam - {{ number_format($continuesRestHours, 2, ',', '.') }} jam = {{ number_format($continuesEffectiveDisplayHours, 2, ',', '.') }} jam
@if ($continuesTargetCoverageHours > 0)
Target Coverage Continues: {{ number_format($continuesTargetCoverageHours, 2, ',', '.') }} jam @endif @if (!empty($row['out_time']) && $row['out_time'] !== '-')
Overtime Cutoff 24 Jam @endif @elseif ($isEmergencyHours) {{ number_format($actualDisplayHours, 2, ',', '.') }}
Jam Aktual Emergency: {{ number_format($actualDisplayHours, 2, ',', '.') }} jam
Baseline Emergency: {{ $emergencyBaselineLabel }}
Profile Multiplier: {{ $emergencyMultiplierLabel }} @if ($emergencyBonusHours > 0)
Tambahan Jam Emergency: {{ number_format($emergencyBonusHours, 2, ',', '.') }} jam @endif @if ($emergencyBonusNominal > 0)
Insentif Emergency: Rp {{ number_format($emergencyBonusNominal, 2, ',', '.') }} @endif @if ($specialPaymentModeLabel !== '-')
Pembayaran Bonus: {{ $specialPaymentModeLabel }} @endif
Actual hour tetap jujur, emergency dimulai setelah baseline selesai. @elseif ($isTargetWorkHours)
Aktual: {{ number_format($actualDisplayHours, 2, ',', '.') }} jam
@if ($isTargetCarryWork)
Carry normal: 4,00 jam
Bonus carry: +4,00 jam
@else @if (!$targetPreviousSplMissing && $workTargetBonusCapHours > 0)
Target +{{ number_format($workTargetBonusCapHours, 2, ',', '.') }} jam
@endif @if (!$targetPreviousSplMissing && $workTargetCalculatedHours > 0)
Bonus: {{ number_format($workTargetCalculatedHours, 2, ',', '.') }} jam
@endif @endif
@elseif ($fixedCreditHours > 0) {{ number_format($fixedCreditHours, 2, ',', '.') }}
Aktual raw: {{ number_format($actualDisplayHours, 2, ',', '.') }} jam
Efektif fixed: {{ number_format($fixedCreditHours, 2, ',', '.') }} jam @elseif ($hasNormalBreakCut)
Aktual - Rest = Efektif
{{ rtrim(rtrim(number_format($sourceHours, 2, ',', '.'), '0'), ',') }} jam - {{ rtrim(rtrim(number_format((float) ($row['break_hours'] ?? 0), 2, ',', '.'), '0'), ',') }} jam = {{ rtrim(rtrim(number_format($actualDisplayHours, 2, ',', '.'), '0'), ',') }} jam
@else @if (! $isHolidayWeekend) {{ number_format($actualDisplayHours, 2, ',', '.') }} @endif @endif
{{ number_format((float) ($row['overtime_before_dynamic'][$otCol['key']] ?? 0), 2, ',', '.') }}
{{ number_format((float) ($row['overtime_after_dynamic'][$otCol['key']] ?? ($row['ot_dynamic'][$otCol['key']] ?? 0)), 2, ',', '.') }}
{{ number_format((float) ($row['overtime_before_weighted_hours'] ?? 0) + (float) ($row['overtime_after_weighted_hours'] ?? 0), 2, ',', '.') }} @if (!empty($row['leave_tag_label']))
Auto Exempt (Leave) @if ((bool) ($row['is_approved'] ?? false) || (bool) ($row['leave_is_payable'] ?? false)) Approved @endif
@elseif ($row['is_approved']) Approved @else Draft @endif
@foreach ($detailMarkerGroups as $detailMarker => $detailReferences)
{{ $detailMarker }} @if ($detailReferences !== [])
    @foreach ($detailReferences as $detailReference) @php $detailReference = rtrim(trim((string) $detailReference), " \t\n\r\0\x0B.,;:"); $erpaSplUrl = 'http://112.109.16.50/erpa25/Prinspl?id='.rawurlencode($detailReference); @endphp
  • {{ $detailReference }}
  • @endforeach
@endif
@endforeach @if ($detailNotes !== [])
{{ implode(' ', $detailNotes) }}
@endif
Rincian NominalRp {{ number_format($paymentBefore, 2, ',', '.') }} Rp {{ number_format($paymentNoRest1, 2, ',', '.') }} Rp {{ number_format($paymentNoRest2, 2, ',', '.') }}Rp {{ number_format($paymentAfter, 2, ',', '.') }} Rp {{ number_format($paymentNormal, 2, ',', '.') }} Rp {{ number_format($paymentTotal, 2, ',', '.') }}
Belum ada data.
GRAND TOTAL {{ $fmt($noRest1Hours) }} {{ $fmt($noRest2Hours) }} {{ $fmt($afterRawHours) }} {{ $fmt($publicView && $isProrataSalary ? $hkBaseHours : $sumPlannedHours) }} {{ $fmt($publicView && $isProrataSalary ? $hkMasuk : $sumHk) }} {{ $fmt($publicView && $isProrataSalary ? $jamMasukNormal : $sumActualEffectiveDisplay) }}{{ $fmt($ovtTotalWeighted) }}
Ringkasan Roster Shift Roster aktif: {{ (int) ($scheduleCounts['scheduled'] ?? 0) }} hari | OFF: {{ (int) ($scheduleCounts['off'] ?? 0) }} hari | Belum ada jadwal: {{ (int) ($scheduleCounts['waiting'] ?? 0) }} hari
{{ $isProrataSalary ? 'HK Efektif' : 'Total Jam Normal Plan Periode' }} {{ $isProrataSalary ? number_format($hkBasis, 2, ',', '.') . ' HK / ' . number_format($hkBaseHours, 2, ',', '.') . ' jam' : number_format($sumPlannedHours, 2, ',', '.') }}
{{ $isProrataSalary ? 'HK Kurang / Jam Kurang' : 'Total Jam Kurang Periode' }} {{ $isProrataSalary ? number_format($hkHoursPerDay > 0 ? ($jamTdkMasuk / $hkHoursPerDay) : 0, 2, ',', '.') . ' HK / ' . number_format($jamTdkMasuk, 2, ',', '.') . ' jam' : number_format($jamTdkMasuk, 2, ',', '.') }}
{{ $isProrataSalary ? 'Total Tanggal Merah bukan Weekend' : $prorateSummaryLabel }} - {{ number_format($isProrataSalary ? $prorataHolidayWeekday : $jamMasukNormal, 2, ',', '.') }}
Total Cuti{{ number_format($prorataCuti, 2, ',', '.') }}
Total Sakit{{ number_format($prorataSakit, 2, ',', '.') }}
Total Izin{{ number_format($prorataIzin, 2, ',', '.') }}
Proyeksi HK Payroll (hari)-{{ number_format($hkMasuk, 2, ',', '.') }} hari
Total Lembur (OT) {{ $fmt($sumOvertime) }}{{ $fmt($otTotals[$k] ?? 0) }}{{ $fmt($sumWeightedOvertime) }}
@if ($segmentView && !empty($detailRows))
@endif @if ($segmentView && !empty($detailRows)) @endif @if (!empty($deficitRows))
Audit Kekurangan Jam
Hanya tanggal dengan jam kurang yang ditampilkan.
{{ count($deficitRows) }} hari bermasalah
@foreach ($deficitRows as $auditRow) @php $auditRowClass = $auditRow['deficit_hours'] >= $hkHoursPerDay ? 'audit-row-heavy' : 'audit-row-light'; @endphp @endforeach
Tanggal Jenis Jam Diakui Kurang Penanda
{{ $auditRow['work_date'] }} ({{ $auditRow['day_name'] }}) {{ ucfirst($auditRow['day_type']) }} @if ($auditRow['leave_tag_label'] !== '')
{{ $auditRow['leave_tag_label'] }} @endif
{{ number_format($auditRow['normal_hours'], 2, ',', '.') }} jam {{ number_format($auditRow['deficit_hours'], 2, ',', '.') }} jam {!! nl2br(e($auditRow['reason'])) !!}
Total Jam Kurang Periode {{ number_format($totalDeficitHours, 2, ',', '.') }} jam
@endif @once @endonce