[freeside-commits] branch FREESIDE_2_3_BRANCH updated. dd242e3eb793772a0ed9f2b9465e6c742e554519

Ivan ivan at 420.am
Wed Feb 27 02:07:27 PST 2013


The branch, FREESIDE_2_3_BRANCH has been updated
       via  dd242e3eb793772a0ed9f2b9465e6c742e554519 (commit)
       via  5614fd23c9675f2b3c3e05f45c14a5038b3ef1b6 (commit)
       via  f46a3afac9bc82bd1ffa77b3729de8407b178615 (commit)
      from  fa4b2ce55c394cfcfa4a09b85ef63536f7e07a39 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dd242e3eb793772a0ed9f2b9465e6c742e554519
Merge: 5614fd2 fa4b2ce
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Feb 27 02:07:13 2013 -0800

    Merge branch 'FREESIDE_2_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_2_3_BRANCH


commit 5614fd23c9675f2b3c3e05f45c14a5038b3ef1b6
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Feb 27 02:07:00 2013 -0800

    add freeside-username_list, RT#21054

diff --git a/FS/bin/freeside-username_list b/FS/bin/freeside-username_list
new file mode 100755
index 0000000..5352f02
--- /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;
+

commit f46a3afac9bc82bd1ffa77b3729de8407b178615
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Feb 27 01:59:54 2013 -0800

    minimal 2.3 patch adding options to svc_acct search for freeside-username_list to work, RT#21054

diff --git a/FS/FS/svc_Tower_Mixin.pm b/FS/FS/svc_Tower_Mixin.pm
index 0b55884..6e61708 100644
--- a/FS/FS/svc_Tower_Mixin.pm
+++ b/FS/FS/svc_Tower_Mixin.pm
@@ -27,12 +27,10 @@ towernum or sectornum can also contain 'none' to allow null values.
 =cut
 
 sub tower_sector_sql {
-  my $class = shift;
-  my $params = shift;
-  return '' unless keys %$params;
-  my $where = '';
+  my( $class, $params ) = @_;
+  return () unless keys %$params;
 
-  my @where;
+  my @where = ();
   for my $field (qw(towernum sectornum)) {
     my $value = $params->{$field} or next;
     if ( ref $value and grep { $_ } @$value ) {
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index b09c587..7737a70 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -2847,6 +2847,28 @@ sub search {
     push @where, "custnum = $1";
   }
 
+  #customer status
+  if ( $params->{'cust_status'} =~ /^([a-z]+)$/ ) {
+    push @where, FS::cust_main->cust_status_sql . " = '$1'";
+  }
+
+  #customer balance
+  if ( $params->{'balance'} =~ /^\s*(\-?\d*(\.\d{1,2})?)\s*$/ && length($1) ) {
+    my $balance = $1;
+
+    my $age = '';
+    if ( $params->{'balance_days'} =~ /^\s*(\d*(\.\d{1,3})?)\s*$/ && length($1) ) {
+      $age = time - 86400 * $1;
+    }
+    push @where, FS::cust_main->balance_date_sql($age) . " > $balance";
+  }
+
+  #payby
+  if ( $params->{'payby'} && scalar(@{ $params->{'payby'} }) ) {
+    my @payby = map "'$_'", grep /^(\w+)$/, @{ $params->{'payby'} };
+    push @where, 'payby IN ('. join(',', @payby ). ')';
+  }
+
   #pkgpart
   if ( $params->{'pkgpart'} && scalar(@{ $params->{'pkgpart'} }) ) {
     #XXX untaint or sql quote

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/svc_Tower_Mixin.pm                           |    8 ++---
 FS/FS/svc_acct.pm                                  |   22 ++++++++++++++
 ...eeside-phonenum_list => freeside-username_list} |   30 +++++++++----------
 3 files changed, 39 insertions(+), 21 deletions(-)
 copy FS/bin/{freeside-phonenum_list => freeside-username_list} (61%)




More information about the freeside-commits mailing list