Refactor invoice creation in webhooks to include accounthierarchy field. Update SQL statements in both PayPal and Mollie webhooks for consistency.

This commit is contained in:
“VeLiTi”
2026-01-30 15:44:04 +01:00
parent 9d33b37b8b
commit 0bec809940
10 changed files with 39 additions and 21 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -102,7 +102,7 @@ if(isset($get_content) && $get_content!=''){
//Filter out only relevant servicereports //Filter out only relevant servicereports
$filter_key_1 = '"%serialnumber%"'; $filter_key_1 = '"%serialnumber%"';
$filter_key_2 = '"ServiceReport"'; $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 //remove from criterias to prevent double binding
unset($criterias[$v[0]]); unset($criterias[$v[0]]);
} }

View File

@@ -51,7 +51,7 @@ if(isset($get_content) && $get_content!=''){
//Define Query //Define Query
if(isset($criterias['totals']) && $criterias['totals'] ==''){ if(isset($criterias['totals']) && $criterias['totals'] ==''){
//Request for total rows //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'] =='') { elseif (isset($criterias['list']) && $criterias['list'] =='') {
//SQL for list //SQL for list

View File

@@ -2127,7 +2127,7 @@ function serviceEvents ($messages,$page){
$service_status = '<span class="status warranty">'.$service_report_outcome_good.'</span>'; $service_status = '<span class="status warranty">'.$service_report_outcome_good.'</span>';
} }
$view_data .= '<tr onclick="window.location.href=\'index.php?page=servicereport&equipmentID='.$message->equipmentID.'&historyID='.$message->historyID.'\'" style="cursor: pointer;"> $view_data .= '<tr onclick="window.location.href=\'index.php?page=servicereport&historyID='.$message->historyID.'\'" style="cursor: pointer;">
<td>'.$TETS->serialnumber.'</td> <td>'.$TETS->serialnumber.'</td>
<td>'.$service_date.'</td> <td>'.$service_date.'</td>
<td>'.$service_renewal_date.'</td> <td>'.$service_renewal_date.'</td>

View File

@@ -308,8 +308,9 @@ $pdf .= '</tbody>
</div>'; </div>';
if ($tax_amount > 0) { if ($tax_amount > 0) {
$tax_percentage = ($subtotal > 0) ? round(($tax_amount / $subtotal) * 100, 2) : 0;
$pdf .= '<div class="total-row"> $pdf .= '<div class="total-row">
<div class="total-label">' . htmlspecialchars($lbl_tax) . '</div> <div class="total-label">' . htmlspecialchars($lbl_tax) . ' (' . $tax_percentage . '%)</div>
<div class="total-amount">€ ' . number_format($tax_amount, 2) . '</div> <div class="total-amount">€ ' . number_format($tax_amount, 2) . '</div>
</div>'; </div>';
} else { } else {

View File

@@ -230,6 +230,10 @@ async function connectDeviceForSoftware() {
deviceVersion = ""; deviceVersion = "";
deviceHwVersion = ""; 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 //set progress bar
progressBar("1", "", ""); progressBar("1", "", "");
@@ -612,14 +616,23 @@ async function fetchSoftwareOptions() {
document.getElementById("softwareOptionsContainer").style.display = "block"; document.getElementById("softwareOptionsContainer").style.display = "block";
progressBar("100", "Software options loaded", "#04AA6D"); progressBar("100", "Software options loaded", "#04AA6D");
// Check if customer data already exists in sessionStorage // Check if we're returning from a payment
const savedCustomerData = sessionStorage.getItem('customerData'); 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 // Check if customer data was already shown in THIS session (not from previous session)
if ((typeof DEBUG === 'undefined' || !DEBUG || typeof DEBUG_ID === 'undefined' || !DEBUG_ID) && !savedCustomerData) { 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(); showUserInfoModal();
} else { } 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"); const softwareOptions = document.getElementById("softwareOptions");
if (softwareOptions) { if (softwareOptions) {
softwareOptions.style.filter = "none"; softwareOptions.style.filter = "none";
@@ -992,6 +1005,9 @@ function showUserInfoModal() {
// Save customer data to sessionStorage // Save customer data to sessionStorage
sessionStorage.setItem('customerData', JSON.stringify(customerData)); 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 // Send to API
await sendUserInfoToAPI(customerData); await sendUserInfoToAPI(customerData);

View File

@@ -61,7 +61,6 @@ if (!empty($invoice_data['customer']['language'])) {
list($message,$pdf, $customer_email, $order_id) = generateSoftwareInvoice($invoice_data, $order_number, $invoice_language); list($message,$pdf, $customer_email, $order_id) = generateSoftwareInvoice($invoice_data, $order_number, $invoice_language);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++
// Check for HTML output request // Check for HTML output request
//+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -341,9 +341,9 @@ main .msg i.fa-times:hover {
} }
main .msg.success { main .msg.success {
background-color: #C3F3D7; border: 1px solid #C3F3D7;
border-left: 4px solid #51a775;
color: #51a775; color: #51a775;
border-radius:4px;
} }
main .msg.success i { main .msg.success i {
@@ -351,9 +351,9 @@ main .msg.success i {
} }
main .msg.error { main .msg.error {
background-color: var(--error-background); border-radius: 4px;
border-left: 4px solid var(--text-red); border: 1px solid var(--color-red);
color: var(--text-red); color: var(--color-red);
} }
main .msg.error i { main .msg.error i {

View File

@@ -204,8 +204,8 @@ try {
if (!$existing_invoice) { if (!$existing_invoice) {
// Create invoice // Create invoice
$sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created) $sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created,accounthierarchy)
VALUES (?, ?, ?, ?, ?, ?, ?)'; VALUES (?, ?, ?, ?, ?, ?, ?,?)';
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->execute([ $stmt->execute([
$transaction['txn_id'], $transaction['txn_id'],
@@ -214,7 +214,8 @@ try {
$transaction['shipping_amount'] ?? 0.00, $transaction['shipping_amount'] ?? 0.00,
$transaction['discount_amount'] ?? 0.00, $transaction['discount_amount'] ?? 0.00,
$transaction['tax_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(); $invoice_id = $pdo->lastInsertId();
} else { } else {

View File

@@ -250,8 +250,8 @@ try {
if (!$existing_invoice) { if (!$existing_invoice) {
// Create invoice // Create invoice
$sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created) $sql = 'INSERT INTO invoice (txn_id, payment_status, payment_amount, shipping_amount, discount_amount, tax_amount, created,accounthierarchy)
VALUES (?, ?, ?, ?, ?, ?, ?)'; VALUES (?, ?, ?, ?, ?, ?, ?,?)';
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->execute([ $stmt->execute([
$transaction['txn_id'], $transaction['txn_id'],
@@ -260,7 +260,8 @@ try {
$transaction['shipping_amount'] ?? 0.00, $transaction['shipping_amount'] ?? 0.00,
$transaction['discount_amount'] ?? 0.00, $transaction['discount_amount'] ?? 0.00,
$transaction['tax_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(); $invoice_id = $pdo->lastInsertId();
} else { } else {