4 my($query) = $cgi->keywords;
5 $query =~ /^((.+)-)?(\d+)$/;
9 my $conf = new FS::Conf;
11 my @payby = grep /\w/, $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 ))
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 <%= include("/elements/header.html",'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'} || $payby{'MCRD'} )
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 <% if ( $payby{'MCRD'} ) { %>
63 <%= $s++ ? ' | ' : '' %>
64 <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<%= $invnum %>">manual credit card</A>
68 payment against this invoice<BR>
72 <A HREF="<%= $p %>misc/print-invoice.cgi?<%= $link %>">Re-print this invoice</A>
74 <% if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { %>
75 | <A HREF="<%= $p %>misc/email-invoice.cgi?<%= $link %>">Re-email
79 <% if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { %>
80 | <A HREF="<%= $p %>misc/fax-invoice.cgi?<%= $link %>">Re-fax
86 <% if ( $conf->exists('invoice_latex') ) { %>
87 <A HREF="<%= $p %>view/cust_bill-pdf.cgi?<%= $link %>.pdf">View typeset invoice</A>
91 <% #false laziness with search/cust_bill_event.cgi
92 unless ( $templatename ) { %>
101 <% foreach my $cust_bill_event (
102 sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event
105 my $status = $cust_bill_event->status;
106 $status .= ': '. encode_entities($cust_bill_event->statustext)
107 if $cust_bill_event->statustext;
108 my $part_bill_event = $cust_bill_event->part_bill_event;
111 <TD><%= $part_bill_event->event %>
113 <% if ( $part_bill_event->templatename ) {
114 my $alt_templatename = $part_bill_event->templatename;
115 my $alt_link = "$alt_templatename-$invnum";
117 ( <A HREF="<%= $p %>view/cust_bill.cgi?<%= $alt_link %>">view</A>
118 | <A HREF="<%= $p %>view/cust_bill-pdf.cgi?<%= $alt_link %>.pdf">view
120 | <A HREF="<%= $p %>misc/print-invoice.cgi?<%= $alt_link %>">re-print</A>
121 <% if ( grep { $_ ne 'POST' }
122 $cust_bill->cust_main->invoicing_list ) { %>
123 | <A HREF="<%= $p %>misc/email-invoice.cgi?<%= $alt_link %>">re-email</A>
126 <% if ( $conf->exists('hylafax')
127 && length($cust_bill->cust_main->fax) ) { %>
128 | <A HREF="<%= $p %>misc/fax-invoice.cgi?<%= $alt_link %>">re-fax</A>
135 <TD><%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD>
136 <TD><%= $status %></TD>
145 <% if ( $conf->exists('invoice_html') ) { %>
146 <%= join('', $cust_bill->print_html('', $templatename) ) %>
148 <PRE><%= join('', $cust_bill->print_text('', $templatename) ) %></PRE>