Restore all zeroed views + add bulk gift certificate creation

The HTML entity sweep script had a bug where it wrote empty files for any
view that contained no target Unicode characters, zeroing out 215 view files.
All views restored from the pre-sweep commit (cefdf3e).

Bulk gift certificate feature:
- BulkCreateGiftCertificateDto with Quantity (1-500), Amount, Reason, Expiry, Notes
- GenerateBulkGiftCertificatePdfAsync on IPdfService / PdfService: one Letter page
  per cert, reusing the same purple/gold branded ComposeGiftCertificateContent helper
- GiftCertificatesController: BulkCreate GET/POST, BulkResult GET, BulkDownloadPdf POST
- Views: BulkCreate.cshtml (form with live total preview), BulkResult.cshtml (table +
  Download All PDF button that POSTs cert IDs to avoid URL length limits)
- gift-certificate-bulk.js: live preview + spinner/disable on submit
- Index.cshtml: Bulk Create button added alongside New Certificate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 20:09:22 -04:00
parent 3eda91f170
commit 4ec55e7290
240 changed files with 73116 additions and 0 deletions
@@ -0,0 +1,107 @@
@model PowderCoating.Application.DTOs.GiftCertificate.BulkCreateGiftCertificateDto
@using PowderCoating.Core.Enums
@{
ViewData["Title"] = "Bulk Create Gift Certificates";
ViewData["PageIcon"] = "bi-gift";
}
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom py-3">
<h5 class="mb-0">
<i class="bi bi-collection me-2 text-primary"></i>Bulk Gift Certificate Generator
</h5>
<p class="text-muted small mb-0 mt-1">
Create a batch of certificates for car shows, events, or promotions. All certificates will have the same
face value and be generated with sequential codes ready to print.
</p>
</div>
<div class="card-body p-4">
<form asp-action="BulkCreate" method="post">
<div asp-validation-summary="ModelOnly" class="alert alert-danger" role="alert"></div>
<div class="row g-3">
<div class="col-md-5">
<label asp-for="Quantity" class="form-label fw-semibold">
<i class="bi bi-123 me-1 text-muted"></i>@Html.DisplayNameFor(m => m.Quantity)
</label>
<input asp-for="Quantity" type="number" class="form-control form-control-lg"
min="1" max="500" placeholder="25" />
<span asp-validation-for="Quantity" class="text-danger small"></span>
<div class="form-text">Max 500 per batch.</div>
</div>
<div class="col-md-7">
<label asp-for="Amount" class="form-label fw-semibold">
<i class="bi bi-currency-dollar me-1 text-muted"></i>@Html.DisplayNameFor(m => m.Amount)
</label>
<div class="input-group input-group-lg">
<span class="input-group-text">$</span>
<input asp-for="Amount" type="number" class="form-control"
min="1" max="9999.99" step="0.01" placeholder="50.00" />
</div>
<span asp-validation-for="Amount" class="text-danger small"></span>
</div>
<div class="col-12">
<label asp-for="IssuedReason" class="form-label fw-semibold">
<i class="bi bi-tag me-1 text-muted"></i>@Html.DisplayNameFor(m => m.IssuedReason)
</label>
<select asp-for="IssuedReason" class="form-select">
@foreach (var reason in Enum.GetValues<GiftCertificateIssuedReason>())
{
<option value="@reason">@reason</option>
}
</select>
<span asp-validation-for="IssuedReason" class="text-danger small"></span>
</div>
<div class="col-12">
<label asp-for="ExpiryDate" class="form-label fw-semibold">
<i class="bi bi-calendar-x me-1 text-muted"></i>@Html.DisplayNameFor(m => m.ExpiryDate)
</label>
<input asp-for="ExpiryDate" type="date" class="form-control" />
<span asp-validation-for="ExpiryDate" class="text-danger small"></span>
<div class="form-text">Leave blank for no expiration.</div>
</div>
<div class="col-12">
<label asp-for="Notes" class="form-label fw-semibold">
<i class="bi bi-chat-left-text me-1 text-muted"></i>@Html.DisplayNameFor(m => m.Notes)
</label>
<textarea asp-for="Notes" class="form-control" rows="2"
placeholder="e.g. Awarded at the 2026 Summer Car Show &mdash; thanks for attending!"></textarea>
<span asp-validation-for="Notes" class="text-danger small"></span>
<div class="form-text">Printed on every certificate in the batch.</div>
</div>
</div>
<!-- Preview summary -->
<div id="batchPreview" class="alert alert-primary mt-4 mb-0" style="display:none">
<i class="bi bi-info-circle me-2"></i>
You are about to create <strong id="prevQty"></strong> certificates worth
<strong id="prevAmt"></strong> each &mdash; total face value
<strong id="prevTotal"></strong>.
</div>
<div class="d-flex justify-content-between align-items-center mt-4 pt-3 border-top">
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i>Cancel
</a>
<button type="submit" class="btn btn-primary btn-lg" id="submitBtn">
<i class="bi bi-plus-circle me-2"></i>Create Certificates
</button>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
<script src="~/js/gift-certificate-bulk.js" asp-append-version="true"></script>
}
@@ -0,0 +1,89 @@
@model List<PowderCoating.Core.Entities.GiftCertificate>
@using PowderCoating.Core.Enums
@{
ViewData["Title"] = "Batch Created";
ViewData["PageIcon"] = "bi-gift";
var count = ViewBag.CertCount as int? ?? Model.Count;
var amount = ViewBag.CertAmount as string ?? "0.00";
var ids = ViewBag.CertIds as List<int> ?? Model.Select(c => c.Id).ToList();
}
<div class="alert alert-success alert-permanent mb-4">
<i class="bi bi-check-circle-fill me-2"></i>
<strong>@count gift certificates created</strong> &mdash; each worth $@amount.
Download the PDF below to print the full batch.
</div>
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-bottom d-flex justify-content-between align-items-center py-3">
<h5 class="mb-0">
<i class="bi bi-collection me-2 text-primary"></i>Batch Certificates (@count)
</h5>
<form asp-action="BulkDownloadPdf" method="post">
@Html.AntiForgeryToken()
@foreach (var id in ids)
{
<input type="hidden" name="certIds" value="@id" />
}
<button type="submit" class="btn btn-primary">
<i class="bi bi-file-pdf me-2"></i>Download All as PDF
</button>
</form>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Certificate Code</th>
<th>Face Value</th>
<th>Issued</th>
<th>Expiry</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var cert in Model)
{
<tr>
<td class="fw-mono fw-semibold">@cert.CertificateCode</td>
<td>@cert.OriginalAmount.ToString("C")</td>
<td>@cert.IssueDate.ToLocalTime().ToString("MMM d, yyyy")</td>
<td>
@(cert.ExpiryDate.HasValue
? cert.ExpiryDate.Value.ToLocalTime().ToString("MMM d, yyyy")
: "&mdash;")
</td>
<td><span class="badge bg-success">Active</span></td>
<td class="text-end">
<a asp-action="Details" asp-route-id="@cert.Id" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-eye"></i>
</a>
<a asp-action="DownloadPdf" asp-route-id="@cert.Id" class="btn btn-sm btn-outline-secondary" title="Download single PDF">
<i class="bi bi-file-pdf"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<div class="card-footer bg-white border-top d-flex justify-content-between align-items-center py-3">
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i>Back to Gift Certificates
</a>
<form asp-action="BulkDownloadPdf" method="post">
@Html.AntiForgeryToken()
@foreach (var id in ids)
{
<input type="hidden" name="certIds" value="@id" />
}
<button type="submit" class="btn btn-primary">
<i class="bi bi-printer me-2"></i>Print Batch PDF (@count pages)
</button>
</form>
</div>
</div>
@@ -0,0 +1,134 @@
@model PowderCoating.Application.DTOs.GiftCertificate.CreateGiftCertificateDto
@using PowderCoating.Core.Enums
@{
ViewData["Title"] = "New Gift Certificate";
ViewData["PageIcon"] = "bi-gift";
}
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="d-flex justify-content-end mb-4">
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-2"></i>Back
</a>
</div>
<form asp-action="Create" method="post">
@Html.AntiForgeryToken()
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-currency-dollar me-2 text-primary"></i>Certificate Details</h5>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-6">
<label asp-for="Amount" class="form-label fw-semibold"></label>
<div class="input-group">
<span class="input-group-text">$</span>
<input asp-for="Amount" type="number" step="0.01" min="1" class="form-control" placeholder="0.00" />
</div>
<span asp-validation-for="Amount" class="text-danger small"></span>
</div>
<div class="col-md-6">
<label asp-for="IssuedReason" class="form-label fw-semibold"></label>
<select asp-for="IssuedReason" class="form-select" id="issuedReasonSelect"
onchange="toggleSaleFields()">
@foreach (var reason in Enum.GetValues<GiftCertificateIssuedReason>())
{
<option value="@((int)reason)">@reason</option>
}
</select>
</div>
<!-- Sale-specific fields -->
<div id="saleFields" class="col-12">
<div class="row g-3">
<div class="col-md-6">
<label asp-for="PurchasePrice" class="form-label fw-semibold">Selling Price <span class="text-muted fw-normal">(what buyer pays)</span></label>
<div class="input-group">
<span class="input-group-text">$</span>
<input asp-for="PurchasePrice" type="number" step="0.01" min="0" class="form-control" placeholder="0.00" />
</div>
<div class="form-text">Leave blank if same as face value.</div>
</div>
<div class="col-md-6">
<label asp-for="PurchasingCustomerId" class="form-label fw-semibold">Purchased By</label>
<select asp-for="PurchasingCustomerId" asp-items="ViewBag.Customers" class="form-select"></select>
</div>
</div>
</div>
<div class="col-md-6">
<label asp-for="ExpiryDate" class="form-label fw-semibold"></label>
<input asp-for="ExpiryDate" type="date" class="form-control" />
<div class="form-text">Leave blank for no expiry.</div>
</div>
</div>
</div>
</div>
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-person me-2 text-primary"></i>Recipient</h5>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-12">
<label asp-for="RecipientCustomerId" class="form-label fw-semibold">Existing Customer</label>
<select asp-for="RecipientCustomerId" asp-items="ViewBag.Customers" class="form-select"
onchange="toggleRecipientName()"></select>
<div class="form-text">Select a customer, or leave blank and fill in the name below.</div>
</div>
<div class="col-md-6" id="recipientNameField">
<label asp-for="RecipientName" class="form-label fw-semibold"></label>
<input asp-for="RecipientName" class="form-control" placeholder="Name on certificate" />
</div>
<div class="col-md-6">
<label asp-for="RecipientEmail" class="form-label fw-semibold"></label>
<input asp-for="RecipientEmail" type="email" class="form-control" placeholder="Optional — for emailing the certificate" />
</div>
</div>
</div>
</div>
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-journal me-2 text-primary"></i>Notes</h5>
</div>
<div class="card-body">
<textarea asp-for="Notes" class="form-control" rows="3" placeholder="Any internal notes about this certificate..."></textarea>
</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-gift me-2"></i>Issue Certificate
</button>
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
@section Scripts {
<script>
function toggleSaleFields() {
const reason = parseInt(document.getElementById('issuedReasonSelect').value);
const saleFields = document.getElementById('saleFields');
// GiftCertificateIssuedReason.Sold = 0
saleFields.style.display = reason === 0 ? '' : 'none';
}
function toggleRecipientName() {
const customerId = document.getElementById('RecipientCustomerId').value;
const nameField = document.getElementById('recipientNameField');
nameField.style.display = customerId ? 'none' : '';
}
// Init on load
toggleSaleFields();
toggleRecipientName();
</script>
}
@@ -0,0 +1,246 @@
@model PowderCoating.Application.DTOs.GiftCertificate.GiftCertificateDto
@using PowderCoating.Core.Enums
@{
ViewData["Title"] = $"Gift Certificate {Model.CertificateCode}";
ViewData["PageIcon"] = "bi-gift";
var isActive = Model.Status == GiftCertificateStatus.Active || Model.Status == GiftCertificateStatus.PartiallyRedeemed;
var (statusClass, statusLabel) = Model.Status switch
{
GiftCertificateStatus.Active => ("success", "Active"),
GiftCertificateStatus.PartiallyRedeemed => ("info", "Partially Redeemed"),
GiftCertificateStatus.FullyRedeemed => ("secondary", "Fully Redeemed"),
GiftCertificateStatus.Expired => ("warning", "Expired"),
GiftCertificateStatus.Voided => ("danger", "Voided"),
_ => ("secondary", Model.Status.ToString())
};
}
<div class="d-flex justify-content-end gap-2 mb-4">
<div class="d-flex gap-2">
<a asp-action="DownloadPdf" asp-route-id="@Model.Id" class="btn btn-outline-primary" target="_blank">
<i class="bi bi-filetype-pdf me-2"></i>Download PDF
</a>
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-2"></i>Back to List
</a>
</div>
</div>
<div class="alert alert-@statusClass d-flex align-items-center mb-4">
<i class="bi bi-gift me-2" style="font-size:1.4rem;"></i>
<div>
<strong>@statusLabel</strong>
@if (isActive)
{
<span class="ms-2">— <strong class="fs-5">@Model.RemainingBalance.ToString("C")</strong> remaining of @Model.OriginalAmount.ToString("C") face value</span>
}
@if (Model.ExpiryDate.HasValue)
{
<span class="ms-2 small">· Expires @Model.ExpiryDate.Value.Tz(ViewBag.CompanyTimeZone as string).ToString("MMMM d, yyyy")</span>
}
</div>
</div>
<div class="row g-4">
<div class="col-lg-8">
<!-- Certificate Info -->
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-info-circle me-2 text-primary"></i>Certificate Information</h5>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-4">
<label class="text-muted small mb-1">Certificate Code</label>
<p class="fw-bold font-monospace mb-0">@Model.CertificateCode</p>
</div>
<div class="col-md-4">
<label class="text-muted small mb-1">Face Value</label>
<p class="fw-bold mb-0">@Model.OriginalAmount.ToString("C")</p>
</div>
<div class="col-md-4">
<label class="text-muted small mb-1">Issued Reason</label>
<p class="mb-0"><span class="badge bg-secondary-subtle text-secondary">@Model.IssuedReason</span></p>
</div>
<div class="col-md-4">
<label class="text-muted small mb-1">Issue Date</label>
<p class="mb-0">@Model.IssueDate.Tz(ViewBag.CompanyTimeZone as string).ToString("MMMM d, yyyy")</p>
</div>
<div class="col-md-4">
<label class="text-muted small mb-1">Expiry Date</label>
<p class="mb-0">@(Model.ExpiryDate.HasValue ? Model.ExpiryDate.Value.Tz(ViewBag.CompanyTimeZone as string).ToString("MMMM d, yyyy") : "No expiry")</p>
</div>
@if (!string.IsNullOrEmpty(Model.IssuedByName))
{
<div class="col-md-4">
<label class="text-muted small mb-1">Issued By</label>
<p class="mb-0">@Model.IssuedByName</p>
</div>
}
@if (Model.PurchasePrice.HasValue)
{
<div class="col-md-4">
<label class="text-muted small mb-1">Selling Price</label>
<p class="mb-0">@Model.PurchasePrice.Value.ToString("C")</p>
</div>
}
@if (!string.IsNullOrEmpty(Model.PurchasingCustomerName))
{
<div class="col-md-4">
<label class="text-muted small mb-1">Purchased By</label>
<p class="mb-0">@Model.PurchasingCustomerName</p>
</div>
}
@if (!string.IsNullOrEmpty(Model.Notes))
{
<div class="col-12">
<label class="text-muted small mb-1">Notes</label>
<p class="mb-0" style="white-space:pre-wrap;">@Model.Notes</p>
</div>
}
</div>
</div>
</div>
<!-- Recipient -->
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-person me-2 text-primary"></i>Recipient</h5>
</div>
<div class="card-body">
@if (!string.IsNullOrEmpty(Model.RecipientName) || Model.RecipientCustomerId.HasValue)
{
<div class="row g-3">
<div class="col-md-6">
<label class="text-muted small mb-1">Name</label>
<p class="mb-0 fw-semibold">@Model.RecipientName</p>
</div>
@if (!string.IsNullOrEmpty(Model.RecipientEmail))
{
<div class="col-md-6">
<label class="text-muted small mb-1">Email</label>
<p class="mb-0"><a href="mailto:@Model.RecipientEmail">@Model.RecipientEmail</a></p>
</div>
}
@if (Model.RecipientCustomerId.HasValue)
{
<div class="col-md-6">
<a asp-controller="Customers" asp-action="Details" asp-route-id="@Model.RecipientCustomerId"
class="btn btn-sm btn-outline-primary">
<i class="bi bi-person me-1"></i>View Customer
</a>
</div>
}
</div>
}
else
{
<p class="text-muted mb-0">No specific recipient assigned.</p>
}
</div>
</div>
<!-- Redemption History -->
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-clock-history me-2 text-primary"></i>Redemption History</h5>
</div>
@if (Model.Redemptions.Any())
{
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th class="ps-3">Date</th>
<th>Invoice</th>
<th class="text-end pe-3">Amount Redeemed</th>
</tr>
</thead>
<tbody>
@foreach (var r in Model.Redemptions)
{
<tr>
<td class="ps-3">@r.RedeemedDate.Tz(ViewBag.CompanyTimeZone as string).ToString("MM/dd/yyyy")</td>
<td>
@if (!string.IsNullOrEmpty(r.InvoiceNumber))
{
<a asp-controller="Invoices" asp-action="Details" asp-route-id="@r.InvoiceId"
class="text-decoration-none">@r.InvoiceNumber</a>
}
else
{
<span class="text-muted">Invoice #@r.InvoiceId</span>
}
</td>
<td class="text-end pe-3 fw-semibold text-success">@r.AmountRedeemed.ToString("C")</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
else
{
<div class="card-body">
<p class="text-muted mb-0">No redemptions recorded yet.</p>
</div>
}
</div>
</div>
<!-- Right: Balance + Actions -->
<div class="col-lg-4">
<div class="card border-0 shadow-sm mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-bar-chart me-2 text-primary"></i>Balance</h5>
</div>
<div class="card-body">
<div class="mb-3">
<label class="text-muted small mb-1">Face Value</label>
<h4 class="mb-0">@Model.OriginalAmount.ToString("C")</h4>
</div>
@if (Model.RedeemedAmount > 0)
{
<div class="mb-3">
<label class="text-muted small mb-1">Amount Used</label>
<p class="mb-0 text-muted">(@Model.RedeemedAmount.ToString("C"))</p>
</div>
}
<hr class="my-2" />
<div>
<label class="text-muted small mb-1">Remaining Balance</label>
<h3 class="mb-0 @(Model.RemainingBalance > 0 ? "text-success" : "text-muted")">
@Model.RemainingBalance.ToString("C")
</h3>
</div>
</div>
</div>
@if (isActive && User.IsInRole("SuperAdmin") || User.IsInRole("Administrator") || User.IsInRole("Manager"))
{
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-lightning me-2 text-primary"></i>Actions</h5>
</div>
<div class="card-body">
<div class="d-grid gap-2">
@if (isActive && (User.IsInRole("SuperAdmin") || User.IsInRole("Administrator")))
{
<form asp-action="Void" asp-route-id="@Model.Id" method="post"
onsubmit="return confirm('Void certificate @Model.CertificateCode? This cannot be undone.')">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-outline-danger w-100">
<i class="bi bi-x-circle me-2"></i>Void Certificate
</button>
</form>
}
</div>
</div>
</div>
}
</div>
</div>
@@ -0,0 +1,142 @@
@model List<PowderCoating.Application.DTOs.GiftCertificate.GiftCertificateListDto>
@using PowderCoating.Core.Enums
@{
ViewData["Title"] = "Gift Certificates";
ViewData["PageIcon"] = "bi-gift";
}
<div class="d-flex justify-content-between align-items-center mb-4">
<p class="text-muted mb-0">@ViewBag.TotalActive active certificates &mdash; @((ViewBag.TotalValue as decimal? ?? 0m).ToString("C")) outstanding value</p>
<div class="d-flex gap-2">
<a asp-action="BulkCreate" class="btn btn-outline-primary">
<i class="bi bi-collection me-2"></i>Bulk Create
</a>
<a asp-action="Create" class="btn btn-primary">
<i class="bi bi-plus-circle me-2"></i>New Certificate
</a>
</div>
</div>
<!-- Filters -->
<div class="card border-0 shadow-sm mb-4">
<div class="card-body py-3">
<form method="get" class="row g-2 align-items-end">
<div class="col-md-5">
<input type="text" name="searchTerm" class="form-control" placeholder="Search code, recipient name or email..."
value="@ViewBag.SearchTerm" />
</div>
<div class="col-md-3">
<select name="statusFilter" class="form-select">
<option value="">All statuses</option>
@foreach (var s in Enum.GetValues<GiftCertificateStatus>())
{
<option value="@s" selected="@(ViewBag.StatusFilter == s.ToString())">@s</option>
}
</select>
</div>
<div class="col-md-auto">
<button type="submit" class="btn btn-outline-primary">
<i class="bi bi-search me-1"></i>Filter
</button>
<a asp-action="Index" class="btn btn-outline-secondary ms-1">Clear</a>
</div>
</form>
</div>
</div>
@if (!Model.Any())
{
<div class="text-center py-5 text-muted">
<i class="bi bi-gift" style="font-size: 3rem;"></i>
<p class="mt-3">No gift certificates found.</p>
<a asp-action="Create" class="btn btn-primary mt-2">Create First Certificate</a>
</div>
}
else
{
<div class="card border-0 shadow-sm">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th class="ps-3">Certificate Code</th>
<th>Recipient</th>
<th>Reason</th>
<th class="text-end">Face Value</th>
<th class="text-end">Remaining</th>
<th>Status</th>
<th>Issued</th>
<th>Expires</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var cert in Model)
{
<tr>
<td class="ps-3">
<a asp-action="Details" asp-route-id="@cert.Id" class="fw-semibold text-decoration-none font-monospace">
@cert.CertificateCode
</a>
</td>
<td>
@if (!string.IsNullOrEmpty(cert.RecipientName))
{
<span>@cert.RecipientName</span>
}
else
{
<span class="text-muted">—</span>
}
@if (!string.IsNullOrEmpty(cert.RecipientEmail))
{
<div class="text-muted small">@cert.RecipientEmail</div>
}
</td>
<td><span class="badge bg-secondary-subtle text-secondary">@cert.IssuedReason</span></td>
<td class="text-end">@cert.OriginalAmount.ToString("C")</td>
<td class="text-end fw-semibold @(cert.RemainingBalance > 0 ? "text-success" : "text-muted")">
@cert.RemainingBalance.ToString("C")
</td>
<td>
@{
var (badgeClass, label) = cert.Status switch
{
GiftCertificateStatus.Active => ("bg-success", "Active"),
GiftCertificateStatus.PartiallyRedeemed => ("bg-info text-dark", "Partial"),
GiftCertificateStatus.FullyRedeemed => ("bg-secondary", "Used"),
GiftCertificateStatus.Expired => ("bg-warning text-dark", "Expired"),
GiftCertificateStatus.Voided => ("bg-danger", "Voided"),
_ => ("bg-secondary", cert.Status.ToString())
};
}
<span class="badge @badgeClass">@label</span>
</td>
<td class="small text-muted">@cert.IssueDate.Tz(ViewBag.CompanyTimeZone as string).ToString("MM/dd/yy")</td>
<td class="small">
@if (cert.ExpiryDate.HasValue)
{
<span class="@(cert.ExpiryDate.Value < DateTime.Now ? "text-danger" : "text-muted")">
@cert.ExpiryDate.Value.ToString("MM/dd/yy")
</span>
}
else
{
<span class="text-muted">No expiry</span>
}
</td>
<td>
<a asp-action="Details" asp-route-id="@cert.Id" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
}