internationalization/localization, RT12515
[freeside.git] / httemplate / view / cust_pay.html
1 % if ( $link eq 'popup' ) { 
2
3   <& /elements/header-popup.html, mt("$thing Receipt") &>
4
5   <div align="center">
6     <A HREF="javascript:self.parent.location = '<% $pr_link %>'"><% mt('Print') |h %></A> | 
7     <A HREF="javascript:self.location = '<% $email_link %>'"><% mt('Re-email') |h %></A>
8   </div><BR>
9
10 % } elsif ( $link eq 'print' ) { 
11
12   <& /elements/header-popup.html, mt("$thing Receipt") &>
13   
14 % #it would be nice if the menubar could be hidden for print, but better to
15 % # have it available than not, otherwise the user winds up at a dead end
16   <% menubar(
17        mt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
18      )
19   %>
20   <BR><BR>
21 % } elsif ( $link eq 'email' ) {
22 %  if ( $email_error ) {
23       <& /elements/header-popup.html, mt("Error re-emailing receipt") &>
24 %       warn "Error re-emailing receipt: $email_error";
25 %  } else {
26       <& /elements/header-popup.html, mt("Re-emailed receipt") &>
27 %  }
28 % } else { 
29
30   <& /elements/header.html, mt("$thing Receipt"), menubar(
31        mt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
32        mt('Print receipt') => $pr_link,
33      )
34   &>
35
36 % }
37
38 % unless ($link =~ /^(popup|email)$/ ) {
39   <& /elements/small_custview.html,
40                $custnum,
41                scalar($conf->config('countrydefault')),
42                1, #no balance
43   &>
44   <BR><BR>
45 % } 
46
47 <% ntable("#cccccc", 2) %>
48
49 <TR>
50   <TD ALIGN="right"><% mt('Payment') |h %>#</TD>
51   <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->paynum %></B></TD>
52 </TR>
53
54 <TR>
55   <TD ALIGN="right"><% mt('Date') |h %></TD>
56   <TD BGCOLOR="#FFFFFF"><B><% time2str"%a&nbsp;%b&nbsp;%o,&nbsp;%Y&nbsp;%r", $cust_pay->_date %></B></TD>
57 </TR>
58
59 % if ( $void ) {
60
61   <TR>
62     <TD ALIGN="right"><% mt('Void Date') |h %></TD>
63     <TD BGCOLOR="#FFFFFF"><B><% time2str"%a&nbsp;%b&nbsp;%o,&nbsp;%Y&nbsp;%r", $cust_pay->void_date %></B></TD>
64   </TR>
65
66 %#  <TR>
67 %#    <TD ALIGN="right"><% mt('Void reason') |h %></TD>
68 %#    <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->reason %></B></TD>
69 %#  </TR>
70
71 % }
72 <TR>
73   <TD ALIGN="right"><% mt('Amount') |h %></TD>
74   <TD BGCOLOR="#FFFFFF"><B><% $money_char. $cust_pay->paid %></B></TD>
75 </TR>
76 <TR>
77   <TD ALIGN="right"><% mt('Payment method') |h %></TD>
78   <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->payby_name %> #<% $cust_pay->paymask %></B></TD>
79 </TR>
80
81 % if ( $cust_pay->payby =~ /^(CARD|CHEK|LECB)$/ && $cust_pay->paybatch ) { 
82
83     <TR>
84       <TD ALIGN="right"><% mt('Processor') |h %></TD>
85       <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->processor %></B></TD>
86     </TR>
87
88     <TR>
89       <TD ALIGN="right"><% mt('Authorization') |h %>#</TD>
90       <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->authorization %></B></TD>
91     </TR>
92
93 %   if ( $cust_pay->order_number ) {
94       <TR>
95         <TD ALIGN="right"><% mt('Order') |h %>#</TD>
96         <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->order_number %></B></TD>
97       </TR>
98 %   }
99
100 % }
101
102 % if ( $conf->exists('pkg-balances') && $cust_pay->pkgnum ) {
103 %   my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_pay->pkgnum } );
104     <TR>
105       <TD ALIGN="right"><% mt('For package') |h %></TD>
106       <TD BGCOLOR="#FFFFFF"><B><% $cust_pkg->pkg_label_long %></B></TD>
107     </TR>
108
109 % }
110
111 </TABLE>
112
113 % if ( $link eq 'print' ) {
114
115   <SCRIPT TYPE="text/javascript">
116     window.print();
117   </SCRIPT>
118
119 % } elsif ( $link eq 'email' ) {
120
121     <SCRIPT TYPE="text/javascript">
122       window.top.location.reload();
123     </SCRIPT>
124
125 % }
126 % if ( $link =~ /^(popup|print|email)$/ ) { 
127     </BODY>
128   </HTML>
129 % } else {
130   <& /elements/footer.html &>
131 % }
132
133 <%init>
134
135 my $curuser = $FS::CurrentUser::CurrentUser;
136
137 die "access denied"
138   unless $curuser->access_right('View invoices') #remove this in 1.9 EVENTUALLY
139   || $curuser->access_right('View customer payments');
140
141 $cgi->param('paynum') =~ /^(\d+)$/ or die "no paynum";
142 my $paynum = $1;
143
144 my $link = '';
145 if ( $cgi->param('link') =~ /^(\w+)$/ ) {
146   $link = $1;
147 }
148
149 my $void = $cgi->param('void') ? 1 : 0;
150 my $thing = $void ? 'Voided Payment' : 'Payment';
151 my $table = $void ? 'cust_pay_void'  : 'cust_pay';
152
153 my $cust_pay = qsearchs({
154   'select'    => "$table.*",
155   'table'     => $table,
156   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
157   'hashref'   => { 'paynum' => $paynum },
158   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
159 });
160 die "$thing #$paynum not found!" unless $cust_pay;
161
162 my $pr_link = "${p}view/cust_pay.html?link=print;paynum=$paynum;void=$void";
163 my $email_link = "${p}view/cust_pay.html?link=email;paynum=$paynum;void=$void";
164
165 my $custnum = $cust_pay->custnum;
166 my $display_custnum = $cust_pay->cust_main->display_custnum;
167
168 my $conf = new FS::Conf;
169
170 my $money_char = $conf->config('money_char') || '$';
171
172 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname;
173
174 my $email_error;
175
176 if ( $link eq 'email' ) {
177     my $email_error = $cust_pay->send_receipt(
178         'manual' => 1,
179     );
180
181     warn "can't send payment receipt/statement: $email_error" if $email_error;
182 }
183
184 </%init>