allow to prefix alternative name with a minus to substract instead of adding its value

This commit is contained in:
Ralf Becker 2014-01-06 13:05:51 +00:00
parent 86df1da45b
commit 44d5801015

View File

@ -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;