Qual: Some change to have graph lib able to use img disk generation

libraries like javascript libraries.
This commit is contained in:
Laurent Destailleur 2011-12-17 15:55:49 +01:00
parent 484d0c82bf
commit cda132ea8c
17 changed files with 563 additions and 541 deletions

View File

@ -22,7 +22,6 @@
*/ */
require("../../main.inc.php"); require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
$graphwidth = 700; $graphwidth = 700;

View File

@ -73,31 +73,31 @@ $filenamenb = $dir.'/subscriptionsnbinyear-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsnbinyear-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsnbinyear-'.$year.'.png';
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px1->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px1->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px1->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("NbOfSubscriptions")); $px1->SetYLabel($langs->trans("NbOfSubscriptions"));
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->mode='depth'; $px1->mode='depth';
$px->SetTitle($langs->trans("NbOfSubscriptions")); $px1->SetTitle($langs->trans("NbOfSubscriptions"));
$px->draw($filenamenb); $px1->draw($filenamenb,$fileurlnb);
} }
// Build graphic amount of object // Build graphic amount of object
@ -108,31 +108,31 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
$filenameamount = $dir.'/subscriptionsamountinyear-'.$year.'.png'; $filenameamount = $dir.'/subscriptionsamountinyear-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsamountinyear-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsamountinyear-'.$year.'.png';
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px2->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px2->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px2->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountOfSubscriptions")); $px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->mode='depth'; $px2->mode='depth';
$px->SetTitle($langs->trans("AmountOfSubscriptions")); $px2->SetTitle($langs->trans("AmountOfSubscriptions"));
$px->draw($filenameamount); $px2->draw($filenameamount,$fileurlamount);
} }
@ -214,9 +214,9 @@ print '<td align="center" valign="top">';
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfSubscriptions").'" alt="'.$langs->trans("NbOfSubscriptions").'">'; print $px1->show();
print "<br>\n"; print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">'; print $px2->show();
} }
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -79,31 +79,31 @@ else
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png';
} }
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px1->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px1->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px1->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("NbOfProposals")); $px1->SetYLabel($langs->trans("NbOfProposals"));
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->mode='depth'; $px1->mode='depth';
$px->SetTitle($langs->trans("NumberOfProposalsByMonth")); $px1->SetTitle($langs->trans("NumberOfProposalsByMonth"));
$px->draw($filenamenb); $px1->draw($filenamenb,$fileurlnb);
} }
// Build graphic amount of object // Build graphic amount of object
@ -122,31 +122,31 @@ else
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png';
} }
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px2->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px2->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px2->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountOfProposals")); $px2->SetYLabel($langs->trans("AmountOfProposals"));
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->mode='depth'; $px2->mode='depth';
$px->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
$px->draw($filenameamount); $px2->draw($filenameamount,$fileurlamount);
} }
print '<table class="notopnoleftnopadd" width="100%"><tr>'; print '<table class="notopnoleftnopadd" width="100%"><tr>';
@ -213,9 +213,9 @@ print '<td align="center" valign="top">';
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfProposals").'" alt="'.$langs->trans("NbOfProposals").'">'; print $px1->show();
print "<br>\n"; print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">'; print $px2->show();
} }
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -70,19 +70,19 @@ else
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnb-'.$year.'.png'; $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnb-'.$year.'.png';
} }
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px1->SetMinValue($px1->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px1->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px1->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->draw($filename); $px1->draw($filename,$fileurl);
} }
@ -100,20 +100,20 @@ else
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamount-'.$year.'.png'; $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamount-'.$year.'.png';
} }
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$px->SetYLabel($langs->trans("AmountTotal")); $px2->SetYLabel($langs->trans("AmountTotal"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px2->SetMinValue($px2->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px2->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px2->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->draw($filename_amount); $px2->draw($filename_amount,$fileurl_amount);
} }
@ -137,38 +137,38 @@ else
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsaverage-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsaverage-'.$year.'.png';
} }
$px = new DolGraph(); $px3 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px3->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px3->SetData($data);
$px->SetPrecisionY(0); $px3->SetPrecisionY(0);
$px->SetYLabel($langs->trans("AmountAverage")); $px3->SetYLabel($langs->trans("AmountAverage"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px3->SetMaxValue($px3->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px3->SetMinValue($px3->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px3->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px3->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px3->SetShading(3);
$px->SetHorizTickIncrement(1); $px3->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px3->SetPrecisionY(0);
$px->draw($filename_avg); $px3->draw($filename_avg,$fileurl_avg);
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("NumberOfProposalsByMonth").'</td>'; print '<tr><td align="center">'.$langs->trans("NumberOfProposalsByMonth").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl.'">'; } else { print $px1->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_amount.'">'; } else { print $px2->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_avg.'">'; } else { print $px3->show(); }
print '</td></tr></table>'; print '</td></tr></table>';
$db->close(); $db->close();

View File

@ -94,30 +94,31 @@ else
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png';
} }
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px1->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px1->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px1->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("NbOfOrder")); $px1->SetYLabel($langs->trans("NbOfOrder"));
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->mode='depth'; $px1->mode='depth';
$px->SetTitle($langs->trans("NumberOfOrdersByMonth")); $px1->SetTitle($langs->trans("NumberOfOrdersByMonth"));
$px->draw($filenamenb);
$px1->draw($filenamenb,$fileurlnb);
} }
// Build graphic amount of object // Build graphic amount of object
@ -138,30 +139,30 @@ else
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png';
} }
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px2->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px2->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px2->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountOfOrders")); $px2->SetYLabel($langs->trans("AmountOfOrders"));
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->mode='depth'; $px2->mode='depth';
$px->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
$px->draw($filenameamount); $px2->draw($filenameamount,$fileurlamount);
} }
print '<table class="notopnoleftnopadd" width="100%"><tr>'; print '<table class="notopnoleftnopadd" width="100%"><tr>';
@ -228,15 +229,15 @@ print '<td align="center" valign="top">';
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfOrders").'" alt="'.$langs->trans("NbOfOrders").'">'; print $px1->show();
print "<br>\n"; print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">'; print $px2->show();
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td></tr></table>'; print '</td></tr></table>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -86,20 +86,20 @@ else
if ($mode == 'supplier') $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnb-'.$year.'.png'; if ($mode == 'supplier') $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnb-'.$year.'.png';
} }
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px1->SetMinValue($px1->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px1->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px1->SetHeight($GRAPHHEIGHT);
$px->SetYLabel($langs->trans("NbOfOrders")); $px1->SetYLabel($langs->trans("NbOfOrders"));
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->draw($filename); $px1->draw($filename,$fileurl);
} }
@ -118,20 +118,20 @@ else
if ($mode == 'supplier') $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamount-'.$year.'.png'; if ($mode == 'supplier') $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamount-'.$year.'.png';
} }
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$px->SetYLabel($langs->trans("AmountTotal")); $px2->SetYLabel($langs->trans("AmountTotal"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px2->SetMinValue($px2->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px2->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px2->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->draw($filename_amount); $px2->draw($filename_amount,$fileurl_amount);
} }
$res = $stats->getAverageByMonth($year); $res = $stats->getAverageByMonth($year);
@ -155,37 +155,37 @@ else
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png';
} }
$px = new DolGraph(); $px3 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px3->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px3->SetData($data);
$px->SetYLabel($langs->trans("AmountAverage")); $px3->SetYLabel($langs->trans("AmountAverage"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px3->SetMaxValue($px3->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px3->SetMinValue($px3->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px3->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px3->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px3->SetShading(3);
$px->SetHorizTickIncrement(1); $px3->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px3->SetPrecisionY(0);
$px->draw($filename_avg); $px3->draw($filename_avg,$fileurl_avg);
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("NumberOfOrdersByMonth").'</td>'; print '<tr><td align="center">'.$langs->trans("NumberOfOrdersByMonth").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl.'">'; } else { print $px1->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_amount.'">'; } else { print $px2->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_avg.'">'; } else { print $px3->show(); }
print '</td></tr></table>'; print '</td></tr></table>';
$db->close(); $db->close();

View File

@ -222,6 +222,7 @@ else
// Fabrication tableau 1 // Fabrication tableau 1
$file= $conf->banque->dir_temp."/balance".$account."-".$year.$month.".png"; $file= $conf->banque->dir_temp."/balance".$account."-".$year.$month.".png";
$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png";
$title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; $title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
$graph_datas=array(); $graph_datas=array();
foreach($datas as $i => $val) foreach($datas as $i => $val)
@ -230,25 +231,26 @@ else
else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
} }
$px = new DolGraph(); $px1 = new DolGraph();
$px->SetData($graph_datas); $px1->SetData($graph_datas);
if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired"))); if ($acct->min_desired) $px1->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired")));
else $px->SetLegend(array($langs->transnoentities("Balance"))); else $px1->SetLegend(array($langs->transnoentities("Balance")));
$px->SetLegendWidthMin(180); $px1->SetLegendWidthMin(180);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); $px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue());
$px->SetTitle($title); $px1->SetTitle($title);
$px->SetWidth($width); $px1->SetWidth($width);
$px->SetHeight($height); $px1->SetHeight($height);
$px->SetType('lines'); $px1->SetType('lines');
$px->setBgColor('onglet'); $px1->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255)); $px1->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->draw($file); $px1->draw($file,$fileurl);
$show1=$px1->show();
unset($graph_datas); unset($graph_datas);
unset($px); unset($px1);
unset($datas); unset($datas);
unset($datamin); unset($datamin);
unset($labels); unset($labels);
@ -351,6 +353,7 @@ else
// Fabrication tableau 2 // Fabrication tableau 2
$file= $conf->banque->dir_temp."/balance".$account."-".$year.".png"; $file= $conf->banque->dir_temp."/balance".$account."-".$year.".png";
$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png";
$title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year; $title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year;
$graph_datas=array(); $graph_datas=array();
foreach($datas as $i => $val) foreach($datas as $i => $val)
@ -358,25 +361,27 @@ else
if ($acct->min_desired) $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i],$datamin[$i]); if ($acct->min_desired) $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i],$datamin[$i]);
else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
} }
$px = new DolGraph(); $px2 = new DolGraph();
$px->SetData($graph_datas); $px2->SetData($graph_datas);
if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired"))); if ($acct->min_desired) $px2->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired")));
else $px->SetLegend(array($langs->transnoentities("Balance"))); else $px2->SetLegend(array($langs->transnoentities("Balance")));
$px->SetLegendWidthMin(180); $px2->SetLegendWidthMin(180);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); $px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue());
$px->SetTitle($title); $px2->SetTitle($title);
$px->SetWidth($width); $px2->SetWidth($width);
$px->SetHeight($height); $px2->SetHeight($height);
$px->SetType('lines'); $px2->SetType('lines');
$px->setBgColor('onglet'); $px2->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255)); $px2->setBgColorGrid(array(255,255,255));
$px->SetHideXGrid(true); $px2->SetHideXGrid(true);
//$px->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne //$px2->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->draw($file); $px2->draw($file,$fileurl);
unset($px); $show2=$px2->show();
unset($px2);
unset($graph_datas); unset($graph_datas);
unset($datas); unset($datas);
unset($datamin); unset($datamin);
@ -457,6 +462,7 @@ else
// Fabrication tableau 3 // Fabrication tableau 3
$file= $conf->banque->dir_temp."/balance".$account.".png"; $file= $conf->banque->dir_temp."/balance".$account.".png";
$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png";
$title=$langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime"); $title=$langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime");
$graph_datas=array(); $graph_datas=array();
foreach($datas as $i => $val) foreach($datas as $i => $val)
@ -464,22 +470,25 @@ else
if ($acct->min_desired) $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i],$datamin[$i]); if ($acct->min_desired) $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i],$datamin[$i]);
else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
} }
$px = new DolGraph(); $px3 = new DolGraph();
$px->SetData($graph_datas); $px3->SetData($graph_datas);
if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired"))); if ($acct->min_desired) $px3->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired")));
else $px->SetLegend(array($langs->transnoentities("Balance"))); else $px3->SetLegend(array($langs->transnoentities("Balance")));
$px->SetLegendWidthMin(180); $px3->SetLegendWidthMin(180);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); $px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); $px3->SetMinValue($px3->GetFloorMinValue()>0?0:$px3->GetFloorMinValue());
$px->SetTitle($title); $px3->SetTitle($title);
$px->SetWidth($width); $px3->SetWidth($width);
$px->SetHeight($height); $px3->SetHeight($height);
$px->SetType('lines'); $px3->SetType('lines');
$px->setBgColor('onglet'); $px3->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255)); $px3->setBgColorGrid(array(255,255,255));
$px->SetPrecisionY(0); $px3->SetPrecisionY(0);
$px->draw($file); $px3->draw($file,$fileurl);
$show3=$px3->show();
unset($px3);
unset($graph_datas); unset($graph_datas);
unset($datas); unset($datas);
unset($datamin); unset($datamin);
@ -582,31 +591,34 @@ else
// Fabrication tableau 4a // Fabrication tableau 4a
$file= $conf->banque->dir_temp."/movement".$account."-".$year.$month.".png"; $file= $conf->banque->dir_temp."/movement".$account."-".$year.$month.".png";
$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png";
$title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; $title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
$graph_datas=array(); $graph_datas=array();
foreach($data_credit as $i => $val) foreach($data_credit as $i => $val)
{ {
$graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]);
} }
$px = new DolGraph(); $px4 = new DolGraph();
$px->SetData($graph_datas); $px4->SetData($graph_datas);
$px->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit"))); $px4->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit")));
$px->SetLegendWidthMin(180); $px4->SetLegendWidthMin(180);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); $px4->SetMaxValue($px4->GetCeilMaxValue()<0?0:$px4->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); $px4->SetMinValue($px4->GetFloorMinValue()>0?0:$px4->GetFloorMinValue());
$px->SetTitle($title); $px4->SetTitle($title);
$px->SetWidth($width); $px4->SetWidth($width);
$px->SetHeight($height); $px4->SetHeight($height);
$px->SetType('bars'); $px4->SetType('bars');
$px->SetShading(3); $px4->SetShading(3);
$px->setBgColor('onglet'); $px4->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255)); $px4->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px4->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px4->SetPrecisionY(0);
$px->draw($file); $px4->draw($file,$fileurl);
$show4=$px4->show();
unset($graph_datas); unset($graph_datas);
unset($px); unset($px4);
unset($debits); unset($debits);
unset($credits); unset($credits);
} }
@ -688,31 +700,34 @@ else
// Fabrication tableau 4b // Fabrication tableau 4b
$file= $conf->banque->dir_temp."/movement".$account."-".$year.".png"; $file= $conf->banque->dir_temp."/movement".$account."-".$year.".png";
$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png";
$title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year; $title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year;
$graph_datas=array(); $graph_datas=array();
foreach($data_credit as $i => $val) foreach($data_credit as $i => $val)
{ {
$graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]);
} }
$px = new DolGraph(); $px5 = new DolGraph();
$px->SetData($graph_datas); $px5->SetData($graph_datas);
$px->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit"))); $px5->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit")));
$px->SetLegendWidthMin(180); $px5->SetLegendWidthMin(180);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); $px5->SetMaxValue($px5->GetCeilMaxValue()<0?0:$px5->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); $px5->SetMinValue($px5->GetFloorMinValue()>0?0:$px5->GetFloorMinValue());
$px->SetTitle($title); $px5->SetTitle($title);
$px->SetWidth($width); $px5->SetWidth($width);
$px->SetHeight($height); $px5->SetHeight($height);
$px->SetType('bars'); $px5->SetType('bars');
$px->SetShading(3); $px5->SetShading(3);
$px->setBgColor('onglet'); $px5->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255)); $px5->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px5->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px5->SetPrecisionY(0);
$px->draw($file); $px5->draw($file,$fileurl);
$show5=$px5->show();
unset($graph_datas); unset($graph_datas);
unset($px); unset($px5);
unset($debits); unset($debits);
unset($credits); unset($credits);
} }
@ -800,6 +815,7 @@ else
print '<br><br></td></tr>'; print '<br><br></td></tr>';
// Graphs
if ($mode == 'standard') if ($mode == 'standard')
{ {
$prevyear=$year;$nextyear=$year; $prevyear=$year;$nextyear=$year;
@ -813,11 +829,11 @@ if ($mode == 'standard')
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "movement".$account."-".$year.$month.".png"; $file = "movement".$account."-".$year.$month.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='.$file.'" alt="" title="">'; print $show4;
print '</td></tr>';
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "balance".$account."-".$year.$month.".png"; print $show1;
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
// For year // For year
@ -826,21 +842,18 @@ if ($mode == 'standard')
print '<tr><td align="right">'.$lien.'</td></tr>'; print '<tr><td align="right">'.$lien.'</td></tr>';
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "movement".$account."-".$year.".png"; print $show5;
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "balance".$account."-".$year.".png"; print $show2;
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
} }
if ($mode == 'showalltime') if ($mode == 'showalltime')
{ {
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "balance".$account.".png"; print $show3;
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -74,30 +74,30 @@ $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
$filenamenb = $dir."/tripsexpensesnbinyear-".$year.".png"; $filenamenb = $dir."/tripsexpensesnbinyear-".$year.".png";
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&amp;file=tripsexpensesnbinyear-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&amp;file=tripsexpensesnbinyear-'.$year.'.png';
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px1->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetWidth($WIDTH); $px1->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px1->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("Number")); $px1->SetYLabel($langs->trans("Number"));
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->mode='depth'; $px1->mode='depth';
$px->SetTitle($langs->trans("NumberByMonth")); $px1->SetTitle($langs->trans("NumberByMonth"));
$px->draw($filenamenb); $px1->draw($filenamenb,$fileurlnb);
} }
// Build graphic amount of object // Build graphic amount of object
@ -108,30 +108,30 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
$filenameamount = $dir."/tripsexpensesamountinyear-".$year.".png"; $filenameamount = $dir."/tripsexpensesamountinyear-".$year.".png";
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&amp;file=tripsexpensesamountinyear-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&amp;file=tripsexpensesamountinyear-'.$year.'.png';
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px2->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px2->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px2->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("Amount")); $px2->SetYLabel($langs->trans("Amount"));
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->mode='depth'; $px2->mode='depth';
$px->SetTitle($langs->trans("AmountTotal")); $px2->SetTitle($langs->trans("AmountTotal"));
$px->draw($filenameamount); $px2->draw($filenameamount,$fileurlamount);
} }
@ -201,13 +201,15 @@ print '<td align="center" valign="top">';
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("Number").'" alt="'.$langs->trans("Number").'">'; print $px1->show();
print "<br>\n"; print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("Amount").'" alt="'.$langs->trans("Amount").'">'; print $px2->show();
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td></tr></table>'; print '</td></tr></table>';
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -69,19 +69,19 @@ $data = $stats->getNbByMonth($year);
$filename = $dir."/tripsexpensesnb-".$year.".png"; $filename = $dir."/tripsexpensesnb-".$year.".png";
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnb-'.$year.'.png'; $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnb-'.$year.'.png';
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px1->SetMinValue($px1->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px1->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px1->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->draw($filename); $px1->draw($filename,$fileurl);
} }
@ -91,20 +91,20 @@ $data = $stats->getAmountByMonth($year);
$filename_amount = $dir."/tripsexpensesamount-".$year.".png"; $filename_amount = $dir."/tripsexpensesamount-".$year.".png";
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamount-'.$year.'.png'; $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamount-'.$year.'.png';
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$px->SetYLabel($langs->trans("AmountTotal")); $px2->SetYLabel($langs->trans("AmountTotal"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px2->SetMinValue($px2->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px2->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px2->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->draw($filename_amount); $px2->draw($filename_amount,$fileurl_amount);
} }
@ -121,37 +121,37 @@ for ($i = 1 ; $i < 13 ; $i++)
$filename_avg = $dir."/tripsexpensesaverage-".$year.".png"; $filename_avg = $dir."/tripsexpensesaverage-".$year.".png";
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesaverage-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesaverage-'.$year.'.png';
$px = new DolGraph(); $px3 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px3->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px3->SetData($data);
$px->SetYLabel($langs->trans("AmountAverage")); $px3->SetYLabel($langs->trans("AmountAverage"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px3->SetMaxValue($px3->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px3->SetMinValue($px3->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px3->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px3->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px3->SetShading(3);
$px->SetHorizTickIncrement(1); $px3->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px3->SetPrecisionY(0);
$px->draw($filename_avg); $px3->draw($filename_avg,$fileurl_avg);
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("NumberByMonth").'</td>'; print '<tr><td align="center">'.$langs->trans("NumberByMonth").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl.'">'; } else { print $px1->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_amount.'">'; } else { print $px2->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_avg.'">'; } else { print $px3->show(); }
print '</td></tr></table>'; print '</td></tr></table>';
$db->close(); $db->close();

View File

@ -82,30 +82,30 @@ $filenamenb = $dir."/invoicesnbinyear-".$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';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicesnbinyear-'.$year.'.png';
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px1->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetWidth($WIDTH); $px1->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px1->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("NumberOfBills")); $px1->SetYLabel($langs->trans("NumberOfBills"));
$px->SetShading(3); $px1->SetShading(3);
$px->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px1->SetPrecisionY(0);
$px->mode='depth'; $px1->mode='depth';
$px->SetTitle($langs->trans("NumberOfBillsByMonth")); $px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
$px->draw($filenamenb); $px1->draw($filenamenb,$fileurlnb);
} }
// Build graphic amount of object // Build graphic amount of object
@ -117,30 +117,30 @@ $filenameamount = $dir."/invoicesamountinyear-".$year.".png";
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png'; if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicesamountinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicesamountinyear-'.$year.'.png';
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$i=$startyear; $i=$startyear;
while ($i <= $endyear) while ($i <= $endyear)
{ {
$legend[]=$i; $legend[]=$i;
$i++; $i++;
} }
$px->SetLegend($legend); $px2->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue())); $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px->SetWidth($WIDTH); $px2->SetWidth($WIDTH);
$px->SetHeight($HEIGHT); $px2->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountOfBills")); $px2->SetYLabel($langs->trans("AmountOfBills"));
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->mode='depth'; $px2->mode='depth';
$px->SetTitle($langs->trans("AmountOfBillsByMonthHT")); $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
$px->draw($filenameamount); $px2->draw($filenameamount,$fileurlamount);
} }
@ -202,8 +202,6 @@ foreach ($data as $val)
print '</table>'; print '</table>';
$db->close();
print '</td>'; print '</td>';
print '<td align="center" valign="top">'; print '<td align="center" valign="top">';
@ -211,13 +209,15 @@ print '<td align="center" valign="top">';
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NumberOfBills").'" alt="'.$langs->trans("NumberOfBills").'">'; print $px1->show();
print "<br>\n"; print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountOfBills").'" alt="'.$langs->trans("AmountOfBills").'">'; print $px2->show();
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td></tr></table>'; print '</td></tr></table>';
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -78,19 +78,20 @@ $filename = $dir."/invoicesnb-".$year.".png";
if ($mode == 'customer') $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnb-'.$year.'.png'; if ($mode == 'customer') $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnb-'.$year.'.png';
if ($mode == 'supplier') $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesnb-'.$year.'.png'; if ($mode == 'supplier') $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesnb-'.$year.'.png';
$px = new DolGraph(); $px1 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px1->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px1->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetYLabel($langs->trans("NumberOfBillsByMonth"));
$px->SetMinValue($px->GetFloorMinValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetWidth($GRAPHWIDTH); $px1->SetMinValue($px1->GetFloorMinValue());
$px->SetHeight($GRAPHHEIGHT); $px1->SetWidth($GRAPHWIDTH);
$px->SetShading(3); $px1->SetHeight($GRAPHHEIGHT);
$px->SetHorizTickIncrement(1); $px1->SetShading(3);
$px->SetPrecisionY(0); $px1->SetHorizTickIncrement(1);
$px->draw($filename); $px1->SetPrecisionY(0);
$px1->draw($filename,$fileurl);
} }
@ -101,20 +102,20 @@ $filename_amount = $dir."/invoicesamount-".$year.".png";
if ($mode == 'customer') $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamount-'.$year.'.png'; if ($mode == 'customer') $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamount-'.$year.'.png';
if ($mode == 'supplier') $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesamount-'.$year.'.png'; if ($mode == 'supplier') $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesamount-'.$year.'.png';
$px = new DolGraph(); $px2 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px2->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px2->SetData($data);
$px->SetYLabel($langs->trans("AmountTotal")); $px2->SetYLabel($langs->trans("AmountTotal"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px2->SetMinValue($px2->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px2->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px2->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px2->SetShading(3);
$px->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px2->SetPrecisionY(0);
$px->draw($filename_amount); $px2->draw($filename_amount,$fileurl_amount);
} }
@ -132,40 +133,40 @@ $filename_avg = $dir."/invoicesaverage-".$year.".png";
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesaverage-'.$year.'.png'; if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesaverage-'.$year.'.png';
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesaverage-'.$year.'.png'; if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesaverage-'.$year.'.png';
$px = new DolGraph(); $px3 = new DolGraph();
$mesg = $px->isGraphKo(); $mesg = $px3->isGraphKo();
if (! $mesg) if (! $mesg)
{ {
$px->SetData($data); $px3->SetData($data);
$px->SetYLabel($langs->trans("AmountAverage")); $px3->SetYLabel($langs->trans("AmountAverage"));
$px->SetMaxValue($px->GetCeilMaxValue()); $px3->SetMaxValue($px3->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px3->SetMinValue($px3->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH); $px3->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT); $px3->SetHeight($GRAPHHEIGHT);
$px->SetShading(3); $px3->SetShading(3);
$px->SetHorizTickIncrement(1); $px3->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px3->SetPrecisionY(0);
$px->draw($filename_avg); $px3->draw($filename_avg,$fileurl_avg);
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("NumberOfBillsByMonth").'</td>'; print '<tr><td align="center">'.$langs->trans("NumberOfBillsByMonth").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl.'">'; } else { print $px1->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_amount.'">'; } else { print $px2->show(); }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>'; print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
print '<td align="center">'; print '<td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_avg.'">'; } else { print $px3->show(); }
print '</td></tr></table>'; print '</td></tr></table>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (c) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (c) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (c) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
/** /**
* \file htdocs/core/class/dolgraph.class.php * \file htdocs/core/class/dolgraph.class.php
* \ingroup core * \ingroup core
* \brief Fichier de la classe mere de gestion des graph * \brief File for class to generate graph
* *
* Usage: * Usage:
* $graph_data = array(array('labelA',yA),array('labelB',yB)); * $graph_data = array(array('labelA',yA),array('labelB',yB));
@ -48,6 +48,7 @@ class DolGraph
//! Tableau de donnees //! Tableau de donnees
var $data; // array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) var $data; // array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...)
var $title;
var $width=380; var $width=380;
var $height=200; var $height=200;
var $MaxValue=0; var $MaxValue=0;
@ -76,6 +77,8 @@ class DolGraph
var $bgcolorgrid; // array(R,G,B) var $bgcolorgrid; // array(R,G,B)
var $datacolor; // array(array(R,G,B),...) var $datacolor; // array(array(R,G,B),...)
private $stringtoshow; // To store string to output graph into HTML page
/** /**
* Constructor * Constructor
@ -117,7 +120,7 @@ class DolGraph
/** /**
* Set Y precision * Set Y precision
* *
* @param float $which_prec * @param float $which_prec
* @return string * @return string
*/ */
@ -129,7 +132,7 @@ class DolGraph
/** /**
* Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
* *
* @param float $xi * @param float $xi
*/ */
function SetHorizTickIncrement($xi) function SetHorizTickIncrement($xi)
@ -140,7 +143,7 @@ class DolGraph
/** /**
* Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
* *
* @param float $xt * @param float $xt
*/ */
function SetNumXTicks($xt) function SetNumXTicks($xt)
@ -151,7 +154,7 @@ class DolGraph
/** /**
* Set label interval to reduce number of labels * Set label interval to reduce number of labels
* *
* @param float $x * @param float $x
*/ */
function SetLabelInterval($x) function SetLabelInterval($x)
@ -179,7 +182,7 @@ class DolGraph
} }
/** /**
* *
* @param unknown_type $label * @param unknown_type $label
*/ */
function SetYLabel($label) function SetYLabel($label)
@ -188,7 +191,7 @@ class DolGraph
} }
/** /**
* *
* @param $w * @param $w
*/ */
function SetWidth($w) function SetWidth($w)
@ -197,7 +200,7 @@ class DolGraph
} }
/** /**
* *
* @param $title * @param $title
*/ */
function SetTitle($title) function SetTitle($title)
@ -206,7 +209,7 @@ class DolGraph
} }
/** /**
* *
* @param $data * @param $data
*/ */
function SetData($data) function SetData($data)
@ -215,7 +218,7 @@ class DolGraph
} }
/** /**
* *
* @param $type * @param $type
*/ */
function SetType($type) function SetType($type)
@ -224,16 +227,16 @@ class DolGraph
} }
/** /**
* *
* @param $legend * @param $legend
*/ */
function SetLegend($legend) function SetLegend($legend)
{ {
$this->Legend = $legend; $this->Legend = $legend;
} }
/** /**
* *
* @param $legendwidthmin * @param $legendwidthmin
*/ */
function SetLegendWidthMin($legendwidthmin) function SetLegendWidthMin($legendwidthmin)
@ -242,16 +245,16 @@ class DolGraph
} }
/** /**
* *
* @param $max * @param $max
*/ */
function SetMaxValue($max) function SetMaxValue($max)
{ {
$this->MaxValue = $max; $this->MaxValue = $max;
} }
/** /**
* *
*/ */
function GetMaxValue() function GetMaxValue()
{ {
@ -259,16 +262,16 @@ class DolGraph
} }
/** /**
* *
* @param $min * @param $min
*/ */
function SetMinValue($min) function SetMinValue($min)
{ {
$this->MinValue = $min; $this->MinValue = $min;
} }
/** /**
* *
*/ */
function GetMinValue() function GetMinValue()
{ {
@ -276,7 +279,7 @@ class DolGraph
} }
/** /**
* *
* @param $h * @param $h
*/ */
function SetHeight($h) function SetHeight($h)
@ -285,7 +288,7 @@ class DolGraph
} }
/** /**
* *
* @param $s * @param $s
*/ */
function SetShading($s) function SetShading($s)
@ -294,7 +297,7 @@ class DolGraph
} }
/** /**
* *
*/ */
function ResetBgColor() function ResetBgColor()
{ {
@ -302,7 +305,7 @@ class DolGraph
} }
/** /**
* *
*/ */
function ResetBgColorGrid() function ResetBgColorGrid()
{ {
@ -310,7 +313,7 @@ class DolGraph
} }
/** /**
* *
*/ */
function isGraphKo() function isGraphKo()
{ {
@ -320,7 +323,7 @@ class DolGraph
/** /**
* Definie la couleur de fond de l'image complete * Definie la couleur de fond de l'image complete
* *
* @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default'
* @return void * @return void
*/ */
@ -347,7 +350,7 @@ class DolGraph
/** /**
* Definie la couleur de fond de la grille * Definie la couleur de fond de la grille
* *
* @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default'
*/ */
function SetBgColorGrid($bg_colorgrid = array(255,255,255)) function SetBgColorGrid($bg_colorgrid = array(255,255,255))
@ -372,7 +375,7 @@ class DolGraph
} }
/** /**
* *
*/ */
function ResetDataColor() function ResetDataColor()
{ {
@ -380,7 +383,7 @@ class DolGraph
} }
/** /**
* *
*/ */
function GetMaxValueInData() function GetMaxValueInData()
{ {
@ -403,7 +406,7 @@ class DolGraph
} }
/** /**
* *
*/ */
function GetMinValueInData() function GetMinValueInData()
{ {
@ -472,34 +475,36 @@ class DolGraph
/** /**
* Build a graph onto disk using correct library * Build a graph onto disk using correct library
* *
* @param string $file Image file name on disk to generate * @param string $file Image file name to use if we save onto disk
* @param string $fileurl Url path to show image if saved onto disk
* @return void * @return void
*/ */
function draw($file) function draw($file,$fileurl='')
{ {
if (! is_array($this->data) || count($this->data) < 1) if (! is_array($this->data) || count($this->data) < 1)
{ {
$this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters"; $this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
dol_syslog("DolGraph::draw ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
return -1; return -1;
} }
$call = "draw_".$this->library; $call = "draw_".$this->library;
$this->$call($file); $this->$call($file,$fileurl);
} }
/** /**
* Build a graph onto disk using Artichow library * Build a graph onto disk using Artichow library
* *
* @param string $file Image file name on disk to generate * @param string $file Image file name to use if we save onto disk
* @param string $fileurl Url path to show image if saved onto disk
* @return void * @return void
*/ */
private function draw_artichow($file) private function draw_artichow($file,$fileurl)
{ {
global $artichow_defaultfont; global $artichow_defaultfont;
dol_syslog("DolGraph.class::draw_artichow this->type=".$this->type); dol_syslog(get_class($this)."::draw_artichow this->type=".$this->type);
if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3); if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3);
if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2); if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2);
@ -662,8 +667,20 @@ class DolGraph
// Generate file // Generate file
$graph->draw($file); $graph->draw($file);
$this->stringtoshow='<img src="'.$fileurl.'" title="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'" alt="'.dol_escape_htmltag($this->title?$this->title:$this->YLabel).'">';
} }
/**
* Output HTML string to show graph
*
* @return string HTML string to show graph
*/
function show()
{
return $this->stringtoshow;
}
} }
?> ?>

View File

@ -29,6 +29,10 @@ require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php");
$langs->load("sendings"); $langs->load("sendings");
/*
* View
*/
llxHeader(); llxHeader();
print_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg); print_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg);
@ -64,7 +68,7 @@ print '</table>';
print '<br>'; print '<br>';
print '<i>'.$langs->trans("StatsOnShipmentsOnlyValidated").'</i>'; print '<i>'.$langs->trans("StatsOnShipmentsOnlyValidated").'</i>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -28,6 +28,10 @@ require_once(DOL_DOCUMENT_ROOT."/expedition/class/expeditionstats.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
/*
* View
*/
llxHeader(); llxHeader();
$WIDTH=500; $WIDTH=500;
@ -35,7 +39,7 @@ $HEIGHT=200;
$mesg = ''; $mesg = '';
print_fiche_titre('Statistiques expeditions '.$_GET["year"], $mesg); print_fiche_titre($langs->trans("StatisticsOfSendings").' '.$_GET["year"], $mesg);
$stats = new ExpeditionStats($db); $stats = new ExpeditionStats($db);
$data = $stats->getNbExpeditionByMonth($_GET["year"]); $data = $stats->getNbExpeditionByMonth($_GET["year"]);
@ -57,17 +61,17 @@ if (! $mesg)
$px->SetShading(3); $px->SetShading(3);
$px->SetHorizTickIncrement(1); $px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($filename); $px->draw($filename,$fileurl);
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td align="center">Nombre d expedition par mois</td>'; print '<tr><td align="center">Nombre d expedition par mois</td>';
print '<td align="center">'; print '<td align="center">';
print '<img src="'.$fileurl.'">'; print $px->show();
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -1480,7 +1480,7 @@ class Product extends CommonObject
for ($j = 0 ; $j < 12 ; $j++) for ($j = 0 ; $j < 12 ; $j++)
{ {
$idx=ucfirst(substr(dol_print_date(dol_mktime(12,0,0,$month,1,$year),"%b"),0,3) ); $idx=ucfirst(dol_trunc(dol_print_date(dol_mktime(12,0,0,$month,1,$year),"%b"),3));
$monthnum=sprintf("%02s",$month); $monthnum=sprintf("%02s",$month);
$result[$j] = array($idx,isset($tab[$year.$month])?$tab[$year.$month]:0); $result[$j] = array($idx,isset($tab[$year.$month])?$tab[$year.$month]:0);

View File

@ -89,23 +89,6 @@ if (! empty($id) || ! empty($ref))
print $object->getLibStatut(2,1); print $object->getLibStatut(2,1);
print '</td></tr>'; print '</td></tr>';
// Graphs additionels generes pas le script product-graph.php
$year = strftime('%Y',time());
$file = get_exdir($object->id, 3) . "ventes-".$year."-".$object->id.".png";
if (file_exists (DOL_DATA_ROOT.'/product/temp/'.$file) )
{
print '<tr><td>Ventes</td><td>';
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&amp;file='.$file;
print '<img src="'.$url.'" alt="Ventes">';
$file = get_exdir($object->id, 3) . "ventes-".$object->id.".png";
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_product&amp;file='.$file;
print '<img src="'.$url.'" alt="Ventes">';
print '</td></tr>';
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -141,20 +124,16 @@ if (! empty($id) || ! empty($ref))
$graphfiles=array( $graphfiles=array(
'propal' =>array('modulepart'=>'productstats_proposals', 'propal' =>array('modulepart'=>'productstats_proposals',
'file' => $object->id.'/propal12m.png', 'file' => $object->id.'/propal12m.png',
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsProposals"):$langs->trans("NumberOfProposals"))), 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))),
'orders' =>array('modulepart'=>'productstats_orders', 'orders' =>array('modulepart'=>'productstats_orders',
'file' => $object->id.'/orders12m.png', 'file' => $object->id.'/orders12m.png',
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsCustomerOrders"):$langs->trans("NumberOfCustomerOrders"))), 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))),
'invoices' =>array('modulepart'=>'productstats_invoices', 'invoices' =>array('modulepart'=>'productstats_invoices',
'file' => $object->id.'/invoices12m.png', 'file' => $object->id.'/invoices12m.png',
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsCustomerInvoices"):$langs->trans("NumberOfCustomerInvoices"))), 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))),
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', 'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers',
'file' => $object->id.'/invoicessuppliers12m.png', 'file' => $object->id.'/invoicessuppliers12m.png',
'label' => ($mode=='byunit'?$langs->trans("NumberOfUnitsSupplierInvoices"):$langs->trans("NumberOfSupplierInvoices"))), 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))),
// 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $object->id.'/orderssuppliers12m.png', 'label' => $langs->trans("Nombre commande fournisseurs sur les 12 derniers mois")),
// 'contracts' =>array('modulepart'=>'productstats_contracts', 'file' => $object->id.'/contracts12m.png', 'label' => $langs->trans("Nombre contrats sur les 12 derniers mois")),
); );
$px = new DolGraph(); $px = new DolGraph();
@ -175,9 +154,11 @@ if (! empty($id) || ! empty($ref))
if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode); if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode);
if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode); if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode);
if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode); if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode);
if (is_array($graph_data)) if (is_array($graph_data))
{ {
$px->SetData($graph_data); $px->SetData($graph_data);
$px->SetYLabel($graphfiles[$key]['label']);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); $px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); $px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue());
$px->SetWidth($WIDTH); $px->SetWidth($WIDTH);
@ -187,7 +168,10 @@ if (! empty($id) || ! empty($ref))
$px->SetShading(3); $px->SetShading(3);
//print 'x '.$key.' '.$graphfiles[$key]['file']; //print 'x '.$key.' '.$graphfiles[$key]['file'];
$px->draw($dir."/".$graphfiles[$key]['file']); $url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&file='.urlencode($graphfiles[$key]['file']);
$px->draw($dir."/".$graphfiles[$key]['file'],$url);
$graphfiles[$key]['output']=$px->show();
} }
else else
{ {
@ -223,16 +207,14 @@ if (! empty($id) || ! empty($ref))
print '</td></tr>'; print '</td></tr>';
// Image // Image
print '<tr><td colspan="2" align="center">'; print '<tr><td colspan="2" align="center">';
//print $graphfiles[$key]['modulepart']."x".urlencode($graphfiles[$key]['file']); print $graphfiles[$key]['output'];
$url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&file='.urlencode($graphfiles[$key]['file']);
//print $url;
print '<img src="'.$url.'" alt="'.$graphfiles[$key]['label'].'">';
print '</td></tr>'; print '</td></tr>';
// Date generation // Date generation
print '<tr>'; print '<tr>';
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file']) && ! $px->isGraphKo()) if ($graphfiles[$key]['output'] && ! $px->isGraphKo())
{ {
print '<td>'.$langs->trans("GeneratedOn",dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).'</td>'; if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) print '<td>'.$langs->trans("GeneratedOn",dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).'</td>';
else print '<td>'.$langs->trans("GeneratedOn",dol_print_date(dol_now()),"dayhour").'</td>';
} }
else else
{ {
@ -264,8 +246,7 @@ else
dol_print_error(); dol_print_error();
} }
llxFooter();
$db->close(); $db->close();
llxFooter();
?> ?>

View File

@ -238,16 +238,16 @@ foreach ($accounts as $account)
{ {
$graph_datas[$i]=array("$labels[$i]",$datas[$i]); $graph_datas[$i]=array("$labels[$i]",$datas[$i]);
} }
$px = new DolGraph(); $px1 = new DolGraph();
$px->SetData($graph_datas); $px1->SetData($graph_datas);
$px->SetLegend(array($langs->trans("Balance"))); $px1->SetLegend(array($langs->trans("Balance")));
$px->SetMaxValue($px->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px1->SetMinValue($px1->GetFloorMinValue());
$px->SetTitle($title); $px1->SetTitle($title);
$px->SetWidth($width); $px1->SetWidth($width);
$px->SetHeight($height); $px1->SetHeight($height);
$px->SetType('lines'); $px1->SetType('lines');
$px->draw($file); $px1->draw($file,'');
// Chargement du tableau $amounts // Chargement du tableau $amounts
@ -333,15 +333,15 @@ foreach ($accounts as $account)
{ {
$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
} }
$px = new DolGraph(); $px2 = new DolGraph();
$px->SetData($graph_datas); $px2->SetData($graph_datas);
$px->SetLegend(array($langs->trans("Balance"))); $px2->SetLegend(array($langs->trans("Balance")));
$px->SetMaxValue($px->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px->SetTitle($title); $px2->SetTitle($title);
$px->SetWidth($width); $px2->SetWidth($width);
$px->SetHeight($height); $px2->SetHeight($height);
$px->SetType('lines'); $px2->SetType('lines');
$px->draw($file); $px2->draw($file,'');
// Chargement du tableau $amounts // Chargement du tableau $amounts
@ -408,16 +408,16 @@ foreach ($accounts as $account)
{ {
$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
} }
$px = new DolGraph(); $px3 = new DolGraph();
$px->SetData($graph_datas); $px3->SetData($graph_datas);
$px->SetLegend(array($langs->trans("Balance"))); $px3->SetLegend(array($langs->trans("Balance")));
$px->SetMaxValue($px->GetCeilMaxValue()); $px3->SetMaxValue($px3->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px3->SetMinValue($px3->GetFloorMinValue());
$px->SetTitle($title); $px3->SetTitle($title);
$px->SetWidth($width); $px3->SetWidth($width);
$px->SetHeight($height); $px3->SetHeight($height);
$px->SetType('lines'); $px3->SetType('lines');
$px->draw($file); $px3->draw($file,'');
// Chargement du tableau $credits, $debits // Chargement du tableau $credits, $debits
@ -488,17 +488,17 @@ foreach ($accounts as $account)
{ {
$graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]);
} }
$px = new DolGraph(); $px4 = new DolGraph();
$px->SetData($graph_datas); $px4->SetData($graph_datas);
$px->SetLegend(array($langs->trans("Debit"),$langs->trans("Credit"))); $px4->SetLegend(array($langs->trans("Debit"),$langs->trans("Credit")));
$px->SetMaxValue($px->GetCeilMaxValue()); $px4->SetMaxValue($px4->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px4->SetMinValue($px4->GetFloorMinValue());
$px->SetTitle($title); $px4->SetTitle($title);
$px->SetWidth($width); $px4->SetWidth($width);
$px->SetHeight($height); $px4->SetHeight($height);
$px->SetType('bars'); $px4->SetType('bars');
$px->SetShading(3); $px4->SetShading(3);
$px->draw($file); $px4->draw($file,'');
} }
$db->close(); $db->close();