@extends('dining.layouts.dining-member')
@section('title', 'Discounted Vouchers - The LaLiT Dining')
@section('content')
| Name |
Status |
Max Usage |
Redeemed |
Available |
Refresh Date |
Action |
@if(isset($discountedVouchers) && count($discountedVouchers) > 0)
@foreach($discountedVouchers as $voucher)
@php
$status = strtoupper($voucher['status'] ?? 'AVAILABLE');
// Set status color based on status value
$statusColor = match($status) {
'USED' => '#28a745', // Green
'AVAILABLE' => '#4169E1', // Blue
'EXPIRED' => '#dc3545', // Red
'TRANSFERED' => '#ffc107', // Yellow
'CANCELLED' => '#6c757d', // Gray
default => '#4169E1' // Default Blue
};
$statusText = ucfirst(strtolower($status));
// Get usage policy data
$maxUsage = $voucher['usage_policy']['usage_count'] ?? 0;
$usageFrequency = $voucher['usage_policy']['usage_frequency'] ?? 'Monthly';
// Calculate redeemed count from history[0]['availment_count']
$redeemedCount = 0;
if (isset($voucher['history']) && is_array($voucher['history']) && count($voucher['history']) > 0) {
$redeemedCount = $voucher['history'][0]['availment_count'] ?? 0;
}
// Calculate available count
$availableCount = max(0, $maxUsage - $redeemedCount);
// Calculate refresh date - 1st of next month
$refreshDate = \Carbon\Carbon::now()->addMonth()->startOfMonth()->format('M d, Y');
// Determine status badge based on availability
if ($availableCount == 0) {
$displayStatusColor = '#dc3545'; // Red for exhausted
$displayStatusText = 'Exhausted';
} elseif ($availableCount <= 2) {
$displayStatusColor = '#ffc107'; // Yellow for limited
$displayStatusText = 'Limited';
} else {
$displayStatusColor = $statusColor; // Use original status color
$displayStatusText = $statusText;
}
@endphp
|
{{ $voucher['product']['name'] ?? 'N/A' }}
Code: {{ $voucher['privilege_code'] ?? 'N/A' }}
|
{{ $displayStatusText }}
|
{{ $maxUsage }} |
{{ $redeemedCount }} |
{{ $availableCount }} |
{{ $refreshDate }}
{{ ucfirst($usageFrequency) }} Reset
|
View Details
|
@endforeach
@else
|
No discounted vouchers available at this time.
|
@endif
| Name |
Status |
Redeemed on Date/ Time |
Redeemed at Location |
Expiry date |
@endsection