b34a908185e3b91c94d5b4c3e701487268073d44
[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 %   if ( $cust_pay->order_number ) {
95       <TR>
96         <TD ALIGN="right"><% mt('Order #') |h %></TD>
97         <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->order_number %></B></TD>
98       </TR>
99 %   }
100
101 % }
102
103 % if ( $cust_pay->payby eq 'CASH' && $cust_pay->payinfo ) {
104     <TR>
105       <TD ALIGN="right"><% mt('Bank') |h %></TD>
106       <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->bank %></B></TD>
107     </TR>
108
109     <TR>
110       <TD ALIGN="right"><% mt('Teller #') |h %></TD>
111       <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->teller %></B></TD>
112     </TR>
113
114     <TR>
115       <TD ALIGN="right"><% mt('Depositor') |h %></TD>
116       <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->depositor %></B></TD>
117     </TR>
118
119     <TR>
120       <TD ALIGN="right"><% mt('Account #') |h %></TD>
121       <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->account %></B></TD>
122     </TR>
123 % }
124
125 % if ( $conf->exists('pkg-balances') && $cust_pay->pkgnum ) {
126 %   my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_pay->pkgnum } );
127     <TR>
128       <TD ALIGN="right"><% mt('For package') |h %></TD>
129       <TD BGCOLOR="#FFFFFF"><B><% $cust_pkg->pkg_label_long %></B></TD>
130     </TR>
131
132 % }
133
134 </TABLE>
135
136 % if ( $link eq 'print' ) {
137
138   <SCRIPT TYPE="text/javascript">
139     window.print();
140   </SCRIPT>
141
142 % } elsif ( $link eq 'email' ) {
143
144     <SCRIPT TYPE="text/javascript">
145       window.top.location.reload();
146     </SCRIPT>
147
148 % }
149 % if ( $link =~ /^(popup|print|email)$/ ) { 
150     </BODY>
151   </HTML>
152 % } else {
153   <& /elements/footer.html &>
154 % }
155
156 <%init>
157
158 my $curuser = $FS::CurrentUser::CurrentUser;
159
160 die "access denied"
161   unless $curuser->access_right('View invoices') #remove this in 2.5 (2.7?)
162   || $curuser->access_right('View payments');
163
164 $cgi->param('paynum') =~ /^(\d+)$/ or die "no paynum";
165 my $paynum = $1;
166
167 my $link = '';
168 if ( $cgi->param('link') =~ /^(\w+)$/ ) {
169   $link = $1;
170 }
171
172 my $void = $cgi->param('void') ? 1 : 0;
173 my $thing = $void ? 'Voided Payment' : 'Payment';
174 my $table = $void ? 'cust_pay_void'  : 'cust_pay';
175
176 my $cust_pay = qsearchs({
177   'select'    => "$table.*",
178   'table'     => $table,
179   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
180   'hashref'   => { 'paynum' => $paynum },
181   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
182 });
183 die "$thing #$paynum not found!" unless $cust_pay;
184
185 my $cust_main = $cust_pay->cust_main;
186
187 my $pr_link = "${p}view/cust_pay.html?link=print;paynum=$paynum;void=$void";
188 my $email_link = "${p}view/cust_pay.html?link=email;paynum=$paynum;void=$void";
189
190 my $custnum = $cust_pay->custnum;
191 my $display_custnum = $cust_main->display_custnum;
192
193 my $conf = new FS::Conf;
194
195 my $money_char = $conf->config('money_char') || '$';
196
197 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname;
198
199 my $email_error;
200
201 if ( $link eq 'email' ) {
202     $email_error = $cust_pay->send_receipt(
203       'manual' => 1,
204       'cust_main' => $cust_main,
205     );
206
207     warn "can't send payment receipt/statement: $email_error" if $email_error;
208 }
209
210 </%init>