1 % if ( $link eq 'popup' ) {
2 <% include('/elements/header-popup.html', $title ) %>
4 <% include("/elements/header.html", $title, '') %>
7 <% include('/elements/init_calendar.html') %>
9 <% include('/elements/error.html') %>
11 % unless ( $link eq 'popup' ) {
12 <% small_custview($custnum, $conf->config('countrydefault')) %>
15 <FORM NAME="PaymentForm" ACTION="<% popurl(1) %>process/cust_pay.cgi" METHOD=POST onSubmit="document.PaymentForm.submit.disabled=true">
16 <INPUT TYPE="hidden" NAME="link" VALUE="<% $link %>">
17 <INPUT TYPE="hidden" NAME="linknum" VALUE="<% $linknum %>">
18 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
19 <INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>">
24 <% ntable("#cccccc", 2) %>
27 <TD ALIGN="right">Date</TD>
29 <INPUT TYPE="text" NAME="_date" ID="_date_text" VALUE="<% time2str($date_format.' %r',$_date) %>">
30 <IMG SRC="../images/calendar.png" ID="_date_button" STYLE="cursor: pointer" TITLE="Select date">
34 <SCRIPT TYPE="text/javascript">
36 inputField: "_date_text",
37 ifFormat: "<% $date_format %>",
38 button: "_date_button",
44 <TD ALIGN="right">Amount</TD>
45 <TD BGCOLOR="#ffffff" ALIGN="right"><% $money_char %></TD>
46 <TD><INPUT TYPE="text" NAME="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=8> by <B><% FS::payby->payname($payby) %></B></TD>
49 % if ( $payby eq 'BILL' ) {
51 <TD ALIGN="right">Check #</TD>
52 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
57 % if ( $link eq 'custnum' || $link eq 'popup' ) {
59 <TD ALIGN="right">Auto-apply<BR>to invoices</TD>
62 <OPTION VALUE="yes" SELECTED>yes
66 % } elsif ( $link eq 'invnum' ) {
68 <TD ALIGN="right">Apply to</TD>
69 <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD>
70 <INPUT TYPE="hidden" NAME="apply" VALUE="no">
75 % if ( $conf->exists('pkg-balances') ) {
76 <% include('/elements/tr-select-cust_pkg-balances.html',
77 'custnum' => $custnum,
82 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
88 <INPUT TYPE="submit" VALUE="Post payment">
92 % if ( $link eq 'popup' ) {
96 <% include('/elements/footer.html') %>
101 my $conf = new FS::Conf;
103 my $money_char = $conf->config('money_char') || '$';
104 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
107 unless $FS::CurrentUser::CurrentUser->access_right('Post payment');
109 my($link, $linknum, $paid, $payby, $payinfo, $_date);
110 if ( $cgi->param('error') ) {
111 $link = $cgi->param('link');
112 $linknum = $cgi->param('linknum');
113 $paid = $cgi->param('paid');
114 $payby = $cgi->param('payby');
115 $payinfo = $cgi->param('payinfo');
116 $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time;
117 } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
118 $link = $cgi->param('popup') ? 'popup' : 'custnum';
121 $payby = $cgi->param('payby') || 'BILL';
124 } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
128 $payby = $cgi->param('payby') || 'BILL';
132 die "illegal query ". $cgi->keywords;
135 my $paybatch = "webui-$_date-$$-". rand() * 2**32;
137 my $title = 'Post '. FS::payby->payname($payby). ' payment';
138 $title .= " against Invoice #$linknum" if $link eq 'invnum';
141 if ( $link eq 'invnum' ) {
142 my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } )
143 or die "unknown invnum $linknum";
144 $custnum = $cust_bill->custnum;
145 } elsif ( $link eq 'custnum' || $link eq 'popup' ) {