From 7d7a9597c1acb36790fb051b6d8f764ce08aa652 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Sep 2022 17:23:38 +0200 Subject: [PATCH] Fix regression --- htdocs/compta/stats/index.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index a81c732017f..9d4392c6b17 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -269,8 +269,8 @@ if ($result) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); - $cum_ht[$obj->dm] = !empty($obj->amount) ? $obj->amount : 0; - $cum[$obj->dm] = $obj->amount_ttc; + $cum_ht[$obj->dm] = empty($obj->amount) ? 0 : $obj->amount; + $cum[$obj->dm] = empty($obj->amount_ttc) ? 0 : $obj->amount_ttc; if ($obj->amount_ttc) { $minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm); $maxyearmonth = max($maxyearmonth, $obj->dm); @@ -302,7 +302,11 @@ if ($modecompta == 'RECETTES-DEPENSES') { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); - $cum[$obj->dm] += $obj->amount_ttc; + if (empty($cum[$obj->dm])) { + $cum[$obj->dm] = $obj->amount_ttc; + } else { + $cum[$obj->dm] += $obj->amount_ttc; + } if ($obj->amount_ttc) { $minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm); $maxyearmonth = max($maxyearmonth, $obj->dm); @@ -404,12 +408,6 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { $case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m"); $caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m"); - $total_ht[$annee]=0; - $total[$annee]=0; - $cum_ht[$case]=0; - $cum[$case]=0; - - if ($annee >= $year_start) { // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output. if ($modecompta == 'CREANCES-DETTES') { // Value turnover of month w/o VAT @@ -452,7 +450,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { print ""; // Percentage of month - print ''; + print ''; //var_dump($annee.' '.$year_end.' '.$mois.' '.$month_end); if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { if ($annee_decalage > $minyear && $case <= $casenow) { @@ -482,7 +480,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { } } } - print ''; + print ''; if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) { print ' ';