[freeside-commits] freeside/FS/FS Record.pm, 1.226.2.12, 1.226.2.13 svc_Tower_Mixin.pm, 1.1.2.2, 1.1.2.3 svc_acct.pm, 1.317.2.6, 1.317.2.7 svc_broadband.pm, 1.24.2.9, 1.24.2.10
Mark Wells
mark at wavetail.420.am
Tue Jan 17 18:48:59 PST 2012
- Previous 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
- Next message: [freeside-commits] freeside/httemplate/browse tower.html, 1.1.2.2, 1.1.2.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv11594/FS/FS
Modified Files:
Tag: FREESIDE_2_3_BRANCH
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.226.2.12
retrieving revision 1.226.2.13
diff -u -w -d -r1.226.2.12 -r1.226.2.13
--- Record.pm 30 Dec 2011 22:12:01 -0000 1.226.2.12
+++ Record.pm 18 Jan 2012 02:48:56 -0000 1.226.2.13
@@ -3040,6 +3040,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.317.2.6
retrieving revision 1.317.2.7
diff -u -w -d -r1.317.2.6 -r1.317.2.7
--- svc_acct.pm 16 Jan 2012 04:23:45 -0000 1.317.2.6
+++ svc_acct.pm 18 Jan 2012 02:48:57 -0000 1.317.2.7
@@ -1462,7 +1462,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);
}
@@ -2846,6 +2846,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}) {
@@ -2873,6 +2876,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.24.2.9
retrieving revision 1.24.2.10
diff -u -w -d -r1.24.2.9 -r1.24.2.10
--- svc_broadband.pm 28 Dec 2011 23:56:19 -0000 1.24.2.9
+++ svc_broadband.pm 18 Jan 2012 02:48:57 -0000 1.24.2.10
@@ -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;
@@ -158,6 +158,10 @@
=item routernum - arrayref
+=item sectornum - arrayref
+
+=item towernum - arrayref
+
=item order_by
=back
@@ -215,6 +219,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.2.2
retrieving revision 1.1.2.3
diff -u -w -d -r1.1.2.2 -r1.1.2.3
--- svc_Tower_Mixin.pm 19 Dec 2011 01:59:16 -0000 1.1.2.2
+++ svc_Tower_Mixin.pm 18 Jan 2012 02:48:56 -0000 1.1.2.3
@@ -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/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
- Next message: [freeside-commits] freeside/httemplate/browse tower.html, 1.1.2.2, 1.1.2.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list