add svc_elec_features merged from reference code RT#7643
[freeside.git] / httemplate / view / cust_bill.cgi
1 <% include("/elements/header.html",'Invoice View', menubar(
2   "View this customer (#$display_custnum)" => "${p}view/cust_main.cgi?$custnum",
3 )) %>
4
5 % if ( $conf->exists('deleteinvoices')
6 %      && $curuser->access_right('Delete invoices' )
7 %    )
8 % {
9
10     <SCRIPT TYPE="text/javascript">
11     function areyousure(href, message) {
12       if (confirm(message) == true)
13         window.location.href = href;
14     }
15     </SCRIPT>
16
17     <A HREF  = "javascript:areyousure(
18                   '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',
19                   'Are you sure you want to delete this invoice?'
20                )"
21        TITLE = "Delete this invoice from the database completely"
22     >Delete this invoice</A>
23     <BR><BR>
24
25 % }
26
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')
31 %    )
32 % {
33 %     my $s = 0;
34
35       Post 
36
37 %     if ( $payby{'BILL'} ) { 
38           <% $s++ ? ' | ' : '' %>
39           <A HREF="<% $p %>edit/cust_pay.cgi?payby=BILL;invnum=<% $invnum %>">check</A>
40 %     } 
41
42 %     if ( $payby{'CASH'} ) { 
43           <% $s++ ? ' | ' : '' %>
44           <A HREF="<% $p %>edit/cust_pay.cgi?payby=CASH;invnum=<% $invnum %>">cash</A>
45 %     } 
46
47 %     if ( $payby{'WEST'} ) { 
48           <% $s++ ? ' | ' : '' %>
49           <A HREF="<% $p %>edit/cust_pay.cgi?payby=WEST;invnum=<% $invnum %>">Western Union</A>
50 %     } 
51
52 %     if ( $payby{'MCRD'} ) { 
53           <% $s++ ? ' | ' : '' %>
54           <A HREF="<% $p %>edit/cust_pay.cgi?payby=MCRD;invnum=<% $invnum %>">manual credit card</A>
55 %     } 
56
57       payment against this invoice<BR><BR>
58
59 % } 
60
61 % if ( $curuser->access_right('Resend invoices') ) {
62
63     <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>">Re-print this invoice</A>
64
65 %   if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { 
66         | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>">Re-email this invoice</A>
67 %   } 
68
69 %   if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
70         | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>">Re-fax this invoice</A>
71 %   } 
72
73     <BR><BR>
74
75 % } 
76
77 % if ( $conf->exists('invoice_latex') ) { 
78
79   <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% $link %>">View typeset invoice PDF</A>
80   <BR><BR>
81 % if ( $conf->exists('svc_elec_features') ) { 
82 % my $reclink = "invnum=$invnum";
83 % $reclink .= ';template='. uri_escape($template) if $template;
84   <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% "$reclink;notice_name=Record" %>">View Record</A><BR>
85   <A HREF="<% $p %>view/cust_bill-pdf.cgi?<% "$reclink;notice_name=Record Ignoring DUE DATE" %>">View Record Ignoring DUE DATE</A>
86 <BR><BR>
87
88 %   } 
89
90 % } 
91
92 % my $br = 0;
93 % if ( $cust_bill->num_cust_event ) { $br++;
94 <A HREF="<%$p%>search/cust_event.html?invnum=<% $cust_bill->invnum %>">(&nbsp;View invoice events&nbsp;)</A> 
95 % } 
96
97 % if ( $cust_bill->num_cust_bill_event ) { $br++;
98 <A HREF="<%$p%>search/cust_bill_event.cgi?invnum=<% $cust_bill->invnum %>">(&nbsp;View deprecated, old-style invoice events&nbsp;)</A> 
99 % }
100
101 <% $br ? '<BR><BR>' : '' %>
102
103 % if ( $conf->exists('invoice_html') ) { 
104   <% join('', $cust_bill->print_html(\%opt) ) %>
105 % } else { 
106   <PRE><% join('', $cust_bill->print_text(\%opt) ) %></PRE>
107 % } 
108
109 <% include('/elements/footer.html') %>
110 <%init>
111
112 my $curuser = $FS::CurrentUser::CurrentUser;
113
114 die "access denied"
115   unless $curuser->access_right('View invoices');
116
117 my( $invnum, $template, $notice_name );
118 my($query) = $cgi->keywords;
119 if ( $query =~ /^((.+)-)?(\d+)$/ ) {
120   $template = $2;
121   $invnum = $3;
122   $notice_name = 'Invoice';
123 } else {
124   $invnum = $cgi->param('invnum');
125   $template = $cgi->param('template');
126   $notice_name = $cgi->param('notice_name');
127 }
128
129 my %opt = (
130   'template'    => $template,
131   'notice_name' => $notice_name,
132 );
133
134 my $conf = new FS::Conf;
135
136 my @payby =  grep /\w/, $conf->config('payby');
137 #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
138 @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
139   unless @payby;
140 my %payby = map { $_=>1 } @payby;
141
142 my $cust_bill = qsearchs({
143   'select'    => 'cust_bill.*',
144   'table'     => 'cust_bill',
145   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
146   'hashref'   => { 'invnum' => $invnum },
147   'extra_sql' => ' AND '. $curuser->agentnums_sql,
148 });
149 die "Invoice #$invnum not found!" unless $cust_bill;
150
151 my $custnum = $cust_bill->custnum;
152 my $display_custnum = $cust_bill->cust_main->display_custnum;
153
154 #my $printed = $cust_bill->printed;
155
156 my $link = "invnum=$invnum";
157 $link .= ';template='. uri_escape($template) if $template;
158 $link .= ';notice_name='. $notice_name if $notice_name;
159
160 </%init>