From 1a7663344dfa2c56c80516b994d16a0edf7390b1 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Thu, 2 Oct 2025 17:45:30 +0200 Subject: [PATCH] Add debugging to investigate account mapping issues Debug Features: - Added debug output to show what form data is being submitted - Shows which lines have data and which are empty/not set - Helps identify if Dolibarr multiselectarray sends empty arrays - Will help diagnose why accounts are being lost This will help us understand what's happening with the form submission! --- admin/setup_mvp.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/admin/setup_mvp.php b/admin/setup_mvp.php index 3421f0e..fd2804e 100644 --- a/admin/setup_mvp.php +++ b/admin/setup_mvp.php @@ -40,13 +40,23 @@ if ($action == 'update_mappings') { $ca3_definitions = $config->getCA3LineDefinitions(); $updated_count = 0; + // Debug: Show what's being submitted + $debug_info = array(); + foreach ($ca3_definitions as $line => $definition) { + $account_codes = GETPOST('account_codes_' . $line, 'array'); + $debug_info[] = "$line: " . (is_array($account_codes) ? implode(',', $account_codes) : 'not set'); + } + setEventMessages("Debug: Form data - " . implode(' | ', $debug_info), null, 'warnings'); + foreach ($ca3_definitions as $line => $definition) { $account_codes = GETPOST('account_codes_' . $line, 'array'); - // Process all lines, even empty ones (to clear mappings) - $result = $config->updateAccountMapping($line, $account_codes); - if ($result) { - $updated_count++; + // Process all lines that have form data + if (isset($_POST['account_codes_' . $line])) { + $result = $config->updateAccountMapping($line, $account_codes); + if ($result) { + $updated_count++; + } } }