From 5620fb4c5e1b5b56ed1d46871faa616d94493f85 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 18 Jan 2013 10:47:02 -0800 Subject: [PATCH] add -t option to cust_main-bulk_change, RT#21036 --- bin/cust_main-bulk_change | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) 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 -- 2.11.0