[freeside-commits] branch FREESIDE_3_BRANCH updated. ff0bc74a18466766d13da2bec0059b12b34b207d

Jonathan Prykop jonathan at 420.am
Tue Aug 9 15:25:05 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  ff0bc74a18466766d13da2bec0059b12b34b207d (commit)
       via  e05ff0efafd8631942c5770eaad69ad8ddfede82 (commit)
      from  9051d439b1d825b5f4ef912d495404082ae0343f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ff0bc74a18466766d13da2bec0059b12b34b207d
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Aug 8 22:07:58 2016 -0500

    RT#71995: Cancel Packages [turned off debug in email_search]

diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 22b8495..66b73dd 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -513,11 +513,9 @@ none or one).
 sub email_search {
   my %options = @_;
 
-  local($DEBUG) = 1;
-
   my $email = delete $options{'email'};
 
-  #we're only being used by RT at the moment... no agent virtualization yet
+  #no agent virtualization yet
   #my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql;
 
   my @cust_main = ();

commit e05ff0efafd8631942c5770eaad69ad8ddfede82
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Aug 8 22:06:30 2016 -0500

    RT#71995: Cancel Packages [parse emails in cust_main-bulk_change]

diff --git a/bin/cust_main-bulk_change b/bin/cust_main-bulk_change
index e039012..47a9ae3 100755
--- a/bin/cust_main-bulk_change
+++ b/bin/cust_main-bulk_change
@@ -1,15 +1,16 @@
 #!/usr/bin/perl
 
 use strict;
-use vars qw( $opt_a $opt_p $opt_t $opt_k $opt_c );
+use vars qw( $opt_a $opt_p $opt_t $opt_k $opt_c $opt_v $opt_E );
 use Getopt::Std;
 use FS::UID qw(adminsuidsetup);
 use FS::Record qw(qsearch qsearchs);
 use FS::cust_main;
+use FS::cust_main::Search;
 use FS::cust_tag;
 use FS::cust_pkg;
 
-getopts('a:p:t:k:c:');
+getopts('a:p:t:k:c:vE');
 
 my $user = shift or &usage;
 adminsuidsetup $user;
@@ -21,16 +22,38 @@ $FS::cust_main::import = 1;
 
 while (<STDIN>) {
 
-  unless ( /^\s*(\d+)\s*$/ ) { 
-    warn "unparsable line: $_";
-    next;
+  my ($custnum,$cust_main);
+  if ($opt_E) {
+    # don't really need to validate input here, search will quote safely
+    unless ( /^\s*(.*)\s*$/ ) { 
+      warn "unparsable line: $_";
+      next;
+    }
+    my @cust_main = FS::cust_main::Search::email_search( 'email' => $1 );
+    if (@cust_main > 1) {
+      warn "muliple matching customers for address, skipping: $_";
+      next;
+    } elsif (@cust_main < 1) {
+      warn "could not find matching customer for address, skipping: $_";
+      next;
+    }
+    $cust_main = $cust_main[0];
+    $custnum = $cust_main->custnum;
+  } else {
+    unless ( /^\s*(\d+)\s*$/ ) { 
+      warn "unparsable line: $_";
+      next;
+    }
+    my $custnum = $1;
+    $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+    unless ( $cust_main ) {
+      warn "unknown custnum $custnum\n";
+      next;
+    }
   }
-  my $custnum = $1;
 
-  my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
-  unless ( $cust_main ) {
-    warn "unknown custnum $custnum\n";
-    next;
+  if ( $opt_v ) {
+    print $cust_main->custnum . ": " . $cust_main->name . "\n";
   }
 
   my %cust_tag = ( custnum=>$custnum, tagnum=>$opt_t );
@@ -72,7 +95,7 @@ while (<STDIN>) {
 }
 
 sub usage {
-  die "usage: cust_main-bulk_change [ -a agentnum ] [ -p NEW_PAYBY ] [ -t tagnum ] [ -k old_pkgpart:new_pkgpart,... ] employee_username <custnums.txt\n";
+  die "usage: cust_main-bulk_change [ -a agentnum ] [ -p NEW_PAYBY ] [ -t tagnum ] [ -k old_pkgpart:new_pkgpart,... ] [-v] [-E] employee_username <custnums.txt\n";
 }
 
 =head1 NAME
@@ -97,6 +120,10 @@ Command-line tool to make bulk changes to a group of customers.
 
 -c: Cancel customer
 
+-v: verbose
+
+-E: input is customer emails, rather than customer numbers
+
 user: Employee username
 
 =head1 BUGS

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_main/Search.pm |    4 +---
 bin/cust_main-bulk_change |   49 +++++++++++++++++++++++++++++++++++----------
 2 files changed, 39 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list