4ec55e7290
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>
247 lines
12 KiB
Plaintext
247 lines
12 KiB
Plaintext
@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>
|