I have a form with a calc element that takes the extended price of a repeating group, adds it up, tacks on the additional fees element then saves that as the grand total.
I've been fiddling with this element for a few days now as it caused all sorts of problems syntax wise when I moved up our PHP version, I've straightened out all the syntax errors but now the calculations are coming back with some unusual results.
This is the code as it exists today. As an example I created a test record where the grand total should have come back as $1 but instead came back as $74. I have no idea where its getting the values from that allows it to calculate up to an amount that high.
Any guidance would be greatly appreciated.
I've been fiddling with this element for a few days now as it caused all sorts of problems syntax wise when I moved up our PHP version, I've straightened out all the syntax errors but now the calculations are coming back with some unusual results.
PHP:
$po_id = '{purchase_orders___id}';
$mydb = JFactory::getDbo();
$myquery = $mydb->getQuery(true);
$myquery
->select('ext_price')
->from('purchase_orders_30_repeat')
->where('parent_id = ' . $po_id);
$all_ext_price = $mydb->loadColumn();
$subtotal = array_sum($all_ext_price);
$grand_total = $subtotal + '{purchase_orders___additional_fees}';
return $grand_total;
This is the code as it exists today. As an example I created a test record where the grand total should have come back as $1 but instead came back as $74. I have no idea where its getting the values from that allows it to calculate up to an amount that high.
Any guidance would be greatly appreciated.