hasRight("declarationtva", "declarationtva", "admin")) { accessforbidden(); } // Load language files $langs->load("declarationtva@declarationtva"); // Initialize objects $config = new DeclarationTVA_Config($db, $conf->entity); // Handle form submission $action = GETPOST('action', 'alpha'); if ($action == 'update_mappings') { $ca3_definitions = $config->getCA3LineDefinitions(); foreach ($ca3_definitions as $line => $definition) { $account_code = GETPOST('account_code_' . $line, 'alpha'); $account_label = GETPOST('account_label_' . $line, 'alpha'); $vat_rate = GETPOST('vat_rate_' . $line, 'alpha'); if (!empty($account_code)) { $config->updateAccountMapping($line, $account_code, $account_label, $vat_rate); } } setEventMessages($langs->trans("ConfigurationUpdated"), null, 'mesgs'); } // Get current mappings $mappings = $config->getAllAccountMappings(); $account_mappings = array(); foreach ($mappings as $mapping) { $account_mappings[$mapping['ca3_line']] = $mapping; } // Get available accounting accounts $accounts = $config->getAccountingAccounts(); $vat_rates = $config->getVATRates(); $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 '
'; print 'Notice 4722 - Summary Table CA3 (3310-CA3-SD)
'; print 'Configuration basée sur la structure officielle la plus récente du formulaire CA-3.'; print '

'; // Print configuration form print '
'; print ''; print '
'; print '
' . $langs->trans("DeclarationTVAPCGMapping") . '
'; // Group CA-3 lines by section $lines_by_section = array(); foreach ($ca3_definitions as $line => $definition) { $section = $definition['section']; if (!isset($lines_by_section[$section])) { $lines_by_section[$section] = array(); } $lines_by_section[$section][$line] = $definition; } // Print each section foreach ($lines_by_section as $section_code => $lines) { $section_info = $section_headers[$section_code]; // Section header print '
' . $section_info['title'] . '
'; print '
' . $section_info['description'] . '
'; if (isset($section_info['notice'])) { print '
Référence: ' . $section_info['notice'] . '
'; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; foreach ($lines as $line => $definition) { $mapping = isset($account_mappings[$line]) ? $account_mappings[$line] : array(); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } print '
' . $langs->trans("CA3Line") . '' . $langs->trans("LineLabel") . '' . $langs->trans("Description") . '' . $langs->trans("PCGAccounts") . '' . $langs->trans("AccountCode") . '' . $langs->trans("AccountLabel") . '' . $langs->trans("VATRate") . '
' . $line . '' . $definition['label'] . '' . $definition['description'] . '' . $definition['pcg_accounts'] . ''; print ''; print ''; print ''; print '
'; print '
'; } print '
' . $langs->trans("Actions") . '
'; print ''; print '
'; print '
'; // Print current configuration summary print '
'; print '
' . $langs->trans("CurrentConfiguration") . '
'; if (empty($mappings)) { print '
' . $langs->trans("NoConfigurationFound") . '
'; } else { // Group by section for display $mappings_by_section = array(); foreach ($mappings as $mapping) { $line = $mapping['ca3_line']; if (isset($ca3_definitions[$line])) { $section = $ca3_definitions[$line]['section']; if (!isset($mappings_by_section[$section])) { $mappings_by_section[$section] = array(); } $mappings_by_section[$section][] = $mapping; } } foreach ($mappings_by_section as $section_code => $section_mappings) { $section_info = $section_headers[$section_code]; print '
' . $section_info['title'] . '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; foreach ($section_mappings as $mapping) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; } print '
' . $langs->trans("CA3Line") . '' . $langs->trans("AccountCode") . '' . $langs->trans("AccountLabel") . '' . $langs->trans("VATRate") . '' . $langs->trans("Status") . '
' . $mapping['ca3_line'] . '' . $mapping['account_code'] . '' . $mapping['account_label'] . '' . $mapping['vat_rate'] . '%' . ($mapping['is_active'] ? $langs->trans("Active") : $langs->trans("Inactive")) . '
'; print '
'; } } print '
'; // Print footer llxFooter(); ?>