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.submitButton.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) %>
28 % 'label' => emt('Date'),
30 % 'format' => $date_format. ' %r',
33 % if ( $FS::CurrentUser::CurrentUser->access_right('Backdate payment') ) {
35 <& /elements/tr-input-date-field.html, \%date_args &>
39 <& /elements/tr-fixed-date.html, \%date_args &>
44 <TD ALIGN="right"><% mt('Amount') |h %></TD>
45 <TD BGCOLOR="#ffffff"><% $money_char |h %><INPUT TYPE="text" NAME="paid" ID="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=9> <% mt('by') |h %> <B><% mt(FS::payby->payname($payby)) |h %></B></TD>
48 % if ( $conf->exists('part_pkg-term_discounts') ) {
49 <& /elements/tr-select-discount_term.html,
50 'custnum' => $custnum,
51 'amount_id' => 'paid',
55 % if ( $payby eq 'BILL' ) {
57 <TD ALIGN="right"><% mt('Check #') |h %></TD>
58 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
61 % elsif ( $payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) {
63 <TD ALIGN="right"><% mt('Bank') |h %></TD>
64 <TD COLSPAN=3><INPUT TYPE="text" NAME="bank" VALUE="<% $cgi->param('bank') %>"></TD>
67 <TD ALIGN="right"><% mt('Check #') |h %></TD>
68 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
71 <TD ALIGN="right"><% mt('Teller #') |h %></TD>
72 <TD COLSPAN=2><INPUT TYPE="text" NAME="teller" VALUE="<% $cgi->param('teller') %>" SIZE=10></TD>
75 <TD ALIGN="right"><% mt('Depositor') |h %></TD>
76 <TD COLSPAN=3><INPUT TYPE="text" NAME="depositor" VALUE="<% $cgi->param('depositor') %>"></TD>
79 <TD ALIGN="right"><% mt('Account #') |h %></TD>
80 <TD COLSPAN=2><INPUT TYPE="text" NAME="account" VALUE="<% $cgi->param('account') %>" SIZE=18></TD>
85 % if ( $link eq 'custnum' || $link eq 'popup' ) {
87 <TD ALIGN="right"><% mt('Auto-apply to invoices') |h %></TD>
90 <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION>
91 <OPTION VALUE=""><% mt('not now') |h %></OPTION>
92 <OPTION VALUE="never"><% mt('never') |h %></OPTION>
96 % } elsif ( $link eq 'invnum' ) {
98 <TD ALIGN="right"><% mt('Apply to') |h %></TD>
99 <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD>
100 <INPUT TYPE="hidden" NAME="apply" VALUE="">
105 % if ( $conf->exists('pkg-balances') ) {
106 <& /elements/tr-select-cust_pkg-balances.html,
107 'custnum' => $custnum,
111 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
117 <INPUT NAME="submitButton" TYPE="submit" VALUE="<% mt('Post payment') |h %>">
121 % if ( $link eq 'popup' ) {
125 <& /elements/footer.html &>
130 my $conf = new FS::Conf;
132 my $money_char = $conf->config('money_char') || '$';
133 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
135 my($link, $linknum, $paid, $payby, $payinfo, $_date);
136 if ( $cgi->param('error') ) {
137 $link = $cgi->param('link');
138 $linknum = $cgi->param('linknum');
139 $paid = $cgi->param('paid');
140 $payby = $cgi->param('payby');
141 $payinfo = $cgi->param('payinfo');
142 $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time;
143 } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
144 $link = $cgi->param('popup') ? 'popup' : 'custnum';
147 $payby = $cgi->param('payby') || 'BILL';
150 } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
154 $payby = $cgi->param('payby') || 'BILL';
158 die "illegal query ". $cgi->keywords;
161 my @rights = ('Post payment');
162 push @rights, 'Post check payment' if $payby eq 'BILL';
163 push @rights, 'Post cash payment' if $payby eq 'CASH';
166 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
168 my $paybatch = "webui-$_date-$$-". rand() * 2**32;
170 my $title = mt('Post '. FS::payby->payname($payby). ' payment');
171 $title .= mt(" against Invoice #[_1]",$linknum) if $link eq 'invnum';
174 if ( $link eq 'invnum' ) {
175 my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } )
176 or die "unknown invnum $linknum";
177 $custnum = $cust_bill->custnum;
178 } elsif ( $link eq 'custnum' || $link eq 'popup' ) {