summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorivan <ivan>2004-04-07 13:11:20 +0000
committerivan <ivan>2004-04-07 13:11:20 +0000
commit3d7ce17fee0a42b8d476ae7e7eaeef5fc24043d0 (patch)
tree4cde05763d678e4e8f66d78bac93778ea16044e8 /FS/bin
parentca19c9b9d3f40739a201e8100c22f5cba3730b9e (diff)
added options to select username, svcnum, svcpart
Diffstat (limited to 'FS/bin')
-rw-r--r--FS/bin/freeside-reexport35
1 files changed, 22 insertions, 13 deletions
diff --git a/FS/bin/freeside-reexport b/FS/bin/freeside-reexport
index b5c50a422..34ccbc715 100644
--- a/FS/bin/freeside-reexport
+++ b/FS/bin/freeside-reexport
@@ -1,6 +1,8 @@
-#!/usr/bin/perl -Tw
+#!/usr/bin/perl -w
use strict;
+use vars qw($opt_s $opt_u $opt_p);
+use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::part_export;
@@ -20,20 +22,27 @@ if ( $export_x =~ /^(\d+)$/ ) {
or die "no exports of type $export_x found\n";
}
-my $svc_something = shift or die &usage;
-my $svc_x;
-if ( $svc_something =~ /^(\d+)$/ ) {
- my $cust_svc = qsearchs('cust_svc', { svcnum=>$1 } )
- or die "svcnum $svc_something not found\n";
- $svc_x = $cust_svc->svc_x;
-} else {
- $svc_x = qsearchs('svc_acct', { username=>$svc_something } )
- or die "username $svc_something not found\n";
+getopts('s:u:p:');
+
+my @svc_x = ();
+if ( $opt_s ) {
+ my $cust_svc = qsearchs('cust_svc', { svcnum=>$opt_s } )
+ or die "svcnum $opt_s not found\n";
+ push @svc_x, $cust_svc->svc_x;
+} elsif ( $opt_u ) {
+ my $svc_x = qsearchs('svc_acct', { username=>$opt_u } )
+ or die "username $opt_u not found\n";
+ push @svc_x, $svc_x;
+} elsif ( $opt_p ) {
+ push @svc_x, map { $_->svc_x } qsearch('cust_svc', { svcpart=>$opt_p } );
+ die "no services with svcpart $opt_p found\n" unless @svc_x;
}
foreach my $part_export ( @part_export ) {
- my $error = $part_export->export_insert($svc_x);
- die $error if $error;
+ foreach my $svc_x ( @svc_x ) {
+ my $error = $part_export->export_insert($svc_x);
+ die $error if $error;
+ }
}
@@ -47,7 +56,7 @@ freeside-reexport - Command line tool to re-trigger export jobs for existing ser
=head1 SYNOPSIS
- freeside-reexport user exportnum|exporttype svcnum|username
+ freeside-reexport user exportnum|exporttype [ -s svcnum | -u username | -p svcpart ]
=head1 DESCRIPTION