#!/usr/bin/perl use strict; use vars qw( $opt_r $opt_m $opt_p $opt_o $opt_v $opt_t $opt_s $opt_S $opt_z $opt_Z ); use Getopt::Std; use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearch qsearchs); use FS::part_pkg; use FS::part_pkg_option; getopts('rm:p:o:v:t:sSzZ'); my $user = shift or &usage; adminsuidsetup $user; my %search = (); $search{'plan'} = $opt_p if $opt_p; $search{'comment'} = $opt_m if $opt_m; foreach my $part_pkg ( qsearch('part_pkg',\%search) ) { next if ! $part_pkg->freq && $opt_r; if ( $opt_o ) { 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; } } if ( $opt_t || $opt_s || $opt_S || $opt_z || $opt_Z ) { $part_pkg->taxclass($opt_t) if $opt_t; $part_pkg->setup_show_zero('') if $opt_s; $part_pkg->setup_show_zero('Y') if $opt_S; $part_pkg->recur_show_zero('') if $opt_z; $part_pkg->recur_show_zero('Y') if $opt_Z; my $error = $part_pkg->replace; } } sub usage { 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"; } =head1 NAME cust_main-bulk_change =head1 SYNOPSIS part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] employee_username =head1 DESCRIPTION Command-line tool to change a set of package definitions. Search options: -r: recurring package definitions only -p: packages with this price plan only -m: packages with this comment only Change options: -o: part_pkg_option optionname -v: part_pkg_option optionvalue -t: new taxclass -s: Turn off "Show zero setup" -S: Turn on "Show zero setup" -z: Turn off "Show zero recurring" -Z: Turn on "Show zero recurring" employee_username =head1 BUGS =head1 SEE ALSO L =cut 1;