Page 1 of 1

calculation in AppGini with hook

Posted: 2013-10-03 11:57
by espo
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.

Re: calculation in AppGini with hook

Posted: 2013-10-03 12:04
by espo
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);
}