diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 9442d0e9275..50017e85da0 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -487,22 +487,29 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { //var_dump($annee.' '.$year_end.' '.$mois.' '.$month_end); if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { if ($annee_decalage > $minyear && $case <= $casenow) { - if (!empty($cumulative_ht[$caseprev]) && !empty($cumulative_ht[$case])) { - $percent = (round(($cumulative_ht[$case] - $cumulative_ht[$caseprev]) / $cumulative_ht[$caseprev], 4) * 100); - //print "X $cumulative_ht[$case] - $cumulative_ht[$caseprev] - $cumulative_ht[$caseprev] - $percent X"; + if ($modecompta=='CREANCES-DETTES') { + $cumulative_previous_year = (!empty($cumulative_ht[$caseprev])?$cumulative_ht[$caseprev]:0); + $cumulative_year = (!empty($cumulative_ht[$case])?$cumulative_ht[$case]:0); + } else { + $cumulative_previous_year = (!empty($cumulative[$caseprev])?$cumulative[$caseprev]:0); + $cumulative_year = (!empty($cumulative[$case])?$cumulative[$case]:0); + } + if (!empty($cumulative_previous_year) && !empty($cumulative_year)) { + $percent = (round(($cumulative_year - $cumulative_previous_year) / $cumulative_previous_year, 4) * 100); + //print "X $cumulative_year - $cumulative_previous_year - $cumulative_previous_year - $percent X"; print($percent >= 0 ? "+$percent" : "$percent").'%'; } - if (!empty($cumulative_ht[$caseprev]) && empty($cumulative_ht[$case])) { + if (!empty($cumulative_previous_year) && empty($cumulative_year)) { print '-100%'; } - if (empty($cumulative_ht[$caseprev]) && !empty($cumulative_ht[$case])) { + if (empty($cumulative_previous_year) && !empty($cumulative_year)) { //print '+Inf%'; print '-'; } - if (isset($cumulative_ht[$caseprev]) && empty($cumulative_ht[$caseprev]) && empty($cumulative_ht[$case])) { + if (isset($cumulative_previous_year) && empty($cumulative_previous_year) && empty($cumulative_year)) { print '+0%'; } - if (!isset($cumulative_ht[$caseprev]) && empty($cumulative_ht[$case])) { + if (!isset($cumulative_previous_year) && empty($cumulative_year)) { print '-'; } } else { @@ -607,7 +614,7 @@ print ''.$langs->trans("Total").''; for ($annee = $year_start; $annee <= $year_end; $annee++) { if ($modecompta == 'CREANCES-DETTES') { // Montant total HT - if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { + if (isset($total_ht[$annee]) || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''; print(empty($total_ht[$annee]) ? '0' : price($total_ht[$annee])); print ""; @@ -627,19 +634,26 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Pourcentage total if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) { - if (!empty($total_ht[$annee - 1]) && !empty($total_ht[$annee])) { - $percent = (round(($total_ht[$annee] - $total_ht[$annee - 1]) / $total_ht[$annee - 1], 4) * 100); + if ($modecompta == 'CREANCES-DETTES') { + $total_previous_year = (!empty($total_ht[$annee - 1])?$total_ht[$annee - 1]:0); + $total_year = (!empty($total_ht[$annee])?$total_ht[$annee]:0); + } else { + $total_previous_year = (!empty($total[$annee - 1])?$total[$annee - 1]:0); + $total_year = (!empty($total[$annee])?$total[$annee]:0); + } + if (!empty($total_previous_year) && !empty($total_year)) { + $percent = (round(($total_year - $total_previous_year) / $total_previous_year, 4) * 100); print ''; print($percent >= 0 ? "+$percent" : "$percent").'%'; print ''; } - if (!empty($total_ht[$annee - 1]) && empty($total_ht[$annee])) { + if (!empty($total_previous_year) && empty($total_year)) { print '-100%'; } - if (empty($total_ht[$annee - 1]) && !empty($total_ht[$annee])) { + if (empty($total_previous_year) && !empty($total_year)) { print '+'.$langs->trans('Inf').'%'; } - if (empty($total_ht[$annee - 1]) && empty($total_ht[$annee])) { + if (empty($total_previous_year) && empty($total_year)) { print '+0%'; } } else { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 5a80dc98f81..67d75d456b1 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -511,7 +511,7 @@ if (empty($reshook)) { } $tva_tx = $lines[$i]->tva_tx; - if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) { $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 609270a284a..ed924373e5e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1339,7 +1339,7 @@ if (empty($reshook)) { } $tva_tx = $lines[$i]->tva_tx; - if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) { $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; }