diff --git a/BACKEND/Modules/Admin/app/Http/Controllers/TicketController.php b/BACKEND/Modules/Admin/app/Http/Controllers/TicketController.php index 9b4fdd7..7fd2542 100644 --- a/BACKEND/Modules/Admin/app/Http/Controllers/TicketController.php +++ b/BACKEND/Modules/Admin/app/Http/Controllers/TicketController.php @@ -628,15 +628,27 @@ class TicketController extends Controller $days_will_use = 0; $days_will_use_without_pay = $monthData['days_requested']; } else if ($remainingDaysInMonthRemaining < $monthData['days_requested']) { // không đủ ngày phép - $hasInsufficientDays = true; - $month_data_status = 'insufficient_days'; - $daysNotEnough = $monthData['days_requested'] - $remainingDaysInMonthRemaining; - $monthMessage = "* Tháng {$monthData['month']}/{$monthData['year']}: \n - Số ngày phép còn lại: {$remainingDaysInMonthRemaining}, Số ngày yêu cầu: {$monthData['days_requested']}.\n - Bạn sẽ sử dụng {$remainingDaysInMonthRemaining} ngày phép và {$daysNotEnough} ngày không phép."; - $errorMessage .= $errorMessage ? "\n\n" . $monthMessage : $monthMessage; - $remainingDaysInMonthIsUsed = $remainingDaysInMonth; // lấy số ngày phép còn lại của tháng đó + if ( + $remainingDaysInMonthRemaining >= $maxDaysPerMonth + ) { + $hasInsufficientDays = true; + $month_data_status = 'exceed_max_days'; + $daysNotEnough = $monthData['days_requested'] - $remainingDaysInMonthRemaining; + $monthMessage = "* Theo quy định ngày phép tối đa mỗi tháng là {$maxDaysPerMonth} ngày. \nTháng {$monthData['month']}/{$monthData['year']}: \n - Bạn đã sử dụng {$usedDaysInMonth} ngày phép, còn lại {$remainingDaysInMonthRemaining} ngày phép.\n - Bạn sẽ sử dụng {$maxDaysPerMonth} ngày phép và {$daysNotEnough} ngày không phép."; + $errorMessage .= $errorMessage ? "\n\n" . $monthMessage : $monthMessage; + $days_will_use = $maxDaysPerMonth; + $days_will_use_without_pay = $monthData['days_requested'] - $maxDaysPerMonth; + } else { + $hasInsufficientDays = true; + $month_data_status = 'insufficient_days'; + $daysNotEnough = $monthData['days_requested'] - $remainingDaysInMonthRemaining; + $monthMessage = "* Tháng {$monthData['month']}/{$monthData['year']}: \n - Số ngày phép còn lại: {$remainingDaysInMonthRemaining}, Số ngày yêu cầu: {$monthData['days_requested']}.\n - Bạn sẽ sử dụng {$remainingDaysInMonthRemaining} ngày phép và {$daysNotEnough} ngày không phép."; + $errorMessage .= $errorMessage ? "\n\n" . $monthMessage : $monthMessage; + $remainingDaysInMonthIsUsed = $remainingDaysInMonth; // lấy số ngày phép còn lại của tháng đó - $days_will_use = $remainingDaysInMonthRemaining; - $days_will_use_without_pay = $daysNotEnough; + $days_will_use = $remainingDaysInMonthRemaining; + $days_will_use_without_pay = $daysNotEnough; + } } else if ( $remainingDaysInMonthRemaining >= $monthData['days_requested'] ) { // Đủ ngày phép ở tháng đó