Files
PowderCoatingLogix/src/PowderCoating.Web/Views/Reports/CustomerRetention.cshtml
T
spouliot 64a9c1531b Fix — HTML entity rendering across 60 views
Razor's @() expression auto-encodes &, turning — into — which
rendered as literal text in the browser. Wrapped all such expressions in
@Html.Raw() so the em-dash entity is passed through unescaped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 09:27:45 -04:00

127 lines
5.2 KiB
Plaintext

@model PowderCoating.Web.ViewModels.Reports.CustomerRetentionViewModel
@{ ViewData["Title"] = "Customer Retention"; }
<partial name="_ReportHeader" model="Model" />
<div class="row g-3 mb-3">
<div class="col-6 col-md">
<div class="card text-center border-success">
<div class="card-body py-2">
<div class="fs-4 fw-bold text-success">@Model.ActiveCount</div>
<div class="small text-muted">Active</div>
<div class="small text-muted">(≤ 30 days)</div>
</div>
</div>
</div>
<div class="col-6 col-md">
<div class="card text-center border-warning">
<div class="card-body py-2">
<div class="fs-4 fw-bold text-warning">@Model.AtRiskCount</div>
<div class="small text-muted">At Risk</div>
<div class="small text-muted">(31&ndash;60 days)</div>
</div>
</div>
</div>
<div class="col-6 col-md">
<div class="card text-center border-orange" style="border-color:#fd7e14!important">
<div class="card-body py-2">
<div class="fs-4 fw-bold" style="color:#fd7e14">@Model.LapsingCount</div>
<div class="small text-muted">Lapsing</div>
<div class="small text-muted">(61&ndash;90 days)</div>
</div>
</div>
</div>
<div class="col-6 col-md">
<div class="card text-center border-danger">
<div class="card-body py-2">
<div class="fs-4 fw-bold text-danger">@Model.ChurnedCount</div>
<div class="small text-muted">Churned</div>
<div class="small text-muted">(> 90 days)</div>
</div>
</div>
</div>
<div class="col-6 col-md">
<div class="card text-center border-secondary">
<div class="card-body py-2">
<div class="fs-4 fw-bold text-secondary">@Model.NeverOrderedCount</div>
<div class="small text-muted">Never Ordered</div>
<div class="small text-muted">&nbsp;</div>
</div>
</div>
</div>
</div>
@{
var statusOrder = new[] { "Churned", "Lapsing", "At Risk", "Active", "Never Ordered" };
var grouped = Model.Items.GroupBy(i => i.RetentionStatus).OrderBy(g => Array.IndexOf(statusOrder, g.Key));
}
@foreach (var group in grouped)
{
var badgeClass = group.Key switch {
"Active" => "bg-success",
"At Risk" => "bg-warning text-dark",
"Lapsing" => "bg-orange",
"Churned" => "bg-danger",
_ => "bg-secondary"
};
var headerClass = group.Key switch {
"Active" => "table-success",
"At Risk" => "table-warning",
"Lapsing" => "table-orange",
"Churned" => "table-danger",
_ => "table-secondary"
};
<div class="card mb-3">
<div class="card-header d-flex justify-content-between align-items-center @headerClass">
<span class="fw-semibold">@group.Key</span>
<span class="badge @badgeClass">@group.Count()</span>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Customer</th>
<th>Email</th>
<th>Phone</th>
<th class="text-end">Jobs</th>
<th class="text-end">Lifetime Revenue</th>
<th>Last Job</th>
<th class="text-end">Days Since</th>
</tr>
</thead>
<tbody>
@foreach (var item in group.OrderByDescending(i => i.LifetimeRevenue))
{
<tr>
<td>
<a asp-controller="Customers" asp-action="Details" asp-route-id="@item.CustomerId">
@item.CustomerName
</a>
</td>
<td class="small">@Html.Raw(item.Email ?? "&mdash;")</td>
<td class="small">@Html.Raw(item.Phone ?? "&mdash;")</td>
<td class="text-end">@item.TotalJobs</td>
<td class="text-end">@item.LifetimeRevenue.ToString("C")</td>
<td>@Html.Raw(item.LastJobDate?.ToString("MMM d, yyyy") ?? "&mdash;")</td>
<td class="text-end">
@if (item.DaysSinceLastJob < 0)
{
<span class="text-muted">&mdash;</span>
}
else
{
<span>@item.DaysSinceLastJob</span>
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
}