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