Billsoft -> Avalara adjustments, checkpoint
[freeside.git] / httemplate / view / cust_main / payment_history / invoice.html
index c0d32df..7c993d6 100644 (file)
@@ -1,45 +1,61 @@
-<% $link %><% $pre %>Invoice #<% $cust_bill->display_invnum %>
-(Balance $ <% $cust_bill->owed %>)<% $post %><% $link ? '</A>' : '' %><% $delete %><% $events %>
+<% $link %><% $invoice %><% $link ? '</A>' : '' %><% "$email$void$under" %>
 <%init>
 
 my( $cust_bill, %opt ) = @_;
 
-my $conf = new FS::Conf;
-
-my $curuser = $FS::CurrentUser::CurrentUser;
-
-my($pre, $post) = ('', '');
-if ( $cust_bill->owed > 0 ) {
-  $pre = '<B><FONT SIZE="+1" COLOR="#FF0000">Open ';
-  $post = '</FONT></B>';
+my $under = '';
+my $invoice;
+if ( $cust_bill->pending ) {
+  $invoice = '<I><FONT SIZE="+1" COLOR="#D05000">' .
+    emt("Pending Invoice #[_1] (Charges of [_2])", $cust_bill->display_invnum, $cust_bill->charged);
+} elsif ( $cust_bill->owed > 0 ) {
+  $invoice = '<B><FONT SIZE="+1" COLOR="#FF0000">' .
+    emt("Open Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed) .
+    '</FONT></B>';
+  if ( $cust_bill->promised_date ) {
+    $under .= '<BR>'. emt('Payment promised on [_1]',
+        time2str($opt{'date_format'}, $cust_bill->promised_date));
+  }
+} else {
+  $invoice = emt("Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed);
 }
 
 my $invnum = $cust_bill->invnum;
 
-my $link = $curuser->access_right('View invoices')
+my $link = $opt{'View invoices'}
              ? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">!
              : '';
 
-my $delete = '';
-if ( $opt{'deleteinvoices'} && $curuser->access_right('Delete invoices') ) {
-  $delete = qq! (<A HREF="javascript:areyousure('!.
-            qq!${p}misc/delete-cust_bill.html?$invnum',!.
-            qq!'Are you sure you want to delete this invoice?')"!.
-            qq! TITLE="Delete this invoice from the database completely"!.
-            qq!>delete</A>)!;
+my $void = '';
+if ( $cust_bill->closed !~ /^Y/i && $opt{'Void invoices'} ) {
+  $void =
+    ' ('. include('/elements/popup_link.html',
+                    'label'     => emt('void'),
+                    'action'    => "${p}misc/void-cust_bill.html?;invnum=".
+                                    $cust_bill->invnum,
+                    'actionlabel' => emt('Void Invoice'),
+                 ).
+     ')';
 }
 
+my $email = ($opt{'has_email_address'} && $opt{'Resend invoices'}) ? 
+  q! (<A HREF="javascript:void(0)" ONCLICK="areyousure_popup('Send email copy of invoice #!.
+  $cust_bill->invnum.
+  q! to customer?','!.
+  "${p}misc/send-invoice.cgi?method=email;notice_name=Invoice;popup=1;invnum=".
+  $cust_bill->invnum.
+  q!','Email Invoice Receipt')" TITLE="Send email invoice">email</A>)!
+  : '';
+
 my $events = '';
-#1.9
 if ( $cust_bill->num_cust_event
-     && (    $curuser->access_right('Billing event reports')
-          || $curuser->access_right('View customer billing events')
-        )
-   ) {
-  $events =
-    qq!<BR><FONT SIZE="-1"><A HREF="${p}search/cust_event.html?invnum=$invnum!.
-    '">(&nbsp;View invoice events&nbsp;)</A></FONT>';
+     && ($opt{'Billing event reports'} || $opt{'View customer billing events'})
+   )
+{
+  $under .=
+    qq!<BR><A HREF="${p}search/cust_event.html?invnum=$invnum">( !.
+      emt('View invoice events').' )</A>';
 }
-#
+$under = '<FONT SIZE="-1">'.$under.'</FONT>' if length($under);
 
 </%init>