calculation in AppGini with hook

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

calculation in AppGini with hook

Post by espo » 2013-10-03 11:57

Hello to all,

I would like to make a calculation in AppGini with hook.

table
id
item PRINTER
price 100
quantity 10
total 1000

I entered this

db_after_insert function ($ data, $ MemberInfo, & $ args) {

/ / Update item price
$id = $data ['SelectedID'];
$price = $data ['price'] * $data ['quantity'];
sql ("update db set price = '$price' where id = '$id'", $eo);

return TRUE;
}

and

db_after_update function ($ data, $ MemberInfo, & $ args) {

return db_after_insert ($ data, $ MemberInfo, $ args);
}

But the total does not appear on the screen.

Where did I go wrong?
Thank you very much.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: calculation in AppGini with hook

Post by espo » 2013-10-03 12:04

Hello,

I solved it.

The correct configuration is

db_after_insert function ($ data, $ MemberInfo, & $ args) {

/ / Update item price
$ id = $ data ['id'];
$ price = $ data ['price'] * $ data ['quantity'];
sql ("update db set total = '$ price' where id = '$ id'", $ o);

return TRUE;
}

and

db_after_update function ($ data, $ MemberInfo, & $ args) {

db_after_insert return ($ data, $ MemberInfo, $ args);
}

Post Reply