1 % if ( $link eq 'popup' ) {
2 <& /elements/header-popup.html, $title &>
4 <& /elements/header.html, $title, '' &>
7 <& /elements/init_calendar.html &>
9 <& /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 %>">
23 <% mt('Payment') |h %>
24 <% ntable("#cccccc", 2) %>
27 <TD ALIGN="right"><% mt('Date') |h %></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="<% mt('Select date') |h %>">
34 <SCRIPT TYPE="text/javascript">
36 inputField: "_date_text",
37 ifFormat: "<% $date_format %>",
38 button: "_date_button",
44 <TD ALIGN="right"><% mt('Amount') |h %></TD>
45 <TD BGCOLOR="#ffffff" ALIGN="right"><% $money_char %></TD>
46 <TD><INPUT TYPE="text" NAME="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=9> <% mt('by') |h %> <B><% mt(FS::payby->payname($payby)) |h %></B></TD>
49 <& /elements/tr-select-discount_term.html,
50 'custnum' => $custnum,
54 % if ( $payby eq 'BILL' ) {
56 <TD ALIGN="right"><% mt('Check #') |h %></TD>
57 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
62 % if ( $link eq 'custnum' || $link eq 'popup' ) {
64 <TD ALIGN="right"><% mt('Auto-apply to invoices') |h %></TD>
67 <OPTION VALUE="yes" SELECTED><% mt('yes') |h %>
68 <OPTION><% mt('no') |h %></SELECT>
71 % } elsif ( $link eq 'invnum' ) {
73 <TD ALIGN="right"><% mt('Apply to') |h %></TD>
74 <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD>
75 <INPUT TYPE="hidden" NAME="apply" VALUE="no">
80 % if ( $conf->exists('pkg-balances') ) {
81 <& /elements/tr-select-cust_pkg-balances.html,
82 'custnum' => $custnum,
86 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
92 <INPUT TYPE="submit" VALUE="<% mt('Post payment') |h %>">
96 % if ( $link eq 'popup' ) {
100 <& /elements/footer.html &>
105 my $conf = new FS::Conf;
107 my $money_char = $conf->config('money_char') || '$';
108 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
110 my($link, $linknum, $paid, $payby, $payinfo, $_date);
111 if ( $cgi->param('error') ) {
112 $link = $cgi->param('link');
113 $linknum = $cgi->param('linknum');
114 $paid = $cgi->param('paid');
115 $payby = $cgi->param('payby');
116 $payinfo = $cgi->param('payinfo');
117 $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time;
118 } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
119 $link = $cgi->param('popup') ? 'popup' : 'custnum';
122 $payby = $cgi->param('payby') || 'BILL';
125 } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
129 $payby = $cgi->param('payby') || 'BILL';
133 die "illegal query ". $cgi->keywords;
136 my @rights = ('Post payment');
137 push @rights, 'Post check payment' if $payby eq 'BILL';
138 push @rights, 'Post cash payment' if $payby eq 'CASH';
141 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
143 my $paybatch = "webui-$_date-$$-". rand() * 2**32;
145 my $title = mt('Post '. FS::payby->payname($payby). ' payment');
146 $title .= mt(" against Invoice #[_1]",$linknum) if $link eq 'invnum';
149 if ( $link eq 'invnum' ) {
150 my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } )
151 or die "unknown invnum $linknum";
152 $custnum = $cust_bill->custnum;
153 } elsif ( $link eq 'custnum' || $link eq 'popup' ) {