diff --git a/declarationtva_line_details.php b/declarationtva_line_details.php
deleted file mode 100644
index 96118c2..0000000
--- a/declarationtva_line_details.php
+++ /dev/null
@@ -1,183 +0,0 @@
-hasRight("declarationtva", "declarationtva", "read")) {
- accessforbidden();
-}
-
-// Get parameters
-$declaration_id = GETPOST('declaration_id', 'int');
-$ca3_line = GETPOST('ca3_line', 'alpha');
-
-// Validate parameters
-if (empty($declaration_id) || empty($ca3_line)) {
- setEventMessages($langs->trans("ErrorMissingParameters"), null, 'errors');
- header("Location: declarationtvaindex.php");
- exit;
-}
-
-// Initialize objects
-$declarationtva = new DeclarationTVA($db);
-$config = new DeclarationTVA_Config($db);
-
-// Get declaration info
-if (!$declarationtva->fetch($declaration_id)) {
- setEventMessages($langs->trans("DeclarationNotFound"), null, 'errors');
- header("Location: declarationtvaindex.php");
- exit;
-}
-
-// Get detailed breakdown
-$line_details = $declarationtva->getCA3LineDetails($declaration_id, $ca3_line);
-
-if (empty($line_details)) {
- setEventMessages($langs->trans("NoDataFoundForLine"), null, 'errors');
- header("Location: declarationtva_view.php?id=" . $declaration_id);
- exit;
-}
-
-// Get CA-3 line definition
-$ca3_definitions = $config->getCA3LineDefinitions();
-$line_definition = isset($ca3_definitions[$ca3_line]) ? $ca3_definitions[$ca3_line] : null;
-
-// Page title
-$title = $langs->trans("CA3LineDetails") . " - " . $ca3_line;
-if ($line_definition) {
- $title .= " - " . $line_definition['label'];
-}
-
-// Load page header
-llxHeader('', $title);
-
-// Page header
-print load_fiche_titre($title, '', 'fa-list-alt');
-
-// Breadcrumb
-print '
';
-
-// Declaration info
-print '';
-print '
';
-print '
';
-print '';
-print '| ' . $langs->trans("DeclarationInfo") . ' | ';
-print '
';
-print '';
-print '| ' . $langs->trans("DeclarationNumber") . ' | ';
-print '' . $declarationtva->declaration_number . ' | ';
-print '
';
-print '';
-print '| ' . $langs->trans("Period") . ' | ';
-print '' . dol_print_date($declarationtva->start_date, 'day') . ' - ' . dol_print_date($declarationtva->end_date, 'day') . ' | ';
-print '
';
-print '';
-print '| ' . $langs->trans("CA3Line") . ' | ';
-print '' . $ca3_line . ' | ';
-print '
';
-if ($line_definition) {
- print '';
- print '| ' . $langs->trans("Description") . ' | ';
- print '' . $line_definition['label'] . ' | ';
- print '
';
-}
-print '
';
-print '
';
-
-print '
';
-print '
';
-print '';
-print '| ' . $langs->trans("LineSummary") . ' | ';
-print '
';
-print '';
-print '| ' . $langs->trans("AccountCount") . ' | ';
-print '' . $line_details['account_count'] . ' | ';
-print '
';
-if ($line_details['calculated_line']) {
- print '';
- print '| ' . $langs->trans("CalculatedTotal") . ' | ';
- print '' . price($line_details['calculated_line']->total_amount) . ' | ';
- print '
';
-}
-print '
';
-print '
';
-print '
';
-
-// Account details table
-print '';
-print '
';
-print '';
-print '| ' . $langs->trans("AccountCode") . ' | ';
-print '' . $langs->trans("AccountLabel") . ' | ';
-print '' . $langs->trans("BaseAmount") . ' | ';
-print '' . $langs->trans("VATAmount") . ' | ';
-print '' . $langs->trans("TotalAmount") . ' | ';
-print '' . $langs->trans("MappingType") . ' | ';
-print '
';
-
-$total_base = 0;
-$total_vat = 0;
-$total_amount = 0;
-
-foreach ($line_details['account_details'] as $account) {
- $total_base += $account['base_amount'];
- $total_vat += $account['vat_amount'];
- $total_amount += $account['total_amount'];
-
- print '';
- print '| ' . $account['account_code'] . ' | ';
- print '' . $account['account_label'] . ' | ';
- print '' . price($account['base_amount']) . ' | ';
- print '' . price($account['vat_amount']) . ' | ';
- print '' . price($account['total_amount']) . ' | ';
- print '' . $account['mapping_type'] . ' | ';
- print '
';
-}
-
-// Totals row
-print '';
-print '| ' . $langs->trans("Total") . ' | ';
-print '' . price($total_base) . ' | ';
-print '' . price($total_vat) . ' | ';
-print '' . price($total_amount) . ' | ';
-print ' | ';
-print '
';
-
-print '
';
-print '
';
-
-// Additional info if calculated line exists
-if ($line_details['calculated_line']) {
- print '';
- print '' . $langs->trans("Note") . ': ';
- print $langs->trans("CalculatedLineNote");
- if (!empty($line_details['calculated_line']->line_label)) {
- print '
' . $line_details['calculated_line']->line_label . '';
- }
- print '
';
-}
-
-// Close page
-llxFooter();
-?>
diff --git a/declarationtva_line_details_ajax.php b/declarationtva_line_details_ajax.php
new file mode 100644
index 0000000..950369a
--- /dev/null
+++ b/declarationtva_line_details_ajax.php
@@ -0,0 +1,119 @@
+hasRight("declarationtva", "declarationtva", "read")) {
+ http_response_code(403);
+ echo "Access denied";
+ exit;
+}
+
+// Get parameters
+$declaration_id = GETPOST('declaration_id', 'int');
+$ca3_line = GETPOST('ca3_line', 'alpha');
+
+// Validate parameters
+if (empty($declaration_id) || empty($ca3_line)) {
+ echo '' . $langs->trans("ErrorMissingParameters") . '
';
+ exit;
+}
+
+// Initialize objects
+$declarationtva = new DeclarationTVA($db);
+$config = new DeclarationTVA_Config($db);
+
+// Get declaration info
+if (!$declarationtva->fetch($declaration_id)) {
+ echo '' . $langs->trans("DeclarationNotFound") . '
';
+ exit;
+}
+
+// Get detailed breakdown
+$line_details = $declarationtva->getCA3LineDetails($declaration_id, $ca3_line);
+
+if (empty($line_details)) {
+ echo '' . $langs->trans("NoDataFoundForLine") . '
';
+ exit;
+}
+
+// Get CA-3 line definition
+$ca3_definitions = $config->getCA3LineDefinitions();
+$line_definition = isset($ca3_definitions[$ca3_line]) ? $ca3_definitions[$ca3_line] : null;
+
+// Display account details table
+echo '';
+echo '';
+echo '| ' . $langs->trans("AccountCode") . ' | ';
+echo '' . $langs->trans("AccountLabel") . ' | ';
+echo '' . $langs->trans("BaseAmount") . ' | ';
+echo '' . $langs->trans("VATAmount") . ' | ';
+echo '' . $langs->trans("TotalAmount") . ' | ';
+echo '' . $langs->trans("MappingType") . ' | ';
+echo '
';
+
+$total_base = 0;
+$total_vat = 0;
+$total_amount = 0;
+
+foreach ($line_details['account_details'] as $account) {
+ $total_base += $account['base_amount'];
+ $total_vat += $account['vat_amount'];
+ $total_amount += $account['total_amount'];
+
+ echo '';
+ echo '| ' . $account['account_code'] . ' | ';
+ echo '' . $account['account_label'] . ' | ';
+ echo '' . price($account['base_amount']) . ' | ';
+ echo '' . price($account['vat_amount']) . ' | ';
+ echo '' . price($account['total_amount']) . ' | ';
+ echo '' . $account['mapping_type'] . ' | ';
+ echo '
';
+}
+
+// Totals row
+echo '';
+echo '| ' . $langs->trans("Total") . ' | ';
+echo '' . price($total_base) . ' | ';
+echo '' . price($total_vat) . ' | ';
+echo '' . price($total_amount) . ' | ';
+echo ' | ';
+echo '
';
+
+echo '
';
+
+// Additional info if calculated line exists
+if ($line_details['calculated_line']) {
+ echo '';
+ echo '' . $langs->trans("Note") . ': ';
+ echo $langs->trans("CalculatedLineNote");
+ if (!empty($line_details['calculated_line']->line_label)) {
+ echo '
' . $line_details['calculated_line']->line_label . '';
+ }
+ echo '
';
+}
+
+// Summary info
+echo '';
+echo '' . $langs->trans("Summary") . ': ';
+echo $langs->trans("AccountCount") . ': ' . $line_details['account_count'] . ' | ';
+echo $langs->trans("Period") . ': ' . dol_print_date($line_details['start_date'], 'day') . ' - ' . dol_print_date($line_details['end_date'], 'day');
+echo '
';
+?>
diff --git a/declarationtva_view.php b/declarationtva_view.php
index b930447..c5c16df 100644
--- a/declarationtva_view.php
+++ b/declarationtva_view.php
@@ -173,10 +173,22 @@ foreach ($section_a_lines as $line) {
$data = isset($ca3_data[$line]) ? $ca3_data[$line] : array('line_label' => '', 'vat_amount' => 0);
$description = isset($ca3_definitions[$line]) ? $ca3_definitions[$line]['label'] : $data['line_label'];
print '';
- print '| ' . $line . ' | ';
+ print '' . $line . ' | ';
print '' . $description . ' | ';
print '' . formatAmountWithOriginal($data['vat_amount'], $data['line_label']) . ' | ';
print '
';
+
+ // Add dropdown row for account details
+ print '';
+ print '';
+ print '';
+ print '';
+ print ' ';
+ print ' ' . $langs->trans("Loading") . '... ';
+ print ' ';
+ print ' ';
+ print ' | ';
+ print '
';
}
// Section B: TVA due
@@ -201,11 +213,23 @@ foreach ($base_vat_lines as $line) {
$data = isset($ca3_data[$line]) ? $ca3_data[$line] : array('line_label' => '', 'base_amount' => 0, 'vat_amount' => 0);
$description = isset($ca3_definitions[$line]) ? $ca3_definitions[$line]['label'] : $data['line_label'];
print '';
- print '| ' . $line . ' | ';
+ print '' . $line . ' | ';
print '' . $description . ' | ';
print '' . formatAmountWithOriginal($data['base_amount'], $data['line_label'], 'base') . ' | ';
print '' . formatAmountWithOriginal($data['vat_amount'], $data['line_label']) . ' | ';
print '
';
+
+ // Add dropdown row for account details
+ print '';
+ print '';
+ print '';
+ print '';
+ print ' ';
+ print ' ' . $langs->trans("Loading") . '... ';
+ print ' ';
+ print ' ';
+ print ' | ';
+ print '
';
}
// Line 16: Subtotal (calculated automatically)
@@ -226,11 +250,23 @@ print '';
$data = isset($ca3_data['17']) ? $ca3_data['17'] : array('line_label' => '', 'vat_amount' => 0);
$description = isset($ca3_definitions['17']) ? $ca3_definitions['17']['label'] : $data['line_label'];
print '';
-print '| 17 | ';
+print '17 | ';
print '' . $description . ' | ';
print '' . formatAmountWithOriginal($data['vat_amount'], $data['line_label']) . ' | ';
print '
';
+// Add dropdown row for account details
+print '';
+print '';
+print '';
+print '';
+print ' ';
+print ' ' . $langs->trans("Loading") . '... ';
+print ' ';
+print ' ';
+print ' | ';
+print '
';
+
// Section C: TVA déductible
print '';
print '| C. ' . $langs->trans("CA3SectionC") . ' | ';
@@ -247,10 +283,22 @@ foreach ($section_c_lines as $line) {
$data = isset($ca3_data[$line]) ? $ca3_data[$line] : array('line_label' => '', 'vat_amount' => 0);
$description = isset($ca3_definitions[$line]) ? $ca3_definitions[$line]['label'] : $data['line_label'];
print '
';
- print '| ' . $line . ' | ';
+ print '' . $line . ' | ';
print '' . $description . ' | ';
print '' . formatAmountWithOriginal($data['vat_amount'], $data['line_label']) . ' | ';
print '
';
+
+ // Add dropdown row for account details
+ print '';
+ print '';
+ print '';
+ print '';
+ print ' ';
+ print ' ' . $langs->trans("Loading") . '... ';
+ print ' ';
+ print ' ';
+ print ' | ';
+ print '
';
}
// Line 23: Subtotal (calculated automatically)
@@ -284,10 +332,22 @@ foreach ($section_d_lines as $line) {
}
print '';
- print '| ' . $line . ' | ';
+ print '' . $line . ' | ';
print '' . $description . ' | ';
print '' . formatAmount($data['vat_amount']) . ' | ';
print '
';
+
+ // Add dropdown row for account details
+ print '';
+ print '';
+ print '';
+ print '';
+ print ' ';
+ print ' ' . $langs->trans("Loading") . '... ';
+ print ' ';
+ print ' ';
+ print ' | ';
+ print '
';
}
// Show message if no data
@@ -320,6 +380,101 @@ print '' . $langs->trans("Ba
print '';
print '';
+// Add CSS for dropdown styling
+print '';
+
+// Add JavaScript for dropdown functionality
+print '';
+
// Print footer
llxFooter();
?>
diff --git a/langs/en_US/declarationtva.lang b/langs/en_US/declarationtva.lang
index 6485d2c..80ed3dd 100644
--- a/langs/en_US/declarationtva.lang
+++ b/langs/en_US/declarationtva.lang
@@ -457,3 +457,7 @@ Note = Note
CalculatedLineNote = This line shows the detail of accounts used to calculate the CA-3 line. Amounts may differ slightly from the calculated total due to rounding.
ErrorMissingParameters = Missing parameters
NoDataFoundForLine = No data found for this line
+AccountBreakdown = Account Breakdown
+Loading = Loading...
+ErrorLoadingDetails = Error loading details
+Summary = Summary
diff --git a/langs/fr_FR/declarationtva.lang b/langs/fr_FR/declarationtva.lang
index 070d83b..465aef3 100644
--- a/langs/fr_FR/declarationtva.lang
+++ b/langs/fr_FR/declarationtva.lang
@@ -446,3 +446,7 @@ Note = Note
CalculatedLineNote = Cette ligne montre le détail des comptes utilisés pour calculer la ligne CA-3. Les montants peuvent différer légèrement du total calculé en raison des arrondis.
ErrorMissingParameters = Paramètres manquants
NoDataFoundForLine = Aucune donnée trouvée pour cette ligne
+AccountBreakdown = Détail des comptes
+Loading = Chargement...
+ErrorLoadingDetails = Erreur lors du chargement des détails
+Summary = Résumé