1 % if ( $link eq 'popup' ) {
2 <& /elements/header-popup.html, $title &>
4 <& /elements/header-cust_main.html, view=>'payment_history', custnum=>$custnum &>
5 <h2><% $title |h %></h2>
8 <& /elements/init_calendar.html &>
10 <& /elements/error.html &>
12 <FORM NAME="PaymentForm" ACTION="<% popurl(1) %>process/cust_pay.cgi" METHOD=POST onSubmit="document.PaymentForm.submitButton.disabled=true">
13 <INPUT TYPE="hidden" NAME="link" VALUE="<% $link %>">
14 <INPUT TYPE="hidden" NAME="linknum" VALUE="<% $linknum %>">
15 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
16 <INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>">
18 <TABLE CLASS="fsinnerbox">
22 % 'label' => emt('Date'),
24 % 'format' => $date_format. ' %r',
27 % if ( $FS::CurrentUser::CurrentUser->access_right('Backdate payment') ) {
29 <& /elements/tr-input-date-field.html, \%date_args &>
33 <& /elements/tr-fixed-date.html, \%date_args &>
38 <TH ALIGN="right"><% mt('Amount') |h %></TH>
39 <TD><% $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>
42 % if ( $conf->exists('part_pkg-term_discounts') ) {
43 <& /elements/tr-select-discount_term.html,
44 'custnum' => $custnum,
45 'amount_id' => 'paid',
49 % if ( $payby eq 'BILL' ) {
51 <TH ALIGN="right"><% mt('Check #') |h %></TH>
52 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
55 % elsif ( $payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) {
57 <TH ALIGN="right"><% mt('Bank') |h %></TH>
58 <TD COLSPAN=3><INPUT TYPE="text" NAME="bank" VALUE="<% $cgi->param('bank') %>"></TD>
61 <TH ALIGN="right"><% mt('Check #') |h %></TH>
62 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
65 <TH ALIGN="right"><% mt('Teller #') |h %></TH>
66 <TD COLSPAN=2><INPUT TYPE="text" NAME="teller" VALUE="<% $cgi->param('teller') %>" SIZE=10></TD>
69 <TH ALIGN="right"><% mt('Depositor') |h %></TH>
70 <TD COLSPAN=3><INPUT TYPE="text" NAME="depositor" VALUE="<% $cgi->param('depositor') %>"></TD>
73 <TH ALIGN="right"><% mt('Account #') |h %></TH>
74 <TD COLSPAN=2><INPUT TYPE="text" NAME="account" VALUE="<% $cgi->param('account') %>" SIZE=18></TD>
79 % if ( $link eq 'custnum' || $link eq 'popup' ) {
81 <TD ALIGN="right"><% mt('Auto-apply to invoices') |h %></TD>
84 <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION>
85 <OPTION VALUE=""><% mt('not now') |h %></OPTION>
86 <OPTION VALUE="never"><% mt('never') |h %></OPTION>
90 % } elsif ( $link eq 'invnum' ) {
92 <TH ALIGN="right"><% mt('Apply to') |h %></TH>
93 <TD COLSPAN=2>Invoice #<B><% $linknum %></B> only</TD>
94 <INPUT TYPE="hidden" NAME="apply" VALUE="">
99 % if ( $conf->exists('pkg-balances') ) {
100 <& /elements/tr-select-cust_pkg-balances.html,
101 'custnum' => $custnum,
105 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
111 <INPUT NAME="submitButton" TYPE="submit" VALUE="<% mt('Post payment') |h %>">
115 % if ( $link eq 'popup' ) {
119 <& /elements/footer-cust_main.html &>
124 my $conf = new FS::Conf;
126 my $money_char = $conf->config('money_char') || '$';
127 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
129 my($link, $linknum, $paid, $payby, $payinfo, $_date);
130 if ( $cgi->param('error') ) {
131 $link = $cgi->param('link');
132 $linknum = $cgi->param('linknum');
133 $paid = $cgi->param('paid');
134 $payby = $cgi->param('payby');
135 $payinfo = $cgi->param('payinfo');
136 $_date = $cgi->param('_date') ? parse_datetime($cgi->param('_date')) : time;
137 } elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
138 $link = $cgi->param('popup') ? 'popup' : 'custnum';
141 $payby = $cgi->param('payby') || 'BILL';
144 } elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
148 $payby = $cgi->param('payby') || 'BILL';
152 die "illegal query ". $cgi->keywords;
155 my @rights = ('Post payment');
156 push @rights, 'Post check payment' if $payby eq 'BILL';
157 push @rights, 'Post cash payment' if $payby eq 'CASH';
160 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
162 my $paybatch = "webui-$_date-$$-". rand() * 2**32;
164 my $title = mt('Post '. FS::payby->payname($payby). ' payment');
165 $title .= mt(" against Invoice #[_1]",$linknum) if $link eq 'invnum';
168 if ( $link eq 'invnum' ) {
169 my $cust_bill = qsearchs('cust_bill', { 'invnum' => $linknum } )
170 or die "unknown invnum $linknum";
171 $custnum = $cust_bill->custnum;
172 } elsif ( $link eq 'custnum' || $link eq 'popup' ) {