Fix tabbed interface using Dolibarr's native tab system

- Replace custom tab implementation with Dolibarr's native dol_get_fiche_head() function
- Use proper tab navigation with URL parameters (?tab=mapping, ?tab=templates)
- Remove custom JavaScript in favor of Dolibarr's built-in tab functionality
- Maintain all existing functionality while using standard Dolibarr patterns
- Fix tab visibility and navigation issues
This commit is contained in:
Frank Cools 2025-10-07 18:35:00 +02:00
parent f7d27ae649
commit f3525ce019

View File

@ -120,19 +120,24 @@ print '<strong>Notice 4722 - Summary Table CA3 (3310-CA3-SD)</strong><br>';
print 'Configuration basée sur la structure officielle la plus récente du formulaire CA-3.';
print '</div><br>';
// Tab navigation
print '<div class="tabs">';
print '<ul class="tabBar">';
print '<li class="tabBar tabBarActive"><a href="#tab_mapping" class="tabBar">' . $langs->trans("PCGMapping") . '</a></li>';
print '<li class="tabBar"><a href="#tab_templates" class="tabBar">' . $langs->trans("TemplateManagement") . '</a></li>';
print '</ul>';
print '</div>';
// 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';
// Tab content container
print '<div class="tabContainer">';
$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
print '<div id="tab_mapping" class="tabContent">';
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() . '">';
@ -266,12 +271,10 @@ if (empty($mappings_by_line)) {
}
}
print '</div>'; // Close tab_mapping
// Tab 2: Template Management
print '<div id="tab_templates" class="tabContent" style="display: none;">';
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
} 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';
@ -387,29 +390,9 @@ print '</form>';
print '</div>';
print '</div>';
print '</div>'; // Close tab_templates
print '</div>'; // Close tabContainer
// Add JavaScript for tab functionality
print '<script type="text/javascript">
jQuery(document).ready(function() {
// Tab switching functionality
jQuery(".tabBar a").click(function(e) {
e.preventDefault();
// Remove active class from all tabs
jQuery(".tabBar li").removeClass("tabBarActive");
jQuery(".tabContent").hide();
// Add active class to clicked tab
jQuery(this).parent().addClass("tabBarActive");
// Show corresponding content
var target = jQuery(this).attr("href");
jQuery(target).show();
});
});
</script>';
print '</div>'; // Close fichehalfleft
print '</div>'; // Close fichecenter
}
// Print footer
llxFooter();