d92266b027
Jobs: use AllJobCount (global total) to distinguish truly-empty from filter-returned-nothing; show Clear Filters button in the latter case. Quotes: expand the filter-active check to include tagFilter and statusCode, which were missing from the condition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
453 lines
24 KiB
Plaintext
453 lines
24 KiB
Plaintext
@model PagedResult<PowderCoating.Application.DTOs.Quote.QuoteListDto>
|
|
|
|
@{
|
|
ViewData["Title"] = "Quotes";
|
|
ViewData["PageIcon"] = "bi-file-text";
|
|
var searchTerm = ViewBag.SearchTerm as string;
|
|
var statusFilter = ViewBag.StatusFilter as int?;
|
|
var statusCode = ViewBag.StatusCode as string;
|
|
}
|
|
|
|
@{
|
|
var _statOpen = (int)(ViewBag.StatOpenCount ?? 0);
|
|
var _statApproved = (int)(ViewBag.StatApprovedCount ?? 0);
|
|
var _statValue = (decimal)(ViewBag.StatTotalValue ?? 0m);
|
|
var _notCalibrated = (bool)(ViewBag.QuotingNotCalibrated ?? false);
|
|
}
|
|
|
|
@if (_notCalibrated)
|
|
{
|
|
<div class="alert alert-warning alert-permanent alert-dismissible d-flex align-items-start gap-3 mb-3" id="quotingCalibrationNudge">
|
|
<i class="bi bi-speedometer2 fs-5 flex-shrink-0 mt-1"></i>
|
|
<div>
|
|
<strong>Your quoting isn't calibrated yet.</strong>
|
|
AI photo quotes and calculated item time estimates are using generic industry averages — they may not match your shop's actual throughput.
|
|
<a href="/CompanySettings#quoting-calibration" class="alert-link ms-1">Set up your equipment profile →</a>
|
|
</div>
|
|
<button type="button" class="btn-close ms-auto flex-shrink-0" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
}
|
|
|
|
<div class="pcl-metric-strip">
|
|
<div class="pcl-metric-strip-cell">
|
|
@await Html.PartialAsync("_Metric", (Label: "TOTAL", Value: Model.TotalCount.ToString(), Delta: (string?)null, DeltaDir: (string?)null))
|
|
</div>
|
|
<div class="pcl-metric-strip-cell">
|
|
@await Html.PartialAsync("_Metric", (Label: "OPEN", Value: _statOpen.ToString(), Delta: (string?)null, DeltaDir: (string?)null))
|
|
</div>
|
|
<div class="pcl-metric-strip-cell">
|
|
@await Html.PartialAsync("_Metric", (Label: "APPROVED", Value: _statApproved.ToString(), Delta: (string?)null, DeltaDir: (string?)null))
|
|
</div>
|
|
<div class="pcl-metric-strip-cell">
|
|
@await Html.PartialAsync("_Metric", (Label: "TOTAL VALUE", Value: _statValue.ToString("C0"), Delta: (string?)null, DeltaDir: (string?)null))
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quote List Card -->
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-header border-0 py-3">
|
|
<div class="d-flex flex-column flex-lg-row justify-content-between align-items-start align-items-lg-center gap-3">
|
|
<div class="d-flex flex-column flex-sm-row gap-2 w-100 w-lg-auto">
|
|
<form asp-action="Index" asp-controller="Quotes" method="get" class="d-flex flex-column flex-sm-row gap-2 flex-grow-1 flex-lg-grow-0">
|
|
<input type="hidden" name="sortColumn" value="@ViewBag.SortColumn" />
|
|
<input type="hidden" name="sortDirection" value="@ViewBag.SortDirection" />
|
|
<input type="hidden" name="pageSize" value="@Model.PageSize" />
|
|
<div class="input-group" style="max-width: 280px; min-width: 200px;">
|
|
<span class="input-group-text border-end-0">
|
|
<i class="bi bi-search text-muted"></i>
|
|
</span>
|
|
<input type="text" name="searchTerm" class="form-control border-start-0"
|
|
placeholder="Search quotes..." value="@searchTerm">
|
|
</div>
|
|
<select class="form-select" name="statusFilter" style="width: auto;">
|
|
<option value="">All Statuses</option>
|
|
@foreach (var status in ViewBag.QuoteStatuses as IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)
|
|
{
|
|
<option value="@status.Value" selected="@status.Selected">@status.Text</option>
|
|
}
|
|
</select>
|
|
<input type="text" name="tagFilter" value="@ViewBag.TagFilter" class="form-control" style="min-width: 140px; max-width: 180px;" placeholder="Filter by tag..." />
|
|
<button type="submit" class="btn btn-primary"><i class="bi bi-search"></i></button>
|
|
@if (!string.IsNullOrEmpty(searchTerm) || statusFilter.HasValue || !string.IsNullOrEmpty(statusCode) || !string.IsNullOrEmpty(ViewBag.TagFilter as string))
|
|
{
|
|
<a asp-action="Index" asp-controller="Quotes" class="btn btn-outline-secondary">Clear</a>
|
|
}
|
|
@if (!string.IsNullOrEmpty(statusCode) && statusCode.ToUpper() == "SENT")
|
|
{
|
|
<span class="badge bg-warning text-dark fs-6 fw-normal">
|
|
<i class="bi bi-funnel-fill me-1"></i>Pending (Sent) Quotes
|
|
</span>
|
|
}
|
|
</form>
|
|
<a asp-action="Create" asp-controller="Quotes" class="btn btn-primary text-nowrap">
|
|
<i class="bi bi-plus-circle me-2"></i>
|
|
<span class="d-none d-sm-inline">New Quote</span>
|
|
<span class="d-inline d-sm-none">New</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
@if (Model != null && Model.Items.Any())
|
|
{
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th sortable="QuoteNumber" current-sort="@ViewBag.SortColumn" current-direction="@ViewBag.SortDirection">Quote Number</th>
|
|
<th>Customer/Prospect</th>
|
|
<th>Type</th>
|
|
<th>Description</th>
|
|
<th sortable="Status" current-sort="@ViewBag.SortColumn" current-direction="@ViewBag.SortDirection">Status</th>
|
|
<th sortable="QuoteDate" current-sort="@ViewBag.SortColumn" current-direction="@ViewBag.SortDirection">Quote Date</th>
|
|
<th sortable="ExpirationDate" current-sort="@ViewBag.SortColumn" current-direction="@ViewBag.SortDirection">Expiration Date</th>
|
|
<th sortable="Total" current-sort="@ViewBag.SortColumn" current-direction="@ViewBag.SortDirection">Total</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var quote in Model.Items)
|
|
{
|
|
<tr class="quote-row @(quote.IsExpired ? "table-warning" : "")" data-quote-id="@quote.Id" style="cursor: pointer;">
|
|
<td>
|
|
<strong>@quote.QuoteNumber</strong>
|
|
@if (!string.IsNullOrWhiteSpace(quote.Tags))
|
|
{
|
|
<div class="mt-1">
|
|
@foreach (var tag in quote.Tags.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(t => t.Trim()).Where(t => !string.IsNullOrWhiteSpace(t)))
|
|
{
|
|
<a href="@Url.Action("Index", new { tagFilter = tag, statusFilter = ViewBag.StatusFilter })" class="badge rounded-pill bg-info text-dark tag-index-badge me-1 text-decoration-none">@tag</a>
|
|
}
|
|
</div>
|
|
}
|
|
</td>
|
|
<td>@quote.CustomerOrProspectName</td>
|
|
<td>
|
|
@await Html.PartialAsync("_StatusChip", (Kind: quote.IsProspect ? "cool" : "ok", Text: quote.IsProspect ? "Prospect" : "Customer"))
|
|
</td>
|
|
<td>
|
|
@if (!string.IsNullOrWhiteSpace(quote.Description))
|
|
{
|
|
<span class="text-muted" title="@quote.Description">
|
|
@(quote.Description.Length > 50 ? quote.Description.Substring(0, 50) + "..." : quote.Description)
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">-</span>
|
|
}
|
|
</td>
|
|
<td>
|
|
<span class="pcl-chip pcl-chip-@StatusChipHelper.QuoteStatus(quote.StatusCode) status-badge"
|
|
style="cursor:pointer;"
|
|
data-quote-id="@quote.Id"
|
|
data-quote-number="@quote.QuoteNumber"
|
|
data-status-id="@quote.QuoteStatusId"
|
|
data-status-name="@quote.StatusDisplayName"
|
|
title="Click to change status">
|
|
<span class="pcl-chip-dot"></span>@quote.StatusDisplayName
|
|
</span>
|
|
@if (quote.IsExpired)
|
|
{
|
|
<i class="bi bi-exclamation-triangle text-warning ms-1" title="Quote has expired"></i>
|
|
}
|
|
</td>
|
|
<td>@quote.QuoteDate.ToString("MM/dd/yyyy")</td>
|
|
<td>
|
|
@if (quote.ExpirationDate.HasValue)
|
|
{
|
|
@quote.ExpirationDate.Value.ToString("MM/dd/yyyy")
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">-</span>
|
|
}
|
|
</td>
|
|
<td>
|
|
<strong>@quote.Total.ToString("C")</strong>
|
|
</td>
|
|
<td>
|
|
<div class="btn-group" role="group">
|
|
<a asp-action="Details" asp-controller="Quotes" asp-route-id="@quote.Id"
|
|
class="btn btn-sm btn-outline-primary"
|
|
title="View Details">
|
|
<i class="bi bi-eye"></i>
|
|
</a>
|
|
<a asp-action="Edit" asp-controller="Quotes" asp-route-id="@quote.Id"
|
|
class="btn btn-sm btn-outline-secondary"
|
|
title="Edit">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
@if (quote.IsProspect && quote.StatusCode == "APPROVED")
|
|
{
|
|
<a asp-action="ConvertToCustomer" asp-controller="Quotes" asp-route-id="@quote.Id"
|
|
class="btn btn-sm btn-outline-success"
|
|
title="Convert to Customer">
|
|
<i class="bi bi-arrow-right-circle"></i>
|
|
</a>
|
|
}
|
|
<a asp-action="Delete" asp-controller="Quotes" asp-route-id="@quote.Id"
|
|
class="btn btn-sm btn-outline-danger"
|
|
title="Delete">
|
|
<i class="bi bi-trash"></i>
|
|
</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Mobile Card View -->
|
|
<div class="mobile-card-view">
|
|
<div class="mobile-card-list">
|
|
@foreach (var quote in Model.Items)
|
|
{
|
|
<div class="mobile-data-card @(quote.IsExpired ? "border-warning" : "")"
|
|
data-id="@quote.Id"
|
|
onclick="window.location.href='@Url.Action("Details", "Quotes", new { id = quote.Id })'">
|
|
|
|
<div class="mobile-card-header">
|
|
<div class="mobile-card-icon" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
|
|
<i class="bi bi-file-text"></i>
|
|
</div>
|
|
<div class="mobile-card-title">
|
|
<h6>@quote.QuoteNumber</h6>
|
|
<small>@quote.CustomerOrProspectName</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mobile-card-body">
|
|
<div class="mobile-card-row">
|
|
<span class="mobile-card-label">Type</span>
|
|
<span class="mobile-card-value">
|
|
@if (quote.IsProspect)
|
|
{
|
|
<span class="badge bg-info">
|
|
<i class="bi bi-person me-1"></i>Prospect
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="badge bg-success">
|
|
<i class="bi bi-building me-1"></i>Customer
|
|
</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="mobile-card-row">
|
|
<span class="mobile-card-label">Status</span>
|
|
<span class="mobile-card-value">
|
|
@await Html.PartialAsync("_StatusChip", (Kind: StatusChipHelper.QuoteStatus(quote.StatusCode), Text: quote.StatusDisplayName))
|
|
@if (quote.IsExpired)
|
|
{
|
|
<i class="bi bi-exclamation-triangle text-warning ms-1" title="Quote has expired"></i>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="mobile-card-row">
|
|
<span class="mobile-card-label">Quote Date</span>
|
|
<span class="mobile-card-value">@quote.QuoteDate.ToString("MM/dd/yyyy")</span>
|
|
</div>
|
|
@if (quote.ExpirationDate.HasValue)
|
|
{
|
|
<div class="mobile-card-row">
|
|
<span class="mobile-card-label">Expires</span>
|
|
<span class="mobile-card-value">@quote.ExpirationDate.Value.ToString("MM/dd/yyyy")</span>
|
|
</div>
|
|
}
|
|
<div class="mobile-card-row">
|
|
<span class="mobile-card-label">Total</span>
|
|
<span class="mobile-card-value fw-semibold">@quote.Total.ToString("C")</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mobile-card-footer">
|
|
<a href="@Url.Action("Details", "Quotes", new { id = quote.Id })"
|
|
class="btn btn-sm btn-outline-primary"
|
|
onclick="event.stopPropagation();">
|
|
<i class="bi bi-eye me-1"></i>View
|
|
</a>
|
|
<a href="@Url.Action("Edit", "Quotes", new { id = quote.Id })"
|
|
class="btn btn-sm btn-outline-secondary"
|
|
onclick="event.stopPropagation();">
|
|
<i class="bi bi-pencil me-1"></i>Edit
|
|
</a>
|
|
@if (quote.IsProspect && quote.StatusCode == "APPROVED")
|
|
{
|
|
<a href="@Url.Action("ConvertToCustomer", "Quotes", new { id = quote.Id })"
|
|
class="btn btn-sm btn-outline-success"
|
|
onclick="event.stopPropagation();"
|
|
title="Convert to Customer">
|
|
<i class="bi bi-arrow-right-circle"></i>
|
|
</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div class="text-center py-5">
|
|
<i class="bi bi-file-text" style="font-size: 4rem; color: #ccc;"></i>
|
|
<p class="text-muted mt-3">No quotes found.</p>
|
|
@if (!string.IsNullOrEmpty(searchTerm) || statusFilter.HasValue || !string.IsNullOrEmpty(statusCode) || !string.IsNullOrEmpty(ViewBag.TagFilter as string))
|
|
{
|
|
<p class="text-muted">No quotes match your current filter. <a asp-action="Index" asp-controller="Quotes">View all quotes</a>.</p>
|
|
}
|
|
else
|
|
{
|
|
<a asp-action="Create" asp-controller="Quotes" class="btn btn-primary mt-2">
|
|
<i class="bi bi-plus-circle me-1"></i>Create Your First Quote
|
|
</a>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
@if (Model.TotalCount > 0)
|
|
{
|
|
@await Html.PartialAsync("_Pagination", Model)
|
|
}
|
|
</div>
|
|
|
|
<!-- Antiforgery Token for AJAX -->
|
|
@Html.AntiForgeryToken()
|
|
|
|
<!-- Status Change Modal -->
|
|
<div class="modal fade" id="statusModal" tabindex="-1" aria-labelledby="statusModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="statusModalLabel">
|
|
<i class="bi bi-flag me-2"></i>Change Quote Status
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="text-muted small mb-1">Quote Number</label>
|
|
<p class="fw-semibold mb-0" id="modalQuoteNumber"></p>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="text-muted small mb-1">Current Status</label>
|
|
<p class="mb-0" id="modalCurrentStatus"></p>
|
|
</div>
|
|
<div>
|
|
<label for="statusSelect" class="form-label">Select Status</label>
|
|
<select id="statusSelect" class="form-select">
|
|
<option value="">Loading statuses...</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="button" class="btn btn-primary" id="saveStatus">
|
|
<i class="bi bi-save me-2"></i>Save Status
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script src="/js/quotes-calibration-nudge.js" asp-append-version="true"></script>
|
|
<script>
|
|
let currentQuoteId = null;
|
|
let currentQuoteStatusId = null;
|
|
let quoteStatuses = [];
|
|
|
|
async function loadQuoteStatuses() {
|
|
try {
|
|
const response = await fetch('/CompanySettings/GetQuoteStatuses');
|
|
const data = await response.json();
|
|
if (Array.isArray(data)) {
|
|
quoteStatuses = data.sort((a, b) => a.displayOrder - b.displayOrder);
|
|
populateStatusDropdown();
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading quote statuses:', error);
|
|
}
|
|
}
|
|
|
|
function populateStatusDropdown() {
|
|
const select = document.getElementById('statusSelect');
|
|
select.innerHTML = '';
|
|
quoteStatuses.forEach(status => {
|
|
if (status.isActive) {
|
|
const option = document.createElement('option');
|
|
option.value = status.id;
|
|
option.textContent = status.displayName;
|
|
select.appendChild(option);
|
|
}
|
|
});
|
|
}
|
|
|
|
loadQuoteStatuses();
|
|
|
|
document.querySelectorAll('.status-badge').forEach(badge => {
|
|
badge.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
currentQuoteId = this.getAttribute('data-quote-id');
|
|
currentQuoteStatusId = this.getAttribute('data-status-id');
|
|
document.getElementById('modalQuoteNumber').textContent = this.getAttribute('data-quote-number');
|
|
document.getElementById('modalCurrentStatus').textContent = this.getAttribute('data-status-name');
|
|
document.getElementById('statusSelect').value = currentQuoteStatusId;
|
|
|
|
new bootstrap.Modal(document.getElementById('statusModal')).show();
|
|
});
|
|
});
|
|
|
|
document.getElementById('saveStatus').addEventListener('click', function() {
|
|
const statusId = document.getElementById('statusSelect').value;
|
|
const token = document.querySelector('input[name="__RequestVerificationToken"]')?.value;
|
|
|
|
fetch('@Url.Action("UpdateQuoteStatus", "Quotes")', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'RequestVerificationToken': token
|
|
},
|
|
body: JSON.stringify({
|
|
quoteId: parseInt(currentQuoteId),
|
|
statusId: parseInt(statusId)
|
|
})
|
|
})
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
bootstrap.Modal.getInstance(document.getElementById('statusModal')).hide();
|
|
location.reload();
|
|
} else {
|
|
showError('Error updating quote status: ' + (data.message || 'Unknown error'), 'Update Failed');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
showError('An error occurred while updating quote status', 'Update Failed');
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('.quote-row').forEach(row => {
|
|
row.addEventListener('click', function(e) {
|
|
if (e.target.closest('a, button, input, .btn-group')) return;
|
|
const quoteId = this.getAttribute('data-quote-id');
|
|
if (quoteId) {
|
|
window.location.href = '@Url.Action("Details", "Quotes")?id=' + quoteId;
|
|
}
|
|
});
|
|
|
|
row.addEventListener('mouseenter', function() {
|
|
if (!this.classList.contains('table-warning')) this.style.backgroundColor = '#f8f9fa';
|
|
});
|
|
row.addEventListener('mouseleave', function() {
|
|
this.style.backgroundColor = '';
|
|
});
|
|
});
|
|
</script>
|
|
}
|