4 use vars qw( $opt_r $opt_m $opt_C $opt_p $opt_o $opt_v $opt_t $opt_s $opt_S $opt_z $opt_Z $opt_e $opt_u );
6 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearch qsearchs);
9 use FS::part_pkg_option;
11 getopts('rm:C:p:o:v:t:sSzZe:u:');
13 my $user = shift or &usage;
17 $search{'plan'} = $opt_p if $opt_p;
18 $search{'comment'} = $opt_m if $opt_m;
19 $search{'classnum'} = { op=>'NOT IN', value=>"($opt_C)" } if $opt_C;
21 foreach my $part_pkg ( qsearch('part_pkg',\%search) ) {
22 next if ! $part_pkg->freq && $opt_r;
27 'pkgpart' => $part_pkg->pkgpart,
28 'optionname' => $opt_o,
31 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
33 if ( $part_pkg_option ) {
34 next if $part_pkg_option->optionvalue eq $opt_v;
35 $part_pkg_option->optionvalue($opt_v);
36 my $error = $part_pkg_option->replace;
39 $part_pkg_option = new FS::part_pkg_option { %hash,
40 'optionvalue'=>$opt_v,
42 my $error = $part_pkg_option->insert;
50 'pkgpart' => $part_pkg->pkgpart,
51 'optionname' => 'setup_fee',
54 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
56 if ( $part_pkg_option ) {
57 $part_pkg_option->optionvalue(
58 sprintf('%.2f', $part_pkg_option->optionvalue * $opt_e)
60 my $error = $part_pkg_option->replace;
67 'pkgpart' => $part_pkg->pkgpart,
68 'optionname' => 'recur_fee',
71 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
73 if ( $part_pkg_option ) {
74 $part_pkg_option->optionvalue(
75 sprintf('%.2f', $part_pkg_option->optionvalue * $opt_u)
77 my $error = $part_pkg_option->replace;
82 if ( $opt_t || $opt_s || $opt_S || $opt_z || $opt_Z ) {
84 $part_pkg->taxclass($opt_t) if $opt_t;
85 $part_pkg->setup_show_zero('') if $opt_s;
86 $part_pkg->setup_show_zero('Y') if $opt_S;
87 $part_pkg->recur_show_zero('') if $opt_z;
88 $part_pkg->recur_show_zero('Y') if $opt_Z;
90 my $error = $part_pkg->replace;
97 die "usage: part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -C classnum,classnum ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] [ -e multiplier ] [ -u multiplier ] employee_username\n";
102 cust_main-bulk_change
106 part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -C classnum,classnum ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] [ -e multiplier ] [ -u multiplier ] employee_username
110 Command-line tool to change a set of package definitions.
114 -r: recurring package definitions only
116 -p: packages with this price plan only
118 -m: packages with this comment only
120 -C: excluding package classnum or classnums (comma-separated list)
124 -o: part_pkg_option optionname
126 -v: part_pkg_option optionvalue
130 -s: Turn off "Show zero setup"
132 -S: Turn on "Show zero setup"
134 -z: Turn off "Show zero recurring"
136 -Z: Turn on "Show zero recurring"
138 -e: Multiply setup fee by this value (i.e. 1.05 for a 5% price increase)
140 -u: Multiply recurring fee by this value (i.e. 1.05 for a 5% price increase)