X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fcustomer-table.html;h=79443dc8b95ab147730587ad5691800902ea0a2e;hb=15dbf6151b7e6e3b32e55fd6609725f650349460;hp=89e54d7038972d42435632e7b4cc02cad7a05cbd;hpb=0d75dc389fccdb680237aa1e244e13d254d12f02;p=freeside.git diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html index 89e54d703..79443dc8b 100644 --- a/httemplate/elements/customer-table.html +++ b/httemplate/elements/customer-table.html @@ -41,6 +41,8 @@ Example: @@ -362,16 +383,17 @@ Example: + + % foreach my $header ( @{$opt{header}} ) { % } - % my $row = 0; % for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { - + + + + + % my $col = 0; % foreach my $field ( @{$opt{fields}} ) { % my $value; @@ -436,19 +495,24 @@ Example: % my $color = $opt{color}->[$col]; % my $font = $color ? qq() : ''; % my $onchange = ''; -% if ( $opt{footer}->[$col] eq '_TOTAL' ) { +% 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"); % } % $col++; % } - % } - - + @@ -548,7 +601,8 @@ Example: var table = document.getElementById('<% $opt{prefix} %>OneTrueTable'); var tablebody = table.getElementsByTagName('tbody').item(0); - var row = table.insertRow(rownum+1); + var row = table.insertRow(table.rows.length - 1); + row.setAttribute('id', 'row'+rownum); var invnum_cell = document.createElement('TD'); @@ -579,6 +633,31 @@ Example: custnum_cell.appendChild(custnum_input); row.appendChild(custnum_cell); + + var status_cell = document.createElement('TD'); + status_cell.style.textAlign = 'center'; + + var status_span = document.createElement('SPAN'); + status_span.setAttribute('id', 'status'+<% $opt{prefix} %>rownum+'_text'); + status_span.style.fontWeight = 'bold'; + status_span.setAttribute('rownum', <% $opt{prefix} %>rownum); + status_cell.appendChild(status_span); + + var status_input = document.createElement('INPUT'); + status_input.setAttribute('type', 'hidden'); + status_input.setAttribute('name', 'status'+<% $opt{prefix} %>rownum); + status_input.setAttribute('id', 'status'+<% $opt{prefix} %>rownum); + status_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + status_cell.appendChild(status_input); + + var statuscolor_input = document.createElement('INPUT'); + statuscolor_input.setAttribute('type', 'hidden'); + statuscolor_input.setAttribute('name', 'statuscolor'+<% $opt{prefix} %>rownum); + statuscolor_input.setAttribute('id', 'statuscolor'+<% $opt{prefix} %>rownum); + statuscolor_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + status_cell.appendChild(statuscolor_input); + + row.appendChild(status_cell); var customer_cell = document.createElement('TD'); @@ -603,6 +682,29 @@ Example: customer_cell.appendChild(customer_select); row.appendChild(customer_cell); + + var balance_cell = document.createElement('TD'); + + balance_cell.style.textAlign = 'right'; + balance_cell.appendChild(document.createTextNode('<%$money_char%>')); + + var balance_span = document.createElement('SPAN'); + balance_span.setAttribute('id', 'balance'+<% $opt{prefix} %>rownum+'_text'); + balance_span.setAttribute('rownum', <% $opt{prefix} %>rownum); + balance_cell.appendChild(balance_span); + + balance_cell.appendChild( + document.createTextNode(String.fromCharCode(160)) //  + ); + + var balance_input = document.createElement('INPUT'); + balance_input.setAttribute('type', 'hidden'); + balance_input.setAttribute('name', 'balance'+<% $opt{prefix} %>rownum); + balance_input.setAttribute('id', 'balance'+<% $opt{prefix} %>rownum); + balance_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + balance_cell.appendChild(balance_input); + + row.appendChild(balance_cell); % my $col = 0; % foreach my $field ( @{$opt{fields}} ) { @@ -617,19 +719,27 @@ Example: % } else { % $value = $param->{"$field$row"}; % } - var my_text = document.createTextNode('<% $value %>'); + var my_text = document.createTextNode(<% $value |js_string %>); my_cell.appendChild(my_text); % } +% my $name = (ref($field) eq 'CODE') ? "column${col}_" : $field; var my_input = document.createElement('INPUT'); - my_input.setAttribute('name', '<% $field %>'+<% $opt{prefix} %>rownum); - my_input.setAttribute('id', '<% $field %>'+<% $opt{prefix} %>rownum); + my_input.setAttribute('name', '<% $name %>'+<% $opt{prefix} %>rownum); + my_input.setAttribute('id', '<% $name %>'+<% $opt{prefix} %>rownum); my_input.style.textAlign = '<% $align{ $opt{align}->[$col] || 'l' } %>'; my_input.setAttribute('size', <% $sizes->[$col] || 10 %>); -% if ($types->[$col] eq 'immutable') { + my_input.setAttribute('rownum', <% $opt{prefix} %>rownum); +% if ( $types->[$col] eq 'immutable' ) { my_input.setAttribute('type', 'hidden'); % } -% if ( $opt{footer}->[$col] eq '_TOTAL' ) { +% elsif ( $types->[$col] eq 'checkbox' ) { + my_input.setAttribute('type', 'checkbox'); +% } +% if ( $opt{onchange}->[$col] ) { + my_input.onchange = <% $opt{onchange}->[$col] %>; +% } +% elsif ( $opt{footer}->[$col] eq '_TOTAL' ) { my_input.onchange = <% $opt{prefix} %>calc_total<%$col%>; my_input.onkeyup = <% $opt{prefix} %>calc_total<%$col%>; % } @@ -640,21 +750,6 @@ Example: % $col++; % } - var balance_cell = document.createElement('TD'); - - var balance_input = document.createElement('INPUT'); - balance_input.setAttribute('name', 'balance'+<% $opt{prefix} %>rownum); - balance_input.setAttribute('id', 'balance'+<% $opt{prefix} %>rownum); - balance_input.style.textAlign = 'right'; - balance_input.setAttribute('size', 8); - balance_input.setAttribute('maxlength', 12); - balance_input.setAttribute('rownum', <% $opt{prefix} %>rownum); - balance_input.disabled = true; - balance_input.style.backgroundColor = '#dddddd'; - balance_cell.appendChild(balance_input); - - row.appendChild(balance_cell); - //update the total # of rows display if ( <% $opt{prefix} %>rownum == 1 ) { <% $opt{prefix} %>total_el.innerHTML = @@ -668,6 +763,11 @@ Example: + ' <% PL($opt{name_singular} || 'customer') %>'; } +% if ( $opt{add_row_callback} ) { + <% $opt{add_row_callback} %>(<% $opt{prefix} %>rownum, + '<% $opt{prefix} %>'); +% } + <% $opt{prefix} %>rownum++; } @@ -680,11 +780,12 @@ Example: <%init> my(%opt) = @_; +my $conf = new FS::Conf; $opt{prefix} = '' unless defined $opt{prefix}; $opt{prefix} .= '_' if $opt{prefix}; -my $types = $opt{'types'} ? [ @{$opt{'types'}} ] : []; +my $types = $opt{'type'} ? [ @{$opt{'type'}} ] : []; my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : []; my $param = $opt{param}; @@ -700,4 +801,5 @@ my %align = ( 'c' => 'center', ); +my $money_char = $conf->config('money_char') || '$';
Inv # Cust #Status CustomerBalance<% $header %>Balance
.onchange = <% $opt{prefix} %>search_custnum; + " + + ><% $param->{"status$row"} %> + " + rownum = "<% $row %>" + > + " + rownum = "<% $row %>" + > + " rownum="<% $row %>"> @@ -422,6 +466,21 @@ Example: + <% $money_char %> + <% $param->{"balance$row"} %> +   + " + rownum = "<% $row %>" + > + -% if (! $types->[$col] || $types->[$col] eq 'text') { - [$col] || 'text'; +% if ($type eq 'text' or $type eq 'checkbox') { + > % } elsif ($types->[$col] eq 'immutable') { @@ -460,22 +524,11 @@ Example: - " - rownum = "<% $row %>" - > -
+
Total <% $row ? $row-1 : 0 %> <% PL($opt{name_singular} || 'customer', ( $row ? $row-1 : 0 ) ) %>