NEW Box use fiscal year (Thanks Yves57)
This commit is contained in:
parent
9f7d118f6f
commit
053ae8224b
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user