optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / view / cust_refund.html
1 % if ( $link eq 'popup' ) { 
2
3   <& /elements/header-popup.html, mt('Refund Receipt') &>
4
5   <CENTER><A HREF="javascript:self.parent.location = '<% $pr_link %>'"><% mt('Print') |h %></A></CENTER><BR>
6
7 % } elsif ( $link eq 'print' ) { 
8
9   <& /elements/header-popup.html, mt('Refund Receipt') &>
10   
11 % #it would be nice if the menubar could be hidden for print, but better to
12 % # have it available than not, otherwise the user winds up at a dead end
13   <% menubar(
14        emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
15      )
16   %>
17   <BR><BR>
18
19 % } else { 
20
21   <& /elements/header.html, mt('Refund Receipt'), menubar(
22        emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
23        emt('Print receipt') => $pr_link,
24      )
25   &>
26
27 % }
28
29 % unless ($link eq 'popup' ) {
30   <& /elements/small_custview.html,
31                $custnum,
32                scalar($conf->config('countrydefault')),
33                1, #no balance
34   &>
35   <BR><BR>
36 % } 
37
38 <% ntable("#cccccc", 2) %>
39
40 <TR>
41   <TD ALIGN="right"><% mt('Refund #') |h %></TD>
42   <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->refundnum %></B></TD>
43 </TR>
44
45 <TR>
46   <TD ALIGN="right"><% mt('Date') |h %></TD>
47   <TD BGCOLOR="#FFFFFF"><B><% time2str"%a&nbsp;%b&nbsp;%o,&nbsp;%Y&nbsp;%r", $cust_refund->_date %></B></TD>
48 </TR>
49
50 <TR>
51   <TD ALIGN="right"><% mt('Amount') |h %></TD>
52   <TD BGCOLOR="#FFFFFF"><B><% $money_char. $cust_refund->refund %></B></TD>
53 </TR>
54
55 <TR>
56   <TD ALIGN="right"><% mt('Reason') |h %></TD>
57   <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->reason %></B></TD>
58 </TR>
59
60 <TR>
61   <TD ALIGN="right"><% mt('Refund method') |h %></TD>
62   <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->payby_name %><% $cust_refund->paymask ? ' #'.$cust_refund->paymask : '' %></B></TD>
63 </TR>
64
65 % if ( $cust_refund->payby =~ /^(CARD|CHEK|LECB)$/ && $cust_refund->paybatch ) { 
66
67     <TR>
68       <TD ALIGN="right"><% mt('Processor') |h %></TD>
69       <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->processor %></B></TD>
70     </TR>
71
72     <TR>
73       <TD ALIGN="right"><% mt('Authorization #') |h %></TD>
74       <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->authorization %></B></TD>
75     </TR>
76
77 %   if ( $cust_refund->order_number ) {
78       <TR>
79         <TD ALIGN="right"><% mt('Order #') |h %></TD>
80         <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->order_number %></B></TD>
81       </TR>
82 %   }
83
84 % }
85
86 </TABLE>
87
88 % if ( $link eq 'print' ) {
89
90   <SCRIPT TYPE="text/javascript">
91     window.print();
92   </SCRIPT>
93
94 % }
95
96 % if ( $link =~ /^(popup|print)$/ ) { 
97     </BODY>
98   </HTML>
99 % } else {
100   <& /elements/footer.html &>
101 % }
102
103 <%init>
104
105 my $curuser = $FS::CurrentUser::CurrentUser;
106
107 die "access denied"
108   unless $curuser->access_right('View invoices') #remove this in 2.5 (2.7?)
109       || $curuser->access_right('View refunds');
110
111 $cgi->param('refundnum') =~ /^(\d+)$/ or die "no refundnum";
112 my $refundnum = $1;
113
114 my $link = '';
115 if ( $cgi->param('link') =~ /^(\w+)$/ ) {
116   $link = $1;
117 }
118
119 my $cust_refund = qsearchs({
120   'select'    => 'cust_refund.*',
121   'table'     => 'cust_refund',
122   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
123   'hashref'   => { 'refundnum' => $refundnum },
124   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
125 });
126 die "Refund #$refundnum not found!" unless $cust_refund;
127
128 my $pr_link = "${p}view/cust_refund.html?link=print;refundnum=$refundnum";
129
130 my $custnum = $cust_refund->custnum;
131 my $display_custnum = $cust_refund->cust_main->display_custnum;
132
133 my $conf = new FS::Conf;
134
135 my $money_char = $conf->config('money_char') || '$';
136
137 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname;
138
139 </%init>