Fixed: Bad value for % increase for first year.

This commit is contained in:
Laurent Destailleur 2014-12-21 14:15:36 +01:00
parent 22c27e8703
commit bdb47921e7

View File

@ -209,6 +209,8 @@ $maxyear=substr($maxyearmonth,0,4);
$nowyear=strftime("%Y",dol_now()); $nowyear=strftime("%Y",dol_now());
$nowyearmonth=strftime("%Y-%m",dol_now()); $nowyearmonth=strftime("%Y-%m",dol_now());
$maxyearmonth=max($maxyearmonth,$nowyearmonth); $maxyearmonth=max($maxyearmonth,$nowyearmonth);
$now=dol_now();
$casenow = dol_print_date($now,"%Y-%m");
// Loop on each month // Loop on each month
$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; $nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0;
@ -220,15 +222,15 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print "<td>".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,2000),"%B")."</td>"; print "<td>".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,2000),"%B")."</td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++) for ($annee = $year_start -1 ; $annee <= $year_end ; $annee++) // We start one year before to have data to be able to make delta
{ {
$now=dol_now();
$annee_decalage=$annee; $annee_decalage=$annee;
if ($mois>12) {$annee_decalage=$annee+1;} if ($mois>12) {$annee_decalage=$annee+1;}
$casenow = dol_print_date($now,"%Y-%m");
$case = dol_print_date(dol_mktime(1,1,1,$mois_modulo,1,$annee_decalage),"%Y-%m"); $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"); $caseprev = dol_print_date(dol_mktime(1,1,1,$mois_modulo,1,$annee_decalage-1),"%Y-%m");
if ($annee >= $year_start)
{
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {
// Valeur CA du mois w/o VAT // Valeur CA du mois w/o VAT
print '<td align="right">'; print '<td align="right">';
@ -293,10 +295,11 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
else { print '&nbsp;'; } else { print '&nbsp;'; }
print '</td>'; print '</td>';
} }
if ($annee_decalage != $year_end) print '<td width="15">&nbsp;</td>';
}
$total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0;; $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0;;
$total[$annee]+=$cum[$case]; $total[$annee]+=$cum[$case];
if ($annee_decalage != $year_end) print '<td width="15">&nbsp;</td>';
} }
print '</tr>'; print '</tr>';
@ -406,7 +409,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
} }
if (! $total[$annee-1] && $total[$annee]) if (! $total[$annee-1] && $total[$annee])
{ {
print '<td align="right" class="borderrightlight">+Inf%</td>'; print '<td align="right" class="borderrightlight">+zzzz'.$total[$annee-1].$langs->trans('Inf').'%</td>';
} }
if (! $total[$annee-1] && ! $total[$annee]) if (! $total[$annee-1] && ! $total[$annee])
{ {