From 0bec80994025befa3fe0bca2ba22bad087d5d51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Fri, 30 Jan 2026 15:44:04 +0100 Subject: [PATCH] Refactor invoice creation in webhooks to include accounthierarchy field. Update SQL statements in both PayPal and Mollie webhooks for consistency. --- .DS_Store | Bin 12292 -> 12292 bytes api/v2/get/history.php | 2 +- api/v2/get/products_software_licenses.php | 2 +- assets/functions.php | 2 +- assets/mail/pdf_template_invoice.php | 3 ++- assets/softwaretool.js | 26 +++++++++++++++++----- factuur.php | 1 - style/admin.css | 10 ++++----- webhook_mollie.php | 7 +++--- webhook_paypal.php | 7 +++--- 10 files changed, 39 insertions(+), 21 deletions(-) diff --git a/.DS_Store b/.DS_Store index 0b0a16d737eedde9cb1079aed4c86b9e84cd7276..5a5416502ec6c067443de8d0804214fb43c43b10 100644 GIT binary patch delta 65 zcmZokXi1ph&uG0dU^hRb_GTV|Fy_stgdKS%He_t(R#?Ht!oa}LJvl*KWV5lj4dZ5Z KjWsAjmW%+L+7d(n delta 139 zcmZokXi1ph&uF_bU^hRb?q(i=FlJ9Kh8%``hIEE_1|tST20exnh6;uf&z$_^q@4UD z1_lNJ1_nl1Ab$5B41gjG49I$nV0tD8iU@PSRBetEcIDa3t+0Y^a-EXK=3+4|#?7o6 J>tH-hMgY9ZDcJx3 diff --git a/api/v2/get/history.php b/api/v2/get/history.php index aa81a11..c2ff77a 100644 --- a/api/v2/get/history.php +++ b/api/v2/get/history.php @@ -102,7 +102,7 @@ if(isset($get_content) && $get_content!=''){ //Filter out only relevant servicereports $filter_key_1 = '"%serialnumber%"'; $filter_key_2 = '"ServiceReport"'; - $clause .= ' AND h.type = '.$filter_key_2.' AND NOT e.productrowid = "31" AND h.description like '.$filter_key_1; + $clause .= ' AND h.type = '.$filter_key_2.' AND e.productrowid = "31" AND h.description like '.$filter_key_1; //remove from criterias to prevent double binding unset($criterias[$v[0]]); } diff --git a/api/v2/get/products_software_licenses.php b/api/v2/get/products_software_licenses.php index f47175d..6b9a1d0 100644 --- a/api/v2/get/products_software_licenses.php +++ b/api/v2/get/products_software_licenses.php @@ -51,7 +51,7 @@ if(isset($get_content) && $get_content!=''){ //Define Query if(isset($criterias['totals']) && $criterias['totals'] ==''){ //Request for total rows - $sql = 'SELECT count(*) as count FROM products_software_licenses '.$whereclause.''; + $sql = 'SELECT count(*) as count FROM products_software_licenses l '.$whereclause.''; } elseif (isset($criterias['list']) && $criterias['list'] =='') { //SQL for list diff --git a/assets/functions.php b/assets/functions.php index 7fb0d5b..c33bce3 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -2127,7 +2127,7 @@ function serviceEvents ($messages,$page){ $service_status = ''.$service_report_outcome_good.''; } - $view_data .= ' + $view_data .= ' '.$TETS->serialnumber.' '.$service_date.' '.$service_renewal_date.' diff --git a/assets/mail/pdf_template_invoice.php b/assets/mail/pdf_template_invoice.php index 29aea68..33a8a1b 100644 --- a/assets/mail/pdf_template_invoice.php +++ b/assets/mail/pdf_template_invoice.php @@ -308,8 +308,9 @@ $pdf .= ' '; if ($tax_amount > 0) { + $tax_percentage = ($subtotal > 0) ? round(($tax_amount / $subtotal) * 100, 2) : 0; $pdf .= '
-
' . htmlspecialchars($lbl_tax) . '
+
' . htmlspecialchars($lbl_tax) . ' (' . $tax_percentage . '%)
€ ' . number_format($tax_amount, 2) . '
'; } else { diff --git a/assets/softwaretool.js b/assets/softwaretool.js index a8855c8..4e5e8f4 100644 --- a/assets/softwaretool.js +++ b/assets/softwaretool.js @@ -230,6 +230,10 @@ async function connectDeviceForSoftware() { deviceVersion = ""; deviceHwVersion = ""; + // Clear the flag so popup shows for each new device connection + // This allows users to connect multiple devices in the same session + sessionStorage.removeItem('customerDataShownThisSession'); + //set progress bar progressBar("1", "", ""); @@ -612,14 +616,23 @@ async function fetchSoftwareOptions() { document.getElementById("softwareOptionsContainer").style.display = "block"; progressBar("100", "Software options loaded", "#04AA6D"); - // Check if customer data already exists in sessionStorage - const savedCustomerData = sessionStorage.getItem('customerData'); + // Check if we're returning from a payment + const urlParams = new URLSearchParams(window.location.search); + const isReturningFromPayment = urlParams.has('payment_return') || urlParams.has('order_id'); - // Show user info modal only if no saved data and not in debug mode - if ((typeof DEBUG === 'undefined' || !DEBUG || typeof DEBUG_ID === 'undefined' || !DEBUG_ID) && !savedCustomerData) { + // Check if customer data was already shown in THIS session (not from previous session) + const customerDataShownThisSession = sessionStorage.getItem('customerDataShownThisSession'); + + // Show user info modal unless: + // 1. We're in debug mode + // 2. We're returning from payment + // 3. We already showed the modal in this session + if ((typeof DEBUG === 'undefined' || !DEBUG || typeof DEBUG_ID === 'undefined' || !DEBUG_ID) + && !isReturningFromPayment + && !customerDataShownThisSession) { showUserInfoModal(); } else { - // Customer data already exists or debug mode - reveal software options immediately + // Debug mode, returning from payment, or already shown this session - reveal software options immediately const softwareOptions = document.getElementById("softwareOptions"); if (softwareOptions) { softwareOptions.style.filter = "none"; @@ -992,6 +1005,9 @@ function showUserInfoModal() { // Save customer data to sessionStorage sessionStorage.setItem('customerData', JSON.stringify(customerData)); + // Mark that we've shown the customer data modal in this session + sessionStorage.setItem('customerDataShownThisSession', 'true'); + // Send to API await sendUserInfoToAPI(customerData); diff --git a/factuur.php b/factuur.php index dea47e3..f583dbb 100644 --- a/factuur.php +++ b/factuur.php @@ -61,7 +61,6 @@ if (!empty($invoice_data['customer']['language'])) { list($message,$pdf, $customer_email, $order_id) = generateSoftwareInvoice($invoice_data, $order_number, $invoice_language); - //+++++++++++++++++++++++++++++++++++++++++++++++++++++ // Check for HTML output request //+++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/style/admin.css b/style/admin.css index 959804a..7dec875 100644 --- a/style/admin.css +++ b/style/admin.css @@ -341,9 +341,9 @@ main .msg i.fa-times:hover { } main .msg.success { - background-color: #C3F3D7; - border-left: 4px solid #51a775; + border: 1px solid #C3F3D7; color: #51a775; + border-radius:4px; } main .msg.success i { @@ -351,9 +351,9 @@ main .msg.success i { } main .msg.error { - background-color: var(--error-background); - border-left: 4px solid var(--text-red); - color: var(--text-red); + border-radius: 4px; + border: 1px solid var(--color-red); + color: var(--color-red); } main .msg.error i { diff --git a/webhook_mollie.php b/webhook_mollie.php index cac5356..d02a021 100644 --- a/webhook_mollie.php +++ b/webhook_mollie.php @@ -204,8 +204,8 @@ try { if (!$existing_invoice) { // Create invoice - $sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created) - VALUES (?, ?, ?, ?, ?, ?, ?)'; + $sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created,accounthierarchy) + VALUES (?, ?, ?, ?, ?, ?, ?,?)'; $stmt = $pdo->prepare($sql); $stmt->execute([ $transaction['txn_id'], @@ -214,7 +214,8 @@ try { $transaction['shipping_amount'] ?? 0.00, $transaction['discount_amount'] ?? 0.00, $transaction['tax_amount'] ?? 0.00, - date('Y-m-d H:i:s') + date('Y-m-d H:i:s'), + '{"salesid":"21-Total Safety Solutions B.V.","soldto":""}' ]); $invoice_id = $pdo->lastInsertId(); } else { diff --git a/webhook_paypal.php b/webhook_paypal.php index f25f56f..3df5306 100644 --- a/webhook_paypal.php +++ b/webhook_paypal.php @@ -250,8 +250,8 @@ try { if (!$existing_invoice) { // Create invoice - $sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created) - VALUES (?, ?, ?, ?, ?, ?, ?)'; + $sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created,accounthierarchy) + VALUES (?, ?, ?, ?, ?, ?, ?,?)'; $stmt = $pdo->prepare($sql); $stmt->execute([ $transaction['txn_id'], @@ -260,7 +260,8 @@ try { $transaction['shipping_amount'] ?? 0.00, $transaction['discount_amount'] ?? 0.00, $transaction['tax_amount'] ?? 0.00, - date('Y-m-d H:i:s') + date('Y-m-d H:i:s'), + '{"salesid":"21-Total Safety Solutions B.V.","soldto":""}' ]); $invoice_id = $pdo->lastInsertId(); } else {