From: Ivan Kohler Date: Fri, 18 Jan 2013 18:47:04 +0000 (-0800) Subject: add -t option to cust_main-bulk_change, RT#21036 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=9cd4b1c1ad795aff32fb0fcb285ae5137edd9167;p=freeside.git 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 618856cdc..6e4a8e1a3 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 () { 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 or I --p: new payby, for example, I or I. +-t: tagnum to add if not present user: Employee username