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