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 <% include('/elements/tr-select-discount_term.html',
50 'custnum' => $custnum,
55 % if ( $payby eq 'BILL' ) {
57 <TD ALIGN="right">Check #</TD>
58 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
63 % if ( $link eq 'custnum' || $link eq 'popup' ) {
65 <TD ALIGN="right">Auto-apply<BR>to invoices</TD>
68 <OPTION VALUE="yes" SELECTED>yes
72 % } elsif ( $link eq 'invnum' ) {
74 <TD ALIGN="right">Apply to</TD>
75 <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD>
76 <INPUT TYPE="hidden" NAME="apply" VALUE="no">
81 % if ( $conf->exists('pkg-balances') ) {
82 <% include('/elements/tr-select-cust_pkg-balances.html',
83 'custnum' => $custnum,
88 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
94 <INPUT TYPE="submit" VALUE="Post payment">
98 % if ( $link eq 'popup' ) {
102 <% include('/elements/footer.html') %>
107 my $conf = new FS::Conf;
109 my $money_char = $conf->config('money_char') || '$';
110 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
112 my($link, $linknum, $paid, $payby, $payinfo, $_date);
113 if ( $cgi->param('error') ) {
114 $link = $cgi->param('link');
115 $linknum = $cgi->param('linknum');
116 $paid = $cgi->param('paid');
117 $payby = $cgi->param('payby');
118 $payinfo = $cgi->param('payinfo');
119 $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time;
120 } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
121 $link = $cgi->param('popup') ? 'popup' : 'custnum';
124 $payby = $cgi->param('payby') || 'BILL';
127 } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
131 $payby = $cgi->param('payby') || 'BILL';
135 die "illegal query ". $cgi->keywords;
138 my @rights = ('Post payment');
139 push @rights, 'Post check payment' if $payby eq 'BILL';
140 push @rights, 'Post cash payment' if $payby eq 'CASH';
143 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
145 my $paybatch = "webui-$_date-$$-". rand() * 2**32;
147 my $title = 'Post '. FS::payby->payname($payby). ' payment';
148 $title .= " against Invoice #$linknum" if $link eq 'invnum';
151 if ( $link eq 'invnum' ) {
152 my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } )
153 or die "unknown invnum $linknum";
154 $custnum = $cust_bill->custnum;
155 } elsif ( $link eq 'custnum' || $link eq 'popup' ) {