X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fcustomer-table.html;h=75e682d928fa359861503fbdcd588ab0c28d7f53;hb=afe30fc7315196cc4ae6da7606995cb8388d1a32;hp=fc298b03e0de99a199ab398bdc3f3acb296623a5;hpb=1b19010429786e0a2987573dc9dbff351091911e;p=freeside.git diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html index fc298b03e..75e682d92 100644 --- a/httemplate/elements/customer-table.html +++ b/httemplate/elements/customer-table.html @@ -1,18 +1,57 @@ -% # options example... -% # -% # #listrefs... -% # 'header' => [ '#', 'Item' ], -% # 'fields' => [ -% # 'column', -% # sub { my ($row,$param) = @_; $param->{"column$row"}; }, -% # ], -% # 'sizes' => [], # sizes ignored for immutable -% # 'types' => ['immutable', ''], # immutable or ''/text -% # 'param' => { column0 => 1 }, # preset column of row 0 to 1 -% # +<%doc> + +Example: + + include( '/elements/customer-table.html', + + ### + # required + ### + + #listrefs... + 'header' => [ '#', 'Item' ], + 'fields' => [ + 'column', + sub { my ($row,$param) = @_; + $param->{"column$row"}; + }, + ], + + ### + # optional + ### + + 'name_singular' => 'customer', #label + 'custnum_update_callback' => 'name_of_js_callback' #passed a rownum + + #listrefs + 'types' => ['immutable', ''], # immutable or ''/text + 'align' => [ 'c', 'l', 'r', '' ], + 'size' => [], # sizes ignored for immutable + 'color' => [], + 'footer' => ['string', '_TOTAL'], # strings or the special + #value _TOTAL + 'footer_align' => [ 'c', 'l', 'r', '' ], + + 'param' => { column0 => 1 }, # preset column of row 0 to 1 + + ) + +%doc>
Inv # | Cust # | +Status | Customer | +Balance | % foreach my $header ( @{$opt{header}} ) {<% $header %> | % } @@ -221,15 +401,61 @@ % my $row = 0; % for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { -|
---|---|---|---|---|---|---|
+ " + rownum = "<% $row %>" + > + + | - " rownum="<% $row %>"> - + " + rownum = "<% $row %>" + > + + | + ++ " + + ><% $param->{"status$row"} %> + " + rownum = "<% $row %>" + > + " + rownum = "<% $row %>" + > | @@ -248,6 +474,21 @@ | ++ <% $money_char %> + <% $param->{"balance$row"} %> + + " + rownum = "<% $row %>" + > + | + % my $col = 0; % foreach my $field ( @{$opt{fields}} ) { % my $value; @@ -256,35 +497,111 @@ % } else { % $value = $param->{"$field$row"}; % } -% my $name = (ref($field) eq 'CODE') ? "column${col}_$row" : "$field$row"; -% my $size = $sizes->[$col] || 10; --% if (! $types->[$col] || $types->[$col] eq 'text') { - +% my $name = (ref($field) eq 'CODE') ? "column${col}_$row" : "$field$row"; +% my $align = $align{ $opt{align}->[$col] || 'l' }; +% my $size = $sizes->[$col] || 10; +% my $color = $opt{color}->[$col]; +% my $font = $color ? qq() : ''; +% my $onchange = ''; +% if ( $opt{onchange}->[$col] ) { +% $onchange = 'onchange="'.$opt{onchange}->[$col].'"'; +% } +% elsif ( $opt{footer}->[$col] eq '_TOTAL' ) { +% $total[$col] += $value; +% $onchange = $opt{prefix}. "calc_total$col();"; +% $onchange = qq(onchange="$onchange" onkeyup="$onchange"); +% } + | +% my $type = $types->[$col] || 'text'; +% if ($type eq 'text' or $type eq 'checkbox') { + + > % } elsif ($types->[$col] eq 'immutable') { - <% $value %> - + <% $font %><% $value %><% $font ? '' : '' %> + % } else { Cannot represent unknown type: <% $types->[$col] %> % } | % $col++; % } -
+ Total <% $row ? $row-1 : 0 %> + <% PL($opt{name_singular} || 'customer', ( $row ? $row-1 : 0 ) ) %> + | +% 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"; +<% sprintf('%.2f', $total[$col] ) %> | +% } else { +<% $footer %> | +% } +% $col++; +% } +