X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2FApplicationCommon.html;h=a531eaad4963cb751a90ed5777d78662967cca95;hb=acb39631e91c32eff550eb756e06d7465c2a1b2c;hp=b46a3c8fe21eb18201ea690f911996363cf86d49;hpb=64fcb43c61c196766260319cd9219eb70ea27767;p=freeside.git diff --git a/httemplate/edit/elements/ApplicationCommon.html b/httemplate/edit/elements/ApplicationCommon.html index b46a3c8fe..a531eaad4 100644 --- a/httemplate/edit/elements/ApplicationCommon.html +++ b/httemplate/edit/elements/ApplicationCommon.html @@ -3,46 +3,47 @@ Examples: #cust_bill_pay - include('elements/ApplicationCommon.html', - 'form_action' => 'process/cust_bill_pay.cgi', + <& elements/ApplicationCommon.html, + 'form_action' => 'process/cust_bill_pay.cgi, 'src_table' => 'cust_pay', 'src_thing' => 'payment', 'dst_table' => 'cust_bill', 'dst_thing' => 'invoice', - ) + &> #cust_credit_bill - include('elements/ApplicationCommon.html', - 'form_action' => 'process/cust_credit_bill.cgi', + <& elements/ApplicationCommon.html', + 'form_action' => 'process/cust_credit_bill.cgi, 'src_table' => 'cust_credit', 'src_thing' => 'credit', 'dst_table' => 'cust_bill', 'dst_thing' => 'invoice', - ) + &> #cust_pay_refund - include('elements/ApplicationCommon.html', - 'form_action' => 'process/cust_pay_refund.cgi', + <& elements/ApplicationCommon.html', + 'form_action' => 'process/cust_pay_refund.cgi, 'src_table' => 'cust_pay', 'src_thing' => 'payment', 'dst_table' => 'cust_refund', 'dst_thing' => 'refund', - ) + &> #cust_credit_refund - include('elements/ApplicationCommon.html', + <& elements/ApplicationCommon.html, 'form_action' => 'process/cust_credit_refund.cgi', 'src_table' => 'cust_credit', 'src_thing' => 'credit', 'dst_table' => 'cust_refund', 'dst_thing' => 'refund', - ) + &> -<% include('/elements/header-popup.html', "Apply $src_thing$to" ) %> +<& /elements/header-popup.html, "Apply $src_thing$to", '', 'onLoad="myOnLoadFunction();"' &> -<% include('/elements/error.html') %> +<& /elements/error.html &> +

<% $src_thing %> #<% $src_pkeyvalue %>
@@ -52,23 +53,31 @@ Examples: Date: - <% time2str("%D", $src->_date) %> + <% time2str($date_format, $src->_date) %> Amount: - <% $money_char %><% $src->amount %> + <% $money_char %><% $src_amount %> + + +% if ($use_sub_dst_thing && $can_change_credit) { + + +% } + + Unapplied amount: - <% $money_char %><% $unapplied %> + <% $money_char %><% $unapplied %> % if ( $src_table eq 'cust_credit' ) { Reason: - <% $src->reason %> + <% $src->reason %> % } @@ -76,15 +85,37 @@ Examples:
Apply to: +% if ($use_sub_dst_thing && $src_pkey eq 'crednum') { +
+ + + + + +
+ + + +
+
+<& /elements/xmlhttp.html, + 'url' => $p.'misc/xmlhttp-calculate_taxes.html', + 'subs' => [ 'calculate_taxes' ], +&> + + +%} + @@ -162,7 +353,7 @@ Apply to: % if ($use_sub_dst_thing) { - + % }
Amount: <% $money_char %> STYLE="text-align:right;">

-
+
-<% include('/elements/footer.html') %> + +<& /elements/footer-popup.html &> <%init> my %opt = @_; my $conf = new FS::Conf; -my $money_char = $conf->config('money_char') || '$'; +my $money_char = $conf->config('money_char') || '$'; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; my $src_thing = ucfirst($opt{'src_thing'}); my $src_table = $opt{'src_table'}; @@ -209,13 +416,23 @@ my $use_sub_dst_thing = 0; $use_sub_dst_thing = 1 if ( $dst_table eq 'cust_bill' && $conf->exists("${link_table}_pkg-manual") ); +my $can_change_credit = 0; +$can_change_credit = 1 + if ( $src_table eq 'cust_credit' && + $FS::CurrentUser::CurrentUser->access_right('Post credit') && + $FS::CurrentUser::CurrentUser->access_right('Delete credit') + ); + my $to = $dst_table eq 'cust_refund' ? ' to Refund' : ''; -my($src_pkeyvalue, $amount, $dst_pkeyvalue); +$m->comp('/elements/handle_uri_query'); + +my($src_pkeyvalue, $amount, $dst_pkeyvalue, $src_amount); if ( $cgi->param('error') ) { $src_pkeyvalue = $cgi->param($src_pkey); $amount = $cgi->param('amount'); $dst_pkeyvalue = $cgi->param($dst_pkey); + $src_amount = $cgi->param('src_amount'); } else { my($query) = $cgi->keywords; $query =~ /^(\d+)$/; @@ -224,13 +441,13 @@ if ( $cgi->param('error') ) { $dst_pkeyvalue = ''; } -my $otaker = getotaker; - my $p1 = popurl(1); my $src = qsearchs($src_table, { $src_pkey => $src_pkeyvalue } ); die "$src_thing $src_pkeyvalue not found!" unless $src; +$src_amount = $src->amount unless $cgi->param('error'); + my $unapplied = $src->unapplied; my @dst = sort { $a->_date <=> $b->_date @@ -240,9 +457,11 @@ my @dst = sort { $a->_date <=> $b->_date qsearch($dst_table, { 'custnum' => $src->custnum } ); my $row_generator = sub { - my ($cust_bill_pkg, $desc, $owed, $amount, $taxXnum) = @_; + my ($key, $cust_bill_pkg, $desc, $owed, $amount, $taxXnum) = @_; + my ($num, $s_or_r, $taxlinenum) = split(':', $key); my $id = $cust_bill_pkg->pkgnum || 'Tax'; my $billpkgnum = $cust_bill_pkg->billpkgnum; + my $s_or_r = $cust_bill_pkg->setup > 0 ? 'setup' : 'recur'; $amount = sprintf("%.2f", $amount); qq! @@ -277,6 +496,20 @@ my $row_generator = sub { taxnum_input.setAttribute('rownum', rownum); taxnum_input.setAttribute('value', "$taxXnum"); amount_cell.appendChild(taxnum_input); + var s_or_r_input = document.createElement('INPUT'); + s_or_r_input.setAttribute('name', 's_or_r'+rownum); + s_or_r_input.setAttribute('id', 's_or_r'+rownum); + s_or_r_input.setAttribute('type', 'hidden'); + s_or_r_input.setAttribute('rownum', rownum); + s_or_r_input.setAttribute('value', "$s_or_r"); + amount_cell.appendChild(s_or_r_input); + var itemdesc_input = document.createElement('INPUT'); + itemdesc_input.setAttribute('name', 'itemdesc'+rownum); + itemdesc_input.setAttribute('id', 'itemdesc'+rownum); + itemdesc_input.setAttribute('type', 'hidden'); + itemdesc_input.setAttribute('rownum', rownum); + itemdesc_input.setAttribute('value', "$desc"); + amount_cell.appendChild(itemdesc_input); row.appendChild(pkg_cell); row.appendChild(amount_cell); rownum++; @@ -294,4 +527,24 @@ my $key_generator = sub { join(':', $cust_bill_pkg->billpkgnum, $setup_or_recur, $taxlinenum); }; +my $onload = 'return true;'; + +if ($cgi->param('error')) { + + my $set_sub_amounts = + join(';', map { "myform.subamount$_.value = ". $cgi->param("subamount$_") } + grep { /.+/ } + map { /^subnum(\d+)$/ ? $1 : '' } + $cgi->param + ); + $set_sub_amounts &&= "$set_sub_amounts;sub_changed(myform.subamount0)"; + + $onload = qq! + var myform = document.getElementById('ApplicationForm'); + changed(myform.elements['$dst_pkey']); + $set_sub_amounts; + return true; + !; +} +