From f1a9daf77e1740bbef9eb12c91ba7242c8e718af Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Nov 2019 12:42:56 +0100 Subject: [PATCH 1/4] NEW add total of value in product stat --- htdocs/product/stats/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 5ca7992be31..0b0399e424f 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Eric Seigne * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2019 Thibault FOUCARt * * 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 @@ -351,6 +352,7 @@ if ($result || empty($id)) $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); $px->draw($dir."/".$graphfiles[$key]['file'], $url); + $graphfiles[$key]['total'] = $px->total(); $graphfiles[$key]['output'] = $px->show(); } else @@ -405,7 +407,7 @@ if ($result || empty($id)) // Label print ''; print $graphfiles[$key]['label']; - print ''; + print ' ('.$graphfiles[$key]['total'].')'; print ''.$linktoregenerate.''; print ''; // Image From 2c810988a6204c09ec973df96ac36eb1a3395387 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Nov 2019 12:43:49 +0100 Subject: [PATCH 2/4] Update dolgraph.class.php --- htdocs/core/class/dolgraph.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 37f1d6036c6..4cd58a63378 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1124,7 +1124,20 @@ class DolGraph $this->stringtoshow .= ''."\n"; } - + /** + * Output HTML string to total value + * + * @return string HTML string to total value + */ + public function total() + { + $value = 0; + foreach($this->data as $valarray) // Loop on each x + { + $value += $valarray[1]; + } + return $value; + } /** * Output HTML string to show graph From 3209d550c2d083b72bee1b7af202329485578186 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 20 Nov 2019 11:45:12 +0000 Subject: [PATCH 3/4] Fixing style errors. --- htdocs/core/class/dolgraph.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 4cd58a63378..c6d610ca5f0 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1131,12 +1131,12 @@ class DolGraph */ public function total() { - $value = 0; - foreach($this->data as $valarray) // Loop on each x + $value = 0; + foreach($this->data as $valarray) // Loop on each x { - $value += $valarray[1]; - } - return $value; + $value += $valarray[1]; + } + return $value; } /** From 4d9894e58e40e6b326f4d49909b9cbc7e9d40919 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 22 Nov 2019 15:49:06 +0100 Subject: [PATCH 4/4] Update card.php --- htdocs/product/stats/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 0b0399e424f..24387ef8b73 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Eric Seigne * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2019 Thibault FOUCARt + * Copyright (C) 2019 Thibault FOUCART * * 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