Categories > TinyButStrong general >

headergroup with ondata function

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Tom
Date: 2006-02-18
Time: 18:04

headergroup with ondata function

Having problem doing math inside of each headergroup(s)

Each group has quantity with which I use to calculate a balance for the group

The ondata function seems to be doing the math correctly - BUT it only does it for the final group (I tested this by doing order by DESC to verify)

Here's what I have done so far...
php
$sql="select * from reservations order by resnumber,id";
//$sql="select * from $table order by resnumber DESC, id";
$db->get_results($sql);
$TBS->MergeBlock('blk', $db);
$TBS->Show() ;
function reservation_balance($BlockName,&$CurrRec,$RecNum){
global $balance;
$CurrRec['memberlogin']=="Minimum" ?  $balance = $CurrRec['quantity'] : $balance=$balance - $CurrRec['quantity'];
}
html
<tr><td colspan=2>Reservations for SKU: <b>[blk.vendorsku;block=tr;headergrp=resnumber]</b> (vendor: [blk.vendorid])</td>
<td align=center >Order</td><td colspan=2   align=center>Amount</td></tr>

  <tr><td>&#160;</td><td> [blk.description;block=tr;headergrp=memberlogin;ondata=reservation_balance]</td>
  <td valign=top align=right>[blk.memberlogin]&#160;</td>
  <td valign=top align=right><font color=Teal>[blk.quantity]</font></td>
  <td valign=top align=left><font color=Teal>[blk.units]</font></td> <td>(bal: [var.balance])</td></tr>

Please, what am I doing incorrectly?

Thanks
Tom
By: Tom
Date: 2006-02-18
Time: 18:22

Re: headergroup with ondata function

Ooops...
You can see what the actual data looks like here
http://tomhenry.us/examples/myinventory/reservations.php
Thx,
Tom
By: Tom
Date: 2006-02-18
Time: 19:01

Re: headergroup with ondata function

Found it (stupido)
Needed to have
function reservation_balance($BlockName,&$CurrRec,$RecNum){
global $balance;
$CurrRec['memberlogin']=="Minimum" ?  $balance = $CurrRec['quantity'] : $balance=$balance - $CurrRec['quantity'];
$CurrRec['balance'] = $balance; // <<<<------- was missing this
}
Sorry to bother you,
Tom