[freeside-commits] freeside/FS/FS tower.pm, NONE, 1.1 tower_sector.pm, NONE, 1.1 Schema.pm, 1.340, 1.341 Mason.pm, 1.84, 1.85 svc_broadband.pm, 1.29, 1.30

Ivan,,, ivan at wavetail.420.am
Fri Dec 9 16:36:48 PST 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv4959/FS/FS

Modified Files:
	Schema.pm Mason.pm svc_broadband.pm 
Added Files:
	tower.pm tower_sector.pm 
Log Message:
tower tracking, RT#15538

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.340
retrieving revision 1.341
diff -u -w -d -r1.340 -r1.341
--- Schema.pm	8 Dec 2011 21:13:16 -0000	1.340
+++ Schema.pm	10 Dec 2011 00:36:46 -0000	1.341
@@ -2501,6 +2501,7 @@
         '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, '', '', 
@@ -2518,6 +2519,30 @@
       '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', '', '', '', '', 

--- NEW FILE: tower_sector.pm ---
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;


Index: svc_broadband.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_broadband.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -w -d -r1.29 -r1.30
--- svc_broadband.pm	9 Dec 2011 04:17:03 -0000	1.29
+++ svc_broadband.pm	10 Dec 2011 00:36:46 -0000	1.30
@@ -2,12 +2,13 @@
 
 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 @@
     '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 @@
   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 @@
   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.

--- NEW FILE: tower.pm ---
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;


Index: Mason.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Mason.pm,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -w -d -r1.84 -r1.85
--- Mason.pm	7 Dec 2011 05:50:32 -0000	1.84
+++ Mason.pm	10 Dec 2011 00:36:46 -0000	1.85
@@ -299,6 +299,8 @@
   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 ) {



More information about the freeside-commits mailing list