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.
calculation in AppGini with hook
Re: calculation in AppGini with hook
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);
}
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);
}