Merge pull request #11569 from aspangaro/11.0_fiscalyear

NEW Box use fiscal year
This commit is contained in:
Laurent Destailleur 2019-08-10 01:47:55 +02:00 committed by GitHub
commit deb6186338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 125 additions and 30 deletions

View File

@ -74,6 +74,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
//$facturestatic=new Facture($db); //$facturestatic=new Facture($db);
$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); $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, '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),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) 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"; $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png';
@ -146,7 +149,14 @@ class box_graph_invoices_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -167,7 +177,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) 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"; $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png';
@ -184,7 +194,14 @@ class box_graph_invoices_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -73,6 +73,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; 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;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, '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),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) 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"; $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$year.'.png';
@ -143,7 +146,14 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -164,7 +174,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) 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"; $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png';
@ -181,7 +191,14 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -74,6 +74,9 @@ class box_graph_orders_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
//$commandestatic=new Commande($db); //$commandestatic=new Commande($db);
$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); $text = $langs->trans("BoxCustomersOrdersPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, '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),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) 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"; $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
@ -144,7 +147,14 @@ class box_graph_orders_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -165,7 +175,7 @@ class box_graph_orders_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) 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"; $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
@ -180,7 +190,14 @@ class box_graph_orders_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -73,6 +73,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; 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;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, '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),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) 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"; $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
@ -143,7 +146,14 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -164,7 +174,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) 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"; $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
@ -179,7 +189,14 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -74,6 +74,9 @@ class box_graph_propales_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
//$propalstatic=new Propal($db); //$propalstatic=new Propal($db);
$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"); $langs->load("propal");
$text = $langs->trans("BoxProposalsPerMonth", $max); $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),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb) 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'); $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars');
$filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png";
@ -144,7 +147,14 @@ class box_graph_propales_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
@ -165,7 +175,7 @@ class box_graph_propales_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot) 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_pad(array(), ($endyear-$startyear+1), 'bars');
//$datatype2 = array('lines','bars'); //$datatype2 = array('lines','bars');
@ -183,7 +193,14 @@ class box_graph_propales_permonth extends ModeleBoxes
$i=$startyear;$legend=array(); $i=$startyear;$legend=array();
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
}
else
{
$legend[]=$i;
}
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);

View File

@ -39,10 +39,12 @@ abstract class Stats
* @param int $endyear Start year * @param int $endyear Start year
* @param int $startyear End 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 $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 $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 $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) public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -86,6 +88,8 @@ abstract class Stats
else else
{ {
$year=$startyear; $year=$startyear;
$sm = $startmonth - 1;
if ($sm != 0) $year = $year - 1;
while ($year <= $endyear) while ($year <= $endyear)
{ {
$datay[$year] = $this->getNbByMonth($year, $format); $datay[$year] = $this->getNbByMonth($year, $format);
@ -96,11 +100,11 @@ abstract class Stats
for ($i = 0 ; $i < 12 ; $i++) for ($i = 0 ; $i < 12 ; $i++)
{ {
$data[$i][]=$datay[$endyear][$i][0]; $data[$i][]=$datay[$endyear][($i+$sm)%12][0];
$year=$startyear; $year=$startyear;
while($year <= $endyear) while($year <= $endyear)
{ {
$data[$i][]=$datay[$year][$i][1]; $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1];
$year++; $year++;
} }
} }
@ -134,9 +138,10 @@ abstract class Stats
* @param int $startyear End 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 $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 $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 1 = january
* @return array Array of values * @return array Array of values
*/ */
public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -181,6 +186,8 @@ abstract class Stats
else else
{ {
$year=$startyear; $year=$startyear;
$sm = $startmonth - 1;
if ($sm != 0) $year = $year - 1;
while($year <= $endyear) while($year <= $endyear)
{ {
$datay[$year] = $this->getAmountByMonth($year, $format); $datay[$year] = $this->getAmountByMonth($year, $format);
@ -191,11 +198,11 @@ abstract class Stats
// $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
for ($i = 0 ; $i < 12 ; $i++) for ($i = 0 ; $i < 12 ; $i++)
{ {
$data[$i][]=$datay[$endyear][$i][0]; // set label $data[$i][]=$datay[$endyear][($i+$sm)%12][0]; // set label
$year=$startyear; $year=$startyear;
while($year <= $endyear) while($year <= $endyear)
{ {
$data[$i][]=$datay[$year][$i][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++; $year++;
} }
} }
@ -411,7 +418,8 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // 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 int $year Year
* @param string $sql SQL * @param string $sql SQL
@ -470,7 +478,8 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // 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 int $year Year
* @param string $sql SQL * @param string $sql SQL
@ -527,6 +536,7 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Renvoie le montant moyen par mois pour une annee donnee * 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 int $year Year
* @param string $sql SQL * @param string $sql SQL