[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 9cd4b1c1ad795aff32fb0fcb285ae5137edd9167

Ivan ivan at 420.am
Fri Jan 18 10:47:05 PST 2013


The branch, FREESIDE_2_3_BRANCH has been updated
       via  9cd4b1c1ad795aff32fb0fcb285ae5137edd9167 (commit)
      from  e89b28b54a01b399be53a628f06386096fd2a055 (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 9cd4b1c1ad795aff32fb0fcb285ae5137edd9167
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Jan 18 10:47:04 2013 -0800

    add -t option to cust_main-bulk_change, RT#21036

diff --git a/bin/cust_main-bulk_change b/bin/cust_main-bulk_change
index 618856c..6e4a8e1 100755
--- a/bin/cust_main-bulk_change
+++ b/bin/cust_main-bulk_change
@@ -1,13 +1,14 @@
 #!/usr/bin/perl
 
 use strict;
-use vars qw( $opt_p );
+use vars qw( $opt_p $opt_t );
 use Getopt::Std;
 use FS::UID qw(adminsuidsetup);
 use FS::Record qw(qsearchs);
 use FS::cust_main;
+use FS::cust_tag;
 
-getopts('p:');
+getopts('p:t:');
 
 my $user = shift or &usage;
 adminsuidsetup $user;
@@ -29,17 +30,24 @@ while (<STDIN>) {
     next;
   }
 
+  my %cust_tag = ( custnum=>$custnum, tagnum=>$opt_t );
+  if ( $opt_t && ! qsearchs('cust_tag', \%cust_tag) ) {
+    my $cust_tag = new FS::cust_tag \%cust_tag;
+    my $error = $cust_tag->insert;
+    die "$error\n" if $error;
+  }
+
   if ( $opt_p ) {
     $cust_main->payby($opt_p);
-  }
 
-  my $error = $cust_main->replace;
-  die "$error\n" if $error;
+    my $error = $cust_main->replace;
+    die "$error\n" if $error;
+  }
 
 }
 
 sub usage {
-  die "usage: cust_main-bulk_change -p NEW_PAYBY employee_username <custnums.txt\n";
+  die "usage: cust_main-bulk_change [ -p NEW_PAYBY ] [ -t tagnum ] employee_username <custnums.txt\n";
 }
 
 =head1 NAME
@@ -48,13 +56,15 @@ cust_main-bulk_change
 
 =head1 SYNOPSIS
 
-  cust_main-bulk_change -p NEW_PAYBY username <custnums.txt
+  cust_main-bulk_change [ -p NEW_PAYBY ] [ -t tagnum ] username <custnums.txt
 
 =head1 DESCRIPTION
 
-Command-line tool to change the payby field for a group of customers.
+Command-line tool to make bulk changes to a group of customers.
+
+-p: new payby, for example, I<CARD> or I<DCRD>
 
--p: new payby, for example, I<CARD> or I<DCRD>.
+-t: tagnum to add if not present
 
 user: Employee username
 

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

Summary of changes:
 bin/cust_main-bulk_change |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)




More information about the freeside-commits mailing list