summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-04-12 15:13:49 -0700
committerIvan Kohler <ivan@freeside.biz>2012-04-12 15:13:49 -0700
commitb17ce7c641ad897ec35cac0c8f8e69320c19ab0e (patch)
tree2c2103960f376419326bd7fd8b6d534b8b8ac1b8 /bin
parent902d15046334045b5f24c2d9e179b3db6e1ee3f4 (diff)
adding quick package definition bulk change tool, RT#17348
Diffstat (limited to 'bin')
-rwxr-xr-xbin/part_pkg-bulk_change72
1 files changed, 72 insertions, 0 deletions
diff --git a/bin/part_pkg-bulk_change b/bin/part_pkg-bulk_change
new file mode 100755
index 000000000..aecfea580
--- /dev/null
+++ b/bin/part_pkg-bulk_change
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+
+use strict;
+use vars qw( $opt_r $opt_o $opt_v );
+use Getopt::Std;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearch qsearchs);
+use FS::part_pkg;
+use FS::part_pkg_option;
+
+getopts('ro:v:');
+
+my $user = shift or &usage;
+adminsuidsetup $user;
+
+foreach my $part_pkg ( qsearch('part_pkg', {}) ) {
+ next if ! $part_pkg->freq && $opt_r;
+
+ my %hash = (
+ 'pkgpart' => $part_pkg->pkgpart,
+ 'optionname' => $opt_o,
+ );
+
+ my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
+
+ if ( $part_pkg_option ) {
+ next if $part_pkg_option->optionvalue eq $opt_v;
+ $part_pkg_option->optionvalue($opt_v);
+ my $error = $part_pkg_option->replace;
+ die $error if $error;
+ } else {
+ $part_pkg_option = new FS::part_pkg_option { %hash, 'optionvalue'=>$opt_v };
+ my $error = $part_pkg_option->insert;
+ die $error if $error;
+ }
+
+}
+
+sub usage {
+ die "usage: part_pkg-bulk_change [ -r ] -o option_name -v option_value employee_username\n";
+}
+
+=head1 NAME
+
+cust_main-bulk_change
+
+=head1 SYNOPSIS
+
+ part_pkg-bulk_change [ -r ] -o option_name -v option_value employee_username
+
+=head1 DESCRIPTION
+
+Command-line tool to change the payby field for a group of customers.
+
+-r: recurring package definitions only
+
+-o: part_pkg_option optionname
+
+-v: part_pkg_option optionvalue
+
+employee_username
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::part_pkg>
+
+=cut
+
+1;
+