Leave Details
{{$leave_pgk->title}}
{{$leave_request->reason}}
Approved Leave ({{ $paid_count }})
@if($paid_count > 0)
@foreach($paid_dates as $d)
{{ \Carbon\Carbon::parse($d)->format('d M Y') }}
@endforeach
@else
No paid dates
@endif
Not Approved Leave ({{ $unpaid_count }})
@if($unpaid_count > 0)
@foreach($unpaid_dates as $d)
{{ \Carbon\Carbon::parse($d)->format('d M Y') }}
@endforeach
@else
No unpaid dates
@endif
@foreach($all_pkgs as $all_pkg)
@php
$color_code = $all_pkg->color_code;
$linear_gradient_start = 'rgba(0, 0, 0, 0.15)';
$linear_gradient_end = 'rgba(0, 0, 0, 0.15)';
$text_color = '#fff';
$leave_requests_for_pkg = DB::table('leave_requests')
->where('leave_package_id', $all_pkg->id)
->where('employee_id', $emp_details->id)
->where('status', 1)
->get();
$count = 0;
foreach ($leave_requests_for_pkg as $leave) {
if (!empty($leave->paid_dates) && $leave->paid_days > 0) {
$count += $leave->paid_days;
} else {
// Recalculate working days excluding weekends
$start_date = new DateTime($leave->from);
$end_date = new DateTime($leave->to);
$working_days = 0;
$current_date = clone $start_date;
while ($current_date <= $end_date) {
// Skip Saturday (6) and Sunday (0)
if ($current_date->format('w') != '0' && $current_date->format('w') != '6') {
$working_days++;
}
$current_date->modify('+1 day');
}
$count += $working_days;
}
}
@endphp
@if ($color_code)
@php
list($r, $g, $b) = sscanf($color_code, "#%02x%02x%02x");
$linear_gradient_start = "rgba($r, $g, $b, 0.15)";
$linear_gradient_end = "rgba($r, $g, $b, 0.15)";
$text_color = "$color_code";
@endphp
@endif
@endforeach
{{$count}} / {{$all_pkg->leave_number}}
{{$all_pkg->title}}
@if($total_days > 1)
@endif