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,17 +64,17 @@ if ($action == 'create_declaration' && $period_id > 0) {
} }
// Get data for display // Get data for display
$periods = $period->getAllPeriods();
$declarations = array(); $declarations = array();
// Get declarations for each period // Get all declarations
foreach ($periods as $p) { $sql = "SELECT d.*, p.period_name, p.start_date, p.end_date
$sql = "SELECT * FROM " . MAIN_DB_PREFIX . "declarationtva_declarations FROM " . MAIN_DB_PREFIX . "declarationtva_declarations d
WHERE period_id = " . $p['rowid'] . " AND entity = " . $conf->entity . " LEFT JOIN " . MAIN_DB_PREFIX . "declarationtva_periods p ON d.period_id = p.rowid
ORDER BY created_date DESC"; WHERE d.entity = " . $conf->entity . "
ORDER BY d.created_date DESC";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
while ($obj = $db->fetch_object($result)) { while ($obj = $db->fetch_object($result)) {
$declarations[] = array( $declarations[] = array(
'rowid' => $obj->rowid, 'rowid' => $obj->rowid,
@ -85,10 +85,11 @@ foreach ($periods as $p) {
'net_vat_due' => $obj->net_vat_due, 'net_vat_due' => $obj->net_vat_due,
'vat_credit' => $obj->vat_credit, 'vat_credit' => $obj->vat_credit,
'created_date' => $obj->created_date, 'created_date' => $obj->created_date,
'period_name' => $p['period_name'] 'period_name' => $obj->period_name,
'start_date' => $obj->start_date,
'end_date' => $obj->end_date
); );
} }
}
} }
// Page title // Page title
@ -98,52 +99,25 @@ llxHeader('', $title);
// Print page header // Print page header
print load_fiche_titre($title, '', 'title_accountancy'); 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 declarations section
print '<div class="fiche">'; print '<div class="fiche">';
print '<div class="fichehalfright">';
print '<div class="titre">' . $langs->trans("DeclarationTVADeclarations") . '</div>'; print '<div class="titre">' . $langs->trans("DeclarationTVADeclarations") . '</div>';
if (empty($declarations)) { if (empty($declarations)) {
print '<div class="info">' . $langs->trans("NoDeclarationsFound") . '</div>'; 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 { } 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 '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>' . $langs->trans("DeclarationNumber") . '</th>'; print '<th>' . $langs->trans("DeclarationNumber") . '</th>';
print '<th>' . $langs->trans("Period") . '</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("Status") . '</th>';
print '<th>' . $langs->trans("NetVATDue") . '</th>'; print '<th>' . $langs->trans("NetVATDue") . '</th>';
print '<th>' . $langs->trans("Actions") . '</th>'; print '<th>' . $langs->trans("Actions") . '</th>';
@ -153,6 +127,8 @@ if (empty($declarations)) {
print '<tr>'; print '<tr>';
print '<td>' . $d['declaration_number'] . '</td>'; print '<td>' . $d['declaration_number'] . '</td>';
print '<td>' . $d['period_name'] . '</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>' . $langs->trans("Status" . ucfirst($d['status'])) . '</td>';
print '<td>' . price($d['net_vat_due']) . '</td>'; print '<td>' . price($d['net_vat_due']) . '</td>';
print '<td>'; print '<td>';
@ -170,7 +146,6 @@ if (empty($declarations)) {
print '</table>'; print '</table>';
} }
print '</div>';
print '</div>'; print '</div>';
// Print configuration section // Print configuration section