X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=bin%2Fcust_main-bulk_change;h=02931abed9b486f357729c6fef12c376a6d3964e;hb=2920cfc494c2811ca7879d6ecaa353d216c9f69d;hp=618856cdcdea47ebca9479c0d8dba72c1d3a3a7e;hpb=b5c4237a34aef94976bc343c8d9e138664fc3984;p=freeside.git diff --git a/bin/cust_main-bulk_change b/bin/cust_main-bulk_change index 618856cdc..02931abed 100755 --- a/bin/cust_main-bulk_change +++ b/bin/cust_main-bulk_change @@ -1,19 +1,22 @@ #!/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; $FS::cust_main::skip_fuzzyfiles = 1; $FS::cust_main::skip_fuzzyfiles = 1; +$FS::cust_main::import = 1; +$FS::cust_main::import = 1; while () { @@ -29,17 +32,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