X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=3b746fc2deaaeef27f33325070835950070499ea;hb=057ae504915d912bc60df87c9914e11752edf680;hp=fea05683d1eaee7e92a56a71d9c0f82f8577ed34;hpb=71231d6bd803d2a3977c3ce2fa1f3c0ed4746b2d;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index fea05683d..3b746fc2d 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -2844,7 +2844,7 @@ sub change_later { # Apply user-specified discount to new cust_pkg $error = $err_or_pkg->change_discount(\%discount) - if !$error && %discount && %discount{discountnum} =~ /^-?\d+$/; + if !$error && %discount && $discount{discountnum} =~ /^-?\d+$/; } else { $error = $err_or_pkg; } @@ -2855,7 +2855,7 @@ sub change_later { # Apply user-specified discount to new cust_pkg $error = $change_to->change_discount(\%discount) - if !$error && %discount && %discount{discountnum} =~ /^-?\d+$/; + if !$error && %discount && $discount{discountnum} =~ /^-?\d+$/; } if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -2898,7 +2898,7 @@ sub change_later { # Apply user-specified discount to new cust_pkg $new->change_discount(\%discount) - if !$error && %discount && %discount{discountnum} =~ /^-?\d+$/; + if !$error && %discount && $discount{discountnum} =~ /^-?\d+$/; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -3179,11 +3179,10 @@ sub process_bulk_cust_pkg { my $param = thaw(decode_base64(shift)); warn Dumper($param) if $DEBUG; - my $old_part_pkg = qsearchs('part_pkg', - { pkgpart => $param->{'old_pkgpart'} }); my $new_part_pkg = qsearchs('part_pkg', { pkgpart => $param->{'new_pkgpart'} }); - die "Must select a new package type\n" unless $new_part_pkg; + die "Must select a new package definition\n" unless $new_part_pkg; + #my $keep_dates = $param->{'keep_dates'} || 0; my $keep_dates = 1; # there is no good reason to turn this off @@ -3198,7 +3197,14 @@ sub process_bulk_cust_pkg { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - my @cust_pkgs = qsearch('cust_pkg', { 'pkgpart' => $param->{'old_pkgpart'} } ); + my @old_pkgpart = ref($param->{'old_pkgpart'}) ? @{ $param->{'old_pkgpart'} } + : $param->{'old_pkgpart'}; + + my @cust_pkgs = qsearch({ + 'table' => 'cust_pkg', + 'extra_sql' => ' WHERE pkgpart IN ('. + join(',', @old_pkgpart). ')', + }); my $i = 0; foreach my $old_cust_pkg ( @cust_pkgs ) { @@ -5887,6 +5893,8 @@ sub search { push @where, $FS::CurrentUser::CurrentUser->agentnums_sql('table'=>'cust_main'); } + push @where, "cust_pkg_reason.reasonnum = '".$params->{reasonnum}."'" if $params->{reasonnum}; + my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; my $addl_from = 'LEFT JOIN part_pkg USING ( pkgpart ) '. @@ -5894,6 +5902,10 @@ sub search { 'LEFT JOIN cust_location USING ( locationnum ) '. FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg'); + if ($params->{reasonnum}) { + $addl_from .= 'LEFT JOIN cust_pkg_reason ON (cust_pkg_reason.pkgnum = cust_pkg.pkgnum) '; + } + my $select; my $count_query; if ( $params->{'select_zip5'} ) {