Page 1 of 1

tablename_init() hook

Posted: 2013-06-27 14:26
by frankotse
appGiniForum.jpg
Photo
appGiniForum.jpg (151.54 KiB) Viewed 3383 times
Is it possible to use tablename_init() hook to update data.

EstimateItem is child table of Product and EstimateForm
When update Product.price will use below script to update EstimateItem contains updated Product.

function Product_after_update($data, $memberInfo, &$args){

// update item price
$id=$data['selectedID'];
$product_price=$data['id'];
$price=sqlValue("select Product.price from Product where id='$product_price'");
sql("update EstimateItem set total='$price'*qty where EstimateItem.price='$product_price'", $eo);

return TRUE;
}


I use below script to update EstimateForm contains updated EstimateItem.

function EstimateForm_after_update($data, $memberInfo, &$args){
updateEstimateTotals($data['selectedID']);
return TRUE;
}


function updateEstimateTotals($estimate_codeID){
// update EstimateForm estimate_total, other_total and total
$estimate_codeID=makeSafe($estimate_codeID);
$total1=sqlValue("select sum(total) from EstimateItem where estimate_code='$estimate_codeID'");
$total2=sqlValue("select sum(total) from OtherItem where estimate_code='$estimate_codeID'");
$total=$total1 + $total2;
sql("update EstimateForm set estimate_total='$total1' where id='$estimate_codeID'", $eo);
sql("update EstimateForm set other_total='$total2' where id='$estimate_codeID'", $eo);
sql("update EstimateForm set total='$total' where id='$estimate_codeID'", $eo);
}
Problem is that EstimateForm contains updated EstimateItem does not update when directly open it or by link from EstimateItem.

I use below script but not worked.

function EstimateForm_init(&$options, $memberInfo, &$args){
updateEstimateTotals($data['selectedID']);

return TRUE;
}

Re: tablename_init() hook

Posted: 2013-07-02 19:18
by toconnell
I am sorry I can not help with this.. but would love to know how you got your arrows for previous and next to appear together at the bottom custom like that?

Your advise would be appreciated.

Thank you,
Tina