From 053ae8224b45b0940d0539e35a4b9be5bfacfab3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Jul 2019 06:36:39 +0200 Subject: [PATCH 1/6] NEW Box use fiscal year (Thanks Yves57) --- .../boxes/box_graph_invoices_permonth.php | 23 +++++++++++++--- .../box_graph_invoices_supplier_permonth.php | 23 +++++++++++++--- .../core/boxes/box_graph_orders_permonth.php | 23 +++++++++++++--- .../box_graph_orders_supplier_permonth.php | 23 +++++++++++++--- .../boxes/box_graph_propales_permonth.php | 23 +++++++++++++--- htdocs/core/class/stats.class.php | 27 +++++++++++++------ 6 files changed, 114 insertions(+), 28 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 5c747065138..ad2505374b8 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -74,6 +74,9 @@ class box_graph_invoices_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($db); + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); $this->info_box_head = array( 'text' => $text, @@ -129,7 +132,7 @@ class box_graph_invoices_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png'; @@ -146,7 +149,13 @@ class box_graph_invoices_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px1->SetLegend($legend); @@ -167,7 +176,7 @@ class box_graph_invoices_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; @@ -184,7 +193,13 @@ class box_graph_invoices_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px2->SetLegend($legend); diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index d06098daa3b..83779501df7 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -73,6 +73,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); $this->info_box_head = array( 'text' => $text, @@ -126,7 +129,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; @@ -143,7 +146,13 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px1->SetLegend($legend); @@ -164,7 +173,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; @@ -181,7 +190,13 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px2->SetLegend($legend); diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 8c4cb250376..8aa465782b6 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -74,6 +74,9 @@ class box_graph_orders_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //$commandestatic=new Commande($db); + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $text = $langs->trans("BoxCustomersOrdersPerMonth", $max); $this->info_box_head = array( 'text' => $text, @@ -129,7 +132,7 @@ class box_graph_orders_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; @@ -144,7 +147,13 @@ class box_graph_orders_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px1->SetLegend($legend); @@ -165,7 +174,7 @@ class box_graph_orders_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; @@ -180,7 +189,13 @@ class box_graph_orders_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px2->SetLegend($legend); diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index a584c7288ca..a5d5c9e6c0f 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -73,6 +73,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); $this->info_box_head = array( 'text' => $text, @@ -128,7 +131,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; @@ -143,7 +146,13 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px1->SetLegend($legend); @@ -164,7 +173,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; @@ -179,7 +188,13 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px2->SetLegend($legend); diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 861c5086704..763cdb855f9 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -74,6 +74,9 @@ class box_graph_propales_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //$propalstatic=new Propal($db); + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $langs->load("propal"); $text = $langs->trans("BoxProposalsPerMonth", $max); @@ -128,7 +131,7 @@ class box_graph_propales_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars'); $filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png"; @@ -144,7 +147,13 @@ class box_graph_propales_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px1->SetLegend($legend); @@ -165,7 +174,7 @@ class box_graph_propales_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0)); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); $datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars'); //$datatype2 = array('lines','bars'); @@ -183,7 +192,13 @@ class box_graph_propales_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - $legend[]=$i; + if ($startmonth != 0) { + $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + } + else + { + $legend[]=$i; + } $i++; } $px2->SetLegend($legend); diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 08025161a0d..b41c1d8dfa6 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -39,10 +39,12 @@ abstract class Stats * @param int $endyear Start year * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array of values + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @param int $startmonth month of the fiscal year start minus 1; 0=january + * @return array Array of values + */ - public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) + public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth=0) { global $conf,$user,$langs; @@ -86,6 +88,10 @@ abstract class Stats else { $year=$startyear; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) { + $startmonth = 0; + } + if ($startmonth != 0) $year = $year - 1; while ($year <= $endyear) { $datay[$year] = $this->getNbByMonth($year, $format); @@ -96,11 +102,11 @@ abstract class Stats for ($i = 0 ; $i < 12 ; $i++) { - $data[$i][]=$datay[$endyear][$i][0]; + $data[$i][]=$datay[$endyear][($i+$startmonth)%12][0]; $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year][$i][1]; + $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; $year++; } } @@ -134,9 +140,10 @@ abstract class Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @param int $startmonth month of the fiscal year start minus 1; 0=january * @return array Array of values */ - public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) + public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth=0) { global $conf,$user,$langs; @@ -181,6 +188,10 @@ abstract class Stats else { $year=$startyear; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) { + $startmonth = 0; + } + if ($startmonth != 0) $year = $year - 1; while($year <= $endyear) { $datay[$year] = $this->getAmountByMonth($year, $format); @@ -191,11 +202,11 @@ abstract class Stats // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) for ($i = 0 ; $i < 12 ; $i++) { - $data[$i][]=$datay[$endyear][$i][0]; // set label + $data[$i][]=$datay[$endyear][($i+$startmonth)%12][0]; // set label $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year][$i][1]; // set yval for x=i + $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; // set yval for x=i $year++; } } From 83e2f71e079641e2ad85ab9db454418490f7f12d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Jul 2019 07:56:33 +0200 Subject: [PATCH 2/6] Fix travis --- htdocs/core/boxes/box_graph_invoices_permonth.php | 6 ++++-- .../core/boxes/box_graph_invoices_supplier_permonth.php | 6 ++++-- htdocs/core/boxes/box_graph_orders_permonth.php | 6 ++++-- htdocs/core/boxes/box_graph_orders_supplier_permonth.php | 6 ++++-- htdocs/core/boxes/box_graph_propales_permonth.php | 6 ++++-- htdocs/core/class/stats.class.php | 8 ++++---- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index ad2505374b8..dc02d7421df 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -149,7 +149,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else @@ -193,7 +194,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 83779501df7..12836031714 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -146,7 +146,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else @@ -190,7 +191,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 8aa465782b6..b338d562132 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -147,7 +147,8 @@ class box_graph_orders_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else @@ -189,7 +190,8 @@ class box_graph_orders_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index a5d5c9e6c0f..e9ec246fef0 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -146,7 +146,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else @@ -188,7 +189,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 763cdb855f9..effe625b930 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -147,7 +147,8 @@ class box_graph_propales_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else @@ -192,7 +193,8 @@ class box_graph_propales_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) { + if ($startmonth != 0) + { $legend[]=sprintf("%d/%d",$i-2001, $i-2000); } else diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index b41c1d8dfa6..2544441e16b 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -40,11 +40,11 @@ abstract class Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @param int $startmonth month of the fiscal year start minus 1; 0=january + * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 0 = january * @return array Array of values */ - public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth=0) + public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 0) { global $conf,$user,$langs; @@ -140,10 +140,10 @@ abstract class Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @param int $startmonth month of the fiscal year start minus 1; 0=january + * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 0 = january * @return array Array of values */ - public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth=0) + public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 0) { global $conf,$user,$langs; From 3e69421ec3abdc9f650873c25cfb3a3088df12b7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 28 Jul 2019 07:33:57 +0200 Subject: [PATCH 3/6] Fix travis --- htdocs/core/boxes/box_graph_invoices_permonth.php | 4 ++-- htdocs/core/boxes/box_graph_invoices_supplier_permonth.php | 4 ++-- htdocs/core/boxes/box_graph_orders_permonth.php | 4 ++-- htdocs/core/boxes/box_graph_orders_supplier_permonth.php | 4 ++-- htdocs/core/boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/class/stats.class.php | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index dc02d7421df..d33600c0fc8 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -151,7 +151,7 @@ class box_graph_invoices_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { @@ -196,7 +196,7 @@ class box_graph_invoices_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 12836031714..d01d5b6252f 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -148,7 +148,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { @@ -193,7 +193,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index b338d562132..f9be1c79cea 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -149,7 +149,7 @@ class box_graph_orders_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { @@ -192,7 +192,7 @@ class box_graph_orders_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index e9ec246fef0..1f907fc01be 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -148,7 +148,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { @@ -191,7 +191,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index effe625b930..7179f255add 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -149,7 +149,7 @@ class box_graph_propales_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 2544441e16b..f873b0f5deb 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -106,7 +106,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; + $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0 )][($i+$startmonth)%12][1]; $year++; } } @@ -206,7 +206,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; // set yval for x=i + $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0 )][($i+$startmonth)%12][1]; // set yval for x=i $year++; } } From 8228979e6777fc71e3aaaedf884637713b401632 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 30 Jul 2019 09:18:18 +0200 Subject: [PATCH 4/6] Fix travis --- htdocs/core/class/stats.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index f873b0f5deb..a15800f8ce6 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -106,7 +106,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0 )][($i+$startmonth)%12][1]; + $data[$i][]=$datay[$year - (1 - (int) (($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; $year++; } } @@ -206,7 +206,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - (int)(($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0 )][($i+$startmonth)%12][1]; // set yval for x=i + $data[$i][]=$datay[$year - (1 - (int) (($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; // set yval for x=i $year++; } } From b146004966870bca95acbd269b0563932a5e8356 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 30 Jul 2019 11:06:40 +0200 Subject: [PATCH 5/6] Fix travis --- htdocs/core/boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/class/stats.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 7179f255add..78cbadc6fb2 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -195,7 +195,7 @@ class box_graph_propales_permonth extends ModeleBoxes { if ($startmonth != 0) { - $legend[]=sprintf("%d/%d",$i-2001, $i-2000); + $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } else { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index a15800f8ce6..85a6f43ed4d 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -106,7 +106,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - (int) (($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; + $data[$i][]=$datay[$year - (1 - ((int) ($i+$startmonth)/12) + ($startmonth == 0 ? 1 : 0))][($i+$startmonth)%12][1]; $year++; } } @@ -206,7 +206,7 @@ abstract class Stats $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - (int) (($i+$startmonth)/12)) + ($startmonth == 0 ? 1 : 0)][($i+$startmonth)%12][1]; // set yval for x=i + $data[$i][]=$datay[$year - (1 - ((int) ($i+$startmonth)/12) + ($startmonth == 0 ? 1 : 0))][($i+$startmonth)%12][1]; // set yval for x=i $year++; } } From 7eb48a3f9ce8ff8ff452dfcef059c1bb16c7f22e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 3 Aug 2019 06:04:42 +0200 Subject: [PATCH 6/6] Fix month of the fiscal year start min 1 max 12 / january = 1 --- .../boxes/box_graph_invoices_permonth.php | 8 ++--- .../box_graph_invoices_supplier_permonth.php | 8 ++--- .../core/boxes/box_graph_orders_permonth.php | 8 ++--- .../box_graph_orders_supplier_permonth.php | 8 ++--- .../boxes/box_graph_propales_permonth.php | 8 ++--- htdocs/core/class/stats.class.php | 35 +++++++++---------- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index d33600c0fc8..6e5afe5df99 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -74,8 +74,8 @@ class box_graph_invoices_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); $this->info_box_head = array( @@ -149,7 +149,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } @@ -194,7 +194,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index d01d5b6252f..df4f4afc146 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -73,8 +73,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); $this->info_box_head = array( @@ -146,7 +146,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } @@ -191,7 +191,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index f9be1c79cea..b530b4ea268 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -74,8 +74,8 @@ class box_graph_orders_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //$commandestatic=new Commande($db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxCustomersOrdersPerMonth", $max); $this->info_box_head = array( @@ -147,7 +147,7 @@ class box_graph_orders_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } @@ -190,7 +190,7 @@ class box_graph_orders_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 1f907fc01be..8359ddbe070 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -73,8 +73,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); $this->info_box_head = array( @@ -146,7 +146,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } @@ -189,7 +189,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 78cbadc6fb2..75673ee3fce 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -74,8 +74,8 @@ class box_graph_propales_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //$propalstatic=new Propal($db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 0; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $langs->load("propal"); @@ -147,7 +147,7 @@ class box_graph_propales_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } @@ -193,7 +193,7 @@ class box_graph_propales_permonth extends ModeleBoxes $i=$startyear;$legend=array(); while ($i <= $endyear) { - if ($startmonth != 0) + if ($startmonth != 1) { $legend[]=sprintf("%d/%d", $i-2001, $i-2000); } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 85a6f43ed4d..8df81bd4495 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -40,11 +40,11 @@ abstract class Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 0 = january + * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january * @return array Array of values */ - public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 0) + public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1) { global $conf,$user,$langs; @@ -88,10 +88,8 @@ abstract class Stats else { $year=$startyear; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) { - $startmonth = 0; - } - if ($startmonth != 0) $year = $year - 1; + $sm = $startmonth - 1; + if ($sm != 0) $year = $year - 1; while ($year <= $endyear) { $datay[$year] = $this->getNbByMonth($year, $format); @@ -102,11 +100,11 @@ abstract class Stats for ($i = 0 ; $i < 12 ; $i++) { - $data[$i][]=$datay[$endyear][($i+$startmonth)%12][0]; + $data[$i][]=$datay[$endyear][($i+$sm)%12][0]; $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - ((int) ($i+$startmonth)/12) + ($startmonth == 0 ? 1 : 0))][($i+$startmonth)%12][1]; + $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1]; $year++; } } @@ -140,10 +138,10 @@ abstract class Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 0 = january + * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january * @return array Array of values */ - public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 0) + public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1) { global $conf,$user,$langs; @@ -188,10 +186,8 @@ abstract class Stats else { $year=$startyear; - if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) { - $startmonth = 0; - } - if ($startmonth != 0) $year = $year - 1; + $sm = $startmonth - 1; + if ($sm != 0) $year = $year - 1; while($year <= $endyear) { $datay[$year] = $this->getAmountByMonth($year, $format); @@ -202,11 +198,11 @@ abstract class Stats // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) for ($i = 0 ; $i < 12 ; $i++) { - $data[$i][]=$datay[$endyear][($i+$startmonth)%12][0]; // set label + $data[$i][]=$datay[$endyear][($i+$sm)%12][0]; // set label $year=$startyear; while($year <= $endyear) { - $data[$i][]=$datay[$year - (1 - ((int) ($i+$startmonth)/12) + ($startmonth == 0 ? 1 : 0))][($i+$startmonth)%12][1]; // set yval for x=i + $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1]; // set yval for x=i $year++; } } @@ -422,7 +418,8 @@ abstract class Stats // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Renvoie le nombre de proposition par mois pour une annee donnee + * Renvoie le nombre de documents par mois pour une annee donnee + * Return number of documents per month for a given year * * @param int $year Year * @param string $sql SQL @@ -481,7 +478,8 @@ abstract class Stats // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Renvoie le nombre d'element par mois pour une annee donnee + * Renvoie le montant totalise par mois pour une annee donnee + * Return the amount per month for a given year * * @param int $year Year * @param string $sql SQL @@ -538,6 +536,7 @@ abstract class Stats // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Renvoie le montant moyen par mois pour une annee donnee + * Return the amount average par month for a given year * * @param int $year Year * @param string $sql SQL