Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / view / cust_main / payment_history / invoice.html
1 <% $link %><% $invoice %><% $link ? '</A>' : '' %><% "$void$delete$under" %>
2 <%init>
3
4 my( $cust_bill, %opt ) = @_;
5
6 my $conf = new FS::Conf;
7
8 my $curuser = $FS::CurrentUser::CurrentUser;
9
10 my $invoice = emt("Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed);
11
12 my $under = '';
13 if ( $cust_bill->owed > 0 ) {
14   $invoice = '<B><FONT SIZE="+1" COLOR="#FF0000">' .
15     emt("Open Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed) .
16     '</FONT></B>';
17   if ( $cust_bill->promised_date ) {
18     $under .= '<BR>'. emt('Payment promised on [_1]',
19         time2str($opt{'date_format'}, $cust_bill->promised_date));
20   }
21 } #if $cust_bill->owed
22
23 my $invnum = $cust_bill->invnum;
24
25 my $link = $curuser->access_right('View invoices')
26              ? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">!
27              : '';
28
29 my $void = '';
30 if ( $cust_bill->closed !~ /^Y/i && $curuser->access_right('Void invoices') ) {
31   $void =
32     ' ('. include('/elements/popup_link.html',
33                     'label'     => emt('void'),
34                     'action'    => "${p}misc/void-cust_bill.html?;invnum=".
35                                     $cust_bill->invnum,
36                     'actionlabel' => emt('Void Invoice'),
37                  ).
38      ')';
39 }
40
41 my $delete = '';
42 $delete = areyousure_link("${p}misc/delete-cust_bill.html?$invnum",
43                             emt('Are you sure you want to delete this invoice?'),
44                             emt('Delete this invoice from the database completely'),
45                             emt('delete')
46                         )
47     if ( $opt{'deleteinvoices'} && $curuser->access_right('Delete invoices') );
48
49 my $events = '';
50 #1.9
51 if ( $cust_bill->num_cust_event
52      && (    $curuser->access_right('Billing event reports')
53           || $curuser->access_right('View customer billing events')
54         )
55    ) {
56   $under .=
57     qq!<BR><A HREF="${p}search/cust_event.html?invnum=$invnum">( !.
58       emt('View invoice events').' )</A>';
59 }
60 $under = '<FONT SIZE="-1">'.$under.'</FONT>' if length($under);
61
62 </%init>