Emailing statements of accounts, RT#4860
[freeside.git] / httemplate / view / cust_statement.html
1 <% include("/elements/header.html",'Statement View', menubar(
2   "View this customer (#$display_custnum)" => "${p}view/cust_main.cgi?$custnum",
3 )) %>
4
5 % if ( $FS::CurrentUser::CurrentUser->access_right('Resend invoices') ) {
6
7     <A HREF="<% $p %>misc/print-invoice.cgi?<% $link %>">Re-print this statement</A>
8
9 %   if ( grep { $_ ne 'POST' } $cust_statement->cust_main->invoicing_list ) { 
10         | <A HREF="<% $p %>misc/email-invoice.cgi?<% $link %>">Re-email this statement</A>
11 %   } 
12
13 %   if ( $conf->exists('hylafax') && length($cust_statement->cust_main->fax) ) { 
14         | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $link %>">Re-fax this statement</A>
15 %   } 
16
17     <BR><BR>
18
19 % } 
20
21
22 % if ( $conf->exists('invoice_latex') ) { 
23
24   <A HREF="<% $p %>view/cust_statement-pdf.cgi?<% $link %>.pdf">View typeset statement</A>
25   <BR><BR>
26 % } 
27
28 % #if ( $cust_statement->num_cust_event ) {
29 % if ( 0 ) {
30 <A HREF="<%$p%>search/cust_event.html?statementnum=<% $cust_statement->statementnum %>">(&nbsp;View statement events&nbsp;)</A><BR><BR>
31 % } 
32
33 % if ( $conf->exists('invoice_html') ) { 
34
35   <% join('', $cust_statement->print_html('', $templatename) ) %>
36 % } else { 
37
38   <PRE><% join('', $cust_statement->print_text('', $templatename) ) %></PRE>
39 % } 
40
41 <% include('/elements/footer.html') %>
42 <%init>
43
44 die "access denied"
45   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
46
47 #untaint statement
48 my($query) = $cgi->keywords;
49 $query =~ /^((.+)-)?(\d+)$/;
50 my $templatename = $2;
51 my $statementnum = $3;
52
53 my $conf = new FS::Conf;
54
55 my @payby =  grep /\w/, $conf->config('payby');
56 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
57 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
58   unless @payby;
59 my %payby = map { $_=>1 } @payby;
60
61 my $cust_statement = qsearchs({
62   'select'    => 'cust_statement.*',
63   'table'     => 'cust_statement',
64   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
65   'hashref'   => { 'statementnum' => $statementnum },
66   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
67 });
68 die "Statement #$statementnum not found!" unless $cust_statement;
69
70 my $custnum = $cust_statement->custnum;
71 my $display_custnum = $cust_statement->cust_main->display_custnum;
72
73 my $link = $templatename ? "$templatename-$statementnum" : $statementnum;
74
75 </%init>