X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-discount_term.html;h=e9faeb228175bc840e3c56862e9a7ca658f21c89;hp=58582675d35681de0839ebe57c6ac48bc1bcd763;hb=c5e31619e5a3071506cff19578e9e377753a96f4;hpb=9dafe1bcc38121281d62ffe2d48eba6b8fd748e7 diff --git a/httemplate/elements/tr-select-discount_term.html b/httemplate/elements/tr-select-discount_term.html index 58582675d..e9faeb228 100644 --- a/httemplate/elements/tr-select-discount_term.html +++ b/httemplate/elements/tr-select-discount_term.html @@ -1,12 +1,33 @@ % if ( scalar(@discount_term) ) { - Prepayment for + <% emt('Prepayment for') %> +% if ( $amount_id ) { + +% } - <% include('select-discount_term.html', - 'discount_term' => \@discount_term, - 'cgi' => $opt{'cgi'}, - ) - %> + <& select.html, + field => 'discount_term', + id => 'discount_term', + options => [ '', @discount_term ], + labels => { '' => mt('1 month'), + map { $_ => mt('[_1] months', $_) } @discount_term }, + curr_value => '', + onchange => $amount_id ? 'change_discount_term(this)' : '', + &> @@ -20,6 +41,16 @@ 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; +my @discount_term = (); +my %discounted_total = (); +my $last_bill = ($cust_main->cust_bill)[-1]; +if ( $last_bill ) { # if not, there are no discounts possible + my %plans = $last_bill->discount_plans; + @discount_term = sort { $a <=> $b } keys %plans; + %discounted_total = map { $_, $plans{$_}->discounted_total } @discount_term; +} + +# the DOM id of an input to be disabled/populated with the amount due +my $amount_id = $opt{'amount_id'};