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