don't start recurring billing when a start date hasn't been reached yet either.....
authorivan <ivan>
Fri, 7 Aug 2009 00:39:14 +0000 (00:39 +0000)
committerivan <ivan>
Fri, 7 Aug 2009 00:39:14 +0000 (00:39 +0000)
FS/FS/cust_main.pm
httemplate/edit/process/quick-cust_pkg.cgi
httemplate/elements/tr-input-date-field.html
httemplate/misc/order_pkg.html
httemplate/view/cust_main/packages.html

index becb905..8cd03eb 100644 (file)
@@ -2857,9 +2857,10 @@ sub _make_lines {
   my $recur = 0;
   my $unitrecur = 0;
   my $sdate;
-  if ( ! $cust_pkg->getfield('susp') and
-           ( $part_pkg->getfield('freq') ne '0' &&
-             ( $cust_pkg->getfield('bill') || 0 ) <= $time
+  if (     ! $cust_pkg->get('susp')
+       and ! $cust_pkg->get('start_date')
+       and ( $part_pkg->getfield('freq') ne '0'
+             && ( $cust_pkg->getfield('bill') || 0 ) <= $time
            )
         || ( $part_pkg->plan eq 'voip_cdr'
               && $part_pkg->option('bill_every_call')
index 57c696e..7a0f082 100644 (file)
@@ -49,6 +49,10 @@ my $locationnum = $1;
 my $cust_pkg = new FS::cust_pkg {
   'custnum'     => $custnum,
   'pkgpart'     => $pkgpart,
+  'start_date'  => ( scalar($cgi->param('start_date'))
+                       ? str2time($cgi->param('start_date'))
+                       : ''
+                   ),
   'refnum'      => $refnum,
   'locationnum' => $locationnum,
 };
index 11581d5..428221a 100644 (file)
@@ -28,12 +28,15 @@ my($name, $value, $label, $format, $usedatetime) = @_;
 $format = "%m/%d/%Y" unless $format;
 $label = $name unless $label;
 
-if ($usedatetime) {
-  my $dt = DateTime->from_epoch(epoch => $value, time_zone => 'floating');
-  $value = $dt->strftime($format)
-    unless $value eq '';
-}else{
-  $value = time2str($format, $value);
+if ( $value =~ /\S/ ) {
+  if ( $usedatetime ) {
+    my $dt = DateTime->from_epoch(epoch => $value, time_zone => 'floating');
+    $value = $dt->strftime($format);
+  } else {
+    $value = time2str($format, $value);
+  }
+} else {
+  $value = '';
 }
 
 </%init>
index 9caa57a..a7571ca 100644 (file)
@@ -1,5 +1,10 @@
 <% include('/elements/header-popup.html', 'Order new package' ) %>
 
+<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
+
 <SCRIPT TYPE="text/javascript">
 
   function enable_order_pkg () {
           )
 %>
 
+%# false laziness w/edit/quick-charge.html
+<TR>
+  <TH ALIGN="right">Start date </TD>
+  <TD COLSPAN=6>
+    <INPUT TYPE  = "text"
+           NAME  = "start_date"
+           SIZE  = 32
+           ID    = "start_date_text"
+           VALUE = "<% $start_date %>"
+    >
+    <IMG SRC   = "../images/calendar.png"
+         ID    = "start_date_button"
+         STYLE = "cursor: pointer"
+         TITLE = "Select date"
+    >
+    <FONT SIZE=-1>(leave blank to start immediately)</FONT>
+  </TD>
+</TR>
+
+<SCRIPT TYPE="text/javascript">
+  Calendar.setup({
+    inputField: "start_date_text",
+    ifFormat:   "%m/%d/%Y",
+    button:     "start_date_button",
+    align:      "BR"
+  });
+</SCRIPT>
+
 % if ( $conf->exists('pkg_referral') ) {
   <% include('/elements/tr-select-part_referral.html',
                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
@@ -68,4 +101,8 @@ my $cust_main = qsearchs({
 
 my $pkgpart = scalar($cgi->param('pkgpart'));
 
+my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi?
+my $start_date = $cust_main->next_bill_date;
+$start_date = $start_date ? time2str($format, $start_date) : '';
+
 </%init>
index 8fbefae..16adc8c 100755 (executable)
@@ -9,6 +9,7 @@
                 'cust_main'   => $cust_main,
                 'closetext'   => 'Close',
                 'width'       => 763,
+                'height'      => 350,
             )
   %>
 % }