Initial commit

This commit is contained in:
2026-04-23 21:38:24 -04:00
commit 63e12a9636
1762 changed files with 1672620 additions and 0 deletions
@@ -0,0 +1,126 @@
@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">(3160 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">(6190 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">@(item.Email ?? "—")</td>
<td class="small">@(item.Phone ?? "—")</td>
<td class="text-end">@item.TotalJobs</td>
<td class="text-end">@item.LifetimeRevenue.ToString("C")</td>
<td>@(item.LastJobDate?.ToString("MMM d, yyyy") ?? "—")</td>
<td class="text-end">
@if (item.DaysSinceLastJob < 0)
{
<span class="text-muted">—</span>
}
else
{
<span>@item.DaysSinceLastJob</span>
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
}