X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2FApplicationCommon.html;h=b46a3c8fe21eb18201ea690f911996363cf86d49;hp=a485d37de5e47837e2b24ec9a824bcca3afa3b51;hb=64fcb43c61c196766260319cd9219eb70ea27767;hpb=08ab7010467cf25578acdf8d9a9a068a87f1c49f diff --git a/httemplate/edit/elements/ApplicationCommon.html b/httemplate/edit/elements/ApplicationCommon.html index a485d37de..b46a3c8fe 100644 --- a/httemplate/edit/elements/ApplicationCommon.html +++ b/httemplate/edit/elements/ApplicationCommon.html @@ -90,16 +90,71 @@ function changed(what) { if ( dst == <% $dst->$dst_pkey %> ) { what.form.amount.value = "<% min($dst->$dst_unapplied, $unapplied) %>"; +% if ($use_sub_dst_thing) { + what.form.display_amount.value = "<% min($dst->$dst_unapplied, $unapplied) %>"; + + var rownum=0 + var table = document.getElementById('ApplicationTable'); + while(table.rows[2]) { + table.deleteRow(2); + } +% my $app_class = "FS::$link_table"; +% my $temp_app = $app_class->new( +% { $src_pkey => $src_pkeyvalue, +% $dst_pkey => $dst->$dst_pkey, +% 'amount' => min($dst->$dst_unapplied, $unapplied), +% } +% ); +% my %apphash = (); +% my $listref_or_error = $temp_app->calculate_applications; +% %apphash = map { &{$key_generator}($_), $_ } @$listref_or_error +% if ref($listref_or_error); +% foreach my $cbp ( $dst->open_cust_bill_pkg ) { +% my $desc = $cbp->desc; +% my $total_owed = $cbp->owed_setup + $cbp->owed_recur; +% my $key = &{$key_generator}([ $cbp, 0, {} ]); +% my $amount = exists($apphash{ $key }) ? $apphash{ $key }->[1] : 0; +% unless ( $cbp->pkgnum ) { +% foreach my $taxX ( $cbp->cust_bill_pkg_tax_Xlocation ) { +% my $pkey = $taxX->primary_key; +% my $owed = $taxX->owed; +% my $key = &{$key_generator}([ $cbp, 0, { $pkey => $taxX->$pkey } ]); +% my $toapp = exists($apphash{ $key }) ? $apphash{ $key }->[1] : 0; + <% &{$row_generator}( $cbp, $taxX->desc, $owed, $toapp, $taxX->$pkey ) %> +% $total_owed -= $owed; +% $amount -= $toapp; +% } +% $desc .= ' (default)'; +% } +% if ( $total_owed > 0 ) { + <% &{$row_generator}($cbp, $desc, $total_owed, $amount, '') %> +% } +% } +% } } % } } + +function sub_changed(what) { + + var amount = 0; + var table = document.getElementById('ApplicationTable'); + var i = table.rows.length; + while(i-- > 2) { + var amount_input = table.rows[i].getElementsByTagName('input').item(0); + amount += parseFloat( amount_input.value ) || 0; + } + what.form.amount.value = parseFloat(amount).toFixed(2); + what.form.display_amount.value = parseFloat(amount).toFixed(2); + +} Apply to: -
<% $dst_thing %>: | @@ -116,7 +171,10 @@ Apply to:||
Amount: | -<% $money_char %> | +<% $money_char %> STYLE="text-align:right;"> | +% if ($use_sub_dst_thing) { + +% }