diff --git a/htdocs/app/Livewire/GudangPos.php b/htdocs/app/Livewire/GudangPos.php index 8567eb80..ead1e972 100644 --- a/htdocs/app/Livewire/GudangPos.php +++ b/htdocs/app/Livewire/GudangPos.php @@ -344,7 +344,20 @@ class GudangPos extends Component $jenisNama = (string) ($row->jenis ?? ''); $expired = (string) ($row->latest_expired ?? ''); if ($jenisNama !== '' && $expired !== '') { - $latestExpiredMap[$jenisNama] = Carbon::parse($expired)->format('d-m-Y'); + $expiredDate = Carbon::parse($expired)->startOfDay(); + $today = Carbon::today(); + $daysLeft = $today->diffInDays($expiredDate, false); + $badgeClass = 'success'; + if ($daysLeft < 0) { + $badgeClass = 'danger'; + } elseif ($daysLeft <= 30) { + $badgeClass = 'warning'; + } + + $latestExpiredMap[$jenisNama] = [ + 'date' => $expiredDate->format('d-m-Y'), + 'badge_class' => $badgeClass, + ]; } } } diff --git a/htdocs/resources/views/livewire/gudang-pos.blade.php b/htdocs/resources/views/livewire/gudang-pos.blade.php index 64f18fa6..ee850b91 100644 --- a/htdocs/resources/views/livewire/gudang-pos.blade.php +++ b/htdocs/resources/views/livewire/gudang-pos.blade.php @@ -48,7 +48,14 @@ Satuan: {{ $p->satuan }} @if(($p->satuan_kecil ?? '') !== '') / {{ $p->satuan_kecil }} @endif