From 5250c44bd7f282c7d782bf0e8349af12376929df Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 22 Sep 2010 19:16:20 +0000 Subject: prepayment discounts rt#5318 --- httemplate/elements/customer-table.html | 13 +++++++++- httemplate/elements/select-discount_term.html | 32 ++++++++++++++++++++++++ httemplate/elements/tr-select-discount_term.html | 25 ++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 httemplate/elements/select-discount_term.html create mode 100644 httemplate/elements/tr-select-discount_term.html (limited to 'httemplate/elements') diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html index f00419f9c..3c3f8b2ee 100644 --- a/httemplate/elements/customer-table.html +++ b/httemplate/elements/customer-table.html @@ -22,6 +22,7 @@ Example: ### 'name_singular' => 'customer', #label + 'custnum_update_callback' => 'name_of_js_callback' #passed a rownum #listrefs 'types' => ['immutable', ''], # immutable or ''/text @@ -98,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'; @@ -162,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 { @@ -223,6 +230,10 @@ Example: this.style.display = 'none'; customer_obj.style.display = ''; +% if ( $opt{custnum_update_callback} ) { + <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') +% } + } } @@ -314,7 +325,7 @@ Example: > % } elsif ($types->[$col] eq 'immutable') { <% $font %><% $value %><% $font ? '' : '' %> - + % } else { Cannot represent unknown type: <% $types->[$col] %> % } diff --git a/httemplate/elements/select-discount_term.html b/httemplate/elements/select-discount_term.html new file mode 100644 index 000000000..26d877a86 --- /dev/null +++ b/httemplate/elements/select-discount_term.html @@ -0,0 +1,32 @@ +% if ( scalar(@discount_term) ) { + +% } +<%init> + +my %opt = @_; + +my $cgi = $opt{'cgi'}; + +my @discount_term; +if ( $opt{discount_term} ) { + + @discount_term = @{ $opt{discount_term} }; + +} else { + + my $custnum = $opt{'custnum'}; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or die "unknown custnum $custnum\n"; + + @discount_term = $cust_main->discount_terms; + +} + + diff --git a/httemplate/elements/tr-select-discount_term.html b/httemplate/elements/tr-select-discount_term.html new file mode 100644 index 000000000..58582675d --- /dev/null +++ b/httemplate/elements/tr-select-discount_term.html @@ -0,0 +1,25 @@ +% if ( scalar(@discount_term) ) { + + Prepayment for + + <% include('select-discount_term.html', + 'discount_term' => \@discount_term, + 'cgi' => $opt{'cgi'}, + ) + %> + + + +% } + +<%init> +my %opt = @_; + +my $custnum = $opt{'custnum'}; + +my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or die "unknown custnum $custnum\n"; + +my @discount_term = $cust_main->discount_terms; + + -- cgit v1.2.1