From 2c8bb92775e3eb274d0aa68ac09bdb1bd8b7ee0a Mon Sep 17 00:00:00 2001 From: Truong Vo <41848815+vmtruong301296@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:31:15 +0700 Subject: [PATCH] =?UTF-8?q?B=E1=BB=95=20sung=20check=20ng=C3=A0y=20ph?= =?UTF-8?q?=C3=A9p=20t=E1=BB=91i=20=C4=91a=201=20th=C3=A1ng=20m=E1=BA=B7c?= =?UTF-8?q?=20d=C3=B9=20c=C3=B2n=20nhi=E1=BB=81u=20ph=C3=A9p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/Http/Controllers/TicketController.php | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) 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 đó