 }})
@php
$fullName = $leave->user->name ?? '';
$last = $first = $middle = '';
if (strpos($fullName, ',') !== false) {
[$last, $rest] = explode(',', $fullName, 2);
$rest = trim($rest);
$restParts = explode(' ', $rest);
$first = $restParts[0] ?? '';
$middle = isset($restParts[1]) ? $restParts[1] : '';
} else {
$parts = explode(' ', $fullName);
$first = $parts[0] ?? '';
$middle = $parts[1] ?? '';
$last = $parts[2] ?? '';
}
$standardTypes = [
'Vacation Leave', 'Mandatory/Forced Leave', 'Sick Leave', 'Maternity Leave', 'Paternity Leave',
'Special Privilege Leave', 'Solo Parent Leave', 'Study Leave', '10-Day VAWC Leave',
'Rehabilitation Privilege', 'Special Leave Benefits for Women', 'Special Emergency (Calamity) Leave', 'Adoption Leave'
];
if (is_array($leave->leave_type)) {
$leaveTypesArr = $leave->leave_type;
} elseif (is_string($leave->leave_type) && $leave->leave_type && $leave->leave_type[0] === '[') {
$leaveTypesArr = json_decode($leave->leave_type, true) ?? [];
} else {
$leaveTypesArr = [];
}
$officeFull = $leave->office ?? ($leave->user->offices ?? '');
if (preg_match('/\(([^)]+)\)/', $officeFull, $matches)) {
$officeShortcut = $matches[1];
} else {
$officeShortcut = '';
}
@endphp
{{ $officeShortcut }}
{{ $last }}
{{ $first }}
{{ $middle }}
@php
$filingDateValue = $filingDate ?? ($leave->filing_date ?? '');
if ($filingDateValue) {
try {
$date = \Carbon\Carbon::parse($filingDateValue);
echo $date->format('M. j, Y');
} catch (Exception $e) {
echo $filingDateValue;
}
}
@endphp
{{ $leave->user->position ?? $leave->position ?? '' }}
{{ $leave->salary ?? '' }}
@foreach($leaveTypesArr as $type)
@if(!in_array($type, $standardTypes))
@endif
@endforeach
{{ $leave->within_ph_details ?? '' }}
{{ $leave->abroad_details ?? '' }}
{{ $leave->in_hospital_details ?? '' }}
{{ $leave->out_patient_details ?? '' }}
{{ $leave->special_leave_details ?? '' }}
{{ $leave->num_days ?? '' }}
@php
$displayed = false;
$raw = $leave->inclusive_dates ?? '';
$ranges = [];
// Try to decode JSON if it looks like a JSON array
if (is_string($raw) && strlen($raw) > 0 && $raw[0] === '[') {
$decoded = json_decode($raw, true);
if (is_array($decoded)) {
$ranges = $decoded;
}
} elseif (is_array($raw)) {
$ranges = $raw;
} elseif (is_string($raw)) {
$ranges = explode(',', $raw);
}
if (count($ranges)) {
foreach($ranges as $idx => $range) {
$range = trim($range, " \"");
$dates = explode(' to ', $range);
if(count($dates) === 2) {
try {
$start = \Carbon\Carbon::parse($dates[0]);
$end = \Carbon\Carbon::parse($dates[1]);
if ($start->format('M Y') === $end->format('M Y')) {
echo $start->format('M j') . '-' . $end->format('j, Y');
} elseif ($start->format('Y') === $end->format('Y')) {
echo $start->format('M j') . ' - ' . $end->format('M j, Y');
} else {
echo $start->format('M j, Y') . ' - ' . $end->format('M j, Y');
}
} catch (Exception $e) {
echo e($range);
}
} else {
// Format single date as 'M j, Y'
try {
$single = \Carbon\Carbon::parse($range);
echo $single->format('M j, Y');
} catch (Exception $e) {
echo e($range);
}
}
if ($idx !== count($ranges) - 1) echo ', ';
$displayed = true;
}
}
if (!$displayed) {
echo e($formattedInclusiveDates ?? $raw);
}
@endphp
@php
// Prefer the HR certification timestamp, fallback to stored as-of value
$asOfRaw = $certData['as_of_date'] ?? $certDate ?? '';
$certifiedAt = $leave->certified_at ?? null;
try {
if (!empty($certifiedAt)) {
$dt = \Carbon\Carbon::parse($certifiedAt)->timezone('Asia/Manila');
echo $dt->format('M j, Y g:i A');
} elseif (!empty($asOfRaw)) {
$dt = \Carbon\Carbon::parse($asOfRaw)->timezone('Asia/Manila');
echo $dt->format('M j, Y g:i A');
}
} catch (Exception $e) {
echo e($certifiedAt ?: $asOfRaw);
}
@endphp
{{ $certData['vl_earned'] ?? '' }}
{{ $certData['vl_less'] ?? '' }}
{{ $certData['vl_balance'] ?? '' }}
{{ $certData['sl_earned'] ?? '' }}
{{ $certData['sl_less'] ?? '' }}
{{ $certData['sl_balance'] ?? '' }}
{{ $certData['hr_name'] ?? 'JOY ROSE C. BAWAYAN' }}
{{ $certData['hr_position'] ?? 'Administrative Officer V (HRMO III)' }}
@php
// Only show 2nd signatory if user provided one
$adminName = '';
$adminPosition = '';
if (!empty($leave->admin_signatory)) {
$adminParts = explode('|', $leave->admin_signatory);
$adminName = $adminParts[0] ?? '';
$adminPosition = $adminParts[1] ?? '';
}
@endphp
@if(!empty($adminName))
{{ $adminName }}
{{ $adminPosition }}
@endif
{{ $certData['director_name'] ?? 'Atty. JENNILYN M. DAWAYAN, CESO IV' }}
{{ $certData['director_position'] ?? 'Regional Executive Director' }}
{{ $certData['approved_with_pay'] ?? '' }}
{{ $certData['approved_without_pay'] ?? '' }}
{{ $certData['approved_others'] ?? '' }}
@yield('signatory_overlay')