From e8bc6dcd197b0b9da834ebeabfed6f82dc6721a1 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 8 Jan 2016 13:35:35 +0000 Subject: [PATCH] Fix not working subtraction option for infolog-value widget --- etemplate/js/et2_widget_entry.js | 5 +++-- infolog/inc/class.infolog_widget.inc.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/etemplate/js/et2_widget_entry.js b/etemplate/js/et2_widget_entry.js index 26cfbdbecf..8bc24fdf88 100644 --- a/etemplate/js/et2_widget_entry.js +++ b/etemplate/js/et2_widget_entry.js @@ -45,7 +45,7 @@ var et2_entry = et2_valueWidget.extend( }, alternate_fields: { name: 'Alternate fields', - description: 'colon (:) separated list of alternative fields. The first non-empty one is used if the selected field is empty', + description: 'colon (:) separated list of alternative fields. The first non-empty one is used if the selected field is empty, (-) used for subtraction', type: 'string', default: et2_no_init }, @@ -134,7 +134,8 @@ var et2_entry = et2_valueWidget.extend( var fields = this.options.alternate_fields.split(':'); for(var i = 0; i < fields.length; i++) { - var value = this.getArrayMgr('content').getEntry(fields[i]); + var value = (fields[i][0] == "-")? this.getArrayMgr('content').getEntry(fields[i].replace('-',''))*-1: + this.getArrayMgr('content').getEntry(fields[i]); sum += parseFloat(value); if(value && this.options.field !== 'sum') { diff --git a/infolog/inc/class.infolog_widget.inc.php b/infolog/inc/class.infolog_widget.inc.php index 4fcb0b147a..990774a395 100644 --- a/infolog/inc/class.infolog_widget.inc.php +++ b/infolog/inc/class.infolog_widget.inc.php @@ -10,6 +10,17 @@ * @version $Id$ */ +/** + * Infolog widget et2 representation: + * Both infolog-value and infolog-fields widgets are using client-side et2_widget_entry + * and the format to address them in template is as follows: + * + * + * + */ + /** * eTemplate extension: InfoLog widget *