Simplify main interface by removing redundant periods section

Main Interface Improvements:
- Removed separate periods section as it was redundant
- Each declaration already represents a specific period
- Updated declarations table to include period dates directly
- Added 'Create Declaration' button for better user experience
- Simplified interface focuses on declarations with period context
- Improved data query to join declarations with periods

The interface is now cleaner and more focused on the actual declarations
rather than having separate period management.
This commit is contained in:
Frank Cools 2025-10-02 18:04:57 +02:00
parent 0d17cfff53
commit 1263eb82bb

View File

@ -64,30 +64,31 @@ if ($action == 'create_declaration' && $period_id > 0) {
}
// Get data for display
$periods = $period->getAllPeriods();
$declarations = array();
// Get declarations for each period
foreach ($periods as $p) {
$sql = "SELECT * FROM " . MAIN_DB_PREFIX . "declarationtva_declarations
WHERE period_id = " . $p['rowid'] . " AND entity = " . $conf->entity . "
ORDER BY created_date DESC";
$result = $db->query($sql);
if ($result) {
while ($obj = $db->fetch_object($result)) {
$declarations[] = array(
'rowid' => $obj->rowid,
'declaration_number' => $obj->declaration_number,
'status' => $obj->status,
'total_vat_collected' => $obj->total_vat_collected,
'total_vat_deductible' => $obj->total_vat_deductible,
'net_vat_due' => $obj->net_vat_due,
'vat_credit' => $obj->vat_credit,
'created_date' => $obj->created_date,
'period_name' => $p['period_name']
);
}
// Get all declarations
$sql = "SELECT d.*, p.period_name, p.start_date, p.end_date
FROM " . MAIN_DB_PREFIX . "declarationtva_declarations d
LEFT JOIN " . MAIN_DB_PREFIX . "declarationtva_periods p ON d.period_id = p.rowid
WHERE d.entity = " . $conf->entity . "
ORDER BY d.created_date DESC";
$result = $db->query($sql);
if ($result) {
while ($obj = $db->fetch_object($result)) {
$declarations[] = array(
'rowid' => $obj->rowid,
'declaration_number' => $obj->declaration_number,
'status' => $obj->status,
'total_vat_collected' => $obj->total_vat_collected,
'total_vat_deductible' => $obj->total_vat_deductible,
'net_vat_due' => $obj->net_vat_due,
'vat_credit' => $obj->vat_credit,
'created_date' => $obj->created_date,
'period_name' => $obj->period_name,
'start_date' => $obj->start_date,
'end_date' => $obj->end_date
);
}
}
@ -98,52 +99,25 @@ llxHeader('', $title);
// Print page header
print load_fiche_titre($title, '', 'title_accountancy');
// Print periods section
print '<div class="fiche">';
print '<div class="fichehalfleft">';
print '<div class="titre">' . $langs->trans("DeclarationTVAPeriods") . '</div>';
if (empty($periods)) {
print '<div class="info">' . $langs->trans("NoPeriodsFound") . '</div>';
} else {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th>' . $langs->trans("PeriodName") . '</th>';
print '<th>' . $langs->trans("StartDate") . '</th>';
print '<th>' . $langs->trans("EndDate") . '</th>';
print '<th>' . $langs->trans("Status") . '</th>';
print '<th>' . $langs->trans("Actions") . '</th>';
print '</tr>';
foreach ($periods as $p) {
print '<tr>';
print '<td>' . $p['period_name'] . '</td>';
print '<td>' . dol_print_date($p['start_date'], 'day') . '</td>';
print '<td>' . dol_print_date($p['end_date'], 'day') . '</td>';
print '<td>' . $langs->trans("Status" . ucfirst($p['status'])) . '</td>';
print '<td>';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=create_declaration&period_id=' . $p['rowid'] . '" class="butAction">' . $langs->trans("CreateDeclaration") . '</a>';
print '</td>';
print '</tr>';
}
print '</table>';
}
print '</div>';
print '</div>';
// Print declarations section
print '<div class="fiche">';
print '<div class="fichehalfright">';
print '<div class="titre">' . $langs->trans("DeclarationTVADeclarations") . '</div>';
if (empty($declarations)) {
print '<div class="info">' . $langs->trans("NoDeclarationsFound") . '</div>';
print '<div class="info">';
print '<a href="declarationtva_create.php" class="butAction">' . $langs->trans("CreateDeclaration") . '</a>';
print '</div>';
} else {
print '<div class="info">';
print '<a href="declarationtva_create.php" class="butAction">' . $langs->trans("CreateDeclaration") . '</a>';
print '</div>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th>' . $langs->trans("DeclarationNumber") . '</th>';
print '<th>' . $langs->trans("Period") . '</th>';
print '<th>' . $langs->trans("StartDate") . '</th>';
print '<th>' . $langs->trans("EndDate") . '</th>';
print '<th>' . $langs->trans("Status") . '</th>';
print '<th>' . $langs->trans("NetVATDue") . '</th>';
print '<th>' . $langs->trans("Actions") . '</th>';
@ -153,6 +127,8 @@ if (empty($declarations)) {
print '<tr>';
print '<td>' . $d['declaration_number'] . '</td>';
print '<td>' . $d['period_name'] . '</td>';
print '<td>' . dol_print_date($d['start_date'], 'day') . '</td>';
print '<td>' . dol_print_date($d['end_date'], 'day') . '</td>';
print '<td>' . $langs->trans("Status" . ucfirst($d['status'])) . '</td>';
print '<td>' . price($d['net_vat_due']) . '</td>';
print '<td>';
@ -170,7 +146,6 @@ if (empty($declarations)) {
print '</table>';
}
print '</div>';
print '</div>';
// Print configuration section