X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pay.cgi;h=cc4ec605dee2e596b5360a72a2d63c14b062a85b;hp=755050bd81b649f464ba30f2a62ea004b88c409f;hb=37591b61f8ad6fc5c5acb2fd8f520d2dbe4f1539;hpb=e84dda39cd83ef67dd2debd7d06d97d1a124b598 diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index 755050bd8..cc4ec605d 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,153 +1,149 @@ - -<% +% if ( $link eq 'popup' ) { + <% include('/elements/header-popup.html', $title ) %> +% } else { + <% include("/elements/header.html", $title, '') %> +% } -my $conf = new FS::Conf; +<% include('/elements/init_calendar.html') %> -my($link, $linknum, $paid, $payby, $payinfo, $quickpay, $_date); -if ( $cgi->param('error') ) { - $link = $cgi->param('link'); - $linknum = $cgi->param('linknum'); - $paid = $cgi->param('paid'); - $payby = $cgi->param('payby'); - $payinfo = $cgi->param('payinfo'); - $quickpay = $cgi->param('quickpay'); - $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time; -} elsif ($cgi->keywords) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $link = 'invnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ""; - $quickpay = ''; - $_date = time; -} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $link = 'custnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ''; - $quickpay = $cgi->param('quickpay'); - $_date = time; -} else { - die "illegal query ". $cgi->keywords; -} - -my $paybatch = "webui-$_date-$$-". rand() * 2**32; +<% include('/elements/error.html') %> -%> +% unless ( $link eq 'popup' ) { + <% small_custview($custnum, $conf->config('countrydefault')) %> +% } -<%= header("Post payment", '') %> +
+ + + + -<% if ( $cgi->param('error') ) { %> -Error: <%= $cgi->param('error') %>

-<% } %> - -<%= ntable("#cccccc",2) %> - - - - - - - - - - -<% -my $custnum; -if ( $link eq 'invnum' ) { - - my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } ) - or die "unknown invnum $linknum"; - print "Invoice #$linknum". ntable("#cccccc",2). - 'Date'. - time2str("%D", $cust_bill->_date). ''. - 'Items'; - foreach ( $cust_bill->cust_bill_pkg ) { #false laziness with FS::cust_bill - if ( $_->pkgnum ) { - - my($cust_pkg)=qsearchs('cust_pkg', { 'pkgnum', $_->pkgnum } ); - my($part_pkg)=qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->pkgpart}); - my($pkg)=$part_pkg->pkg; - - if ( $_->setup != 0 ) { - print "$pkg Setup
"; # $money_char. sprintf("%10.2f",$_->setup); - print join('
', - map { " ". $_->[0]. ": ". $_->[1] } $cust_pkg->labels - ). '
'; - } - - if ( $_->recur != 0 ) { - print - "$pkg (" . time2str("%x",$_->sdate) . " - " . - time2str("%x",$_->edate) . ")
"; - #$money_char. sprintf("%10.2f",$_->recur) - print join('
', - map { '--->'. $_->[0]. ": ". $_->[1] } $cust_pkg->labels - ). '
'; - } - - } else { #pkgnum Tax - print "Tax
" # $money_char. sprintf("%10.2f",$_->setup) - if $_->setup != 0; - } - - } - print '

'; - - $custnum = $cust_bill->custnum; - -} elsif ( $link eq 'custnum' ) { - $custnum = $linknum; -} -%> - -<%= small_custview($custnum, $conf->config('countrydefault')) %> - - - -

Payment -<%= ntable("#cccccc", 2) %> +<% ntable("#cccccc", 2) %> + Date - "> + + + Amount - $ - - - - Check # - + <% $money_char %> + by <% FS::payby->payname($payby) %> + +% if ( $payby eq 'BILL' ) { + + Check # + + +% } + +% if ( $link eq 'custnum' || $link eq 'popup' ) { + Auto-apply
to invoices - + + + + +% } elsif ( $link eq 'invnum' ) { + + Apply to + Invoice #<% $linknum %> only + + +% } - +% if ( $conf->exists('pkg-balances') ) { + <% include('/elements/tr-select-cust_pkg-balances.html', + 'custnum' => $custnum, + 'cgi' => $cgi + ) + %> +% } else { + +% } - +
-
- - + + + +% if ( $link eq 'popup' ) { + + +% } else { + <% include('/elements/footer.html') %> +% } + +<%init> + +my $conf = new FS::Conf; + +my $money_char = $conf->config('money_char') || '$'; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Post payment'); + +my($link, $linknum, $paid, $payby, $payinfo, $_date); +if ( $cgi->param('error') ) { + $link = $cgi->param('link'); + $linknum = $cgi->param('linknum'); + $paid = $cgi->param('paid'); + $payby = $cgi->param('payby'); + $payinfo = $cgi->param('payinfo'); + $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time; +} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { + $link = $cgi->param('popup') ? 'popup' : 'custnum'; + $linknum = $1; + $paid = ''; + $payby = $cgi->param('payby') || 'BILL'; + $payinfo = ''; + $_date = time; +} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { + $link = 'invnum'; + $linknum = $1; + $paid = ''; + $payby = $cgi->param('payby') || 'BILL'; + $payinfo = ""; + $_date = time; +} else { + die "illegal query ". $cgi->keywords; +} + +my $paybatch = "webui-$_date-$$-". rand() * 2**32; + +my $title = 'Post '. FS::payby->payname($payby). ' payment'; +$title .= " against Invoice #$linknum" if $link eq 'invnum'; + +my $custnum; +if ( $link eq 'invnum' ) { + my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } ) + or die "unknown invnum $linknum"; + $custnum = $cust_bill->custnum; +} elsif ( $link eq 'custnum' || $link eq 'popup' ) { + $custnum = $linknum; +} + +