summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorivan <ivan>2011-04-12 02:29:42 +0000
committerivan <ivan>2011-04-12 02:29:42 +0000
commit5668de2e9beab1c2881dc697aaf9fa19a3be6f2b (patch)
tree20d42fe7af1a69fa0eca90fa28edb3584f4eef07 /bin
parentd1384806285ae03e8132ad2844d376ff64bd5e6d (diff)
adding quick cust_main-bulk_change hask to change payby, RT#12430
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cust_main-bulk_change69
1 files changed, 69 insertions, 0 deletions
diff --git a/bin/cust_main-bulk_change b/bin/cust_main-bulk_change
new file mode 100755
index 0000000..618856c
--- /dev/null
+++ b/bin/cust_main-bulk_change
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+use strict;
+use vars qw( $opt_p );
+use Getopt::Std;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearchs);
+use FS::cust_main;
+
+getopts('p:');
+
+my $user = shift or &usage;
+adminsuidsetup $user;
+
+$FS::cust_main::skip_fuzzyfiles = 1;
+$FS::cust_main::skip_fuzzyfiles = 1;
+
+while (<STDIN>) {
+
+ unless ( /^\s*(\d+)\s*$/ ) {
+ warn "unparsable line: $_";
+ next;
+ }
+ my $custnum = $1;
+
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+ unless ( $cust_main ) {
+ warn "unknown custnum $custnum\n";
+ next;
+ }
+
+ if ( $opt_p ) {
+ $cust_main->payby($opt_p);
+ }
+
+ my $error = $cust_main->replace;
+ die "$error\n" if $error;
+
+}
+
+sub usage {
+ die "usage: cust_main-bulk_change -p NEW_PAYBY employee_username <custnums.txt\n";
+}
+
+=head1 NAME
+
+cust_main-bulk_change
+
+=head1 SYNOPSIS
+
+ cust_main-bulk_change -p NEW_PAYBY username <custnums.txt
+
+=head1 DESCRIPTION
+
+Command-line tool to change the payby field for a group of customers.
+
+-p: new payby, for example, I<CARD> or I<DCRD>.
+
+user: Employee username
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::payinfo_Mixin>, L<FS::cust_main>, L<FS::payby>
+
+=cut
+
+1;