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("%m/%d/%Y %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",
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">
78 <INPUT TYPE="submit" VALUE="Post payment">
82 % if ( $link eq 'popup' ) {
86 <% include('/elements/footer.html') %>
91 my $conf = new FS::Conf;
93 my $money_char = $conf->config('money_char') || '$';
96 unless $FS::CurrentUser::CurrentUser->access_right('Post payment');
98 my($link, $linknum, $paid, $payby, $payinfo, $_date);
99 if ( $cgi->param('error') ) {
100 $link = $cgi->param('link');
101 $linknum = $cgi->param('linknum');
102 $paid = $cgi->param('paid');
103 $payby = $cgi->param('payby');
104 $payinfo = $cgi->param('payinfo');
105 $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time;
106 } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
107 $link = $cgi->param('popup') ? 'popup' : 'custnum';
110 $payby = $cgi->param('payby') || 'BILL';
113 } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
117 $payby = $cgi->param('payby') || 'BILL';
121 die "illegal query ". $cgi->keywords;
124 my $paybatch = "webui-$_date-$$-". rand() * 2**32;
126 my $title = 'Post '. FS::payby->payname($payby). ' payment';
127 $title .= " against Invoice #$linknum" if $link eq 'invnum';
130 if ( $link eq 'invnum' ) {
131 my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } )
132 or die "unknown invnum $linknum";
133 $custnum = $cust_bill->custnum;
134 } elsif ( $link eq 'custnum' ) {