Page 1 of 1

Great to be able to sum browse columns with nuGetBrowseSum()

Posted: Tue Mar 31, 2015 8:10 pm
by Fike
Hi,

I have just found that now nuBuilder can sum the records of browese columns using the php nuGetBrowseSum() function and it is great!

I made some tests and I found that when the browse columns have format the sum does not display correctly (as shown on image below)
img_01.png
This is because $fields variable inside the nuSumColumns($s) function found on line 1759 of nuapi.php file, includes the the format of the field tables.

Therefore I relpaced line 1769 of the nuapi.php file

from:

Code: Select all

$SQL->addField('SUM(IFNULL(' . $fields[$i] . ')');
to:

Code: Select all

               $pos = strpos($fields[$i],'ORMAT(');
                        if($pos === false)
                        {

                               $fld = $fields[$i];
                        }
                        else
                        {
                              $fld_for = explode('ORMAT(',$fields[$i]);
                              $fld_com = explode(',',$fld_for[1]);
                              $fld = $fld_com[0].",'')";
                        }
                        $SQL->addField('SUM(IFNULL(' . $fld . ')');
Now the sum of browse column displays correctly (as shown on image below)
img_02.png
If there is a better way to make the nuSumColumns($s) function to compute the sum correctly when using formatted fields please share it.

KInd regrads,

Fike

Re: Great to be able to sum browse columns with nuGetBrowseS

Posted: Fri Apr 24, 2015 1:25 am
by admin
Fike,

My only answer would be to create another hidden column that is not formatted and sum that.

Steven