4 %my($query) = $cgi->keywords;
5 %$query =~ /^((.+)-)?(\d+)$/;
6 %my $templatename = $2;
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;
27 <% include("/elements/header.html",'Invoice View', menubar(
29 "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'} ) {
43 <% $s++ ? ' | ' : '' %>
44 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>">check</A>
46 % if ( $payby{'CASH'} ) {
49 <% $s++ ? ' | ' : '' %>
50 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>">cash</A>
52 % if ( $payby{'WEST'} ) {
55 <% $s++ ? ' | ' : '' %>
56 <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>">Western Union</A>
58 % if ( $payby{'MCRD'} ) {
61 <% $s++ ? ' | ' : '' %>
62 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>">manual credit card</A>
66 payment against this invoice<BR>
70 <A HREF="<% $p %>misc/print-invoice.cgi?<% $link %>">Re-print this invoice</A>
71 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
73 | <A HREF="<% $p %>misc/email-invoice.cgi?<% $link %>">Re-email
76 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
78 | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $link %>">Re-fax
84 % if ( $conf->exists('invoice_latex') ) {
86 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>.pdf">View typeset invoice</A>
89 % #false laziness with search/cust_bill_event.cgi
90 % unless ( $templatename ) {
99 % foreach my $cust_bill_event (
100 % sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event
103 % my $status = $cust_bill_event->status;
104 % $status .= ': '. encode_entities($cust_bill_event->statustext)
105 % if $cust_bill_event->statustext;
106 % my $part_bill_event = $cust_bill_event->part_bill_event;
110 <TD><% $part_bill_event->event %>
111 % if ( $part_bill_event->templatename ) {
112 % my $alt_templatename = $part_bill_event->templatename;
113 % my $alt_link = "$alt_templatename-$invnum";
116 ( <A HREF="<% $p %>view/cust_bill.cgi?<% $alt_link %>">view</A>
117 | <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $alt_link %>.pdf">view
119 | <A HREF="<% $p %>misc/print-invoice.cgi?<% $alt_link %>">re-print</A>
120 % if ( grep { $_ ne 'POST' }
121 % $cust_bill->cust_main->invoicing_list ) {
123 | <A HREF="<% $p %>misc/email-invoice.cgi?<% $alt_link %>">re-email</A>
125 % if ( $conf->exists('hylafax')
126 % && length($cust_bill->cust_main->fax) ) {
128 | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $alt_link %>">re-fax</A>
137 <TD><% time2str("%a %b %e %T %Y", $cust_bill_event->_date) %></TD>
138 <TD><% $status %></TD>
146 % if ( $conf->exists('invoice_html') ) {
148 <% join('', $cust_bill->print_html('', $templatename) ) %>
151 <PRE><% join('', $cust_bill->print_text('', $templatename) ) %></PRE>