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