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,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>
}