X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=e2f7aca1636c0cea56d870d722eccb1af35ff98a;hb=b5d9087e43d24bfa76ca1d87480cc7d95e85c285;hp=1d0cc4fbc5c002c403b83dc83dbbb59c9be050ec;hpb=5f2c3a88d92952d13a5231a230e332e1a8e94016;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 1d0cc4fbc..e2f7aca16 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -60,6 +60,8 @@ our $upgrade = 0; #go away after setup+start dates cleaned up for old customers our $cache_enabled = 0; +our $disable_start_on_hold = 0; + sub _simplecache { my( $self, $hashref ) = @_; if ( $cache_enabled && $hashref->{'pkg'} && $hashref->{'plan'} ) { @@ -397,7 +399,10 @@ sub insert { $self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) ); } - if ($self->susp eq 'now' or $part_pkg->start_on_hold) { + if ( $self->susp eq 'now' + or ( $part_pkg->start_on_hold && ! $disable_start_on_hold ) + ) + { # if the package was ordered on hold: # - suspend it # - don't set the start date (it will be started manually) @@ -5560,6 +5565,23 @@ sub forward_emails { } # Used by FS::Upgrade to migrate to a new database. +sub _upgrade_schema { # class method + my ($class, %opts) = @_; + + my $sql = ' + UPDATE cust_pkg SET change_to_pkgnum = NULL + WHERE change_to_pkgnum IS NOT NULL + AND NOT EXISTS ( SELECT 1 FROM cust_pkg AS ctcp + WHERE ctcp.pkgnum = cust_pkg.change_to_pkgnum + ) + '; + + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + ''; +} + +# Used by FS::Upgrade to migrate to a new database. sub _upgrade_data { # class method my ($class, %opts) = @_; $class->_upgrade_otaker(%opts);