4 use vars qw( $opt_r $opt_p $opt_o $opt_v $opt_s $opt_S $opt_z $opt_Z );
6 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearch qsearchs);
9 use FS::part_pkg_option;
11 getopts('rm:p:o:v:sSzZ');
13 my $user = shift or &usage;
17 $search{'plan'} = $opt_p if $opt_p;
18 $search{'comment'} = $opt_m if $opt_m;
20 foreach my $part_pkg ( qsearch('part_pkg',\%search) ) {
21 next if ! $part_pkg->freq && $opt_r;
24 'pkgpart' => $part_pkg->pkgpart,
25 'optionname' => $opt_o,
28 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
30 if ( $part_pkg_option ) {
31 next if $part_pkg_option->optionvalue eq $opt_v;
32 $part_pkg_option->optionvalue($opt_v);
33 my $error = $part_pkg_option->replace;
36 $part_pkg_option = new FS::part_pkg_option { %hash, 'optionvalue'=>$opt_v };
37 my $error = $part_pkg_option->insert;
41 if ( $opt_t || $opt_s || $opt_S || $opt_z || $opt_Z ) {
43 $part_pkg->setup_show_zero('') if $opt_s;
44 $part_pkg->setup_show_zero('Y') if $opt_S;
45 $part_pkg->recur_show_zero('') if $opt_z;
46 $part_pkg->recur_show_zero('Y') if $opt_Z;
48 $part_pkg->taxclass($opt_t);
49 my $error = $part_pkg->replace;
56 die "usage: part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -s | -S ] [ -z | -Z ] employee_username\n";
65 part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -s | -S ] [ -z | -Z ] employee_username
69 Command-line tool to change a set of package definitions.
73 -r: recurring package definitions only
75 -p: packages with this price plan only
77 -m: packages with this comment only
81 -o: part_pkg_option optionname
83 -v: part_pkg_option optionvalue
85 -s: Turn off "Show zero setup"
87 -S: Turn on "Show zero setup"
89 -z: Turn off "Show zero recurring"
91 -Z: Turn on "Show zero recurring"