@extends('layouts.app') @section('header_title', 'Pengajuan Cuti Karyawan') @section('content')

Sisa Jatah & Hutang Kuota Cuti

Kuota otomatis disesuaikan dengan syarat masa kerja, agenda cuti bersama, dan riwayat cuti disetujui.

@foreach($leaveTypes as $lType) @php $employeeModel = App\Models\Employee::find(Auth::id()); $joinDate = \Carbon\Carbon::parse($employeeModel->join_date ?? $employeeModel->created_at ?? now()); $currentEmployeeMonths = $joinDate->diffInMonths(now()); $collectiveDeductionDays = $collectiveLeaves->filter(function($col) use ($lType) { $isActive = $col->is_active; $isDeduct = (string)$col->is_deduct_leave === '1'; $isMatchingType = is_null($col->leave_type_id) || (string)$col->leave_type_id === (string)$lType->id; return $isActive && $isDeduct && $isMatchingType; })->sum(function($col) { return \Carbon\Carbon::parse($col->start_date)->diffInDays(\Carbon\Carbon::parse($col->end_date)) + 1; }); $approvedLeaveDays = App\Models\EmployeeLeave::where('employee_id', Auth::id()) ->where('leave_type_id', $lType->id) ->where('status', 'approved') ->sum('total_days'); $effectiveQuota = $lType->default_quota; $isEligibleByService = true; if ($lType->requires_service_requirement && !is_null($lType->min_service_months)) { if ($currentEmployeeMonths < $lType->min_service_months) { $effectiveQuota = 0; $isEligibleByService = false; } } $netQuota = $effectiveQuota - $collectiveDeductionDays - $approvedLeaveDays; @endphp

{{ $lType->name }}

@if(!$isEligibleByService) Belum memenuhi masa kerja (Min. {{ $lType->min_service_months }} bln) @else Default: {{ $lType->default_quota }} Hari @if($collectiveDeductionDays > 0) (Potong Bersama: -{{ $collectiveDeductionDays }}h) @endif @endif
@if($netQuota < 0)
Hutang: {{ abs($netQuota) }} Hari
@else
Sisa: {{ $netQuota }} Hari
@endif
@endforeach

Agenda Cuti Bersama & Libur

Aturan pemotongan kuota berdasarkan agenda aktif:

@forelse($collectiveLeaves as $agenda)
{{ $agenda->title }} {{ (string)$agenda->is_deduct_leave === '1' ? 'Potong Kuota (1)' : 'Tidak Potong (0)' }}

{{ \Carbon\Carbon::parse($agenda->start_date)->format('d M Y') }} s/d {{ \Carbon\Carbon::parse($agenda->end_date)->format('d M Y') }}

@empty

Belum ada agenda aktif.

@endforelse

Riwayat Pengajuan Cuti

Kelola cuti dan lacak status alur persetujuan berjenjang ala ekspedisi.

@if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif
@forelse($leaves as $item) @empty @endforelse
Karyawan & Jenis Cuti Durasi Tanggal Alasan & Lampiran Status Dokumen Lacak Ekspedisi Aksi
{{ $item->employee->name ?? '-' }} {{ $item->leaveType->name ?? '-' }}
{{ \Carbon\Carbon::parse($item->start_date)->format('d M Y') }} s/d {{ \Carbon\Carbon::parse($item->end_date)->format('d M Y') }}
Total: {{ $item->total_days }} Hari

{{ $item->reason }}

@php $attachmentPath = $item->attachment ?? $item->file ?? $item->file_path ?? null; $attachmentUrl = $attachmentPath ? asset('storage/' . $attachmentPath) : null; @endphp @if($attachmentUrl)
@else Tidak ada lampiran @endif
@php $statusBadge = [ 'pending' => 'bg-amber-50 text-amber-700 border-amber-200', 'approved' => 'bg-emerald-50 text-emerald-700 border-emerald-200', 'rejected' => 'bg-rose-50 text-rose-700 border-rose-200', ][$item->status ?? 'pending']; @endphp {{ $item->status }} @if($item->status === 'pending' && ($item->employee_id === Auth::id() || $isAdminOrHR))
@csrf @method('DELETE')
@endif
Belum ada data pengajuan cuti.[cite: 11]
{{ $leaves->links() }}
@endsection @push('scripts') @endpush