hasRight("declarationtva", "declarationtva", "admin")) { accessforbidden(); } // Load language files $langs->load("declarationtva@declarationtva"); // Initialize objects $config = new DeclarationTVA_Config($db, $conf->entity); $form = new Form($db); // Handle form submission $action = GETPOST('action', 'alpha'); if ($action == 'update_mappings') { $ca3_definitions = $config->getCA3LineDefinitions(); $updated_count = 0; $debug_info = array(); foreach ($ca3_definitions as $line => $definition) { $account_codes = GETPOST('account_codes_' . $line, 'array'); $debug_info[] = "Line $line: " . (is_array($account_codes) ? implode(',', $account_codes) : 'empty'); // Process all lines, even empty ones (to clear mappings) $result = $config->updateAccountMapping($line, $account_codes); if ($result) { $updated_count++; } } // Debug output if (empty($debug_info)) { setEventMessages("Debug: No form data received", null, 'warnings'); } else { setEventMessages("Debug: " . implode(' | ', $debug_info), null, 'warnings'); } if ($updated_count > 0) { setEventMessages($langs->trans("ConfigurationUpdated"), null, 'mesgs'); } else { setEventMessages($langs->trans("NoChangesDetected"), null, 'warnings'); } } // Get current mappings $mappings_by_line = $config->getAccountMappingsByLine(); $accounts = $config->getAccountingAccounts(); $ca3_definitions = $config->getCA3LineDefinitions(); $section_headers = $config->getCA3SectionHeaders(); // Page title $title = $langs->trans("DeclarationTVASetup"); llxHeader('', $title); // Print page header print load_fiche_titre($title, '', 'title_accountancy'); // Print notice information print '
| ' . $langs->trans("CA3Line") . ' | '; print '' . $langs->trans("SelectedAccounts") . ' | '; print '' . $langs->trans("AccountCount") . ' | '; print '
|---|---|---|
| ' . $line . ' | '; print '' . implode(', ', $account_codes) . ' | '; print '' . count($account_codes) . ' | '; print '