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:
@@ -196,6 +196,7 @@
|
||||
data-status-id="@job.JobStatusId"
|
||||
data-status-name="@job.StatusDisplayName"
|
||||
data-customer-notify="@job.CustomerNotifyByEmail.ToString().ToLower()"
|
||||
data-customer-email="@(string.IsNullOrWhiteSpace(job.CustomerEmail) ? "false" : "true")"
|
||||
title="Click to change status">
|
||||
<span class="pcl-chip-dot"></span>@job.StatusDisplayName
|
||||
</span>
|
||||
@@ -504,16 +505,18 @@
|
||||
<option value="">Loading statuses...</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch"
|
||||
id="statusModalSendEmail"
|
||||
@(ViewBag.EmailDefaultOnStatusChange == true ? "checked" : "") />
|
||||
<label class="form-check-label small" for="statusModalSendEmail">
|
||||
<i class="bi bi-envelope me-1"></i>Notify customer via email
|
||||
</label>
|
||||
</div>
|
||||
<div id="statusModalEmailOptOutNote" class="alert alert-warning alert-permanent py-1 px-2 mt-2 small" style="display:none;">
|
||||
<i class="bi bi-bell-slash me-1"></i>This customer has email notifications turned off.
|
||||
<div id="statusModalEmailRow">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch"
|
||||
id="statusModalSendEmail"
|
||||
@(ViewBag.EmailDefaultOnStatusChange == true ? "checked" : "") />
|
||||
<label class="form-check-label small" for="statusModalSendEmail">
|
||||
<i class="bi bi-envelope me-1"></i>Notify customer via email
|
||||
</label>
|
||||
</div>
|
||||
<div id="statusModalEmailOptOutNote" class="alert alert-warning alert-permanent py-1 px-2 mt-2 small" style="display:none;">
|
||||
<i class="bi bi-bell-slash me-1"></i>This customer has email notifications turned off.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -750,20 +753,25 @@
|
||||
const jobNumber = this.getAttribute('data-job-number');
|
||||
const statusName = this.getAttribute('data-status-name');
|
||||
const customerNotify = this.getAttribute('data-customer-notify') !== 'false';
|
||||
const customerHasEmail = this.getAttribute('data-customer-email') !== 'false';
|
||||
|
||||
// Update modal content
|
||||
document.getElementById('modalStatusJobNumber').textContent = jobNumber;
|
||||
document.getElementById('modalCurrentStatus').textContent = statusName;
|
||||
document.getElementById('statusSelect').value = currentJobStatusId;
|
||||
|
||||
// Show email controls only when the customer has an email address on file
|
||||
const emailRow = document.getElementById('statusModalEmailRow');
|
||||
if (emailRow) emailRow.style.display = customerHasEmail ? '' : 'none';
|
||||
|
||||
// Reflect customer email opt-out preference
|
||||
const emailCheckbox = document.getElementById('statusModalSendEmail');
|
||||
const emailOptOutNote = document.getElementById('statusModalEmailOptOutNote');
|
||||
if (emailCheckbox) {
|
||||
if (emailCheckbox && customerHasEmail) {
|
||||
emailCheckbox.disabled = !customerNotify;
|
||||
if (!customerNotify) emailCheckbox.checked = false;
|
||||
}
|
||||
if (emailOptOutNote) emailOptOutNote.style.display = customerNotify ? 'none' : 'block';
|
||||
if (emailOptOutNote) emailOptOutNote.style.display = (customerHasEmail && !customerNotify) ? 'block' : 'none';
|
||||
|
||||
// Show modal
|
||||
const modal = new bootstrap.Modal(document.getElementById('statusModal'));
|
||||
|
||||
Reference in New Issue
Block a user