Calculating total amount of detail sub-form.

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Thomas Pang
Posts: 11
Joined: 2015-04-14 16:16

Calculating total amount of detail sub-form.

Post by Thomas Pang » 2015-04-24 12:39

Hi,

I create an orders(parent table) and order_details(sub-form table), I would like to sum the Amount of sub-form table and update to the field called SubTotal of the parent table:

// OrderID_D - sub-form field that contain order id, Amount - total of each item
// SubTotal - parent field to keep total item amount of sub-form table
$id = makeSafe($data['OrderID_D']);
$tot = sqlValue("SELECT SUM(Amount) FROM order_details WHERE OrderID_D='$id' ");
sql("UPDATE orders SET SubTotal = '$tot' WHERE OrderID='$id'", $eo);

I get zero SubTotal after keeping the above code in the sub-form function order_details_after_update($data, $memberInfo, &$args), am I coded wrongly or keeping at the wrong function?

Any help will be appreciated.

Regards

Thomas Pang
-----------------------------------
Thomas Pang
[email protected]
AppGini 25.13
Summary Report 3.4
Customizing AppGini web applications (Udemy)

Satya Kavala
Veteran Member
Posts: 45
Joined: 2015-04-15 06:33
Location: Hyderabad
Contact:

Re: Calculating total amount of detail sub-form.

Post by Satya Kavala » 2015-05-21 06:27

Hello Thomas,
Please Check Your PM.
Thanks&Regards
Satya Kavala
[email protected]

vdubuk
Posts: 3
Joined: 2016-02-26 08:08

Re: Calculating total amount of detail sub-form.

Post by vdubuk » 2016-02-26 08:10

Hi Thomas, did you manage to work out how to do it?

Post Reply