- Add comprehensive accounting integration with OD and bank journal entries - Create configurable accounting entries toggle in setup - Implement submission workflow with accounting entry creation - Add proper error handling and validation - Support VAT refund threshold logic for account selection - Integrate with Dolibarr's AccountingBookkeeping class - Add French language strings for new features
670 lines
26 KiB
PHP
670 lines
26 KiB
PHP
<?php
|
|
/**
|
|
* MVP Setup page for DeclarationTVA module
|
|
* Advanced multi-select PCG account mapping using Dolibarr native style
|
|
*/
|
|
|
|
// Load Dolibarr environment
|
|
if (file_exists('../../main.inc.php')) {
|
|
$res = @include '../../main.inc.php';
|
|
} elseif (file_exists('../../../main.inc.php')) {
|
|
$res = @include '../../../main.inc.php';
|
|
} else {
|
|
$res = 0;
|
|
}
|
|
|
|
if (!$res) {
|
|
die("Include of main fails");
|
|
}
|
|
|
|
// Libraries
|
|
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
|
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
|
|
|
|
// Access control
|
|
if (!$user->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');
|
|
|
|
// Handle template actions (must be processed before tab logic)
|
|
if ($action == 'upload_template' || $action == 'reset_template' || $action == 'update_template') {
|
|
// Load PDF class
|
|
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_pdf.class.php';
|
|
$pdf_generator = new DeclarationTVA_PDF($db);
|
|
|
|
if ($action == 'upload_template') {
|
|
$uploaded_file = $_FILES['template_file'];
|
|
if ($pdf_generator->uploadCustomTemplate($uploaded_file)) {
|
|
setEventMessages($langs->trans("TemplateUploaded"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($pdf_generator->error, null, 'errors');
|
|
}
|
|
}
|
|
|
|
if ($action == 'reset_template') {
|
|
if ($pdf_generator->resetToDefaultTemplate()) {
|
|
setEventMessages($langs->trans("TemplateReset"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("TemplateResetFailed"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
if ($action == 'update_template') {
|
|
if ($pdf_generator->autoUpdateTemplate()) {
|
|
setEventMessages($langs->trans("TemplateUpdated"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($pdf_generator->error ?: $langs->trans("TemplateUpdateFailed"), null, 'errors');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Handle journal configuration updates
|
|
if ($action == 'update_journal_config') {
|
|
$journal_accounts = array(
|
|
'vat_to_pay' => GETPOST('journal_vat_to_pay', 'alpha'),
|
|
'vat_to_receive' => GETPOST('journal_vat_to_receive', 'alpha'),
|
|
'vat_refund' => GETPOST('journal_vat_refund', 'alpha'),
|
|
'other_charges' => GETPOST('journal_other_charges', 'alpha'),
|
|
'other_products' => GETPOST('journal_other_products', 'alpha')
|
|
);
|
|
|
|
$updated = $config->updateJournalConfiguration($journal_accounts);
|
|
if ($updated) {
|
|
setEventMessages($langs->trans("JournalConfigurationUpdated"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("JournalConfigurationUpdateFailed"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
// Handle VAT refund threshold configuration updates
|
|
if ($action == 'update_vat_refund_threshold') {
|
|
// Debug: Log all POST data
|
|
error_log("VAT Refund Threshold Debug - All POST data:");
|
|
error_log("POST data: " . print_r($_POST, true));
|
|
|
|
$threshold_config = array(
|
|
'refund_threshold' => (float)$_POST['vat_refund_threshold'],
|
|
'refund_threshold_enabled' => (int)$_POST['vat_refund_threshold_enabled']
|
|
);
|
|
|
|
// Debug: Log the received values
|
|
error_log("VAT Refund Threshold Debug - Received values:");
|
|
error_log("refund_threshold: " . $threshold_config['refund_threshold']);
|
|
error_log("refund_threshold_enabled: " . $threshold_config['refund_threshold_enabled']);
|
|
|
|
$updated = $config->updateVATRefundThresholdConfiguration($threshold_config);
|
|
if ($updated) {
|
|
setEventMessages($langs->trans("VATRefundThresholdConfigurationUpdated"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("VATRefundThresholdConfigurationUpdateFailed"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
// Handle bank account configuration updates
|
|
if ($action == 'update_bank_config') {
|
|
$bank_account = GETPOST('journal_bank_account', 'int');
|
|
|
|
$updated = $config->updateBankAccountConfiguration($bank_account);
|
|
if ($updated) {
|
|
setEventMessages($langs->trans("BankAccountConfigurationUpdated"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("BankAccountConfigurationUpdateFailed"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
// Handle auto-create accounting entries configuration
|
|
if ($action == 'update_auto_create_config') {
|
|
$auto_create_accounting = GETPOST('auto_create_accounting', 'int');
|
|
|
|
$updated = $config->updateAutoCreateAccountingConfiguration($auto_create_accounting);
|
|
if ($updated) {
|
|
setEventMessages($langs->trans("AutoCreateAccountingConfigurationUpdated"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("AutoCreateAccountingConfigurationUpdateFailed"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
// Handle amount calculation configuration
|
|
if ($action == 'update_amount_calc_config') {
|
|
$calculation_method = GETPOST('amount_calculation_method', 'alpha');
|
|
|
|
$updated = $config->updateAmountCalculationConfiguration($calculation_method);
|
|
if ($updated) {
|
|
setEventMessages($langs->trans("AmountCalculationConfigurationUpdated"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("AmountCalculationConfigurationUpdateFailed"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
if ($action == 'update_mappings') {
|
|
$ca3_definitions = $config->getCA3LineDefinitions();
|
|
$updated_count = 0;
|
|
|
|
|
|
foreach ($ca3_definitions as $line => $definition) {
|
|
// Special handling for lines 08, 09, 9B (need both base and VAT accounts)
|
|
if (in_array($line, array('08', '09', '9B'))) {
|
|
$base_account_codes = GETPOST('base_account_codes_' . $line, 'array');
|
|
$vat_account_codes = GETPOST('vat_account_codes_' . $line, 'array');
|
|
|
|
// Always process base accounts (even if empty)
|
|
$result = $config->updateAccountMapping($line . '_BASE', $base_account_codes);
|
|
if ($result) {
|
|
$updated_count++;
|
|
}
|
|
|
|
// Always process VAT accounts (even if empty)
|
|
$result = $config->updateAccountMapping($line . '_VAT', $vat_account_codes);
|
|
if ($result) {
|
|
$updated_count++;
|
|
}
|
|
} else {
|
|
// Normal processing for other lines
|
|
$account_codes = GETPOST('account_codes_' . $line, 'array');
|
|
|
|
// Always process account mappings (even if empty)
|
|
$result = $config->updateAccountMapping($line, $account_codes);
|
|
if ($result) {
|
|
$updated_count++;
|
|
}
|
|
}
|
|
}
|
|
|
|
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();
|
|
|
|
// Ensure table exists (create if missing)
|
|
$table_name = MAIN_DB_PREFIX . "declarationtva_account_mappings";
|
|
$check_table_sql = "SHOW TABLES LIKE '" . $table_name . "'";
|
|
$table_exists = $db->query($check_table_sql);
|
|
if (!$table_exists || $db->num_rows($table_exists) == 0) {
|
|
// Create the table if it doesn't exist
|
|
$create_table_sql = "CREATE TABLE IF NOT EXISTS `" . $table_name . "` (
|
|
`rowid` int(11) NOT NULL AUTO_INCREMENT,
|
|
`entity` int(11) NOT NULL DEFAULT 1,
|
|
`ca3_line` varchar(8) NOT NULL COMMENT 'A1, A2, A3, A4, A5, 08, 09, 9B, 17, 20, 21, 22, 25, 26, 28, 29',
|
|
`account_code` varchar(32) NOT NULL COMMENT 'PCG account code',
|
|
`account_label` varchar(255) DEFAULT NULL,
|
|
`vat_rate` decimal(5,2) DEFAULT NULL,
|
|
`is_active` tinyint(1) DEFAULT 1,
|
|
`created_date` datetime DEFAULT NULL,
|
|
PRIMARY KEY (`rowid`),
|
|
UNIQUE KEY `uk_mapping_entity_line_account` (`entity`, `ca3_line`, `account_code`),
|
|
KEY `idx_ca3_line` (`ca3_line`),
|
|
KEY `idx_account_code` (`account_code`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
|
|
|
|
$db->query($create_table_sql);
|
|
}
|
|
$section_headers = $config->getCA3SectionHeaders();
|
|
|
|
// Page title
|
|
$title = $langs->trans("DeclarationTVASetup");
|
|
llxHeader('', $title);
|
|
|
|
// Print page header
|
|
print load_fiche_titre($title, '', 'title_accountancy');
|
|
|
|
|
|
// Use Dolibarr's native tab system
|
|
$head = array();
|
|
$head[0][0] = $_SERVER['PHP_SELF'] . '?tab=mapping';
|
|
$head[0][1] = $langs->trans("PCGMapping");
|
|
$head[0][2] = 'mapping';
|
|
$head[1][0] = $_SERVER['PHP_SELF'] . '?tab=templates';
|
|
$head[1][1] = $langs->trans("TemplateManagement");
|
|
$head[1][2] = 'templates';
|
|
$head[2][0] = $_SERVER['PHP_SELF'] . '?tab=journal';
|
|
$head[2][1] = $langs->trans("JournalConfiguration");
|
|
$head[2][2] = 'journal';
|
|
|
|
$tab = GETPOST('tab', 'alpha');
|
|
if (empty($tab)) {
|
|
$tab = 'mapping';
|
|
}
|
|
|
|
print dol_get_fiche_head($head, $tab, $langs->trans("DeclarationTVASetup"), -1, "declarationtva@declarationtva");
|
|
|
|
// Tab 1: PCG Mapping
|
|
if ($tab == 'mapping') {
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_mappings">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
|
|
print '<div class="fiche">';
|
|
|
|
// 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 '<div class="titre">' . $section_info['title'] . '</div>';
|
|
if (!empty($section_info['description'])) {
|
|
print '<div class="info">' . $section_info['description'] . '</div>';
|
|
}
|
|
if (isset($section_info['notice']) && !empty($section_info['notice'])) {
|
|
print '<div class="info"><strong>Référence:</strong> ' . $section_info['notice'] . '</div>';
|
|
}
|
|
|
|
// Skip D-section lines (25, 26, 28, 29) as they are calculated
|
|
if ($section_code == 'D') {
|
|
continue;
|
|
}
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th>' . $langs->trans("CA3Line") . '</th>';
|
|
print '<th>' . $langs->trans("LineLabel") . '</th>';
|
|
print '<th>' . $langs->trans("Description") . '</th>';
|
|
print '<th>' . $langs->trans("PCGAccounts") . '</th>';
|
|
print '<th>' . $langs->trans("AccountSelection") . '</th>';
|
|
print '</tr>';
|
|
|
|
foreach ($lines as $line => $definition) {
|
|
print '<tr>';
|
|
print '<td><strong>' . $line . '</strong></td>';
|
|
print '<td>' . $definition['label'] . '</td>';
|
|
print '<td><small>' . $definition['description'] . '</small></td>';
|
|
print '<td><small>' . $definition['pcg_accounts'] . '</small></td>';
|
|
print '<td>';
|
|
|
|
// Create account options array for Dolibarr multi-select
|
|
$account_options = array();
|
|
foreach ($accounts as $account) {
|
|
$account_options[$account['account_number']] = $account['account_number'] . ' - ' . $account['label'];
|
|
}
|
|
|
|
// Special handling for lines 08, 09, 9B (need both base and VAT accounts)
|
|
if (in_array($line, array('08', '09', '9B'))) {
|
|
// Load separate mappings for base and VAT
|
|
$base_selected_accounts = isset($mappings_by_line[$line . '_BASE']) ? $mappings_by_line[$line . '_BASE'] : array();
|
|
$vat_selected_accounts = isset($mappings_by_line[$line . '_VAT']) ? $mappings_by_line[$line . '_VAT'] : array();
|
|
|
|
print '<div style="margin-bottom: 10px;">';
|
|
print '<strong>Comptes de base (ventes):</strong><br>';
|
|
print $form->multiselectarray('base_account_codes_' . $line, $account_options, $base_selected_accounts, 0, 0, '', 0, '200px');
|
|
print '</div>';
|
|
print '<div>';
|
|
print '<strong>Comptes de TVA:</strong><br>';
|
|
print $form->multiselectarray('vat_account_codes_' . $line, $account_options, $vat_selected_accounts, 0, 0, '', 0, '200px');
|
|
print '</div>';
|
|
} else {
|
|
// Normal single selection for other lines
|
|
$selected_accounts = isset($mappings_by_line[$line]) ? $mappings_by_line[$line] : array();
|
|
print $form->multiselectarray('account_codes_' . $line, $account_options, $selected_accounts, 0, 0, '', 0, '200px');
|
|
}
|
|
print '</td>';
|
|
print '</tr>';
|
|
}
|
|
|
|
print '</table>';
|
|
print '<br>';
|
|
}
|
|
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
|
|
|
|
} elseif ($tab == 'templates') {
|
|
// Tab 2: Template Management
|
|
print '<div class="fichecenter">';
|
|
print '<div class="fichehalfleft">';
|
|
|
|
// Load PDF class
|
|
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_pdf.class.php';
|
|
$pdf_generator = new DeclarationTVA_PDF($db);
|
|
|
|
// Get template information
|
|
$template_info = $pdf_generator->getTemplateInfo();
|
|
|
|
// Get update status
|
|
$update_status = $pdf_generator->getTemplateUpdateStatus();
|
|
|
|
print '<form name="template_form" method="POST" enctype="multipart/form-data">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
print '<input type="hidden" name="action" value="upload_template">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>Gestion des modèles PDF CA-3</strong></td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>Modèle actuel</strong></td>';
|
|
print '<td>';
|
|
if ($template_info['custom_template']) {
|
|
print '<span class="badge badge-status4">Modèle personnalisé</span>';
|
|
} else {
|
|
print '<span class="badge badge-status1">Modèle officiel</span>';
|
|
}
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>Version actuelle</strong></td>';
|
|
print '<td>' . $template_info['official_number'] . '</td>';
|
|
print '</tr>';
|
|
|
|
// Update status
|
|
if ($update_status['update_available']) {
|
|
print '<tr class="warning">';
|
|
print '<td><strong>Mise à jour disponible</strong></td>';
|
|
print '<td>';
|
|
print '<span class="badge badge-status4">Version ' . $update_status['latest_version'] . ' disponible</span>';
|
|
print ' <a href="' . $_SERVER['PHP_SELF'] . '?action=update_template&token=' . newToken() . '" class="button button-save">Mettre à jour</a>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
} else {
|
|
print '<tr>';
|
|
print '<td><strong>Statut</strong></td>';
|
|
print '<td><span class="badge badge-status1">À jour</span></td>';
|
|
print '</tr>';
|
|
}
|
|
|
|
if (!empty($update_status['error'])) {
|
|
print '<tr class="error">';
|
|
print '<td><strong>Erreur</strong></td>';
|
|
print '<td>' . $update_status['error'] . '</td>';
|
|
print '</tr>';
|
|
}
|
|
|
|
print '<tr>';
|
|
print '<td><strong>Nouveau modèle</strong></td>';
|
|
print '<td>';
|
|
print '<input type="file" name="template_file" accept=".pdf" required>';
|
|
print '<br><small>Format PDF uniquement, taille max 10MB</small>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<input type="submit" class="button" value="Télécharger le modèle">';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
if ($template_info['custom_template']) {
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=reset_template&token=' . newToken() . '" class="button button-delete">Revenir au modèle officiel</a>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
}
|
|
|
|
print '</table>';
|
|
print '</form>';
|
|
|
|
print '</div>';
|
|
print '</div>';
|
|
|
|
print '</div>'; // Close fichehalfleft
|
|
print '</div>'; // Close fichecenter
|
|
|
|
} elseif ($tab == 'journal') {
|
|
// Tab 3: Journal Configuration
|
|
print '<div class="fiche">';
|
|
|
|
// Get current journal configuration
|
|
$journal_config = $config->getJournalConfiguration();
|
|
|
|
// Get current auto-create configuration
|
|
$auto_create_config = $config->getAutoCreateAccountingConfiguration();
|
|
|
|
// Get current amount calculation configuration
|
|
$amount_calc_config = $config->getAmountCalculationConfiguration();
|
|
|
|
// First section: Amount Calculation Method
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_amount_calc_config">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>' . $langs->trans("AmountCalculationConfiguration") . '</strong></td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("AmountCalculationMethod") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("AmountCalculationMethodDescription") . '</small><br>';
|
|
|
|
$calculation_options = array(
|
|
'round' => $langs->trans("RoundAmounts"),
|
|
'truncate' => $langs->trans("TruncateAmounts")
|
|
);
|
|
|
|
print $form->selectarray('amount_calculation_method', $calculation_options, $amount_calc_config['amount_calculation_method'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
print '</form>';
|
|
|
|
// Second section: Auto-create accounting entries
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_auto_create_config">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>' . $langs->trans("AutoCreateAccountingConfiguration") . '</strong></td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("AutoCreateAccountingEntries") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("AutoCreateAccountingEntriesDescription") . '</small><br>';
|
|
print '<input type="checkbox" name="auto_create_accounting" value="1"' . ($auto_create_config['auto_create_accounting'] ? ' checked' : '') . '>';
|
|
print ' ' . $langs->trans("EnableAutoCreateAccounting");
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
print '</form>';
|
|
|
|
// Second section: Journal Account Configuration
|
|
print '<br>';
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_journal_config">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>' . $langs->trans("JournalAccountConfiguration") . '</strong></td>';
|
|
print '</tr>';
|
|
|
|
// Create account options array exactly like in the mapping section
|
|
$account_options = array();
|
|
foreach ($accounts as $account) {
|
|
$account_options[$account['account_number']] = $account['account_number'] . ' - ' . $account['label'];
|
|
}
|
|
|
|
// Accounting entries toggle
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("CreateAccountingEntries") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("CreateAccountingEntriesDescription") . '</small><br>';
|
|
print $form->selectyesno('journal_create_accounting_entries', $journal_config['create_accounting_entries'], 1);
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("VATToPayAccount") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("VATToPayAccountDescription") . '</small><br>';
|
|
print $form->selectarray('journal_vat_to_pay', $account_options, $journal_config['vat_to_pay'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("VATToReceiveAccount") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("VATToReceiveAccountDescription") . '</small><br>';
|
|
print $form->selectarray('journal_vat_to_receive', $account_options, $journal_config['vat_to_receive'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("VATRefundAccount") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("VATRefundAccountDescription") . '</small><br>';
|
|
print $form->selectarray('journal_vat_refund', $account_options, $journal_config['vat_refund'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("OtherChargesAccount") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("OtherChargesAccountDescription") . '</small><br>';
|
|
print $form->selectarray('journal_other_charges', $account_options, $journal_config['other_charges'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("OtherProductsAccount") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("OtherProductsAccountDescription") . '</small><br>';
|
|
print $form->selectarray('journal_other_products', $account_options, $journal_config['other_products'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
print '</form>';
|
|
|
|
// Second section: Bank Account Configuration
|
|
print '<br>';
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_bank_config">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>' . $langs->trans("BankAccountConfiguration") . '</strong></td>';
|
|
print '</tr>';
|
|
|
|
// Get current bank account configuration
|
|
$bank_config = $config->getBankAccountConfiguration();
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("VATPaymentBankAccount") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("VATPaymentBankAccountDescription") . '</small><br>';
|
|
|
|
// Get bank accounts for selection
|
|
$bank_accounts = $config->getBankAccounts();
|
|
$bank_options = array();
|
|
foreach ($bank_accounts as $bank) {
|
|
$bank_options[$bank['rowid']] = $bank['label'] . ' (' . $bank['number'] . ')';
|
|
}
|
|
|
|
if (empty($bank_options)) {
|
|
print '<span class="error">' . $langs->trans("NoBankAccountsFound") . '</span>';
|
|
} else {
|
|
print $form->selectarray('journal_bank_account', $bank_options, $bank_config['bank_account'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
|
|
}
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
print '</form>';
|
|
|
|
// VAT Refund Threshold Configuration Section
|
|
print '<br>';
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_vat_refund_threshold">';
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>' . $langs->trans("VATRefundThresholdConfiguration") . '</strong></td>';
|
|
print '</tr>';
|
|
|
|
// Get current threshold configuration
|
|
$threshold_config = $config->getVATRefundThresholdConfiguration();
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("VATRefundThreshold") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("VATRefundThresholdHelp") . '</small><br>';
|
|
print '<input type="number" name="vat_refund_threshold" id="vat_refund_threshold" value="' . $threshold_config['refund_threshold'] . '" step="0.01" min="0" class="minwidth200" required>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $langs->trans("VATRefundThresholdEnabled") . '</strong></td>';
|
|
print '<td>';
|
|
print '<small>' . $langs->trans("VATRefundThresholdEnabledHelp") . '</small><br>';
|
|
print $form->selectyesno('vat_refund_threshold_enabled', $threshold_config['refund_threshold_enabled'], 1);
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '<tr>';
|
|
print '<td colspan="2" class="center">';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
print '</form>';
|
|
|
|
print '</div>';
|
|
}
|
|
|
|
// Print footer
|
|
llxFooter();
|
|
?>
|