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_lines = array('A1', 'A2', 'B1', 'B2', 'B3', 'B4', '17', '20', '21', '22', '28', '29'); foreach ($ca3_lines as $line) { $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(); // Page title $title = $langs->trans("DeclarationTVASetup"); llxHeader('', $title); // Print page header print load_fiche_titre($title, '', 'title_accountancy'); // Print configuration form print '
'; print ''; print '
'; print '
' . $langs->trans("DeclarationTVAPCGMapping") . '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; foreach ($ca3_definitions as $line => $definition) { $mapping = isset($account_mappings[$line]) ? $account_mappings[$line] : array(); print ''; print ''; print ''; print ''; print ''; print ''; print ''; } print '
' . $langs->trans("CA3Line") . '' . $langs->trans("LineLabel") . '' . $langs->trans("AccountCode") . '' . $langs->trans("AccountLabel") . '' . $langs->trans("VATRate") . '
' . $line . '' . $definition['label'] . ''; print ''; print ''; print ''; print '
'; print '
' . $langs->trans("Actions") . '
'; print ''; print '
'; print '
'; // Print current configuration print '
'; print '
' . $langs->trans("CurrentConfiguration") . '
'; if (empty($mappings)) { print '
' . $langs->trans("NoConfigurationFound") . '
'; } else { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; foreach ($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 footer llxFooter(); ?>