+ // update the next available row number
+ if (thisrownum >= rownum) {
+ rownum = thisrownum + 1;
+ }
+
+ } // end of addRow
+
+
+</SCRIPT>
+
+<TABLE ID="OneTrueTable" CLASS="fsinnerbox">
+
+<TR>
+ <TH>Inv #</TH>
+ <TH>Cust #</TH>
+ <TH>Status</TH>
+ <TH>Customer</TH>
+ <TH>Balance</TH>
+% foreach my $header ( @{$opt{header}} ) {
+ <TH style="white-space: nowrap"><% $header %></TH>
+% }
+</TR>
+
+% my @rownums = sort { $a <=> $b } map /^custnum(\d+)$/, keys %$param;
+<TR id="row_total">
+ <TH COLSPAN=5 ID="_TOTAL_TOTAL">
+ Total <% @rownums || 0 %>
+ <% PL($opt{name_singular} || 'customer', ( @rownums || 0 ) ) %>
+ </TH>
+% my $col = 0;
+% foreach my $footer ( @{$opt{footer}} ) {
+% my $align = $align{ $opt{'footer_align'}->[$col] || 'c' };
+% if ($footer eq '_TOTAL' ) {
+% my $id = $opt{'fields'}->[$col];
+% $id = ref($id) ? "column${col}_TOTAL" : "${id}_TOTAL";
+ <TH ALIGN="<% $align %>" ID="<% $id %>"> <% sprintf('%.2f', $total[$col] ) %></TH>
+% } else {
+ <TH ALIGN="<% $align %>"><% $footer %></TH>
+% }
+% $col++;
+% }
+</TR>
+
+</TABLE>
+
+<SCRIPT TYPE="text/javascript">
+
+total_el =
+ document.getElementById("_TOTAL_TOTAL");
+
+rownum = 1; // really more of a "next row", used by addrow
+totalrows = 0; // will not include empty rows
+allrows = []; // will include empty rows
+
+% foreach my $row ( @rownums ) {
+% if ( grep($param->{$_.$row},qw(invnum display_custnum custnum status statuscolor customer balance),@{$opt{fields}} ) ) {
+
+addRow({
+ rownum:<% $row %>,
+ num_open:<% $param->{"num_open$row"} |js_string %>,
+ invnum:<% $param->{"invnum$row"} |js_string %>,
+ display_custnum:<% $param->{"display_custnum$row"} |js_string %>,
+ custnum:<% $param->{"custnum$row"} |js_string %>,
+ status:<% $param->{"status$row"} |js_string %>,
+ statuscolor:<% $param->{"statuscolor$row"} |js_string %>,
+ customer:<% $param->{"customer$row"} |js_string %>,
+ balance:<% $param->{"balance$row"} |js_string %>,
+% my $col = 0;
+% foreach my $field ( @{$opt{fields}} ) {
+% my $value;
+% if ( ref($field) eq 'CODE' ) {
+% $value = &{$field}($row,$param) || '';
+% } else {
+% $value = $param->{"$field$row"} || '';
+% }
+% my $name = (ref($field) eq 'CODE') ? "column${col}" : "$field";
+ <% $name %>:<% $value |js_string %>,
+% $col++;
+% }
+});
+% }
+% }
+
+addRow();
+
+% my $col = 0;
+% foreach my $footer ( @{$opt{footer}} ) {
+% if ($footer eq '_TOTAL' ) {
+% my $name = $opt{fields}->[$col];
+% $name = ref($name) ? "column$col" : $name;
+ var th_el = document.getElementById("<%$name%>_TOTAL");
+ function calc_total<% $col %>() {
+ var row = 0;
+ var total = 0;
+ for (i = 0; i < allrows.length; i++) {
+ var value = document.getElementById("<%$name%>"+allrows[i]).value;
+ value = parseFloat(value);
+ if ( ! isNaN(value) ) {
+ total = total + value;
+ }
+ }
+ th_el.innerHTML = ' ' + total.toFixed(2);
+ }
+ calc_total<% $col %>()
+% }
+% $col++;