X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fcustomer-table.html;h=3c3f8b2ee32531b36310965ed9ddbd4d1324efa8;hb=e4c72328fb4c89eca20c4fe7645252ecb287ba89;hp=779b01c51e25b9ea69d582d61ce02807d5296b75;hpb=bb51c09147a727688b6cd49e8838b9219ff25d43;p=freeside.git diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html index 779b01c51..3c3f8b2ee 100644 --- a/httemplate/elements/customer-table.html +++ b/httemplate/elements/customer-table.html @@ -4,17 +4,37 @@ Example: include( '/elements/customer-table.html', + ### + # required + ### + #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 + '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 + ) @@ -79,6 +99,9 @@ Example: if ( name.length > 0 ) { customer.value = name; customer.setAttribute('magic', 'nosearch'); +% if ( $opt{custnum_update_callback} ) { + <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') +% } } else { customer.value = 'Not found'; customer.style.color = '#ff0000'; @@ -143,6 +166,9 @@ Example: customer_obj.style.display = ''; customer_select.style.display = 'none'; +% if ( $opt{custnum_update_callback} ) { + <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') +% } } else { @@ -204,6 +230,10 @@ Example: this.style.display = 'none'; customer_obj.style.display = ''; +% if ( $opt{custnum_update_callback} ) { + <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') +% } + } } @@ -232,12 +262,20 @@ Example: - " rownum="<% $row %>"> - + " + rownum = "<% $row %>" + > + @@ -264,14 +302,30 @@ Example: % } else { % $value = $param->{"$field$row"}; % } -% my $name = (ref($field) eq 'CODE') ? "column${col}_$row" : "$field$row"; -% my $size = $sizes->[$col] || 10; - +% 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{footer}->[$col] eq '_TOTAL' ) { +% $total[$col] += $value; +% $onchange = $opt{prefix}. "calc_total$col();"; +% $onchange = qq(onchange="$onchange" onkeyup="$onchange"); +% } + % if (! $types->[$col] || $types->[$col] eq 'text') { - + + > % } elsif ($types->[$col] eq 'immutable') { - <% $value %> - + <% $font %><% $value %><% $font ? '' : '' %> + % } else { Cannot represent unknown type: <% $types->[$col] %> % } @@ -282,9 +336,62 @@ Example: % } + + + 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++; +% } + + + <% include('/elements/xmlhttp.html', 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', 'subs' => [qw( custnum_search smart_search )], @@ -293,6 +400,9 @@ Example: