Better way to present open invoice graph

This commit is contained in:
Laurent Destailleur 2021-10-04 05:27:07 +02:00
parent b6ec7ae77a
commit 7b02560c4f
3 changed files with 18 additions and 8 deletions

View File

@ -741,7 +741,7 @@ class DolGraph
/**
* Build a graph using JFlot library. Input when calling this method should be:
* $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB));
* $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x
* $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // when there is n series to show for each x
* $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated
* $this->legend= array("Val1",...,"Valn"); // list of n series name
* $this->type = array('bars',...'lines','linesnopoint'); or array('pie') or array('polar')
@ -1028,7 +1028,7 @@ class DolGraph
/**
* Build a graph using Chart library. Input when calling this method should be:
* $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB));
* $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x
* $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // when there is n series to show for each x
* $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated
* $this->legend= array("Val1",...,"Valn"); // list of n series name
* $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar') or array('piesemicircle');
@ -1303,6 +1303,8 @@ class DolGraph
$this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
if (empty($showlegend)) {
$this->stringtoshow .= 'legend: { display: false }, ';
} else {
$this->stringtoshow .= 'legend: { position: \'' . ($showlegend == 2 ? 'right' : 'top') . '\' },';
}
$this->stringtoshow .= 'scales: { xAxes: [{ ';
if ($this->hideXValues) {

View File

@ -480,7 +480,8 @@ function getNumberInvoicesPieChart($mode)
date_add($datenowadd30, $interval30days);
date_add($datenowadd15, $interval15days);
$sql = "SELECT sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", 1, 0).") as nblate30";
$sql = "SELECT";
$sql .= " sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", 1, 0).") as nblate30";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub15, 'Y-m-d')."'", 1, 0).") as nblate15";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($now, 'Y-m-d')."'", 1, 0).") as nblatenow";
$sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($now, 'Y-m-d')."'", 1, 0).") as nbnotlatenow";
@ -508,17 +509,19 @@ function getNumberInvoicesPieChart($mode)
while ($i < $num) {
$obj = $db->fetch_object($resql);
$dataseries = array(array($langs->trans('InvoiceLate30Days'), $obj->nblate30)
/*$dataseries = array(array($langs->trans('InvoiceLate30Days'), $obj->nblate30)
,array($langs->trans('InvoiceLate15Days'), $obj->nblate15 - $obj->nblate30)
,array($langs->trans('InvoiceLateMinus15Days'), $obj->nblatenow - $obj->nblate15)
,array($langs->trans('InvoiceNotLate'), $obj->nbnotlatenow - $obj->nbnotlate15)
,array($langs->trans('InvoiceNotLate15Days'), $obj->nbnotlate15 - $obj->nbnotlate30)
,array($langs->trans('InvoiceNotLate30Days'), $obj->nbnotlate30));
,array($langs->trans('InvoiceNotLate30Days'), $obj->nbnotlate30));*/
$dataseries[0]=array($langs->trans('NbOfOpenInvoices'), $obj->nblate30, $obj->nblate15 - $obj->nblate30, $obj->nblatenow - $obj->nblate15, $obj->nbnotlatenow - $obj->nbnotlate15, $obj->nbnotlate15 - $obj->nbnotlate30, $obj->nbnotlate30);
$i++;
}
foreach ($dataseries as $key=>$value) {
$total += $value[1];
}
$legend = array($langs->trans('InvoiceLate30Days'), $langs->trans('InvoiceLate15Days'), $langs->trans('InvoiceLateMinus15Days'), $langs->trans('InvoiceNotLate'), $langs->trans('InvoiceNotLate15Days'), $langs->trans('InvoiceNotLate30Days'));
$colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11, '-'.$badgeStatus11);
@ -537,14 +540,18 @@ function getNumberInvoicesPieChart($mode)
$result .= '</tr>';
if ($conf->use_javascript_ajax) {
//var_dump($dataseries);
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setLegend($legend);
$dolgraph->SetDataColor(array_values($colorseries));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(['pie']);
$dolgraph->setHeight('150');
$dolgraph->setWidth('300');
$dolgraph->SetType(array('bars', 'bars', 'bars', 'bars', 'bars', 'bars'));
$dolgraph->setHeight('180');
$dolgraph->setWidth('500');
if ($mode == 'customers') {
$dolgraph->draw('idgraphcustomerinvoices');
} elseif ($mode == 'fourn' || $mode == 'suppliers') {

View File

@ -265,6 +265,7 @@ DateInvoice=Invoice date
DatePointOfTax=Point of tax
NoInvoice=No invoice
NoOpenInvoice=No open invoice
NbOfOpenInvoices=Number of open invoices
ClassifyBill=Classify invoice
SupplierBillsToPay=Unpaid vendor invoices
CustomerBillsUnpaid=Unpaid customer invoices