X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pay.cgi;h=638679a46302765bc29dff277efcd4af55a38b5a;hb=3714fa41c5306981c9f500df13eea52c72d82545;hp=3c0dbb2fe448a6880088a09c4585d0096a9bca44;hpb=c14a267229fc0d6f2d2afdebab3bd34d825df2ef;p=freeside.git diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index 3c0dbb2fe..638679a46 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,84 +1,159 @@ -<% -# +% if ( $link eq 'popup' ) { + <% include('/elements/header-popup.html', $title ) %> +% } else { + <% include("/elements/header.html", $title, '') %> +% } + +<% include('/elements/init_calendar.html') %> + +<% include('/elements/error.html') %> + +% unless ( $link eq 'popup' ) { + <% small_custview($custnum, $conf->config('countrydefault')) %> +% } + +
+ + + + + +

+ +Payment +<% ntable("#cccccc", 2) %> + + + Date + + + + + + + + + + Amount + <% $money_char %> + by <% FS::payby->payname($payby) %> + + + <% include('/elements/tr-select-discount_term.html', + 'custnum' => $custnum, + 'cgi' => $cgi + ) + %> + +% 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 { + +% } + + -use strict; -use vars qw( $cgi $link $linknum $p1 $_date $payby $payinfo $paid ); -use Date::Format; -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl); +
+ -$cgi = new CGI; -cgisuidsetup($cgi); +
-if ( $cgi->param('error') ) { - $link = $cgi->param('link'); - $linknum = $cgi->param('linknum'); - $paid = $cgi->param('paid'); - $payby = $cgi->param('payby'); - $payinfo = $cgi->param('payinfo'); -} elsif ($cgi->keywords) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $link = 'invnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ""; -} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { - $link = 'custnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ''; -} else { - die "illegal query ". $cgi->keywords; -} -$_date = time; +% if ( $link eq 'popup' ) { + + +% } else { + <% include('/elements/footer.html') %> +% } -$p1 = popurl(1); -print header("Enter payment", ''); +<%init> -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); +my $conf = new FS::Conf; -print < - - -END +my $money_char = $conf->config('money_char') || '$'; +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; -if ( $link eq 'invnum' ) { - print "Invoice #$linknum"; -} elsif ( $link eq 'custnum' ) { - print "Customer #$linknum"; +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; } -print qq!
Date: !, time2str("%D",$_date), qq!!; - -print qq!
Amount \$!; - -print qq!
Payby: $payby!; - -#payinfo (check # now as payby="BILL" hardcoded.. what to do later?) -print qq!
Check #!; +my @rights = ('Post payment'); +push @rights, 'Post check payment' if $payby eq 'BILL'; +push @rights, 'Post cash payment' if $payby eq 'CASH'; -#paybatch -print qq!!; +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right(\@rights); -print < -
- -END +my $paybatch = "webui-$_date-$$-". rand() * 2**32; -print <payname($payby). ' payment'; +$title .= " against Invoice #$linknum" if $link eq 'invnum'; - - - -END +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; +} -%> +