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