From 44d580101514df99bce7787e922704a4a2006ebc Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 6 Jan 2014 13:05:51 +0000 Subject: [PATCH] allow to prefix alternative name with a minus to substract instead of adding its value --- infolog/inc/class.infolog_widget.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/infolog/inc/class.infolog_widget.inc.php b/infolog/inc/class.infolog_widget.inc.php index 4d94329a47..cd5193665a 100644 --- a/infolog/inc/class.infolog_widget.inc.php +++ b/infolog/inc/class.infolog_widget.inc.php @@ -106,13 +106,21 @@ class infolog_widget switch($type) { - case '': // Sum of the alternatives + case '': // Sum of the alternatives, field-name can be prefixed with a minus to substract it's value $cell['type'] = 'float'; $cell['size'] = ',,,%0.2lf'; $value = 0.0; foreach(explode(':',$alternatives) as $name) { - $value += str_replace(array(' ',','),array('','.'),$this->data[$name]); + if ($name[0] === '-') + { + $val = '-'.$this->data[substr($name, 1)]; + } + else + { + $val = $this->data[$name]; + } + $value += str_replace(array(' ',','), array('','.'), $val); } $alternatives = ''; break;