diff --git a/CHANGELOG.md b/CHANGELOG.md index 03360cab5..0958afccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `` 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] diff --git a/admin/labor_costs.php b/admin/labor_costs.php index 3faaf186d..3fae21532 100644 --- a/admin/labor_costs.php +++ b/admin/labor_costs.php @@ -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)); }; ?> diff --git a/admin/modals/labor_cost/labor_cost_rates.php b/admin/modals/labor_cost/labor_cost_rates.php index c607bc140..003fdbb43 100644 --- a/admin/modals/labor_cost/labor_cost_rates.php +++ b/admin/modals/labor_cost/labor_cost_rates.php @@ -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(); diff --git a/admin/settings.php b/admin/settings.php index 99da272e6..5381bb5f8 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -42,8 +42,8 @@ $summaries = [ 'localization' => escapeHtml(implode(' · ', array_filter([$localization['locales'][$company['company_locale'] ?? ''] ?? '', $company['company_currency'] ?? '', $config_timezone]))), 'theme' => '' . 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), diff --git a/agent/client_overview.php b/agent/client_overview.php index 33558b763..341160bd5 100644 --- a/agent/client_overview.php +++ b/agent/client_overview.php @@ -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); }; ?> diff --git a/agent/clients.php b/agent/clients.php index 23ab5dda3..f729bce80 100644 --- a/agent/clients.php +++ b/agent/clients.php @@ -684,20 +684,20 @@ $total_leads = intval($row['leads']); 0.004) { ?> - + 0.004) { ?> -
overdue
+
overdue
- + 0.004) { ?> - /mo + /mo -
/hr(default)' : '' ?>
+
/hr(default)' : '' ?>
- diff --git a/agent/includes/inc_client_top_head.php b/agent/includes/inc_client_top_head.php index f6a1a0d42..b7daf53f4 100644 --- a/agent/includes/inc_client_top_head.php +++ b/agent/includes/inc_client_top_head.php @@ -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); }; ?> diff --git a/agent/modals/client/client_credit_add.php b/agent/modals/client/client_credit_add.php index 1a252f5ae..fe2b1d389 100644 --- a/agent/modals/client/client_credit_add.php +++ b/agent/modals/client/client_credit_add.php @@ -2,7 +2,7 @@ diff --git a/agent/modals/vendor/vendor.php b/agent/modals/vendor/vendor.php index a9e5d8c4f..ed7247738 100644 --- a/agent/modals/vendor/vendor.php +++ b/agent/modals/vendor/vendor.php @@ -164,7 +164,7 @@ ob_start();
- this year · last + this year · last
diff --git a/agent/post/credit.php b/agent/post/credit.php index cfbb6711e..991e16a70 100644 --- a/agent/post/credit.php +++ b/agent/post/credit.php @@ -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(); diff --git a/agent/post/payment.php b/agent/post/payment.php index df7aa1161..224427d65 100644 --- a/agent/post/payment.php +++ b/agent/post/payment.php @@ -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 " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " added"); + flashAlert("Payment amount " . billingMoney($amount, $invoice_currency_code) . " 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 " . numfmt_format_currency($currency_format, $amount, $session_company_currency) . " added"); + flashAlert("Payment edited to amount " . billingMoney($amount, $session_company_currency) . " 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 " . numfmt_format_currency($currency_format, $amount, $session_company_currency) . " applied"); + flashAlert("Credit amount " . billingMoney($amount, $session_company_currency) . " 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 " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "$fee_text added"); + flashAlert("Payment amount " . billingMoney($pi_amount_paid, $invoice_currency_code) . "$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"); diff --git a/agent/post/recurring_invoice.php b/agent/post/recurring_invoice.php index 1b4b52b75..984c6a9a2 100644 --- a/agent/post/recurring_invoice.php +++ b/agent/post/recurring_invoice.php @@ -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 $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_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 Disabled for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number", 'error'); } diff --git a/agent/vendor.php b/agent/vendor.php index df60babce..a6f764173 100644 --- a/agent/vendor.php +++ b/agent/vendor.php @@ -733,9 +733,9 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
- this year - last year - in all + this year + last year + in all
All @@ -757,7 +757,7 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
' . escapeHtml($expense['paid_by_name'] ?: 'An agent') : (moduleOn('bookkeeping') ? escapeHtml($expense['account_name']) : 'The business') ?> - + @@ -793,7 +793,7 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
-' ?>
- + diff --git a/agent/vendors.php b/agent/vendors.php index c6fb3914e..00b719abc 100644 --- a/agent/vendors.php +++ b/agent/vendors.php @@ -397,7 +397,7 @@ $missing_templates = $view === 'client' && !$archived ? vendorTemplatesMissingFo - this year + this year diff --git a/client/index.php b/client/index.php index 56b170f39..cb7d035c9 100644 --- a/client/index.php +++ b/client/index.php @@ -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']), ' ') ?: ''; - + 0) { ?> - past due + past due 0 && $next_due) { ?> Due diff --git a/client/post.php b/client/post.php index 75eae1898..a1b9b0592 100644 --- a/client/post.php +++ b/client/post.php @@ -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"); } diff --git a/functions/dashboard.php b/functions/dashboard.php index 5e20c9728..aae36a13c 100644 --- a/functions/dashboard.php +++ b/functions/dashboard.php @@ -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); } /** diff --git a/functions/reports.php b/functions/reports.php index 3f76e73e5..a51478238 100644 --- a/functions/reports.php +++ b/functions/reports.php @@ -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. */ diff --git a/functions/search.php b/functions/search.php index 881e408c2..618b0bacb 100644 --- a/functions/search.php +++ b/functions/search.php @@ -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. */ diff --git a/guest/guest_pay_invoice_stripe.php b/guest/guest_pay_invoice_stripe.php index 4e56de035..af8387acd 100644 --- a/guest/guest_pay_invoice_stripe.php +++ b/guest/guest_pay_invoice_stripe.php @@ -117,14 +117,14 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent - + 0) { ?> Discount - + @@ -132,18 +132,18 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent Paid - + 0) { ?> Balance - + Card fee
- + @@ -155,11 +155,11 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
-

Payment Total:

+

Payment Total:

0) { ?> -

With a card fee for paying by card, which goes on the invoice as a line.

+

With a card fee for paying by card, which goes on the invoice as a line.