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;
21 $extra_sql = ( keys(%search) ? 'AND' : 'WHERE' ).
22 " classnum NOT IN ($opt_C)"
25 foreach my $part_pkg ( qsearch({ 'table' => 'part_pkg',
26 'hashref' => \%search,
27 'extra_sql' => $extra_sql,
31 next if ! $part_pkg->freq && $opt_r;
36 'pkgpart' => $part_pkg->pkgpart,
37 'optionname' => $opt_o,
40 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
42 if ( $part_pkg_option ) {
43 next if $part_pkg_option->optionvalue eq $opt_v;
44 $part_pkg_option->optionvalue($opt_v);
45 my $error = $part_pkg_option->replace;
48 $part_pkg_option = new FS::part_pkg_option { %hash,
49 'optionvalue'=>$opt_v,
51 my $error = $part_pkg_option->insert;
59 'pkgpart' => $part_pkg->pkgpart,
60 'optionname' => 'setup_fee',
63 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
65 if ( $part_pkg_option ) {
66 $part_pkg_option->optionvalue(
67 sprintf('%.2f', $part_pkg_option->optionvalue * $opt_e)
69 my $error = $part_pkg_option->replace;
76 'pkgpart' => $part_pkg->pkgpart,
77 'optionname' => 'recur_fee',
80 my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
82 if ( $part_pkg_option ) {
83 $part_pkg_option->optionvalue(
84 sprintf('%.2f', $part_pkg_option->optionvalue * $opt_u)
86 my $error = $part_pkg_option->replace;
91 if ( $opt_t || $opt_s || $opt_S || $opt_z || $opt_Z ) {
93 $part_pkg->taxclass($opt_t) if $opt_t;
94 $part_pkg->setup_show_zero('') if $opt_s;
95 $part_pkg->setup_show_zero('Y') if $opt_S;
96 $part_pkg->recur_show_zero('') if $opt_z;
97 $part_pkg->recur_show_zero('Y') if $opt_Z;
99 my $error = $part_pkg->replace;
106 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";
111 cust_main-bulk_change
115 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
119 Command-line tool to change a set of package definitions.
123 -r: recurring package definitions only
125 -p: packages with this price plan only
127 -m: packages with this comment only
129 -C: excluding package classnum or classnums (comma-separated list)
133 -o: part_pkg_option optionname
135 -v: part_pkg_option optionvalue
139 -s: Turn off "Show zero setup"
141 -S: Turn on "Show zero setup"
143 -z: Turn off "Show zero recurring"
145 -Z: Turn on "Show zero recurring"
147 -e: Multiply setup fee by this value (i.e. 1.05 for a 5% price increase)
149 -u: Multiply recurring fee by this value (i.e. 1.05 for a 5% price increase)