@extends('layouts.app') @section('title', '請假統計') @section('content')

請假統計

{{ $year }} 年度全員請假彙整
@foreach([now()->year, now()->year-1] as $y) {{ $y }} @endforeach @if($showInactive) 含已離職 點此回到在職 @else 查看已離職 @endif 配額設定
@foreach($types as $t) @endforeach @php $asOf = $year >= now()->year ? now() : \Carbon\Carbon::create($year, 12, 31); @endphp @foreach($users as $u) @php $userRequests = $requests[$u->id] ?? collect(); $total = 0; // 年資計算(以所選年度 +1/1/1 為基準,使 12/31 整月計入) $seniority = '—'; if ($u->joined_at) { $months = $u->joined_at->diffInMonths($asOf); $yrs = intdiv($months, 12); $rem = $months % 12; $senPart = ($yrs > 0 ? "{$yrs}年" : '') . ($rem > 0 ? "{$rem}月" : ''); $seniority = $senPart ?: '< 1月'; } // 法定特休(年度比例計算) $leaveCalc = $u->annualLeaveForYear($year); $annualDays = $annualQuotas[$u->id] ?? null; @endphp @foreach($types as $lt) @php $used = $userRequests->where('leave_type_id', $lt->id)->sum('days'); $total += $used; @endphp @endforeach @endforeach
員工編號 部門 職稱 姓名 年資 核定特休 {{ $t->name }} 合計
{{ $u->employee_no ?: '—' }} {{ $u->department ?: '—' }} {{ $u->position ?: '—' }} {{ $u->name }} @if($showInactive && !$u->is_active) 已離職 @endif {{ $seniority }} @if($annualDays !== null && $leaveCalc) @php $mismatch = (float)$annualDays < $leaveCalc['days']; @endphp {{ number_format((float)$annualDays, 2) }} @if($mismatch) @endif @elseif($annualDays !== null) {{ number_format((float)$annualDays, 2) }} @else @endif @if($used > 0) {{ number_format((float)$used, 2) }} @else @endif {{ $total > 0 ? number_format((float)$total, 2) : '—' }}
@endsection