don't show invoice resend and payment posting links if you can't do that anyway
[freeside.git] / httemplate / view / cust_bill.cgi
1 <% include("/elements/header.html",'Invoice View', menubar(
2   "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
3 )) %>
4
5
6 % if ( $cust_bill->owed > 0
7 %      && scalar( grep $payby{$_}, qw(BILL CASH WEST MCRD) )
8 %      && $FS::CurrentUser::CurrentUser->access_right('Post payment')
9 %    )
10 % {
11 %     my $s = 0;
12
13       Post 
14
15 %     if ( $payby{'BILL'} ) { 
16           <% $s++ ? ' | ' : '' %>
17           <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>">check</A>
18 %     } 
19
20 %     if ( $payby{'CASH'} ) { 
21           <% $s++ ? ' | ' : '' %>
22           <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>">cash</A>
23 %     } 
24
25 %     if ( $payby{'WEST'} ) { 
26           <% $s++ ? ' | ' : '' %>
27           <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>">Western Union</A>
28 %     } 
29
30 %     if ( $payby{'MCRD'} ) { 
31           <% $s++ ? ' | ' : '' %>
32           <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>">manual credit card</A>
33 %     } 
34
35       payment against this invoice<BR><BR>
36
37 % } 
38
39
40 % if ( $FS::CurrentUser::CurrentUser->access_right('Resend invoices') ) {
41
42     <A HREF="<% $p %>misc/print-invoice.cgi?<% $link %>">Re-print this invoice</A>
43
44 %   if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { 
45         | <A HREF="<% $p %>misc/email-invoice.cgi?<% $link %>">Re-email this invoice</A>
46 %   } 
47
48 %   if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
49         | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $link %>">Re-fax this invoice</A>
50 %   } 
51
52     <BR><BR>
53
54 % } 
55
56
57 % if ( $conf->exists('invoice_latex') ) { 
58
59   <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>.pdf">View typeset invoice</A>
60   <BR><BR>
61 % } 
62
63 % my $br = 0;
64 % if ( $cust_bill->num_cust_event ) { $br++;
65 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">(&nbsp;View invoice events&nbsp;)</A> 
66 % } 
67
68 % if ( $cust_bill->num_cust_bill_event ) { $br++;
69 <A HREF="<%$p%>search/cust_bill_event.cgi?invnum=<% $cust_bill->invnum %>">(&nbsp;View deprecated, old-style invoice events&nbsp;)</A> 
70 % }
71
72 <% $br ? '<BR><BR>' : '' %>
73
74 % if ( $conf->exists('invoice_html') ) { 
75
76   <% join('', $cust_bill->print_html('', $templatename) ) %>
77 % } else { 
78
79   <PRE><% join('', $cust_bill->print_text('', $templatename) ) %></PRE>
80 % } 
81
82 <% include('/elements/footer.html') %>
83 <%init>
84
85 die "access denied"
86   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
87
88 #untaint invnum
89 my($query) = $cgi->keywords;
90 $query =~ /^((.+)-)?(\d+)$/;
91 my $templatename = $2;
92 my $invnum = $3;
93
94 my $conf = new FS::Conf;
95
96 my @payby =  grep /\w/, $conf->config('payby');
97 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
98 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
99   unless @payby;
100 my %payby = map { $_=>1 } @payby;
101
102 my $cust_bill = qsearchs({
103   'select'    => 'cust_bill.*',
104   'table'     => 'cust_bill',
105   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
106   'hashref'   => { 'invnum' => $invnum },
107   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
108 });
109 die "Invoice #$invnum not found!" unless $cust_bill;
110
111 my $custnum = $cust_bill->custnum;
112
113 #my $printed = $cust_bill->printed;
114
115 my $link = $templatename ? "$templatename-$invnum" : $invnum;
116
117 </%init>
118
119