blob: cf65c39a282c26f617c4be14a83f874d7cc3a221 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/perl
use strict;
use vars qw( $opt_r $opt_p $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('rp:o:v:');
my $user = shift or &usage;
adminsuidsetup $user;
my %plan;
%plan = ( 'plan' => $opt_p ) if $opt_p;
foreach my $part_pkg ( qsearch('part_pkg',\%plan) ) {
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 a set of package definitions.
-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;
|