minimal 2.3 patch adding options to svc_acct search for freeside-username_list to...
authorIvan Kohler <ivan@freeside.biz>
Wed, 27 Feb 2013 09:59:54 +0000 (01:59 -0800)
committerIvan Kohler <ivan@freeside.biz>
Wed, 27 Feb 2013 09:59:54 +0000 (01:59 -0800)
FS/FS/svc_Tower_Mixin.pm
FS/FS/svc_acct.pm

index 0b55884..6e61708 100644 (file)
@@ -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 ) {
index b09c587..7737a70 100644 (file)
@@ -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