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