Files
PowderCoatingLogix/src/PowderCoating.Web/Views/GiftCertificates/Index.cshtml
T
spouliot 38748c2152 Add BatchId to GiftCertificate for persistent bulk batch tracking
BatchId (Guid?) is stamped on every certificate in a bulk run so the batch
is permanently addressable. BulkResult is now a bookmarkable GET by batchId
rather than TempData, so users can return to re-download at any time.
BatchDownloadPdf is a GET link (no form POST needed). Index shows a Batch
badge on bulk certs that links directly back to the batch result page.

Migration: AddGiftCertificateBatchId

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 20:32:56 -04:00

151 lines
7.4 KiB
Plaintext

@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>
@if (cert.BatchId.HasValue)
{
<a asp-action="BulkResult" asp-route-batchId="@cert.BatchId"
class="badge bg-primary-subtle text-primary text-decoration-none ms-1"
title="View &amp; download batch">
<i class="bi bi-collection me-1"></i>Batch
</a>
}
</td>
<td>
@if (!string.IsNullOrEmpty(cert.RecipientName))
{
<span>@cert.RecipientName</span>
}
else
{
<span class="text-muted">&mdash;</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>
}