X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=bin%2Fcust_main-bulk_change;h=02931abed9b486f357729c6fef12c376a6d3964e;hb=c3b8e954dbf5ddd04930809edfb77fa106fccaee;hp=fdf53d9995cef70442b18f7eece1c5b111c9aa9c;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/bin/cust_main-bulk_change b/bin/cust_main-bulk_change index fdf53d999..02931abed 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; @@ -31,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