diff --git a/cp/app/Controllers/FinancialsController.php b/cp/app/Controllers/FinancialsController.php index a465bc5..3716d0e 100644 --- a/cp/app/Controllers/FinancialsController.php +++ b/cp/app/Controllers/FinancialsController.php @@ -53,6 +53,9 @@ class FinancialsController extends Controller $billing_company = $db->selectValue('SELECT companyNumber FROM registrar WHERE id = ?', [ $invoice_details['registrar_id'] ] ); + $currency = $db->selectValue('SELECT currency FROM registrar WHERE id = ?', + [ $invoice_details['registrar_id'] ] + ); $billing_vat = $db->selectValue('SELECT vatNumber FROM registrar WHERE id = ?', [ $invoice_details['registrar_id'] ] ); @@ -87,7 +90,6 @@ class FinancialsController extends Controller $billing_country = $billing_country['name']; $locale = $_SESSION['_lang'] ?? 'en_US'; // Fallback to 'en_US' if no locale is set - $currency = $_SESSION['_currency'] ?? 'USD'; // Fallback to 'USD' if no currency is set // Initialize the number formatter for the locale $numberFormatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL); diff --git a/cp/resources/views/partials/js-invoices.twig b/cp/resources/views/partials/js-invoices.twig index 3d28cf1..b7ab22c 100644 --- a/cp/resources/views/partials/js-invoices.twig +++ b/cp/resources/views/partials/js-invoices.twig @@ -18,8 +18,6 @@ `; } - currency = "{{ currency }} "; - table = new Tabulator("#invoicesTable", { ajaxURL:"/api/records/invoices?join=registrar", // Set the URL for your JSON data ajaxConfig:"GET", @@ -40,12 +38,14 @@ {formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0}, {title:"{{ __('Number') }}", field:"invoice_number", width:200, resizable:false, headerSort:true, formatter: invoiceLinkFormatter, responsive:0}, {title:"{{ __('Registrar') }}", field:"registrar_id.name", width:300, resizable:false, headerSort:true, responsive:0}, - {title:"{{ __('Date') }}", field:"issue_date", width:300, resizable:false, headerSort:true, responsive:0}, - {title:"{{ __('Amount') }}", field:"total_amount", width:200, resizable:false, headerSort:true, responsive:0, formatter:"money", formatterParams:{ - decimal:".", - thousand:" ", - symbol:currency, - negativeSign:true, + {title:"{{ __('Date') }}", field:"issue_date", width:300, resizable:false, headerSort:true, responsive:0}, + {title:"{{ __('Amount') }}", field:"total_amount", width:200, resizable:false, headerSort:true, responsive:0, formatter:"money", formatterParams:function(cell){ + return { + decimal: ".", + thousand: " ", + symbol: (cell.getRow().getData().registrar_id.currency || "$") + " ", // Ensures space after currency symbol + negativeSign: true + }; }}, {title: "{{ __('Actions') }}", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }}, ]