4 use vars qw( $opt_o $opt_l $opt_p $opt_b $opt_d $opt_s $opt_t );
6 use FS::UID qw(adminsuidsetup);
8 use FS::Record qw(qsearch);
11 getopts('olp:b:d:s:t:');
13 my $user = shift or &usage;
16 my $conf = new FS::Conf;
17 my $default_locale = $conf->config('locale') || 'en_US';
21 $search{payby} = [ split(/\s*,\s*/, $opt_p) ] if $opt_p;
22 $search{balance} = $opt_b if $opt_b;
23 $search{balance_days} = $opt_d if $opt_d;
24 $search{svcpart} = [ split(/\s*,\s*/, $opt_s) ] if $opt_s;
25 $search{cust_status} = lc($opt_t) if $opt_t;
27 my @svc_acct = qsearch( FS::svc_acct->search(\%search) );
29 foreach my $svc_acct (@svc_acct) {
30 print $svc_acct->username;
31 print '@'. $svc_acct->domain if $opt_o;
33 my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
34 print ','. ($cust_pkg && $cust_pkg->cust_main->locale || $default_locale);
40 die "usage: freeside-username_list [ -c ] [ -l ] [ -p payby,payby... ] [ -b balance [ -d balance_days ] ] [ -s svcpart,svcpart... ] username \n";
45 freeside-username_list
49 freeside-username_list [ -c ] [ -l ] [ -p payby,payby... ] [ -b balance [ -d balance_days ] ] [ -s svcpart,svcpart... ] username
53 Command-line tool to list usernames.
59 -l: Include customer locale
63 -p: Customer payby (CARD, BILL, etc.). Separate multiple values with commas.
65 -b: Customer balance over (or equal to) this amount
67 -d: Customer balance age over this many days
69 -s: Service definition (svcpart). Separate multiple values with commas.
71 -t: Customer status: prospect, active, ordered, inactive, suspended or cancelled
73 username: Employee username
79 L<FS::svc_acct>, L<FS::cust_main>