better display/edit of contacts on customer view, RT#16819
[freeside.git] / httemplate / view / cust_main / payment_history.html
index fa9c166..b5b7161 100644 (file)
     </TD>
     <TD ALIGN="right" VALIGN="top">
 
-%# invoice reports
+%# invoice reports, combined statement
 % if ( $curuser->access_right('List invoices') ) { 
+%   if ( $conf->exists('cust_main-print_statement_link')
+%        and $num_cust_bill > 0 ) {
+  <A HREF="<% $p %>view/cust_main_statement-pdf.cgi?<% $custnum %>"><%
+  mt('Print a current statement') |h %></A>
+  <BR>
+%   }
   <A HREF="<% $p %>search/report_cust_bill.html?custnum=<% $custnum %>"><% mt('Invoice reports') |h %></A>
 % } 
 <BR>
 %
 %  my $charge  = exists($item->{'charge'})
 %                  ? sprintf("$money_char\%.2f", $item->{'charge'})
-%                  : '';
+%                  : exists($item->{'charge_nobal'})
+%                    ? sprintf("$money_char\%.2f", $item->{'charge_nobal'})
+%                    : '';
 %
 %  my $payment = exists($item->{'payment'})
 %                  ? sprintf("-&nbsp;$money_char\%.2f", $item->{'payment'})
@@ -396,13 +404,26 @@ my %opt = (
   )
 );
 
+$opt{'date_format'} ||= '%m/%d/%Y';
+
+#legacy invoices
+foreach my $legacy_cust_bill ($cust_main->legacy_cust_bill) {
+  push @history, {
+    'date'   => $legacy_cust_bill->_date,
+    'desc'   => include('payment_history/legacy_invoice.html', $legacy_cust_bill, %opt ),
+    'charge_nobal' => $legacy_cust_bill->charged,
+  };
+}
+
 #invoices
+my $num_cust_bill = 0;
 foreach my $cust_bill ($cust_main->cust_bill) {
   push @history, {
     'date'   => $cust_bill->_date,
     'desc'   => include('payment_history/invoice.html', $cust_bill, %opt ),
     'charge' => $cust_bill->charged,
   };
+  $num_cust_bill++;
 }
 
 #statements
@@ -507,6 +528,8 @@ sub translate_payinfo {
     my $payby = $object->payby;
     my $payinfo = $object->payinfo;
 
+    my $conf = new FS::Conf;
+
     if ( $payby eq 'CARD' ) {
         $payinfo = $object->paymask;
     } elsif ( $payby eq 'CHEK' ) {