4 use vars qw( $opt_r $opt_m $opt_p $opt_o $opt_v $opt_t $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:t: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;
26 'pkgpart' => $part_pkg->pkgpart,
27 'optionname' => $opt_o,
30 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
32 if ( $part_pkg_option ) {
33 next if $part_pkg_option->optionvalue eq $opt_v;
34 $part_pkg_option->optionvalue($opt_v);
35 my $error = $part_pkg_option->replace;
38 $part_pkg_option = new FS::part_pkg_option { %hash,
39 'optionvalue'=>$opt_v,
41 my $error = $part_pkg_option->insert;
47 if ( $opt_t || $opt_s || $opt_S || $opt_z || $opt_Z ) {
49 $part_pkg->taxclass($opt_t) if $opt_t;
50 $part_pkg->setup_show_zero('') if $opt_s;
51 $part_pkg->setup_show_zero('Y') if $opt_S;
52 $part_pkg->recur_show_zero('') if $opt_z;
53 $part_pkg->recur_show_zero('Y') if $opt_Z;
55 my $error = $part_pkg->replace;
62 die "usage: part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] employee_username\n";
71 part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] employee_username
75 Command-line tool to change a set of package definitions.
79 -r: recurring package definitions only
81 -p: packages with this price plan only
83 -m: packages with this comment only
87 -o: part_pkg_option optionname
89 -v: part_pkg_option optionvalue
93 -s: Turn off "Show zero setup"
95 -S: Turn on "Show zero setup"
97 -z: Turn off "Show zero recurring"
99 -Z: Turn on "Show zero recurring"