1 % if ( $link eq 'popup' ) {
2 <% include('/elements/header-popup.html', $title ) %>
4 <% include("/elements/header.html", $title, '') %>
7 <% include('/elements/error.html') %>
9 % unless ( $link eq 'popup' ) {
10 <% small_custview($custnum, $conf->config('countrydefault')) %>
13 <FORM NAME="RefundForm" ACTION="<% $p1 %>process/cust_refund.cgi" METHOD=POST onSubmit="document.RefundForm.submit.disabled=true">
14 <INPUT TYPE="hidden" NAME="popup" VALUE="<% $link %>">
15 <INPUT TYPE="hidden" NAME="refundnum" VALUE="">
16 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
17 <INPUT TYPE="hidden" NAME="paynum" VALUE="<% $paynum %>">
18 <INPUT TYPE="hidden" NAME="_date" VALUE="<% $_date %>">
19 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
20 <INPUT TYPE="hidden" NAME="paybatch" VALUE="">
21 <INPUT TYPE="hidden" NAME="credited" VALUE="">
27 % #false laziness w/FS/FS/cust_pay.pm
28 % my $payby = FS::payby->payname($cust_pay->payby);
29 % my $paymask = $cust_pay->paymask;
30 % my $paydate = $cust_pay->paydate;
31 % if ( $cgi->param('error') ) {
32 % $paydate = $cgi->param('exp_year'). '-'. $cgi->param('exp_month'). '-01';
33 % $paydate = '' unless ($paydate =~ /^\d{2,4}-\d{1,2}-01$'/);
37 <% ntable("#cccccc", 2) %>
40 <TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">$<% $cust_pay->paid %></TD>
44 <TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff"><% time2str($date_format, $cust_pay->_date) %></TD>
48 <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff"><% $payby %> # <% $paymask %></TD>
51 % unless ( $paydate || $cust_pay->payby ne 'CARD' ) { # possibly other reasons: i.e. card has since expired
53 <TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">
54 <% include( '/elements/select-month_year.html',
56 'selected_date' => $paydate,
57 'empty_option' => !$paydate,
64 % #false laziness w/FS/FS/cust_main::realtime_refund_bop
65 % if ( $cust_pay->paybatch =~ /^(\w+):(\w+)(:(\w+))?$/ ) {
66 % my ( $processor, $auth, $order_number ) = ( $1, $2, $4 );
71 <TD ALIGN="right">Processor</TD><TD BGCOLOR="#ffffff"><% $processor %></TD>
73 % if ( length($auth) ) {
76 <TD ALIGN="right">Authorization</TD><TD BGCOLOR="#ffffff"><% $auth %></TD>
79 % if ( length($order_number) ) {
82 <TD ALIGN="right">Order number</TD><TD BGCOLOR="#ffffff"><% $order_number %></TD>
92 <% ntable("#cccccc", 2) %>
95 <TD ALIGN="right">Date</TD>
96 <TD BGCOLOR="#ffffff"><% time2str($date_format, $_date) %></TD>
100 <TD ALIGN="right">Amount</TD>
101 <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="refund" VALUE="<% $refund %>" SIZE=8 MAXLENGTH=8> by <B><% FS::payby->payname($payby) %></B></TD>
104 % if ( $payby eq 'BILL' ) {
106 <TD ALIGN="right">Check #</TD>
107 <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
110 <INPUT TYPE="hidden" NAME="payinfo" VALUE="">
114 <TD ALIGN="right">Reason</TD>
115 <TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<% $reason %>"></TD>
120 <INPUT TYPE="submit" NAME="submit" VALUE="Post refund">
124 % if ( $link eq 'popup' ) {
128 <% include('/elements/footer.html') %>
133 my $conf = new FS::Conf;
134 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
136 my $custnum = $cgi->param('custnum');
137 my $refund = $cgi->param('refund');
138 my $payby = $cgi->param('payby');
139 my $payinfo = $cgi->param('payinfo');
140 my $reason = $cgi->param('reason');
141 my $link = $cgi->param('popup') ? 'popup' : '';
144 push @rights, 'Post refund' if $payby =~ /^(BILL|CASH)$/;
145 push @rights, 'Post check refund' if $payby eq 'BILL';
146 push @rights, 'Post cash refund ' if $payby eq 'CASH';
147 push @rights, 'Refund payment' if $payby =~ /^(CARD|CHEK)$/;
148 push @rights, 'Refund credit card payment' if $payby eq 'CARD';
149 push @rights, 'Refund Echeck payment' if $payby eq 'CHEK';
152 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
154 my( $paynum, $cust_pay ) = ( '', '' );
155 if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
157 $cust_pay = qsearchs('cust_pay', { paynum=>$paynum } )
158 or die "unknown payment # $paynum";
159 $refund ||= $cust_pay->unrefunded;
161 die "payment # $paynum is not for specified customer # $custnum"
162 unless $custnum == $cust_pay->custnum;
164 $custnum = $cust_pay->custnum;
167 die "no custnum or paynum specified!" unless $custnum;
173 my $title = 'Refund '. FS::payby->payname($payby). ' payment';