1 <% include("/elements/header.html",'Invoice View', menubar(
2 "View this customer (#$display_custnum)" => "${p}view/cust_main.cgi?$custnum",
5 % if ( $conf->exists('deleteinvoices')
6 % && $curuser->access_right('Delete invoices' )
10 <SCRIPT TYPE="text/javascript">
11 function areyousure(href, message) {
12 if (confirm(message) == true)
13 window.location.href = href;
17 <A HREF = "javascript:areyousure(
18 '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',
19 'Are you sure you want to delete this invoice?'
21 TITLE = "Delete this invoice from the database completely"
22 >Delete this invoice</A>
27 % if ( $cust_bill->owed > 0
28 % && scalar( grep $payby{$_}, qw(BILL CASH WEST MCRD) )
29 % && $curuser->access_right('Post payment')
30 % && ! $conf->exists('pkg-balances')
37 % if ( $payby{'BILL'} ) {
38 <% $s++ ? ' | ' : '' %>
39 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>">check</A>
42 % if ( $payby{'CASH'} ) {
43 <% $s++ ? ' | ' : '' %>
44 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>">cash</A>
47 % if ( $payby{'WEST'} ) {
48 <% $s++ ? ' | ' : '' %>
49 <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>">Western Union</A>
52 % if ( $payby{'MCRD'} ) {
53 <% $s++ ? ' | ' : '' %>
54 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>">manual credit card</A>
57 payment against this invoice<BR><BR>
61 % if ( $curuser->access_right('Resend invoices') ) {
63 <A HREF="<% $p %>misc/print-invoice.cgi?<% $link %>">Re-print this invoice</A>
65 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
66 | <A HREF="<% $p %>misc/email-invoice.cgi?<% $link %>">Re-email this invoice</A>
69 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
70 | <A HREF="<% $p %>misc/fax-invoice.cgi?<% $link %>">Re-fax this invoice</A>
77 % if ( $conf->exists('invoice_latex') ) {
79 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>.pdf">View typeset invoice PDF</A>
84 % if ( $cust_bill->num_cust_event ) { $br++;
85 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">( View invoice events )</A>
88 % if ( $cust_bill->num_cust_bill_event ) { $br++;
89 <A HREF="<%$p%>search/cust_bill_event.cgi?invnum=<% $cust_bill->invnum %>">( View deprecated, old-style invoice events )</A>
92 <% $br ? '<BR><BR>' : '' %>
94 % if ( $conf->exists('invoice_html') ) {
96 <% join('', $cust_bill->print_html('', $templatename) ) %>
99 <PRE><% join('', $cust_bill->print_text('', $templatename) ) %></PRE>
102 <% include('/elements/footer.html') %>
105 my $curuser = $FS::CurrentUser::CurrentUser;
108 unless $curuser->access_right('View invoices');
111 my($query) = $cgi->keywords;
112 $query =~ /^((.+)-)?(\d+)$/;
113 my $templatename = $2;
116 my $conf = new FS::Conf;
118 my @payby = grep /\w/, $conf->config('payby');
119 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
120 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
122 my %payby = map { $_=>1 } @payby;
124 my $cust_bill = qsearchs({
125 'select' => 'cust_bill.*',
126 'table' => 'cust_bill',
127 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
128 'hashref' => { 'invnum' => $invnum },
129 'extra_sql' => ' AND '. $curuser->agentnums_sql,
131 die "Invoice #$invnum not found!" unless $cust_bill;
133 my $custnum = $cust_bill->custnum;
134 my $display_custnum = $cust_bill->cust_main->display_custnum;
136 #my $printed = $cust_bill->printed;
138 my $link = $templatename ? "$templatename-$invnum" : $invnum;