add cust_pkg.order_date, RT6628
[freeside.git] / httemplate / view / cust_main / packages / status.html
index f3b2faa..2707803 100644 (file)
@@ -3,6 +3,10 @@
 
 %#this should use cust_pkg->status and cust_pkg->statuscolor eventually
 
+% if ( $cust_pkg->order_date ) {
+    <% pkg_status_row($cust_pkg, 'Ordered', 'order_date', %opt ) %>
+% }
+
 % if ( $cust_pkg->get('cancel') ) { #status: cancelled
 %   my $cpr = $cust_pkg->last_cust_pkg_reason('cancel');
 
        )
     %>
 
+    <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
+    <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
 %   unless ( $cust_pkg->get('setup') ) { 
       <% pkg_status_row_colspan( $cust_pkg, 'Never billed', '', 'colspan'=>$colspan, %opt ) %>
 %   } else { 
 
     <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
     <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
-%   # pkg_status_row($cust_pkg, 'Next bill', 'bill', %opt)
+%   if ( $part_pkg->option('suspend_bill', 1) ) {
+      <% pkg_status_row_if( $cust_pkg, 'Next&nbsp;bill', 'bill', %opt, curuser=>$curuser ) %>
+%   }
     <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
+    <% pkg_status_row_if( $cust_pkg, 'Contract ends', 'contract_end', %opt ) %>
 
     <TR>
       <TD COLSPAN=<%$colspan%>>
 %
 %     unless ( $cust_pkg->get('setup') ) { #not setup
 %
-%       unless ( $part_pkg->freq ) { 
+%       unless ( $part_pkg->freq ) {
 
           <% pkg_status_row_colspan( $cust_pkg, 'Not&nbsp;yet&nbsp;billed&nbsp;(one-time&nbsp;charge)', '', 'colspan'=>$colspan, %opt ) %>
 
-          <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
+          <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
+          <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
+          <% pkg_status_row_if(
+               $cust_pkg,
+               ( $part_pkg->freq ? 'Start billing' : 'Bill on' ),
+               'start_date',
+               %opt
+             )
+          %>
 
           <TR>
             <TD COLSPAN=<%$colspan%>>
 
 %       } else { 
 
-         <% pkg_status_row_colspan($cust_pkg, "Not&nbsp;yet&nbsp;billed&nbsp;($billed_or_prepaid&nbsp;". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %>
+          <% pkg_status_row_colspan($cust_pkg, "Not&nbsp;yet&nbsp;billed&nbsp;($billed_or_prepaid&nbsp;". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %>
+
+          <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
+          <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
 
           <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
 
 
           <% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %>
 
+          <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
+          <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
 %       } else { 
 %
 %         if (scalar($cust_pkg->overlimit)) {
             %>
 %         } 
 
+          <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
+          <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
           <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %>
 
 %       } 
       <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %>
       <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %>
       <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %>
+      <% pkg_status_row_if( $cust_pkg, 'Contract ends', 'contract_end', %opt ) %>
 
 %     if ( $part_pkg->freq ) { 
 
@@ -267,12 +301,61 @@ sub pkg_status_row_changed {
                                      'size'    => '-1',
                                      'align'   => 'right',
                                      'colspan' => $opt{'colspan'},
+                                     #%opt,
                                    );
   }
 
   $html;
 }
 
+sub pkg_status_row_noauto {
+  my( $cust_pkg, %opt ) = @_;
+  my $part_pkg = $opt{'part_pkg'};
+  return '' unless $cust_pkg->no_auto || $part_pkg->no_auto;
+
+  #inefficient, should be passed in
+  my $cust_main = $cust_pkg->cust_main;
+
+  return '' unless $cust_main->payby =~ /^(CARD|CHEK)$/;
+  my $what = lc(FS::payby->shortname($cust_main->payby));
+
+  pkg_status_row_colspan( $cust_pkg, "No automatic $what charge", '',
+                          'colspan' => $opt{'colspan'},
+                          #%opt,
+                        );
+}
+
+sub pkg_status_row_discount {
+  my( $cust_pkg, %opt ) = @_;
+
+  my $html;
+
+  foreach my $cust_pkg_discount ( $cust_pkg->cust_pkg_discount_active ) {
+
+    my $discount = $cust_pkg_discount->discount;
+
+    my $label = '<B>Discount</B>: '. $discount->description;
+    if ( $discount->months ) {
+      my $remaining = $discount->months - $cust_pkg_discount->months_used;
+      $remaining = sprintf('%.2f', $remaining) if $remaining =~ /\./;
+      $label .= " ($remaining months remaining)"
+    }
+
+    $label .= ' <FONT SIZE="-1">('.
+                '<A HREF="../misc/delete-cust_pkg_discount.html?'.
+                  $cust_pkg_discount->pkgdiscountnum.
+                '">remove&nbsp;discount</A>)</FONT>';
+
+    $html .= pkg_status_row_colspan( $cust_pkg, $label, '',
+                                     'colspan' => $opt{'colspan'},
+                                     #%opt,
+                                   );
+
+  }
+
+  $html;
+}
+
 sub pkg_status_row_colspan {
   my($cust_pkg, $title, $addl, %opt) = @_;