1 <& /elements/header.html, mt('Invoice View'), menubar(
2 emt("View this customer (#[_1])",$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 '<% mt('Are you sure you want to delete this invoice?') |h %>'
21 TITLE = "<% mt('Delete this invoice from the database completely') |h %>"
22 ><% mt('Delete this invoice') |h %></A>
27 % if ( $cust_bill->owed > 0
28 % && scalar( grep $payby{$_}, qw(BILL CASH WEST MCRD) )
29 % && $curuser->access_right(['Post payment', 'Post check payment', 'Post cash payment'])
30 % && ! $conf->exists('pkg-balances')
37 % if ( $payby{'BILL'} && $curuser->access_right(['Post payment', 'Post check payment']) ) {
38 <% $s++ ? ' | ' : '' %>
39 <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>"><% mt('check') |h %></A>
42 % if ( $payby{'CASH'} && $curuser->access_right(['Post payment', 'Post cash payment']) ) {
43 <% $s++ ? ' | ' : '' %>
44 <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>"><% mt('cash') |h %></A>
47 % if ( $payby{'WEST'} && $curuser->access_right(['Post payment']) ) {
48 <% $s++ ? ' | ' : '' %>
49 <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>"><% mt('Western Union') |h %></A>
52 % if ( $payby{'MCRD'} && $curuser->access_right(['Post payment']) ) {
53 <% $s++ ? ' | ' : '' %>
54 <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>"><% mt('manual credit card') |h %></A>
57 <% mt('payment against this invoice') |h %><BR><BR>
61 % if ( $curuser->access_right('Resend invoices') ) {
63 <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
65 % if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
66 | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
69 % if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
70 | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
77 % if ( $conf->exists('invoice_latex') ) {
79 <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>"><% mt('View typeset invoice PDF') |h %></A>
84 % if ( $cust_bill->num_cust_event ) { $br++;
85 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">( <% mt('View invoice events') |h %> )</A>
88 % if ( $cust_bill->num_cust_bill_event ) { $br++;
89 <A HREF="<%$p%>search/cust_bill_event.cgi?invnum=<% $cust_bill->invnum %>">( <% mt('View deprecated, old-style invoice events') |h %> )</A>
92 <% $br ? '<BR><BR>' : '' %>
94 % if ( $conf->exists('invoice_html') ) {
95 <% join('', $cust_bill->print_html(\%opt) ) %>
97 <PRE><% join('', $cust_bill->print_text(\%opt) ) %></PRE>
100 <& /elements/footer.html &>
103 my $curuser = $FS::CurrentUser::CurrentUser;
106 unless $curuser->access_right('View invoices');
108 my( $invnum, $template, $notice_name );
109 my($query) = $cgi->keywords;
110 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
113 $notice_name = 'Invoice';
115 $invnum = $cgi->param('invnum');
116 $template = $cgi->param('template');
117 $notice_name = $cgi->param('notice_name');
120 my $conf = new FS::Conf;
123 'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
124 'template' => $template,
125 'notice_name' => $notice_name,
128 $opt{'barcode_img'} = 1 if $conf->exists('invoice-barcode');
130 my @payby = grep /\w/, $conf->config('payby');
131 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
132 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
134 my %payby = map { $_=>1 } @payby;
136 my $cust_bill = qsearchs({
137 'select' => 'cust_bill.*',
138 'table' => 'cust_bill',
139 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
140 'hashref' => { 'invnum' => $invnum },
141 'extra_sql' => ' AND '. $curuser->agentnums_sql,
143 die "Invoice #$invnum not found!" unless $cust_bill;
145 my $custnum = $cust_bill->custnum;
146 my $display_custnum = $cust_bill->cust_main->display_custnum;
148 #my $printed = $cust_bill->printed;
150 my $link = "invnum=$invnum";
151 $link .= ';template='. uri_escape($template) if $template;
152 $link .= ';notice_name='. $notice_name if $notice_name;