From ead04cbddc1cfd8732243da48ac76f3b442fa83b Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Mon, 8 Sep 2008 07:37:53 +0000
Subject: [PATCH] New: Add statistics report for supplier invoices

---
 ChangeLog                             |  2 ++
 htdocs/compta/facture/stats/index.php | 10 ++++------
 htdocs/lib/functions.lib.php          |  6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0c1da9b1b4a..e63d2f537b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@ For users:
 - Support bookmark add of product cards.
 - New view in ecm module.
 - Look enhancements for graphics (add transparency).
+- Added statistics report for supplier invoices
+- Added average amount in invoices statistics reports.
 
 For translators:
 - The errors language file contains only error or warning messages with 
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index 37cb32e6aa9..dcc7381dd35 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -160,9 +160,7 @@ $oldyear=0;
 foreach ($data as $val)
 {
 	$year = $val['year'];
-	$nbproduct = $val['nb'];
-	$total = price($val['total']);
-	$avg = price($val['avg']);
+	print $avg;
 	while ($oldyear > $year+1)
 	{	// If we have empty year
 		$oldyear--;
@@ -175,9 +173,9 @@ foreach ($data as $val)
 	}
 	print '<tr height="24">';
 	print '<td align="center"><a href="month.php?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a></td>';
-	print '<td align="right">'.$nbproduct.'</td>';
-	print '<td align="right">'.$total.'</td>';
-	print '<td align="right">'.$avg.'</td>';
+	print '<td align="right">'.$val['nb'].'</td>';
+	print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
+	print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
 	print '</tr>';
 	$oldyear=$year;
 }
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 269eb14b25e..5778df29c69 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -1994,7 +1994,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2)
 	// Output separators by default (french)
 	$dec=','; $thousand=' ';
 
-	// Si $outlangs non force, on prend langue utilisateur
+	// If $outlangs not forced, we use use language
 	if (! is_object($outlangs)) $outlangs=$langs;
 
 	if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal")  $dec=$outlangs->trans("SeparatorDecimal");
@@ -2010,7 +2010,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2)
 	//print "decpart=".$decpart."<br>";
 	$end='';
 
-	// On augmente nbdecimal au besoin si il y a plus de decimales que nbdecimal
+	// We increase nbdecimal if there is more decimal than asked (to not loose information)
 	if (strlen($decpart) > $nbdecimal) $nbdecimal=strlen($decpart);
 	// Si on depasse max
 	if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN)
@@ -2023,7 +2023,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2)
 		}
 	}
 
-	// Formate nombre
+	// Format number
 	if ($html)
 	{
 		$output=ereg_replace(' ','&nbsp;',number_format($amount, $nbdecimal, $dec, $thousand));
-- 
GitLab