ACLs
[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 %        && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} || $payby{'MCRD'} )
8 %      )
9 %   {
10 %     my $s = 0;
11
12   Post 
13 % if ( $payby{'BILL'} ) { 
14
15   
16     <% $s++ ? ' | ' : '' %>
17     <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>">check</A>
18 % } 
19 % if ( $payby{'CASH'} ) { 
20
21   
22     <% $s++ ? ' | ' : '' %>
23     <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>">cash</A>
24 % } 
25 % if ( $payby{'WEST'} ) { 
26
27   
28     <% $s++ ? ' | ' : '' %>
29     <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>">Western Union</A>
30 % } 
31 % if ( $payby{'MCRD'} ) { 
32
33   
34     <% $s++ ? ' | ' : '' %>
35     <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>">manual credit card</A>
36 % } 
37
38
39   payment against this invoice<BR>
40 % } 
41
42
43 <A HREF="<% $p %>misc/print-invoice.cgi?<% $link %>">Re-print this invoice</A>
44 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { 
45
46   | <A HREF="<% $p %>misc/email-invoice.cgi?<% $link %>">Re-email
47       this invoice</A>
48 % } 
49 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
50
51   | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $link %>">Re-fax
52       this invoice</A>
53 % } 
54
55
56 <BR><BR>
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 % #false laziness with search/cust_bill_event.cgi
63 %   unless ( $templatename ) { 
64
65
66   <% table() %>
67   <TR>
68     <TH>Event</TH>
69     <TH>Date</TH>
70     <TH>Status</TH>
71   </TR>
72 % foreach my $cust_bill_event (
73 %       sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event
74 %     ) {
75 %
76 %    my $status = $cust_bill_event->status;
77 %    $status .= ': '. encode_entities($cust_bill_event->statustext)
78 %      if $cust_bill_event->statustext;
79 %    my $part_bill_event = $cust_bill_event->part_bill_event;
80 %  
81
82     <TR>
83       <TD><% $part_bill_event->event %>
84 % if ( $part_bill_event->templatename ) {
85 %          my $alt_templatename = $part_bill_event->templatename;
86 %          my $alt_link = "$alt_templatename-$invnum";
87 %        
88
89           ( <A HREF="<% $p %>view/cust_bill.cgi?<% $alt_link %>">view</A>
90           | <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $alt_link %>.pdf">view
91               typeset</A>
92           | <A HREF="<% $p %>misc/print-invoice.cgi?<% $alt_link %>">re-print</A>
93 % if ( grep { $_ ne 'POST' }
94 %                       $cust_bill->cust_main->invoicing_list ) { 
95
96             | <A HREF="<% $p %>misc/email-invoice.cgi?<% $alt_link %>">re-email</A>
97 % } 
98 % if ( $conf->exists('hylafax')
99 %                  && length($cust_bill->cust_main->fax) ) { 
100
101             | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $alt_link %>">re-fax</A>
102 % } 
103
104
105           )
106 % } 
107
108   
109       </TD>
110       <TD><% time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD>
111       <TD><% $status %></TD>
112     </TR>
113 % } 
114
115
116   </TABLE>
117   <BR>
118 % } 
119 % if ( $conf->exists('invoice_html') ) { 
120
121   <% join('', $cust_bill->print_html('', $templatename) ) %>
122 % } else { 
123
124   <PRE><% join('', $cust_bill->print_text('', $templatename) ) %></PRE>
125 % } 
126
127 <% include('/elements/footer.html') %>
128 <%init>
129
130 die "access denied"
131   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
132
133 #untaint invnum
134 my($query) = $cgi->keywords;
135 $query =~ /^((.+)-)?(\d+)$/;
136 my $templatename = $2;
137 my $invnum = $3;
138
139 my $conf = new FS::Conf;
140
141 my @payby =  grep /\w/, $conf->config('payby');
142 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
143 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
144   unless @payby;
145 my %payby = map { $_=>1 } @payby;
146
147 my $cust_bill = qsearchs({
148   'select'    => 'cust_bill.*',
149   'table'     => 'cust_bill',
150   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
151   'hashref'   => { 'invnum' => $invnum },
152   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
153 });
154 die "Invoice #$invnum not found!" unless $cust_bill;
155
156 my $custnum = $cust_bill->custnum;
157
158 #my $printed = $cust_bill->printed;
159
160 my $link = $templatename ? "$templatename-$invnum" : $invnum;
161
162 </%init>
163
164