Re: [htmltmpl] Can HTML::Template do subtotals?
Brought to you by:
samtregar
From: Mathew R. <mat...@re...> - 2004-01-01 23:07:41
|
Since you are stuffing the H::T loop with the dollar value for the = "current month" and "year-to-date" values, why not calculate the running = sub-total and stick that on the loop as well. Then in your template you = can, for example, use a <TMPL_IF EXPR=3D"__counter % 4">...</TMPL_IF> = syntax to display the sub-total at every 4th position. Having the sub-total available for each row allows the template file to = choose when it wants to display the sub-total. ----- Original Message -----=20 From: LDT=20 To: htm...@li...=20 Sent: Thursday, January 01, 2004 12:27 AM Subject: [htmltmpl] Can HTML::Template do subtotals? This is my first project using Perl and HTML::Template, and my first = posting to this users list (after searching = http://www.bluedot.net/mail/archive/ for things like "totals" and "total = row" and "subtotal"). =20 I'm trying to figure out how to insert subtotals periodically and to = calculate differences between two rows. For example, this is a mock up = similar to what I'm doing (mine is more complex): accounts curr month year-to-date 10-19 $xxx $xxx 20-29 $xxx $xxx 30-39 $xxx $xxx sub1 10-39 $xxxxx $xxxxx 40-49 $xxx $xxx 50-59 $xxx $xxx sub2 40-59 $xxxx $xxxx grand total $xxxxx $xxxxx diff b/w sub1 & sub 2 $xxx $xxx Right now, I'm using several case statements in my Sybase SQL and = several unions (which I know is pretty ugly)... but if I could get = HTML::Template and Perl to play nicely together and let me generate = occasional subtotals along the way (or differences as the case may be), = that would be great. Does HTML::Template have a way to do this? I have = the H:T documentation printed out (because I refer to it so often), and = I'm wondering if a TMPL_IF might be the answer. But, I can't wrap my = brain around how I could use it for subtotalling and differences. Oh, and feel free to dumb it down for me since I'm new to Perl, SQL, = [insert language here]. ;-) Thanks! Lori P.S. I didn't include my Perl code because I wasn't sure if it would = be necessary (and it's 600+ lines), but for the masochists among you, = you can see it here along with the .tmpl file: = http://www.perlmonks.org/index.pl?node_id=3D108949&user=3DLori713. The = .tmpl file is also included below: <!-- Begin Summary Report --> <TMPL_INCLUDE 'nc_start.tmpl'> <TMPL_INCLUDE 'nc_style.tmpl'> <TMPL_INCLUDE 'nc_titlebar.tmpl'> <TMPL_INCLUDE 'nc_rpt_hdr.tmpl'> <hr> <form name=3Dfrm_summ_rept method=3DPOST = action=3D"http://www.ncsu.edu"> <table border=3D1 cellspacing=3D0 cellpadding=3D1 width=3D"100%" = summary=3D"Column Headings and Data Cells"> <tr valign=3D"bottom"> <th width=3D"9%">Account Summary</th> <th width=3D"18%">Description</th> <th width=3D"4%">Current FTE</th> <th width=3D"9%">Current Budget</th> <th width=3D"9%">Current Month Activity</th> <th width=3D"9%">FYTD Activity</th> <th width=3D"9%">Pre-Encumbrances</th> <th width=3D"9%">Encumbrances</th> <th width=3D"11%">Budget Balance Available</th> <th width=3D"4%">Future FTE</th> <th width=3D"9%">Future Budget</th> </tr> <TMPL_LOOP NAME=3Dpassacts> <tr class=3D<TMPL_VAR NAME=3Dtrclass> bgcolor=3D<TMPL_VAR = NAME=3Dbgcolor>> <td align=3D"left" style=3D"cursor:pointer;cursor:hand;" onmouseover=3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <font color=3D#000000><TMPL_VAR = NAME=3Dcol_acct></td> <td align=3D"left" style=3D"cursor:pointer;cursor:hand;" title=3D"Account(s) <TMPL_VAR NAME=3Dcol_acct>"> <font color=3D#000000><TMPL_VAR = NAME=3Dcol_descr></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_cfte></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_cbud></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_cmo></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_fytd></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_pre></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_enc></td> <td align=3D"right"><TMPL_VAR NAME=3Dcol_bba></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_ffte></td> <td align=3D"right" style=3D"cursor:pointer;cursor:hand;"=20 title=3D"Click to drill down" onmouseover=3D"style.background=3D'#CCCCFF';"=20 onmouseout =3D"style.background=3D'<TMPL_VAR = NAME=3Dbgcolor>';"> <TMPL_VAR NAME=3Dcol_fbud></td> </tr> </TMPL_LOOP> </table> </form> <TMPL_INCLUDE 'nc_buttons.tmpl'> <TMPL_INCLUDE 'nc_end.tmpl'> <!-- End Summary Report --> -------------------------------------------------------------------------= ----- Do you Yahoo!? Yahoo! Photos - Get your photo on the big screen in Times Square |