Hide email controls when no email on file; show SMS hint for quote/job events
- Quotes Create/Edit: hide 'Send via email' checkbox when customer has no email; show badge 'send via SMS from details' or 'SMS consent required' when customer has a mobile number. JS responds to customer dropdown change. - Quotes Details: hide 'Send Quote via Email' button and approval email checkbox; hide SMS button when no mobile; show consent-required note. - Jobs Details (Mark Complete modal): hide email checkbox; show 'SMS notification will be sent' badge or consent-required note. - Jobs Index (status modal): hide email row when customer has no email. - Jobs Edit: hide 'Notify customer if status changes' when no email. - Invoices Details: hide Send/Re-send buttons when no email (vs. disabled). DTOs: added CustomerEmail + CustomerNotifyByEmail to JobDto/JobListDto; added CustomerNotifyByEmail/CustomerMobilePhone/CustomerNotifyBySms to QuoteDto. Mapped in JobProfile and QuotesController customer blocks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
var isVoided = Model.Status == InvoiceStatus.Voided || Model.Status == InvoiceStatus.WrittenOff;
|
||||
var canPay = !isVoided && Model.BalanceDue > 0;
|
||||
var canResend = !isDraft && !isVoided && Model.Status != InvoiceStatus.Paid;
|
||||
var emailOptedOut = !Model.CustomerNotifyByEmail;
|
||||
var hasEmail = !string.IsNullOrWhiteSpace(Model.CustomerEmail);
|
||||
var emailOptedOut = hasEmail && !Model.CustomerNotifyByEmail;
|
||||
var hasAvailableCredits = ViewBag.AvailableCreditMemos != null && ((IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.AvailableCreditMemos).Any();
|
||||
var canIssueRefund = !isDraft && !isVoided && Model.AmountPaid > 0;
|
||||
var canApplyCredit = !isVoided && Model.BalanceDue > 0 && hasAvailableCredits;
|
||||
@@ -58,7 +59,17 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (emailOptedOut)
|
||||
@if (!hasEmail)
|
||||
{
|
||||
<div class="alert alert-warning d-flex align-items-center gap-2 mb-4">
|
||||
<i class="bi bi-envelope-slash fs-5"></i>
|
||||
<span>
|
||||
<strong>@Model.CustomerName</strong> has no email address on file — email buttons are hidden.
|
||||
<a asp-controller="Customers" asp-action="Edit" asp-route-id="@Model.CustomerId" class="alert-link">Add one in customer settings</a>.
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
else if (emailOptedOut)
|
||||
{
|
||||
<div class="alert alert-warning d-flex align-items-center gap-2 mb-4">
|
||||
<i class="bi bi-envelope-x fs-5"></i>
|
||||
@@ -560,23 +571,26 @@
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-outline-primary">
|
||||
<i class="bi bi-pencil me-2"></i>Edit Invoice
|
||||
</a>
|
||||
<form id="sendInvoiceForm" asp-action="Send" asp-route-id="@Model.Id" method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (emailOptedOut)
|
||||
{
|
||||
<button type="button" class="btn btn-primary w-100" disabled
|
||||
title="Email notifications are turned off for this customer">
|
||||
<i class="bi bi-send me-2"></i>Send Invoice
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-primary w-100"
|
||||
data-bs-toggle="modal" data-bs-target="#sendInvoiceModal">
|
||||
<i class="bi bi-send me-2"></i>Send Invoice
|
||||
</button>
|
||||
}
|
||||
</form>
|
||||
@if (hasEmail)
|
||||
{
|
||||
<form id="sendInvoiceForm" asp-action="Send" asp-route-id="@Model.Id" method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (emailOptedOut)
|
||||
{
|
||||
<button type="button" class="btn btn-primary w-100" disabled
|
||||
title="Email notifications are turned off for this customer">
|
||||
<i class="bi bi-send me-2"></i>Send Invoice
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-primary w-100"
|
||||
data-bs-toggle="modal" data-bs-target="#sendInvoiceModal">
|
||||
<i class="bi bi-send me-2"></i>Send Invoice
|
||||
</button>
|
||||
}
|
||||
</form>
|
||||
}
|
||||
}
|
||||
@if (canPay)
|
||||
{
|
||||
@@ -587,7 +601,7 @@
|
||||
<a asp-action="DownloadPdf" asp-route-id="@Model.Id" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-file-pdf me-2"></i>Download PDF
|
||||
</a>
|
||||
@if (canResend)
|
||||
@if (canResend && hasEmail)
|
||||
{
|
||||
@if (emailOptedOut)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user