4 my($query) = $cgi->keywords;
5 $query =~ /^((.+)-)?(\d+)$/;
9 my $conf = new FS::Conf;
11 my @payby = $conf->config('payby');
12 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
13 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
14 unless grep /\w/, @payby;
15 my %payby = map { $_=>1 } @payby;
17 my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
18 die "Invoice #$invnum not found!" unless $cust_bill;
19 my $custnum = $cust_bill->getfield('custnum');
21 #my $printed = $cust_bill->printed;
23 my $link = $templatename ? "$templatename-$invnum" : $invnum;
26 <%= header('Invoice View', menubar(
28 "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
31 <% if ( $cust_bill->owed > 0
32 && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} )
40 <% if ( $payby{'BILL'} ) { %>
42 <%= $s++ ? ' | ' : '' %>
43 <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;invnum=<%= $invnum %>">check</A>
47 <% if ( $payby{'CASH'} ) { %>
49 <%= $s++ ? ' | ' : '' %>
50 <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;invnum=<%= $invnum %>">cash</A>
54 <% if ( $payby{'WEST'} ) { %>
56 <%= $s++ ? ' | ' : '' %>
57 <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;invnum=<%= $invnum %>">Western Union</A>
61 payment against this invoice<BR>
65 <A HREF="<%= $p %>misc/print-invoice.cgi?<%= $link %>">Re-print this invoice</A>
67 <% if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { %>
68 | <A HREF="<%= $p %>misc/email-invoice.cgi?<%= $link %>">Re-email
72 <% if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { %>
73 | <A HREF="<%= $p %>misc/fax-invoice.cgi?<%= $link %>">Re-fax
79 <% if ( $conf->exists('invoice_latex') ) { %>
80 <A HREF="<%= $p %>view/cust_bill-pdf.cgi?<%= $link %>.pdf">View typeset invoice</A>
84 <% #false laziness with search/cust_bill_event.cgi
85 unless ( $templatename ) { %>
94 <% foreach my $cust_bill_event (
95 sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event
98 my $status = $cust_bill_event->status;
99 $status .= ': '. encode_entities($cust_bill_event->statustext)
100 if $cust_bill_event->statustext;
101 my $part_bill_event = $cust_bill_event->part_bill_event;
104 <TD><%= $part_bill_event->event %>
106 <% if ( $part_bill_event->templatename ) {
107 my $alt_templatename = $part_bill_event->templatename;
108 my $alt_link = "$alt_templatename-$invnum";
110 ( <A HREF="<%= $p %>view/cust_bill.cgi?<%= $alt_link %>">view</A>
111 | <A HREF="<%= $p %>view/cust_bill-pdf.cgi?<%= $alt_link %>.pdf">view
113 | <A HREF="<%= $p %>misc/print-invoice.cgi?<%= $alt_link %>">re-print</A>
114 <% if ( grep { $_ ne 'POST' }
115 $cust_bill->cust_main->invoicing_list ) { %>
116 | <A HREF="<%= $p %>misc/email-invoice.cgi?<%= $alt_link %>">re-email</A>
119 <% if ( $conf->exists('hylafax')
120 && length($cust_bill->cust_main->fax) ) { %>
121 | <A HREF="<%= $p %>misc/fax-invoice.cgi?<%= $alt_link %>">re-fax</A>
128 <TD><%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD>
129 <TD><%= $status %></TD>
138 <% if ( $conf->exists('invoice_html') ) { %>
139 <%= join('', $cust_bill->print_html('', $templatename) ) %>
141 <PRE><%= join('', $cust_bill->print_text('', $templatename) ) %></PRE>