@extends('admin.admin_dashboard') @section('admin') @php $statusColors = [ 'pending' => ['bg' => '#fef3c7', 'text' => '#92400e', 'border' => '#f59e0b', 'badge' => 'warning', 'label' => 'Pending'], 'approved' => ['bg' => '#dcfce7', 'text' => '#166534', 'border' => '#22c55e', 'badge' => 'success', 'label' => 'Approved'], 'rejected' => ['bg' => '#fee2e2', 'text' => '#991b1b', 'border' => '#ef4444', 'badge' => 'danger', 'label' => 'Rejected'], 'cancelled' => ['bg' => '#f1f5f9', 'text' => '#475569', 'border' => '#94a3b8', 'badge' => 'secondary', 'label' => 'Cancelled'], ]; $st = $statusColors[$leave->status] ?? $statusColors['pending']; $fromDate = \Carbon\Carbon::parse($leave->from_date); $toDate = \Carbon\Carbon::parse($leave->to_date); $totalDays = $fromDate->diffInDays($toDate) + 1; $schoolProfile = \App\Models\SchoolProfile::first(); $schoolName = $schoolProfile->school_name ?? 'Mascot Innovative School and College'; $schoolLogo = !empty($schoolProfile?->school_logo) ? (file_exists(public_path('storage/' . ltrim($schoolProfile->school_logo, '/'))) ? asset('storage/' . ltrim($schoolProfile->school_logo, '/')) : asset('core/storage/app/public/' . ltrim($schoolProfile->school_logo, '/'))) : asset('asset/images/school_logo.png'); @endphp
{{-- Breadcrumb --}} {{-- Session Alerts --}} @if(session('success')) @endif @if(session('error')) @endif {{-- Top Action / Control Bar --}}
Back to List | Application #{{ str_pad($leave->id, 5, '0', STR_PAD_LEFT) }} {{ $st['label'] }}
{{-- Print Button --}} {{-- Approve / Reject Actions (Only if Pending) --}} @if($leave->status === 'pending') @canAny(['Admin','Approve Leave', 'Reject Leave'])
@csrf
@csrf
@endcanAny @endif
{{-- Main Application Document Paper --}}
{{-- Document Letterhead --}}

{{ $schoolName }}

@if(!empty($schoolProfile?->address)) {{ $schoolProfile->address }} @endif @if(!empty($schoolProfile?->phone)) • Phone: {{ $schoolProfile->phone }} @endif @if(!empty($schoolProfile?->email)) • Email: {{ $schoolProfile->email }} @endif
Official Leave Application
@if($leave->status === 'approved') APPROVED @elseif($leave->status === 'rejected') REJECTED @else PENDING @endif
{{-- Meta Information Bar --}}
Tracking ID: #LA-{{ str_pad($leave->id, 5, '0', STR_PAD_LEFT) }}
Leave Type: {{ ucfirst($leave->leave_type) }}
Submission Date: {{ $leave->created_at->format('d F, Y') }}
{{-- Recipient Section (বরাবর) --}}
Date: {{ $leave->created_at->format('d F, Y') }}
To,
The Principal / Head of Institution,
{{ $schoolName }}
@if(!empty($schoolProfile?->address))
{{ $schoolProfile->address }}
@endif
{{-- Subject Line --}}
Subject: Application for {{ ucfirst($leave->leave_type) }} Leave for {{ $totalDays }} day{{ $totalDays > 1 ? 's' : '' }} (From {{ $fromDate->format('d M, Y') }} to {{ $toDate->format('d M, Y') }}).
{{-- Salutation & Letter Body --}}

Respected Sir / Madam,

With due respect and humble submission, I am writing to state that I am unable to perform my official / academic duties from {{ $fromDate->format('d F, Y (l)') }} to {{ $toDate->format('d F, Y (l)') }} (Total {{ $totalDays }} day{{ $totalDays > 1 ? 's' : '' }}) due to the following reason:

{{-- Reason Statement Box --}}
Reason for Absence:
"{{ $leave->reason }}"

I, therefore, earnestly pray and hope that your honor would be kind enough to grant me {{ ucfirst($leave->leave_type) }} leave for the stated period and oblige thereby. I will resume my duties promptly on the next working day and ensure any pending responsibilities are addressed.

{{-- Summary Table inside Document --}} @if(in_array($leave->status, ['approved', 'rejected'])) @endif
Applicant Name {{ $leave->employee->name ?? 'N/A' }}
Designation / Post {{ $leave->employee->postDetails->name ?? $leave->employee->post ?? 'N/A' }}
Employee ID {{ $leave->employee->e_id ?? 'N/A' }}
Contact Information Phone: {{ $leave->employee->phone ?? 'N/A' }} @if(!empty($leave->employee?->email)) • Email: {{ $leave->employee->email }} @endif
Leave Period {{ $fromDate->format('d M Y') }} to {{ $toDate->format('d M Y') }} {{ $totalDays }} Day{{ $totalDays > 1 ? 's' : '' }}
Applied On {{ $leave->created_at->copy()->timezone('Asia/Dhaka')->format('d M Y, h:i A') }} (Asia/Dhaka)
{{ $leave->status === 'approved' ? 'Approval' : 'Rejection' }} Note {{ ucfirst($leave->status) }} by {{ $leave->approvedBy->name ?? 'Authority' }} at {{ $leave->approved_at ? $leave->approved_at->copy()->timezone('Asia/Dhaka')->format('d M Y, h:i A') : 'N/A' }}
{{-- Signature & Endorsement Block --}}
{{-- Applicant Signature --}}
{{ $leave->employee->name ?? 'Applicant Signature' }}
{{ $leave->employee->postDetails->name ?? $leave->employee->post ?? 'Employee' }}
ID: {{ $leave->employee->e_id ?? 'N/A' }}
Date: {{ $leave->created_at->format('d/m/Y') }}
{{-- Authority Signature --}}
@if($leave->status === 'approved')
Digitally Approved
@elseif($leave->status === 'rejected')
Application Rejected
@endif
@if(!empty($leave->approvedBy)) {{ $leave->approvedBy->name }} @else Principal / Authority Signature @endif
{{ $schoolName }}
@if($leave->approved_at) Date: {{ $leave->approved_at->format('d/m/Y, h:i A') }} @else Date: ____________________ @endif
@endsection