[freeside-commits] freeside/FS/FS Record.pm, 1.239, 1.240 svc_Tower_Mixin.pm, 1.1, 1.2 svc_acct.pm, 1.324, 1.325 svc_broadband.pm, 1.33, 1.34
Mark Wells
mark at wavetail.420.am
Tue Jan 17 18:48:06 PST 2012
- Previous message: [freeside-commits] freeside/httemplate/elements select-tower_sector.html, 1.1, 1.2 tr-selectmultiple-part_pkg.html, 1.4, 1.5
- Next message: [freeside-commits] freeside/httemplate/search report_svc_acct.html, 1.9, 1.10 report_svc_broadband.html, 1.1, 1.2 svc_acct.cgi, 1.64, 1.65 svc_broadband.cgi, 1.12, 1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv11201/FS/FS
Modified Files:
Record.pm svc_Tower_Mixin.pm svc_acct.pm svc_broadband.pm
Log Message:
search services by tower/sector, #15950
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -w -d -r1.239 -r1.240
--- Record.pm 30 Dec 2011 22:11:36 -0000 1.239
+++ Record.pm 18 Jan 2012 02:48:02 -0000 1.240
@@ -2802,6 +2802,22 @@
defined($scalar) ? $scalar : '';
}
+=item count [ WHERE ]
+
+Convenience method for the common case of "SELECT COUNT(*) FROM table",
+with optional WHERE. Must be called as method on a class with an
+associated table.
+
+=cut
+
+sub count {
+ my($self, $where) = (shift, shift);
+ my $table = $self->table or die 'count called on object of class '.ref($self);
+ my $sql = "SELECT COUNT(*) FROM $table";
+ $sql .= " WHERE $where" if $where;
+ $self->scalar_sql($sql);
+}
+
=back
=head1 SUBROUTINES
Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.324
retrieving revision 1.325
diff -u -w -d -r1.324 -r1.325
--- svc_acct.pm 16 Jan 2012 04:23:50 -0000 1.324
+++ svc_acct.pm 18 Jan 2012 02:48:02 -0000 1.325
@@ -1464,7 +1464,7 @@
if ( !$encoding ) {
# set encoding to system default
($encoding, $encryption) =
- split(/-/, lc($conf->config('default-password-encoding')));
+ split(/-/, lc($conf->config('default-password-encoding') || ''));
$encoding ||= 'legacy';
$self->_password_encoding($encoding);
}
@@ -2848,6 +2848,9 @@
push @where, "svcpart = $1";
}
+ # sector and tower
+ my @where_sector = $class->tower_sector_sql($params);
+ push @where, @where_sector if @where_sector;
# here is the agent virtualization
#if ($params->{CurrentUser}) {
@@ -2875,6 +2878,9 @@
' LEFT JOIN cust_pkg USING ( pkgnum ) '.
' LEFT JOIN cust_main USING ( custnum ) ';
+ $addl_from .= ' LEFT JOIN tower_sector USING ( sectornum )'
+ if @where_sector;
+
my $count_query = "SELECT COUNT(*) FROM svc_acct $addl_from $extra_sql";
#if ( keys %svc_acct ) {
# $count_query .= ' WHERE '.
Index: svc_broadband.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_broadband.pm,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -w -d -r1.33 -r1.34
--- svc_broadband.pm 28 Dec 2011 23:55:32 -0000 1.33
+++ svc_broadband.pm 18 Jan 2012 02:48:02 -0000 1.34
@@ -4,7 +4,7 @@
use vars qw(@ISA $conf);
use base qw(FS::svc_Radius_Mixin FS::svc_Tower_Mixin FS::svc_Common);
-use NetAddr::IP;
+{ no warnings 'redefine'; use NetAddr::IP; }
use FS::Record qw( qsearchs qsearch dbh );
use FS::svc_Common;
use FS::cust_svc;
@@ -159,6 +159,10 @@
=item routernum - arrayref
+=item sectornum - arrayref
+
+=item towernum - arrayref
+
=item order_by
=back
@@ -216,6 +220,13 @@
}
}
+ #sector and tower, as above
+ my @where_sector = $class->tower_sector_sql($params);
+ if ( @where_sector ) {
+ push @where, @where_sector;
+ push @from, 'LEFT JOIN tower_sector USING ( sectornum )';
+ }
+
#svcnum
if ( $params->{'svcnum'} =~ /^(\d+)$/ ) {
push @where, "svcnum = $1";
Index: svc_Tower_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Tower_Mixin.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- svc_Tower_Mixin.pm 19 Dec 2011 01:59:14 -0000 1.1
+++ svc_Tower_Mixin.pm 18 Jan 2012 02:48:02 -0000 1.2
@@ -14,4 +14,43 @@
qsearchs('tower_sector', { sectornum => $self->sectornum });
}
+=item tower_sector_sql HASHREF
+
+Class method which returns a list of WHERE clause fragments to
+search for services with tower/sector given by HASHREF. Can
+contain 'towernum' and 'sectornum' keys, either of which can be
+an arrayref or a single value. To use this, the search needs to
+join to tower_sector.
+
+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 @where;
+ for my $field (qw(towernum sectornum)) {
+ my $value = $params->{$field} or next;
+ if ( ref $value and grep { $_ } @$value ) {
+ my $in = join(',', map { /^(\d+)$/ ? $1 : () } @$value);
+ my @orwhere;
+ push @orwhere, "tower_sector.$field IN ($in)" if $in;
+ push @orwhere, "tower_sector.$field IS NULL" if grep /^none$/, @$value;
+ push @where, '( '.join(' OR ', @orwhere).' )';
+ }
+ elsif ( $value =~ /^(\d+)$/ ) {
+ push @where, "tower_sector.$field = $1";
+ }
+ elsif ( $value eq 'none' ) {
+ push @where, "tower_sector.$field IS NULL";
+ }
+ }
+ @where;
+}
+
+
1;
- Previous message: [freeside-commits] freeside/httemplate/elements select-tower_sector.html, 1.1, 1.2 tr-selectmultiple-part_pkg.html, 1.4, 1.5
- Next message: [freeside-commits] freeside/httemplate/search report_svc_acct.html, 1.9, 1.10 report_svc_broadband.html, 1.1, 1.2 svc_acct.cgi, 1.64, 1.65 svc_broadband.cgi, 1.12, 1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list