diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 1899d96c57d..a9906304ccf 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -64,13 +64,13 @@ class box_graph_invoices_permonth extends ModeleBoxes global $conf, $user, $langs, $db; $this->max=$max; - + $refreshaction='refresh_'.$this->boxcode; - + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facturestatic=new Facture($db); - $text = $langs->trans("BoxInvoicesPerMonth",$max); + $text = $langs->trans("BoxCustomersInvoicesPerMonth",$max); $this->info_box_head = array( 'text' => $text, 'limit'=> dol_strlen($text), @@ -85,7 +85,7 @@ class box_graph_invoices_permonth extends ModeleBoxes { require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facturestats.class.php'; - + $nowarray=dol_getdate(dol_now(),true); $endyear=$nowarray['year']; $startyear=$endyear-1; @@ -93,23 +93,22 @@ class box_graph_invoices_permonth extends ModeleBoxes $userid=0; $WIDTH='256'; $HEIGHT='192'; - + $stats = new FactureStats($this->db, 0, $mode, ($userid>0?$userid:0)); - - // Build graphic number of object - // $data = array(array('Lib',val1,val2,val3),...) - $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action')==$refreshaction?-1:(3600*24))); - //var_dump($data); - + + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) + $data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action')==$refreshaction?-1:(3600*24))); + $filenamenb = $dir."/invoicesnbinyear-".$year.".png"; if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesnbinyear-'.$year.'.png'; - + $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (! $mesg) { - $px1->SetData($data); + $px1->SetData($data1); + unset($data1); $px1->SetPrecisionY(0); $i=$startyear;$legend=array(); while ($i <= $endyear) @@ -124,17 +123,61 @@ class box_graph_invoices_permonth extends ModeleBoxes $px1->SetYLabel($langs->trans("NumberOfBills")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->SetPrecisionY(0); + $px1->SetPrecisionY(0); + $px1->SetCssPrefix("cssboxes"); $px1->mode='depth'; - //$px1->SetTitle($langs->trans("NumberOfBillsByMonth")); - + $px1->SetTitle($langs->trans("NumberOfBillsByMonth")); + $px1->draw($filenamenb,$fileurlnb); } - + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) + $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action')==$refreshaction?-1:(3600*24))); + + $filenamenb = $dir."/invoicesnbinyear-".$year.".png"; + if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; + if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesamountinyear-'.$year.'.png'; + + $px2 = new DolGraph(); + $mesg = $px2->isGraphKo(); + if (! $mesg) + { + $px2->SetData($data2); + unset($data2); + $px2->SetPrecisionY(0); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfBillsHT")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->SetPrecisionY(0); + $px2->SetCssPrefix("cssboxes"); + $px2->mode='depth'; + $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT")); + + $px2->draw($filenamenb,$fileurlnb); + } + + if (! $mesg) { - $this->info_box_contents[0][0] = array('td' => 'align="center"','textnoformat'=>$px1->show()); + $stringtoshow ='