From 958afb8d05de67e12df258b57bedcf85028b6253 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 7 Aug 2009 00:39:14 +0000 Subject: [PATCH] don't start recurring billing when a start date hasn't been reached yet either... and since that works, add the start date to new package order, RT#5347 --- FS/FS/cust_main.pm | 7 +++--- httemplate/edit/process/quick-cust_pkg.cgi | 4 +++ httemplate/elements/tr-input-date-field.html | 15 ++++++----- httemplate/misc/order_pkg.html | 37 ++++++++++++++++++++++++++++ httemplate/view/cust_main/packages.html | 1 + 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index becb9054b..8cd03ebc6 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -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') diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 57c696e7e..7a0f08280 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -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, }; diff --git a/httemplate/elements/tr-input-date-field.html b/httemplate/elements/tr-input-date-field.html index 11581d5bc..428221a5c 100644 --- a/httemplate/elements/tr-input-date-field.html +++ b/httemplate/elements/tr-input-date-field.html @@ -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 = ''; } diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index 9caa57a69..a7571ca58 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -1,5 +1,10 @@ <% include('/elements/header-popup.html', 'Order new package' ) %> + + + + + + % 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) : ''; + diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index 8fbefae50..16adc8c5f 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -9,6 +9,7 @@ 'cust_main' => $cust_main, 'closetext' => 'Close', 'width' => 763, + 'height' => 350, ) %> % } -- 2.11.0