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 '