summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS.pm4
-rw-r--r--FS/FS/Mason.pm2
-rw-r--r--FS/FS/Schema.pm51
-rwxr-xr-xFS/FS/svc_broadband.pm19
-rw-r--r--FS/FS/tower.pm142
-rw-r--r--FS/FS/tower_sector.pm154
-rw-r--r--FS/MANIFEST4
-rw-r--r--FS/t/tower.t5
-rw-r--r--FS/t/tower_sector.t5
-rw-r--r--httemplate/browse/tower.html44
-rw-r--r--httemplate/edit/process/tower.html7
-rw-r--r--httemplate/edit/svc_broadband.cgi4
-rw-r--r--httemplate/edit/tower.html37
-rw-r--r--httemplate/elements/select-tower_sector.html7
-rw-r--r--httemplate/elements/tower_sector.html60
-rw-r--r--httemplate/elements/tr-select-tower_sector.html11
-rw-r--r--httemplate/elements/tr-tower_sector.html24
-rw-r--r--httemplate/view/svc_broadband.cgi12
18 files changed, 576 insertions, 16 deletions
diff --git a/FS/FS.pm b/FS/FS.pm
index e8f2cdc..2552dbd 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -162,6 +162,10 @@ L<FS::addr_block> - Address block class
L<FS::router> - Router class
+L<FS::tower> - Tower class
+
+L<FS::tower_sector> - Tower sector class
+
L<FS::part_virtual_field> - Broadband virtual field class
L<FS::svc_phone> - Phone service class
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 99cc1cd..0cb2a0b 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -299,6 +299,8 @@ if ( -e $addl_handler_use_file ) {
use FS::rate_tier_detail;
use FS::radius_attr;
use FS::discount_plan;
+ use FS::tower;
+ use FS::tower_sector;
# Sammath Naur
if ( $FS::Mason::addl_handler_use ) {
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 18df708..f92d7e4 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2498,26 +2498,51 @@ sub tables_hashref {
'svc_broadband' => {
'columns' => [
- 'svcnum', 'int', '', '', '', '',
- 'description', 'varchar', 'NULL', $char_d, '', '',
- 'blocknum', 'int', 'NULL', '', '', '',
- 'speed_up', 'int', 'NULL', '', '', '',
- 'speed_down', 'int', 'NULL', '', '', '',
- 'ip_addr', 'varchar', 'NULL', 15, '', '',
- 'mac_addr', 'varchar', 'NULL', 12, '', '',
- 'authkey', 'varchar', 'NULL', 32, '', '',
- 'latitude', 'decimal', 'NULL', '', '', '',
- 'longitude', 'decimal', 'NULL', '', '', '',
- 'altitude', 'decimal', 'NULL', '', '', '',
- 'vlan_profile', 'varchar', 'NULL', $char_d, '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'description', 'varchar', 'NULL', $char_d, '', '',
+ 'blocknum', 'int', 'NULL', '', '', '',
+ 'sectornum', 'int', 'NULL', '', '', '',
+ 'speed_up', 'int', 'NULL', '', '', '',
+ 'speed_down', 'int', 'NULL', '', '', '',
+ 'ip_addr', 'varchar', 'NULL', 15, '', '',
+ 'mac_addr', 'varchar', 'NULL', 12, '', '',
+ 'authkey', 'varchar', 'NULL', 32, '', '',
+ 'latitude', 'decimal', 'NULL', '', '', '',
+ 'longitude', 'decimal', 'NULL', '', '', '',
+ 'altitude', 'decimal', 'NULL', '', '', '',
+ 'vlan_profile', 'varchar', 'NULL', $char_d, '', '',
'performance_profile', 'varchar', 'NULL', $char_d, '', '',
- 'plan_id', 'varchar', 'NULL', $char_d, '', '',
+ 'plan_id', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'svcnum',
'unique' => [ [ 'mac_addr' ] ],
'index' => [],
},
+ 'tower' => {
+ 'columns' => [
+ 'towernum', 'serial', '', '', '', '',
+ #'agentnum', 'int', 'NULL', '', '', '',
+ 'towername', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'towernum',
+ 'unique' => [ [ 'towername' ] ], # , 'agentnum' ] ],
+ 'index' => [],
+ },
+
+ 'tower_sector' => {
+ 'columns' => [
+ 'sectornum', 'serial', '', '', '', '',
+ 'towernum', 'int', '', '', '', '',
+ 'sectorname', 'varchar', '', $char_d, '', '',
+ 'ip_addr', 'varchar', 'NULL', 15, '', '',
+ ],
+ 'primary_key' => 'sectornum',
+ 'unique' => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ],
+ 'index' => [ [ 'towernum' ] ],
+ },
+
'part_virtual_field' => {
'columns' => [
'vfieldpart', 'serial', '', '', '', '',
diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm
index a0cd090..c5034b0 100755
--- a/FS/FS/svc_broadband.pm
+++ b/FS/FS/svc_broadband.pm
@@ -2,12 +2,13 @@ package FS::svc_broadband;
use strict;
use vars qw(@ISA $conf);
+use NetAddr::IP;
use FS::Record qw( qsearchs qsearch dbh );
use FS::svc_Common;
use FS::cust_svc;
use FS::addr_block;
use FS::part_svc_router;
-use NetAddr::IP;
+use FS::tower_sector;
@ISA = qw( FS::svc_Radius_Mixin FS::svc_Common );
@@ -95,11 +96,14 @@ sub table_info {
'longname_plural' => 'Fixed wireless broadband services',
'display_weight' => 50,
'cancel_weight' => 70,
+ 'ip_field' => 'ip_addr',
'fields' => {
- 'description' => 'Descriptive label for this particular device.',
+ 'svcnum' => 'Service',
+ 'description' => 'Descriptive label for this particular device',
'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.',
'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.',
'ip_addr' => 'IP address. Leave blank for automatic assignment.',
+ 'sectornum' => 'Tower sector',
'blocknum' => { 'label' => 'Address block',
'type' => 'select',
'select_table' => 'addr_block',
@@ -355,6 +359,7 @@ sub check {
my $error =
$self->ut_numbern('svcnum')
|| $self->ut_numbern('blocknum')
+ || $self->ut_foreign_keyn('sectornum', 'tower_sector', 'sectornum')
|| $self->ut_textn('description')
|| $self->ut_numbern('speed_up')
|| $self->ut_numbern('speed_down')
@@ -477,6 +482,16 @@ sub NetAddr {
new NetAddr::IP ($self->ip_addr);
}
+=item tower_sector
+
+=cut
+
+sub tower_sector {
+ my $self = shift;
+ return '' unless $self->sectornum;
+ qsearchs('tower_sector', { sectornum => $self->sectornum });
+}
+
=item addr_block
Returns the FS::addr_block record (i.e. the address block) for this broadband service.
diff --git a/FS/FS/tower.pm b/FS/FS/tower.pm
new file mode 100644
index 0000000..0d94477
--- /dev/null
+++ b/FS/FS/tower.pm
@@ -0,0 +1,142 @@
+package FS::tower;
+
+use strict;
+use base qw( FS::o2m_Common FS::Record );
+use FS::Record qw( qsearch ); #qsearchs );
+use FS::tower_sector;
+
+=head1 NAME
+
+FS::tower - Object methods for tower records
+
+=head1 SYNOPSIS
+
+ use FS::tower;
+
+ $record = new FS::tower \%hash;
+ $record = new FS::tower { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::tower object represents a tower. FS::tower inherits from
+FS::Record. The following fields are currently supported:
+
+=over 4
+
+=item towernum
+
+primary key
+
+=item towername
+
+Tower name
+
+=item disabled
+
+Disabled flag, empty or 'Y'
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new tower. To add the tower to the database, see L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to. You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'tower'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+# the insert method can be inherited from FS::Record
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+# the delete method can be inherited from FS::Record
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+# the replace method can be inherited from FS::Record
+
+=item check
+
+Checks all fields to make sure this is a valid tower. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+# the check method should currently be supplied - FS::Record contains some
+# data checking routines
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('towernum')
+ || $self->ut_text('towername')
+ || $self->ut_enum('disabled', [ '', 'Y' ])
+ ;
+ return $error if $error;
+
+ $self->SUPER::check;
+}
+
+=item tower_sector
+
+Returns the sectors of this tower, as FS::tower_sector objects (see
+L<FS::tower_sector>).
+
+=cut
+
+sub tower_sector {
+ my $self = shift;
+ qsearch({
+ 'table' => 'tower_sector',
+ 'hashref' => { 'towernum' => $self->towernum },
+ 'order_by' => 'ORDER BY sectorname',
+ });
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::tower_sector>, L<FS::svc_broadband>, L<FS::Record>
+
+=cut
+
+1;
+
diff --git a/FS/FS/tower_sector.pm b/FS/FS/tower_sector.pm
new file mode 100644
index 0000000..583b933
--- /dev/null
+++ b/FS/FS/tower_sector.pm
@@ -0,0 +1,154 @@
+package FS::tower_sector;
+
+use strict;
+use base qw( FS::Record );
+use FS::Record qw( qsearchs ); # qsearch );
+use FS::tower;
+
+=head1 NAME
+
+FS::tower_sector - Object methods for tower_sector records
+
+=head1 SYNOPSIS
+
+ use FS::tower_sector;
+
+ $record = new FS::tower_sector \%hash;
+ $record = new FS::tower_sector { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::tower_sector object represents an example. FS::tower_sector inherits from
+FS::Record. The following fields are currently supported:
+
+=over 4
+
+=item sectornum
+
+primary key
+
+=item towernum
+
+towernum
+
+=item sectorname
+
+sectorname
+
+=item ip_addr
+
+ip_addr
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new example. To add the example to the database, see L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to. You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'tower_sector'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+# the insert method can be inherited from FS::Record
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+# the delete method can be inherited from FS::Record
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+# the replace method can be inherited from FS::Record
+
+=item check
+
+Checks all fields to make sure this is a valid example. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+# the check method should currently be supplied - FS::Record contains some
+# data checking routines
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('sectornum')
+ || $self->ut_number('towernum', 'tower', 'towernum')
+ || $self->ut_text('sectorname')
+ || $self->ut_textn('ip_addr')
+ ;
+ return $error if $error;
+
+ $self->SUPER::check;
+}
+
+=item tower
+
+Returns the tower for this sector, as an FS::tower object (see L<FS::tower>).
+
+=cut
+
+sub tower {
+ my $self = shift;
+ qsearchs('tower', { 'towernum'=>$self->towernum } );
+}
+
+=item description
+
+Returns a description for this sector including tower name.
+
+=cut
+
+sub description {
+ my $self = shift;
+ $self->tower->towername. ' sector '. $self->sectorname;
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::tower>, L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 3cd5c38..dac2af0 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -624,3 +624,7 @@ FS/rate_tier_detail.pm
t/rate_tier_detail.t
FS/radius_attr.pm
t/radius_attr.t
+FS/tower.pm
+t/tower.t
+FS/tower_sector.pm
+t/tower_sector.t
diff --git a/FS/t/tower.t b/FS/t/tower.t
new file mode 100644
index 0000000..66b93e2
--- /dev/null
+++ b/FS/t/tower.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::tower;
+$loaded=1;
+print "ok 1\n";
diff --git a/FS/t/tower_sector.t b/FS/t/tower_sector.t
new file mode 100644
index 0000000..f082ebe
--- /dev/null
+++ b/FS/t/tower_sector.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::tower_sector;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/tower.html b/httemplate/browse/tower.html
new file mode 100644
index 0000000..660e924
--- /dev/null
+++ b/httemplate/browse/tower.html
@@ -0,0 +1,44 @@
+<% include( 'elements/browse.html',
+ 'title' => 'Towers',
+ 'name' => 'towers',
+ 'menubar' => [ 'Add a new tower' =>
+ $p.'edit/tower.html',
+ ],
+ 'query' => { 'table' => 'tower', },
+ 'count_query' => 'SELECT COUNT(*) FROM tower',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 1,
+ 'header' => [ 'Name', 'Sectors', ],
+ 'fields' => [ 'towername',
+ $sector_sub,
+ ],
+ 'links' => [ $link,
+ '',
+ ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $link = [ "${p}edit/tower.html?", 'towernum' ];
+
+my $sector_sub = sub {
+ my $tower = shift;
+
+ [ map {
+
+ [
+ { 'data' => $_->sectorname,
+ 'link' => ( $_->ip_addr ? 'http://'. $_->ip_addr : '' ),
+ },
+ ],
+
+ }
+ $tower->tower_sector
+ ];
+
+};
+
+</%init>
diff --git a/httemplate/edit/process/tower.html b/httemplate/edit/process/tower.html
new file mode 100644
index 0000000..7353784
--- /dev/null
+++ b/httemplate/edit/process/tower.html
@@ -0,0 +1,7 @@
+<& elements/process.html,
+ table => 'tower',
+ viewall_dir => 'browse',
+ process_o2m => { 'table' => 'tower_sector',
+ 'fields' => [qw( sectorname ip_addr )],
+ },
+&>
diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi
index d4baf35..ad4d604 100644
--- a/httemplate/edit/svc_broadband.cgi
+++ b/httemplate/edit/svc_broadband.cgi
@@ -97,7 +97,9 @@ END
;
my @fields = (
- qw( description ip_addr speed_down speed_up blocknum ),
+ qw( description ip_addr speed_down speed_up ),
+ { field=>'sectornum', type=>'select-tower_sector', },
+ qw( blocknum ),
{ field=>'block_label', type=>'fixed' },
qw( mac_addr latitude longitude altitude vlan_profile
performance_profile authkey plan_id ),
diff --git a/httemplate/edit/tower.html b/httemplate/edit/tower.html
new file mode 100644
index 0000000..c27d9d2
--- /dev/null
+++ b/httemplate/edit/tower.html
@@ -0,0 +1,37 @@
+<& elements/edit.html,
+ name_singular => 'tower',
+ table => 'tower',
+ viewall_dir => 'browse',
+ fields => [ 'towername',
+ { field=>'disabled', type=>'checkbox', value=>'Y', },
+ { field => 'sectornum',
+ type => 'tower_sector',
+ o2m_table => 'tower_sector',
+ m2_label => 'Sector',
+ m2_error_callback => $m2_error_callback,
+ },
+ ],
+ labels => { 'towernum' => 'Tower',
+ 'towername' => 'Name',
+ 'sectornum' => 'Sector',
+ 'disabled' => 'Disabled',
+ },
+&>
+<%init>
+
+my $m2_error_callback = sub { # reconstruct the list
+ my ($cgi, $object) = @_;
+
+ my @fields = qw(sectorname ip_addr);
+ map {
+ my $k = $_;
+ next if !length($cgi->param($k.'_sectorname'));
+ new FS::tower_sector {
+ 'towernum' => $object->towernum,
+ 'sectornum' => scalar( $cgi->param($k) ),
+ map { $_ => scalar( $cgi->param($k.'_'.$_) ) } @fields,
+ };
+ } grep /^sectornum\d+$/, ($cgi->param);
+};
+
+</%init>
diff --git a/httemplate/elements/select-tower_sector.html b/httemplate/elements/select-tower_sector.html
new file mode 100644
index 0000000..a64d886
--- /dev/null
+++ b/httemplate/elements/select-tower_sector.html
@@ -0,0 +1,7 @@
+<& /elements/select-table.html,
+ table => 'tower_sector',
+ name_col => 'description',
+ order_by => 'ORDER BY towernum,sectorname',
+ empty_label => ' ',
+ @_
+&>
diff --git a/httemplate/elements/tower_sector.html b/httemplate/elements/tower_sector.html
new file mode 100644
index 0000000..a8bbbc5
--- /dev/null
+++ b/httemplate/elements/tower_sector.html
@@ -0,0 +1,60 @@
+% unless ( $opt{'js_only'} ) {
+
+ <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
+
+ <TABLE>
+ <TR>
+% foreach my $field ( @fields ) {
+
+ <TD>
+ <INPUT TYPE = "text"
+ NAME = "<%$name%>_<%$field%>"
+ ID = "<%$id%>_<%$field%>"
+ SIZE = "<% $size{$field} || 15 %>"
+ VALUE = "<% scalar($cgi->param($name."_$field"))
+ || $tower_sector->get($field) |h %>"
+ <% $onchange %>
+ ><BR>
+ <FONT SIZE="-1"><% $label{$field} %></FONT>
+ </TD>
+% }
+ </TR>
+ </TABLE>
+
+
+% }
+<%init>
+
+my( %opt ) = @_;
+
+my $name = $opt{'element_name'} || $opt{'field'} || 'sectornum';
+my $id = $opt{'id'} || 'sectornum';
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+my $onchange = '';
+if ( $opt{'onchange'} ) {
+ $onchange = $opt{'onchange'};
+ $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
+ $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
+ #callbacks should act the same
+ $onchange = 'onChange="'. $onchange. '"';
+}
+
+my $tower_sector;
+if ( $curr_value ) {
+ $tower_sector = qsearchs('tower_sector', { 'sectornum' => $curr_value } );
+} else {
+ $tower_sector = new FS::tower_sector {};
+}
+
+my %size = ( 'title' => 12 );
+
+tie my %label, 'Tie::IxHash',
+ 'sectorname' => 'Name',
+ 'ip_addr' => 'IP Address',
+;
+
+my @fields = keys %label;
+
+</%init>
diff --git a/httemplate/elements/tr-select-tower_sector.html b/httemplate/elements/tr-select-tower_sector.html
new file mode 100644
index 0000000..d55f42b
--- /dev/null
+++ b/httemplate/elements/tr-select-tower_sector.html
@@ -0,0 +1,11 @@
+<% include('tr-td-label.html', label => emt('Tower sector'), %opt ) %>
+ <TD <% $style %>>
+ <% include( '/elements/select-tower_sector.html', %opt ) %>
+ </TD>
+</TR>
+<%init>
+
+my( %opt ) = @_;
+my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+</%init>
diff --git a/httemplate/elements/tr-tower_sector.html b/httemplate/elements/tr-tower_sector.html
new file mode 100644
index 0000000..871c7fd
--- /dev/null
+++ b/httemplate/elements/tr-tower_sector.html
@@ -0,0 +1,24 @@
+% unless ( $opt{'js_only'} ) {
+
+ <% include('tr-td-label.html', %opt) %>
+ <TD <% $cell_style %>>
+
+% }
+%
+ <% include( '/elements/sector.html', %opt ) %>
+%
+% unless ( $opt{'js_only'} ) {
+
+ </TD>
+ </TR>
+
+% }
+<%init>
+
+my( %opt ) = @_;
+
+my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+$opt{'label'} ||= 'Sector';
+
+</%init>
diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi
index 6277759..22cbb1f 100644
--- a/httemplate/view/svc_broadband.cgi
+++ b/httemplate/view/svc_broadband.cgi
@@ -22,6 +22,7 @@ my @fields = (
'speed_down',
'speed_up',
{ field => 'ip_addr', value => \&ip_addr },
+ { field => 'sectornum', value => \&sectornum },
'mac_addr',
'latitude',
'longitude',
@@ -60,4 +61,15 @@ sub usergroup {
join('<BR>', $svc->radius_groups('long_description'));
}
+sub sectornum {
+ my $svc_broadband = shift;
+ return '' unless $svc_broadband->sectornum;
+ my $tower_sector = $svc_broadband->tower_sector;
+ my $link = $tower_sector->ip_addr
+ ? '<A HREF="http://'. $tower_sector->ip_addr. '">'
+ : '';
+
+ $link . $tower_sector->description. ( $link ? '</A>' : '');
+}
+
</%init>