4 use vars qw( $opt_a $opt_p $opt_t $opt_k );
6 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearch qsearchs);
14 my $user = shift or &usage;
17 $FS::cust_main::skip_fuzzyfiles = 1;
18 $FS::cust_main::skip_fuzzyfiles = 1;
22 unless ( /^\s*(\d+)\s*$/ ) {
23 warn "unparsable line: $_";
28 my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
29 unless ( $cust_main ) {
30 warn "unknown custnum $custnum\n";
34 my %cust_tag = ( custnum=>$custnum, tagnum=>$opt_t );
35 if ( $opt_t && ! qsearchs('cust_tag', \%cust_tag) ) {
36 my $cust_tag = new FS::cust_tag \%cust_tag;
37 my $error = $cust_tag->insert;
38 die "$error\n" if $error;
41 if ( $opt_p || $opt_a ) {
42 $cust_main->agentnum($opt_a) if $opt_a;
43 $cust_main->payby($opt_p) if $opt_p;
45 my $error = $cust_main->replace;
46 die "$error\n" if $error;
50 foreach my $k (split(/\s*,\s*/, $opt_k)) {
51 my($old, $new) = split(/\s*:\s*/, $k);
52 foreach my $cust_pkg ( qsearch('cust_pkg', {
53 'custnum' => $cust_main->custnum,
58 $cust_pkg->pkgpart($new);
59 my $error = $cust_pkg->replace;
60 die "$error\n" if $error;
68 die "usage: cust_main-bulk_change [ -a agentnum ] [ -p NEW_PAYBY ] [ -t tagnum ] [ -k old_pkgpart:new_pkgpart,... ] employee_username <custnums.txt\n";
77 cust_main-bulk_change [ -a agentnum ] [ -p NEW_PAYBY ] [ -t tagnum ] [ -k old_pkgpart:new_pkgpart,... ] username <custnums.txt
81 Command-line tool to make bulk changes to a group of customers.
85 -p: new payby, for example, I<CARD> or I<DCRD>
87 -t: tagnum to add if not present
89 -k: old_pkgpart:new_pkgpart, for example, I<5:4>. Multiple entries can be comma-separated.
91 user: Employee username
97 L<FS::payinfo_Mixin>, L<FS::cust_main>, L<FS::payby>