summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-02-27 02:06:52 -0800
committerIvan Kohler <ivan@freeside.biz>2013-02-27 02:06:52 -0800
commitd41d5864be28897265f544d69518fe217376d318 (patch)
tree1582a61df13c031ff57ba27fa256bcee98d7f7ea /FS/bin
parent0e5eacb11e6745871c9521e2d5e72da44f65e0f2 (diff)
add freeside-username_list, RT#21054
Diffstat (limited to 'FS/bin')
-rwxr-xr-xFS/bin/freeside-username_list84
1 files changed, 84 insertions, 0 deletions
diff --git a/FS/bin/freeside-username_list b/FS/bin/freeside-username_list
new file mode 100755
index 000000000..5352f02eb
--- /dev/null
+++ b/FS/bin/freeside-username_list
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+use strict;
+use vars qw( $opt_o $opt_l $opt_p $opt_b $opt_d $opt_s $opt_t );
+use Getopt::Std;
+use FS::UID qw(adminsuidsetup);
+use FS::Conf;
+use FS::Record qw(qsearch);
+use FS::svc_acct;
+
+getopts('olp:b:d:s:t:');
+
+my $user = shift or &usage;
+adminsuidsetup $user;
+
+my $conf = new FS::Conf;
+my $default_locale = $conf->config('locale') || 'en_US';
+
+my %search = ();
+
+$search{payby} = [ split(/\s*,\s*/, $opt_p) ] if $opt_p;
+$search{balance} = $opt_b if $opt_b;
+$search{balance_days} = $opt_d if $opt_d;
+$search{svcpart} = [ split(/\s*,\s*/, $opt_s) ] if $opt_s;
+$search{cust_status} = lc($opt_t) if $opt_t;
+
+my @svc_acct = qsearch( FS::svc_acct->search(\%search) );
+
+foreach my $svc_acct (@svc_acct) {
+ print $svc_acct->username;
+ print '@'. $svc_acct->domain if $opt_o;
+ if ( $opt_l ) {
+ my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
+ print ','. ($cust_pkg && $cust_pkg->cust_main->locale || $default_locale);
+ }
+ print "\n";
+}
+
+sub usage {
+ die "usage: freeside-username_list [ -c ] [ -l ] [ -p payby,payby... ] [ -b balance [ -d balance_days ] ] [ -s svcpart,svcpart... ] username \n";
+}
+
+=head1 NAME
+
+freeside-username_list
+
+=head1 SYNOPSIS
+
+ freeside-username_list [ -c ] [ -l ] [ -p payby,payby... ] [ -b balance [ -d balance_days ] ] [ -s svcpart,svcpart... ] username
+
+=head1 DESCRIPTION
+
+Command-line tool to list usernames.
+
+Display options:
+
+-o: Include domain
+
+-l: Include customer locale
+
+Selection options:
+
+-p: Customer payby (CARD, BILL, etc.). Separate multiple values with commas.
+
+-b: Customer balance over (or equal to) this amount
+
+-d: Customer balance age over this many days
+
+-s: Service definition (svcpart). Separate multiple values with commas.
+
+-t: Customer status: prospect, active, ordered, inactive, suspended or cancelled
+
+username: Employee username
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::svc_acct>, L<FS::cust_main>
+
+=cut
+
+1;
+