Format money through billingMoney in the 51 places that called numfmt_format_currency directly, on client and vendor pages, payment and credit messages, the portal home, the guest card page and the report, dashboard and search helpers

This commit is contained in:
johnnyq
2026-11-20 23:58:05 -05:00
parent 31c34fd92a
commit d0caeee324
23 changed files with 52 additions and 51 deletions

View File

@@ -434,6 +434,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
- Dates: `formatDate()`, `formatDateTime()` (with `$seconds` for logs), `formatTime()` and `formatDay()` in `functions/format.php` show a stored date or time (or a timestamp) as `M j, Y`, `M j, Y g:i A`, `g:i A` and `D, M j, Y`, and give '' for nothing or a zero date. Raw `Y-m-d` values printed on pages, windows, `includes/billing_paper.php`, `functions/billing_pdf.php` and the guest pages now go through them, as do the `title` hovers beside `timeAgo()`; `billingEmailDate()` calls `formatDate()`; the odd `date()` formats (`g:ia`, `M d, Y • g:i A`, `D j M`, `F j, Y`, `m/d/Y`, `M y` and the like) are the standard ones; `$config_date_format` is `M j, Y`; and the scripts' `toLocale*String()` calls pass `en-US` so they match. New code uses the helpers.
- Messages: a note added to an asset or a contact sets its message with `flashAlert()`, its names escaped, rather than writing `$_SESSION['alert_message']` itself; the `archive_ticket_reply` and `archive_account` handlers offer Undo through `undoArchivedBefore()` / `undoOfferArchived()`; and the SLA list no longer builds the archive prompt's text.
- Pickers: the 78 plain `<select class="form-select">` left in `agent/modals` and `admin/modals` are `select2`, so `js/itflow_select.js` draws them; it now carries `w-auto`, `flex-grow-0`, `flex-shrink-0` and an inline `max-width` from the `<select>` to the picker, so one set narrow inside an input group stays narrow. Every select in a window is the picker now - new ones should be too.
- Money: the 51 places that called `numfmt_format_currency($currency_format, ...)` themselves - client and vendor lists and pages, payment and credit messages, the client portal's home, the guest card payment page, and the report, dashboard and search helpers - call `billingMoney($amount, $currency)`, the one formatter. Left as they are: `billingMoney()` itself, `reportMoneyWhole()` (whole amounts), the trip rate (more decimals) and the localization settings' sample.
## [26.11.8]

View File

@@ -86,7 +86,7 @@ $pill_url = function ($view) {
return '?' . http_build_query(array_filter(['q' => $_GET['q'] ?? '', 'show' => $view]));
};
$money = function ($amount) use ($currency_format, $session_company_currency) {
return escapeHtml(numfmt_format_currency($currency_format, $amount, $session_company_currency));
return escapeHtml(billingMoney($amount, $session_company_currency));
};
?>

View File

@@ -12,7 +12,7 @@ $agent = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT user_id, user_name, us
$list = $agent && laborCostReady() ? array_reverse(laborCostRates()[$user_id] ?? []) : [];
$default = laborCostDefault();
$money = function ($amount) use ($currency_format, $session_company_currency) {
return escapeHtml(numfmt_format_currency($currency_format, $amount, $session_company_currency));
return escapeHtml(billingMoney($amount, $session_company_currency));
};
ob_start();

View File

@@ -42,8 +42,8 @@ $summaries = [
'localization' => escapeHtml(implode(' · ', array_filter([$localization['locales'][$company['company_locale'] ?? ''] ?? '', $company['company_currency'] ?? '', $config_timezone]))),
'theme' => '<span class="itflow-settings-dot theme-' . escapeHtml($config_theme) . '"></span>' . escapeHtml($themes[$config_theme] ?? $config_theme) . (file_exists(dirname(__DIR__) . '/uploads/favicon.ico') ? ' · its own tab icon' : ''),
'default' => 'Opens on ' . escapeHtml($start_pages[$config_start_page] ?? $config_start_page) . ' · ' . ($config_default_net_terms ? 'net ' . intval($config_default_net_terms) : 'due on receipt')
. ($config_default_hourly_rate > 0 ? ' · ' . escapeHtml(numfmt_format_currency($currency_format, $config_default_hourly_rate, $session_company_currency)) . ' an hour' : '')
. (billingDefaults()['after_hours'] > 0 ? ', ' . escapeHtml(numfmt_format_currency($currency_format, billingDefaults()['after_hours'], $session_company_currency)) . ' after hours' : ''),
. ($config_default_hourly_rate > 0 ? ' · ' . escapeHtml(billingMoney($config_default_hourly_rate, $session_company_currency)) . ' an hour' : '')
. (billingDefaults()['after_hours'] > 0 ? ', ' . escapeHtml(billingMoney(billingDefaults()['after_hours'], $session_company_currency)) . ' after hours' : ''),
'ticket' => 'Next ' . escapeHtml($config_ticket_prefix . $config_ticket_next_number) . ' · email to ticket ' . $on_off($config_ticket_email_parse),
'project' => 'Next ' . escapeHtml($config_project_prefix . $config_project_next_number),
'quote' => 'Next ' . escapeHtml($config_quote_prefix . $config_quote_next_number),

View File

@@ -46,7 +46,7 @@ if ($access['financial']) {
$priority_colors = ['Urgent' => 'dark', 'High' => 'danger', 'Medium' => 'warning', 'Low' => 'info'];
$tone_text = ['danger' => 'text-danger-emphasis', 'warning' => 'text-warning-emphasis', 'info' => 'text-info-emphasis', 'secondary' => 'text-body'];
$money_format = function ($amount) use ($currency_format, $client_currency_code, $session_company_currency) {
return numfmt_format_currency($currency_format, floatval($amount), $client_currency_code ?: $session_company_currency);
return billingMoney(floatval($amount), $client_currency_code ?: $session_company_currency);
};
?>

View File

@@ -684,20 +684,20 @@ $total_leads = intval($row['leads']);
<?php if ($show_billing) { ?>
<td class="text-end text-nowrap">
<?php if ($balance > 0.004) { ?>
<a href="invoices.php?client_id=<?= $client_id ?>&status=Unpaid" class="fw-semibold text-decoration-none <?= $money['overdue'] > 0.004 ? 'text-danger-emphasis' : 'text-reset' ?>"><?= numfmt_format_currency($currency_format, $balance, $client_currency_code) ?></a>
<a href="invoices.php?client_id=<?= $client_id ?>&status=Unpaid" class="fw-semibold text-decoration-none <?= $money['overdue'] > 0.004 ? 'text-danger-emphasis' : 'text-reset' ?>"><?= billingMoney($balance, $client_currency_code) ?></a>
<?php if ($money['overdue'] > 0.004) { ?>
<div class="small text-danger-emphasis"><?= numfmt_format_currency($currency_format, $money['overdue'], $client_currency_code) ?> overdue</div>
<div class="small text-danger-emphasis"><?= billingMoney($money['overdue'], $client_currency_code) ?> overdue</div>
<?php } ?>
<?php } else { ?>
<span class="text-body-tertiary"><?= numfmt_format_currency($currency_format, max(0, $balance), $client_currency_code) ?></span>
<span class="text-body-tertiary"><?= billingMoney(max(0, $balance), $client_currency_code) ?></span>
<?php } ?>
</td>
<td class="text-end text-nowrap d-none d-lg-table-cell">
<?php if ($money['recurring'] > 0.004) { ?>
<a href="recurring_invoices.php?client_id=<?= $client_id ?>" class="text-reset text-decoration-none"><?= numfmt_format_currency($currency_format, $money['recurring'], $client_currency_code) ?><span class="small text-body-secondary">/mo</span></a>
<a href="recurring_invoices.php?client_id=<?= $client_id ?>" class="text-reset text-decoration-none"><?= billingMoney($money['recurring'], $client_currency_code) ?><span class="small text-body-secondary">/mo</span></a>
<?php } ?>
<?php if (isset($client_rates[$client_id])) { ?>
<div class="small text-body-secondary" title="<?= escapeHtml($client_rates[$client_id][1]) ?>" data-client-rate><?= numfmt_format_currency($currency_format, $client_rates[$client_id][0], $client_currency_code) ?>/hr<?= !empty($client_rates[$client_id][2]) ? ' <span class="text-body-tertiary" data-client-rate-default>(default)</span>' : '' ?></div>
<div class="small text-body-secondary" title="<?= escapeHtml($client_rates[$client_id][1]) ?>" data-client-rate><?= billingMoney($client_rates[$client_id][0], $client_currency_code) ?>/hr<?= !empty($client_rates[$client_id][2]) ? ' <span class="text-body-tertiary" data-client-rate-default>(default)</span>' : '' ?></div>
<?php } elseif ($money['recurring'] <= 0.004) { ?>
<span class="text-body-tertiary">-</span>
<?php } ?>

View File

@@ -27,7 +27,7 @@ if (empty($client_top_head_skip)) {
$client_head_glance_tickets = $client_head_support && $num_active_tickets > 0;
$client_head_glance_due = $client_head_billing && $balance > 0;
$client_head_money = function ($amount) use ($currency_format, $client_currency_code, $session_company_currency) {
return numfmt_format_currency($currency_format, floatval($amount), $client_currency_code ?: $session_company_currency);
return billingMoney(floatval($amount), $client_currency_code ?: $session_company_currency);
};
?>

View File

@@ -2,7 +2,7 @@
<div class="modal-dialog">
<div class="modal-content border-dark">
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-wallet me-2"></i>Adding <strong>Credit</strong> (Credit Balance: <?= numfmt_format_currency($currency_format, $credit_balance, $client_currency_code) ?>)</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-wallet me-2"></i>Adding <strong>Credit</strong> (Credit Balance: <?= billingMoney($credit_balance, $client_currency_code) ?>)</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">

View File

@@ -98,7 +98,7 @@ ob_start();
<div class="alert alert-secondary">
<i class="fa fa-fw fa-balance-scale me-2"></i>Current outstanding balance:
<strong><?= numfmt_format_currency($currency_format, $outstanding_balance, $client_currency_code) ?></strong>
<strong><?= billingMoney($outstanding_balance, $client_currency_code) ?></strong>
</div>
<h6 class="text-bold">Statement Options</h6>

View File

@@ -28,7 +28,7 @@ ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-wallet me-2"></i><?= "$invoice_prefix$invoice_number" ?>: Apply Credit (Balance: <?= numfmt_format_currency($currency_format, $credit_balance, $session_company_currency) ?>)</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-wallet me-2"></i><?= "$invoice_prefix$invoice_number" ?>: Apply Credit (Balance: <?= billingMoney($credit_balance, $session_company_currency) ?>)</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">

View File

@@ -182,7 +182,7 @@ ob_start();
<input type="text" class="form-control" inputmode="decimal" pattern="-?[0-9]*\.?[0-9]{0,2}" name="price" value="<?= number_format($client_rate, 2, '.', '') ?>" required>
</div>
<small class="form-text text-muted">
<?= escapeHtml(ucfirst($client_rate_info['note'])) ?> is <strong><?= numfmt_format_currency($currency_format, $client_rate, $session_company_currency); ?></strong> an hour
<?= escapeHtml(ucfirst($client_rate_info['note'])) ?> is <strong><?= billingMoney($client_rate, $session_company_currency); ?></strong> an hour
</small>
</div>
</div>

View File

@@ -164,7 +164,7 @@ ob_start();
<?php if ($spend) { ?>
<div class="itflow-glance-item" title="Spent with them">
<i class="fas fa-fw fa-receipt"></i>
<span><?= numfmt_format_currency($currency_format, $spend['year'], $session_company_currency) ?> this year<?php if ($spend['last']) { ?> <span class="text-body-secondary">&middot; last <?= escapeHtml($spend['last']) ?></span><?php } ?></span>
<span><?= billingMoney($spend['year'], $session_company_currency) ?> this year<?php if ($spend['last']) { ?> <span class="text-body-secondary">&middot; last <?= escapeHtml($spend['last']) ?></span><?php } ?></span>
</div>
<?php } ?>
</div>

View File

@@ -25,9 +25,9 @@ if (isset($_POST['add_credit'])) {
$credit_id = mysqli_insert_id($mysqli);
logAudit("Credit", "Create", "$session_name added " . numfmt_format_currency($currency_format, $amount, $session_company_currency) . "", $client_id, $credit_id);
logAudit("Credit", "Create", "$session_name added " . billingMoney($amount, $session_company_currency) . "", $client_id, $credit_id);
flashAlert(numfmt_format_currency($currency_format, $amount, $session_company_currency) . " Credit Added");
flashAlert(billingMoney($amount, $session_company_currency) . " Credit Added");
redirect();

View File

@@ -59,7 +59,7 @@ if (isset($_POST['add_payment'])) {
//Add Payment to History
mysqli_query($mysqli,"INSERT INTO history SET history_status = '$invoice_status', history_description = 'Payment added', history_invoice_id = $invoice_id");
logAudit("Invoice", "Payment", "Payment amount of " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " added to invoice $invoice_prefix$invoice_number", $client_id, $invoice_id);
logAudit("Invoice", "Payment", "Payment amount of " . billingMoney($amount, $invoice_currency_code) . " added to invoice $invoice_prefix$invoice_number", $client_id, $invoice_id);
// The client's receipt - functions/billing_email.php
if ($email_receipt == 1) {
@@ -71,7 +71,7 @@ if (isset($_POST['add_payment'])) {
triggerCustomAction('invoice_pay', $invoice_id);
flashAlert("Payment amount <strong>" . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . "</strong> added");
flashAlert("Payment amount <strong>" . billingMoney($amount, $invoice_currency_code) . "</strong> added");
redirect();
@@ -110,9 +110,9 @@ if (isset($_POST['edit_payment'])) {
// A changed amount can leave the invoice paid, part paid or owing again
updateInvoiceStatusFromPayments(intval(getFieldById('payments', $payment_id, 'payment_invoice_id')));
logAudit("Payment", "Edit", "Payment edited amount of " . numfmt_format_currency($currency_format, $amount, $session_company_currency));
logAudit("Payment", "Edit", "Payment edited amount of " . billingMoney($amount, $session_company_currency));
flashAlert("Payment edited to amount <strong>" . numfmt_format_currency($currency_format, $amount, $session_company_currency) . "</strong> added");
flashAlert("Payment edited to amount <strong>" . billingMoney($amount, $session_company_currency) . "</strong> added");
redirect();
@@ -219,11 +219,11 @@ if (isset($_POST['apply_credit'])) {
history_invoice_id = $invoice_id
");
logAudit("Invoice", "Payment", "Credit " . numfmt_format_currency($currency_format, $amount, $session_company_currency) . " applied to invoice $invoice_prefix$invoice_number", $client_id, $invoice_id);
logAudit("Invoice", "Payment", "Credit " . billingMoney($amount, $session_company_currency) . " applied to invoice $invoice_prefix$invoice_number", $client_id, $invoice_id);
triggerCustomAction('invoice_pay', $invoice_id);
flashAlert("Credit amount <strong>" . numfmt_format_currency($currency_format, $amount, $session_company_currency) . "</strong> applied");
flashAlert("Credit amount <strong>" . billingMoney($amount, $session_company_currency) . "</strong> applied");
redirect();
@@ -415,11 +415,11 @@ if (isset($_POST['add_payment_stripe'])) {
// Notify/log
appNotify("Invoice Paid", "Invoice $invoice_prefix$invoice_number automatically paid", "/agent/invoice.php?invoice_id=$invoice_id", $client_id);
$fee_text = $fee_cents > 0 ? ' (with a ' . numfmt_format_currency($currency_format, $fee_cents / 100, $invoice_currency_code) . ' card fee)' : '';
logAudit("Invoice", "Payment", "$session_name initiated Stripe payment amount of " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "$fee_text added to invoice $invoice_prefix$invoice_number - $pi_id $extended_log_desc", $client_id, $invoice_id);
$fee_text = $fee_cents > 0 ? ' (with a ' . billingMoney($fee_cents / 100, $invoice_currency_code) . ' card fee)' : '';
logAudit("Invoice", "Payment", "$session_name initiated Stripe payment amount of " . billingMoney($pi_amount_paid, $invoice_currency_code) . "$fee_text added to invoice $invoice_prefix$invoice_number - $pi_id $extended_log_desc", $client_id, $invoice_id);
triggerCustomAction('invoice_pay', $invoice_id);
flashAlert("Payment amount <strong>" . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "</strong>$fee_text added");
flashAlert("Payment amount <strong>" . billingMoney($pi_amount_paid, $invoice_currency_code) . "</strong>$fee_text added");
redirect();
@@ -530,7 +530,7 @@ if (isset($_POST['add_bulk_payment'])) {
}
}
logAudit("Invoice", "Payment", "Bulk Payment amount of " . numfmt_format_currency($currency_format, $bulk_payment_amount_static, $currency_code) . " applied to multiple invoices", $client_id);
logAudit("Invoice", "Payment", "Bulk Payment amount of " . billingMoney($bulk_payment_amount_static, $currency_code) . " applied to multiple invoices", $client_id);
flashAlert("$alert_message Bulk Payment added");

View File

@@ -404,14 +404,14 @@ if (isset($_POST['set_recurring_payment'])) {
// Get Payment ID for reference
$recurring_payment_id = mysqli_insert_id($mysqli);
logAudit("Recurring Invoice", "Auto Payment", "$session_name created Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . numfmt_format_currency($currency_format, $recurring_invoice_amount, $recurring_invoice_currency_code), $client_id, $recurring_invoice_id);
logAudit("Recurring Invoice", "Auto Payment", "$session_name created Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . billingMoney($recurring_invoice_amount, $recurring_invoice_currency_code), $client_id, $recurring_invoice_id);
flashAlert("Automatic Payment <strong>$saved_payment_description</strong> enabled for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number");
} else {
// Delete
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_recurring_invoice_id = $recurring_invoice_id");
logAudit("Recurring Invoice", "Auto Payment", "$session_name removed Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . numfmt_format_currency($currency_format, $recurring_invoice_amount, $recurring_invoice_currency_code), $client_id, $recurring_invoice_id);
logAudit("Recurring Invoice", "Auto Payment", "$session_name removed Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . billingMoney($recurring_invoice_amount, $recurring_invoice_currency_code), $client_id, $recurring_invoice_id);
flashAlert("Automatic Payment <strong>Disabled</strong> for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number", 'error');
}

View File

@@ -733,9 +733,9 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
<div class="tab-pane fade" id="vendor-pane-expenses" role="tabpanel">
<div class="itflow-asset-pane-bar">
<span class="text-body-secondary small d-flex flex-wrap column-gap-3">
<span><strong class="text-body"><?= numfmt_format_currency($currency_format, $spend['year'], $session_company_currency) ?></strong> this year</span>
<span><?= numfmt_format_currency($currency_format, $spend['last_year'], $session_company_currency) ?> last year</span>
<span><?= numfmt_format_currency($currency_format, $spend['total'], $session_company_currency) ?> in all</span>
<span><strong class="text-body"><?= billingMoney($spend['year'], $session_company_currency) ?></strong> this year</span>
<span><?= billingMoney($spend['last_year'], $session_company_currency) ?> last year</span>
<span><?= billingMoney($spend['total'], $session_company_currency) ?> in all</span>
</span>
<div class="d-flex gap-2">
<a class="btn btn-sm btn-outline-secondary" href="expenses.php?vendor=<?= $vendor_id ?>"><i class="fas fa-list me-2"></i>All</a>
@@ -757,7 +757,7 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
<div class="small text-body-secondary"><?= escapeHtml(implode(' · ', array_filter([$expense['category_name'], $expense['expense_reference']]))) ?></div>
</td>
<td class="text-nowrap small"><?= intval($expense['expense_paid_by']) ? '<i class="fas fa-hand-holding-usd text-body-secondary me-1" title="Paid personally"></i>' . escapeHtml($expense['paid_by_name'] ?: 'An agent') : (moduleOn('bookkeeping') ? escapeHtml($expense['account_name']) : 'The business') ?></td>
<td class="text-end text-nowrap font-monospace"><?= numfmt_format_currency($currency_format, floatval($expense['expense_amount']), $expense['expense_currency_code']) ?></td>
<td class="text-end text-nowrap font-monospace"><?= billingMoney(floatval($expense['expense_amount']), $expense['expense_currency_code']) ?></td>
</tr>
<?php } ?>
</tbody>
@@ -793,7 +793,7 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
<div><?= escapeHtml(truncate((string) $recurring_expense['recurring_expense_description'], 90)) ?: '<span class="text-body-secondary">-</span>' ?></div>
<div class="small text-body-secondary"><?= escapeHtml($recurring_expense['category_name']) ?></div>
</td>
<td class="text-end text-nowrap font-monospace"><?= numfmt_format_currency($currency_format, floatval($recurring_expense['recurring_expense_amount']), $recurring_expense['recurring_expense_currency_code']) ?></td>
<td class="text-end text-nowrap font-monospace"><?= billingMoney(floatval($recurring_expense['recurring_expense_amount']), $recurring_expense['recurring_expense_currency_code']) ?></td>
</tr>
<?php } ?>
</tbody>

View File

@@ -397,7 +397,7 @@ $missing_templates = $view === 'client' && !$archived ? vendorTemplatesMissingFo
<?php } ?>
<?php if ($view === 'ours') { ?>
<?php if ($can_financial && $counts['expense']) { ?>
<span class="w-100 small text-nowrap"><strong><?= numfmt_format_currency($currency_format, $counts['spend_year'], $session_company_currency) ?></strong> <span class="text-body-secondary">this year</span></span>
<span class="w-100 small text-nowrap"><strong><?= billingMoney($counts['spend_year'], $session_company_currency) ?></strong> <span class="text-body-secondary">this year</span></span>
<?php } ?>
<?php if ($can_financial && $counts['expense']) { ?>
<a class="itflow-contact-chip" href="<?= $vendor_url ?>#expenses" title="<?= $counts['expense'] ?> expense<?= $counts['expense'] === 1 ? '' : 's' ?>"><i class="fas fa-receipt"></i><?= $counts['expense'] ?></a>

View File

@@ -83,7 +83,7 @@ if ($can_billing) {
'icon' => 'fa-file-invoice-dollar',
'tone' => 'is-danger',
'title' => 'Invoice ' . $invoice['invoice_prefix'] . $invoice['invoice_number'] . ' is past due',
'line' => numfmt_format_currency($currency_format, $left, $client_currency) . ' left - due ' . date('M j, Y', strtotime($invoice['invoice_due'])),
'line' => billingMoney($left, $client_currency) . ' left - due ' . date('M j, Y', strtotime($invoice['invoice_due'])),
];
} elseif ($next_due === null || $invoice['invoice_due'] < $next_due) {
$next_due = $invoice['invoice_due'];
@@ -215,10 +215,10 @@ $first_name = strtok(trim((string) $contact['contact_name']), ' ') ?: '';
<a class="itflow-portal-stat<?= $overdue > 0 ? ' itflow-portal-stat-danger' : '' ?>" href="<?= $balance > 0 ? $pay_href : 'invoices.php' ?>">
<span class="itflow-portal-stat-icon"><i class="fas fa-file-invoice-dollar"></i></span>
<span class="min-w-0">
<span class="itflow-portal-stat-value d-block"><?= numfmt_format_currency($currency_format, $balance, $client_currency) ?></span>
<span class="itflow-portal-stat-value d-block"><?= billingMoney($balance, $client_currency) ?></span>
<span class="itflow-portal-stat-label">
<?php if ($overdue > 0) { ?>
<?= numfmt_format_currency($currency_format, $overdue, $client_currency) ?> past due
<?= billingMoney($overdue, $client_currency) ?> past due
<?php } elseif ($balance > 0 && $next_due) { ?>
Due <?= date('M j', strtotime($next_due)) ?>
<?php } else { ?>

View File

@@ -1647,14 +1647,14 @@ if (isset($_POST['set_recurring_payment'])) {
// Get Payment ID for reference
$recurring_payment_id = mysqli_insert_id($mysqli);
logAudit("Recurring Invoice", "Auto Payment", "$session_contact_name created Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . numfmt_format_currency($currency_format, $recurring_invoice_amount, $recurring_invoice_currency_code), $session_client_id, $recurring_invoice_id);
logAudit("Recurring Invoice", "Auto Payment", "$session_contact_name created Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . billingMoney($recurring_invoice_amount, $recurring_invoice_currency_code), $session_client_id, $recurring_invoice_id);
flashAlert("Automatic Payment $saved_payment_description enabled for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number");
} else {
// Delete
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_recurring_invoice_id = $recurring_invoice_id");
logAudit("Recurring Invoice", "Auto Payment", "$session_contact_name removed Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . numfmt_format_currency($currency_format, $recurring_invoice_amount, $recurring_invoice_currency_code), $session_client_id, $recurring_invoice_id);
logAudit("Recurring Invoice", "Auto Payment", "$session_contact_name removed Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . billingMoney($recurring_invoice_amount, $recurring_invoice_currency_code), $session_client_id, $recurring_invoice_id);
flashAlert("Automatic Payment Disabled for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number");
}

View File

@@ -663,7 +663,7 @@ function dashboardTicketTrend() {
function dashboardMoney($amount) {
global $currency_format, $session_company_currency;
return numfmt_format_currency($currency_format, floatval($amount), $session_company_currency);
return billingMoney(floatval($amount), $session_company_currency);
}
/**

View File

@@ -611,7 +611,7 @@ function reportClientSql($column, $client_id) {
function reportMoney($amount) {
global $currency_format, $session_company_currency;
return numfmt_format_currency($currency_format, floatval($amount), $session_company_currency);
return billingMoney(floatval($amount), $session_company_currency);
}
/** Money to the whole unit - for the wide year-of-months grids, where cents only crowd the columns. */

View File

@@ -81,7 +81,7 @@ function globalSearchMoney($amount, $currency_code) {
return number_format(floatval($amount), 2);
}
return numfmt_format_currency($currency_format, floatval($amount), $currency_code ?: 'USD');
return billingMoney(floatval($amount), $currency_code ?: 'USD');
}
/** Where a client-scoped record lives: the client's own copy of a page, or the global one. */

View File

@@ -117,14 +117,14 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
<tr>
<td><?= $item_name ?></td>
<td class="text-center"><?= $item_quantity ?></td>
<td class="text-end"><?= numfmt_format_currency($currency_format, $item_total, $invoice_currency_code) ?></td>
<td class="text-end"><?= billingMoney($item_total, $invoice_currency_code) ?></td>
</tr>
<?php } ?>
<?php if ($invoice_discount > 0) { ?>
<tr class="text-end">
<td colspan="2">Discount</td>
<td>
<?= numfmt_format_currency($currency_format, $invoice_discount, $invoice_currency_code) ?>
<?= billingMoney($invoice_discount, $invoice_currency_code) ?>
</td>
</tr>
<?php } ?>
@@ -132,18 +132,18 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
<tr class="text-end">
<td colspan="2">Paid</td>
<td>
<?= numfmt_format_currency($currency_format, $amount_paid, $invoice_currency_code) ?>
<?= billingMoney($amount_paid, $invoice_currency_code) ?>
</td>
</tr>
<?php } ?>
<?php if ($card_fee > 0) { ?>
<tr class="text-end">
<td colspan="2">Balance</td>
<td><?= numfmt_format_currency($currency_format, $balance_to_pay, $invoice_currency_code) ?></td>
<td><?= billingMoney($balance_to_pay, $invoice_currency_code) ?></td>
</tr>
<tr class="text-end">
<td colspan="2">Card fee <div class="small text-body-secondary"><?= escapeHtml(billingCardFeeTerms($fee_rates, $invoice_currency_code)) ?></div></td>
<td><?= numfmt_format_currency($currency_format, $card_fee, $invoice_currency_code) ?></td>
<td><?= billingMoney($card_fee, $invoice_currency_code) ?></td>
</tr>
<?php } ?>
</tbody>
@@ -155,11 +155,11 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
<div class="col-sm offset-sm-1">
<div class="card">
<div class="card-header">
<h3 class="card-title">Payment Total: <strong><?= numfmt_format_currency($currency_format, $balance_to_pay + $card_fee, $invoice_currency_code) ?></strong></h3>
<h3 class="card-title">Payment Total: <strong><?= billingMoney($balance_to_pay + $card_fee, $invoice_currency_code) ?></strong></h3>
</div>
<div class="card-body">
<?php if ($card_fee > 0) { ?>
<p class="small text-body-secondary">With a <?= numfmt_format_currency($currency_format, $card_fee, $invoice_currency_code) ?> card fee for paying by card, which goes on the invoice as a line.</p>
<p class="small text-body-secondary">With a <?= billingMoney($card_fee, $invoice_currency_code) ?> card fee for paying by card, which goes on the invoice as a line.</p>
<?php } ?>
<form id="payment-form">
<input type="hidden" id="stripe_publishable_key" value="<?= $stripe_publishable ?>">