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:
@@ -0,0 +1,272 @@
|
||||
@model List<PowderCoating.Core.Entities.DashboardTip>
|
||||
@{
|
||||
ViewData["Title"] = "Dashboard Tips";
|
||||
int page = (int)ViewBag.Page;
|
||||
int totalPages = (int)ViewBag.TotalPages;
|
||||
int total = (int)ViewBag.Total;
|
||||
int activeCount = (int)ViewBag.ActiveCount;
|
||||
int totalCount = (int)ViewBag.TotalCount;
|
||||
string? search = ViewBag.Search as string;
|
||||
bool activeOnly = (bool)ViewBag.ActiveOnly;
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
<style>
|
||||
[data-bs-theme="dark"] a.text-dark { color: var(--bs-body-color) !important; }
|
||||
</style>
|
||||
}
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<div>
|
||||
<h4 class="mb-0"><i class="bi bi-lightbulb me-2 text-warning"></i>Dashboard Tips</h4>
|
||||
<p class="text-muted mb-0 small">Tips shown to users on the dashboard welcome section. Displayed randomly, one per session.</p>
|
||||
</div>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>Add Tip
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (TempData["Success"] != null)
|
||||
{
|
||||
<div class="alert alert-success alert-permanent mb-3">@TempData["Success"]</div>
|
||||
}
|
||||
|
||||
<!-- Stats row -->
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card text-center shadow-sm h-100">
|
||||
<div class="card-body py-3">
|
||||
<div class="fs-3 fw-bold text-primary">@totalCount</div>
|
||||
<div class="small text-muted">Total Tips</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card text-center shadow-sm h-100">
|
||||
<div class="card-body py-3">
|
||||
<div class="fs-3 fw-bold text-success">@activeCount</div>
|
||||
<div class="small text-muted">Active</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card text-center shadow-sm h-100">
|
||||
<div class="card-body py-3">
|
||||
<div class="fs-3 fw-bold text-secondary">@(totalCount - activeCount)</div>
|
||||
<div class="small text-muted">Inactive</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filters -->
|
||||
<form method="get" class="card shadow-sm mb-3">
|
||||
<div class="card-body py-2">
|
||||
<div class="row g-2 align-items-end">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="search" value="@search" class="form-control"
|
||||
placeholder="Search tip text..." />
|
||||
</div>
|
||||
<div class="col-md-3 d-flex align-items-center gap-2">
|
||||
<div class="form-check mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="activeOnly" value="true"
|
||||
id="activeOnly" @(activeOnly ? "checked" : "") onchange="this.form.submit()" />
|
||||
<label class="form-check-label" for="activeOnly">Active only</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 d-flex gap-2">
|
||||
<button type="submit" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-search me-1"></i>Search
|
||||
</button>
|
||||
@if (!string.IsNullOrEmpty(search) || activeOnly)
|
||||
{
|
||||
<a asp-action="Index" class="btn btn-outline-danger btn-sm">
|
||||
<i class="bi bi-x-lg me-1"></i>Clear
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center py-2">
|
||||
<span class="fw-semibold">
|
||||
@total tip@(total == 1 ? "" : "s") found
|
||||
@if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
<span class="text-muted fw-normal">for "@search"</span>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width:60px">#</th>
|
||||
<th>Tip Text</th>
|
||||
<th style="width:100px" class="text-center">Status</th>
|
||||
<th style="width:130px" class="text-muted small">Added</th>
|
||||
<th style="width:140px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (!Model.Any())
|
||||
{
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted py-4">
|
||||
<i class="bi bi-lightbulb fs-3 d-block mb-2 opacity-25"></i>
|
||||
No tips found.
|
||||
@if (string.IsNullOrEmpty(search) && !activeOnly)
|
||||
{
|
||||
<a asp-action="Create">Add the first one</a>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var tip in Model)
|
||||
{
|
||||
<tr class="@(tip.IsActive ? "" : "table-secondary opacity-75")">
|
||||
<td class="text-muted small">@tip.Id</td>
|
||||
<td>
|
||||
<span class="@(tip.IsActive ? "" : "text-muted fst-italic")">
|
||||
@tip.TipText
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if (tip.IsActive)
|
||||
{
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td class="text-muted small">@tip.CreatedAt.ToString("MMM d, yyyy")</td>
|
||||
<td class="text-end">
|
||||
<div class="d-flex gap-1 justify-content-end">
|
||||
<!-- Toggle Active -->
|
||||
<form method="post" asp-action="ToggleActive" asp-route-id="@tip.Id" class="d-inline">
|
||||
@Html.AntiForgeryToken()
|
||||
<button type="submit" class="btn btn-sm @(tip.IsActive ? "btn-outline-secondary" : "btn-outline-success")"
|
||||
title="@(tip.IsActive ? "Deactivate" : "Activate")">
|
||||
<i class="bi @(tip.IsActive ? "bi-toggle-on" : "bi-toggle-off")"></i>
|
||||
</button>
|
||||
</form>
|
||||
<a asp-action="Edit" asp-route-id="@tip.Id" class="btn btn-sm btn-outline-primary" title="Edit">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" title="Delete"
|
||||
onclick="confirmDelete(@tip.Id, this)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- Mobile card view — shown on screens < 992px -->
|
||||
<div class="mobile-card-view">
|
||||
<div class="mobile-card-list">
|
||||
@if (!Model.Any())
|
||||
{
|
||||
<p class="text-center text-muted py-4">
|
||||
No tips found.
|
||||
@if (string.IsNullOrEmpty(search) && !activeOnly)
|
||||
{
|
||||
<a asp-action="Create">Add the first one</a>
|
||||
}
|
||||
</p>
|
||||
}
|
||||
@foreach (var tip in Model)
|
||||
{
|
||||
var tipPreview = tip.TipText.Length > 60 ? tip.TipText.Substring(0, 60) + "…" : tip.TipText;
|
||||
<div class="mobile-data-card">
|
||||
<div class="mobile-card-header">
|
||||
<div class="mobile-card-icon bg-warning"><i class="bi bi-lightbulb"></i></div>
|
||||
<div class="mobile-card-title">
|
||||
<h6>@tipPreview</h6>
|
||||
<small>Added @tip.CreatedAt.ToString("MMM d, yyyy")</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mobile-card-body">
|
||||
<div class="mobile-card-row">
|
||||
<span class="mobile-card-label">Status</span>
|
||||
<span class="mobile-card-value">
|
||||
@if (tip.IsActive)
|
||||
{
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">Inactive</span>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mobile-card-row">
|
||||
<span class="mobile-card-label">ID</span>
|
||||
<span class="mobile-card-value text-muted">#@tip.Id</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mobile-card-footer">
|
||||
<a asp-action="Edit" asp-route-id="@tip.Id" class="btn btn-sm btn-outline-primary">Edit →</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger ms-1"
|
||||
onclick="confirmDelete(@tip.Id, this)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (totalPages > 1)
|
||||
{
|
||||
<div class="card-footer d-flex justify-content-between align-items-center py-2">
|
||||
<span class="small text-muted">
|
||||
Page @(page) of @(totalPages)
|
||||
</span>
|
||||
<div class="d-flex gap-1">
|
||||
@if (page > 1)
|
||||
{
|
||||
<a asp-action="Index" asp-route-page="@(page - 1)" asp-route-search="@search"
|
||||
asp-route-activeOnly="@activeOnly" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-chevron-left"></i>
|
||||
</a>
|
||||
}
|
||||
@if (page < totalPages)
|
||||
{
|
||||
<a asp-action="Index" asp-route-page="@(page + 1)" asp-route-search="@search"
|
||||
asp-route-activeOnly="@activeOnly" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden delete form -->
|
||||
<form id="deleteForm" method="post" style="display:none">
|
||||
@Html.AntiForgeryToken()
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function confirmDelete(id, btn) {
|
||||
if (!confirm('Delete this tip? This cannot be undone.')) return;
|
||||
var form = document.getElementById('deleteForm');
|
||||
form.action = '/DashboardTips/Delete/' + id;
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user