From 1eb88333569da70e46f160ab68a9e80a2b1f2124 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 23:39:51 +0100 Subject: [PATCH] Fix total when no data --- .../accountancy/bookkeeping/listbyaccount.php | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 0b063adb1ff..4847dfd2e9a 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -749,40 +749,42 @@ while ($i < min($num, $limit)) $i++; } -// Show sub-total of last shown account -if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; -} else { - $colnumber = 4; - $colnumberend = 7; +if ($num > 0) { + // Show sub-total of last shown account + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { + $colnumber = 3; + $colnumberend = 7; + } else { + $colnumber = 4; + $colnumberend = 7; + } + $colspan = $totalarray['nbfield'] - $colnumber; + $colspanend = $totalarray['nbfield'] - $colnumberend; + print ''; + print ''.$langs->trans("TotalForAccount").' '.$accountg.':'; + print ''.price($sous_total_debit).''; + print ''.price($sous_total_credit).''; + print ''; + print ''; + // Show balance of last shown account + $balance = $sous_total_debit - $sous_total_credit; + print ''; + print ''.$langs->trans("Balance").':'; + if ($balance > 0) + { + print ''; + print price($sous_total_debit - $sous_total_credit); + print ''; + print ''; + } else { + print ''; + print ''; + print price($sous_total_credit - $sous_total_debit); + print ''; + } + print ''; + print ''; } -$colspan = $totalarray['nbfield'] - $colnumber; -$colspanend = $totalarray['nbfield'] - $colnumberend; -print ''; -print ''.$langs->trans("TotalForAccount").' '.$accountg.':'; -print ''.price($sous_total_debit).''; -print ''.price($sous_total_credit).''; -print ''; -print ''; -// Show balance of last shown account -$balance = $sous_total_debit - $sous_total_credit; -print ''; -print ''.$langs->trans("Balance").':'; -if ($balance > 0) -{ - print ''; - print price($sous_total_debit - $sous_total_credit); - print ''; - print ''; -} else { - print ''; - print ''; - print price($sous_total_credit - $sous_total_debit); - print ''; -} -print ''; -print ''; // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';