[freeside-commits] branch FREESIDE_3_BRANCH updated. 0fc158f576b404002225284b5dfc1634502f7569

Mark Wells mark at 420.am
Mon Dec 21 15:15:38 PST 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  0fc158f576b404002225284b5dfc1634502f7569 (commit)
      from  cc76d8abb5dec3012f6c24d18ccef346296b6579 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0fc158f576b404002225284b5dfc1634502f7569
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Dec 21 14:41:40 2015 -0800

    svc_fiber, #35260

diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 7539403..91793f9 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -316,8 +316,10 @@ tie my %rights, 'Tie::IxHash',
     'Services: Mailing lists',
     'Services: Alarm services',
     'Services: External services',
-    'Usage: RADIUS sessions',
     'Services: Circuits',
+    'Services: Fiber',
+    'Services: Fiber: Advanced search',
+    'Usage: RADIUS sessions',
     'Usage: Call Detail Records (CDRs)',
     'Usage: Unrateable CDRs',
     'Usage: Time worked',
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index ba56cff..23eb591 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -385,6 +385,8 @@ if ( -e $addl_handler_use_file ) {
   use FS::report_batch;
   use FS::report_batch;
   use FS::password_history;
+  use FS::svc_fiber;
+  use FS::fiber_olt;
   # Sammath Naur
 
   if ( $FS::Mason::addl_handler_use ) {
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 0793af4..4d931b4 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4707,6 +4707,125 @@ sub tables_hashref {
       'unique'      => [],
       'index'       => [ [ 'providernum' ], [ 'typenum' ] ],
     },
+
+    'svc_fiber' => {
+      'columns' => [
+        'svcnum',         'int',     '',      '', '', '',
+        'oltnum',         'int', 'NULL',      '', '', '',
+        'shelf',          'int', 'NULL',      '', '', '',
+        'card',           'int', 'NULL',      '', '', '',
+        'olt_port',       'int', 'NULL',      '', '', '',
+        'ont_id',         'int', 'NULL',      '', '', '',
+        'ont_typenum',    'int', 'NULL',      '', '', '',
+        'ont_serial', 'varchar', 'NULL', $char_d, '', '',
+        'ont_port',   'varchar', 'NULL',      16, '', '',
+        'vlan',           'int', 'NULL',      '', '', '',
+        'signal',         'int', 'NULL',      '', '', '',
+        'speed_up',       'int', 'NULL',      '', '', '',
+        'speed_down',     'int', 'NULL',      '', '', '',
+        'ont_install','varchar', 'NULL', $char_d, '', '',
+      ],
+      'primary_key' => 'svcnum',
+      'unique'      => [ ],
+      'index'       => [ [ 'ont_serial' ] ],
+    },
+
+    'fiber_olt' => {
+      'columns' => [
+        'oltnum',   'serial', '',       '', '', '',
+        'oltname', 'varchar', '',  $char_d, '', '',
+        'serial',  'varchar', '',  $char_d, '', '',
+        'disabled',   'char', 'NULL',    1, '', '',
+      ],
+      'primary_key' => 'oltnum',
+      'unique' => [ ],
+      'index'  => [ ],
+    },
+
+    'vend_main' => {
+      'columns' => [
+        'vendnum',   'serial',     '',      '', '', '',
+        'vendname', 'varchar',     '', $char_d, '', '',
+        'classnum',     'int',     '',      '', '', '',
+        'disabled',    'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key'  => 'vendnum',
+      'unique'       => [ ['vendname', 'disabled'] ],
+      'index'        => [],
+      'foreign_keys' => [
+                          { columns    => [ 'classnum' ],
+                            table      => 'vend_class',
+                          },
+                        ],
+    },
+
+    'vend_class' => {
+      'columns' => [
+        'classnum',     'serial',     '',      '', '', '', 
+        'classname',   'varchar',     '', $char_d, '', '', 
+        'disabled',       'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key' => 'classnum',
+      'unique'      => [],
+      'index'       => [ ['disabled'] ],
+    },
+
+    'vend_bill' => {
+      'columns' => [
+        'vendbillnum',    'serial',     '',      '', '', '', 
+        'vendnum',           'int',     '',      '', '', '', 
+        #'_date',        @date_type,                  '', '', 
+        '_date',     'int', '', '',                   '', '', 
+        'charged',     @money_type,                  '', '', 
+      ],
+      'primary_key'  => 'vendbillnum',
+      'unique'       => [],
+      'index'        => [ ['vendnum'], ['_date'], ],
+      'foreign_keys' => [
+                          { columns    => [ 'vendnum' ],
+                            table      => 'vend_main',
+                          },
+                        ],
+    },
+
+    'vend_pay' => {
+      'columns' => [
+        'vendpaynum',   'serial',    '',       '', '', '',
+        'vendnum',         'int',    '',       '', '', '', 
+        #'_date',     @date_type,                   '', '', 
+        '_date',     'int', '', '',                   '', '', 
+        'paid',      @money_type,                  '', '', 
+      ],
+      'primary_key'  => 'vendpaynum',
+      'unique'       => [],
+      'index'        => [ [ 'vendnum' ], [ '_date' ], ],
+      'foreign_keys' => [
+                          { columns    => [ 'vendnum' ],
+                            table      => 'vend_main',
+                          },
+                        ],
+    },
+
+    'vend_bill_pay' => {
+      'columns' => [
+        'vendbillpaynum', 'serial',     '',   '', '', '', 
+        'vendbillnum',       'int',     '',   '', '', '', 
+        'vendpaynum',        'int',     '',   '', '', '', 
+        'amount',  @money_type, '', '', 
+        #? '_date',   @date_type, '', '', 
+      ],
+      'primary_key'  => 'vendbillpaynum',
+      'unique'       => [],
+      'index'        => [ [ 'vendbillnum' ], [ 'vendpaynum' ] ],
+      'foreign_keys' => [
+                          { columns    => [ 'vendbillnum' ],
+                            table      => 'vend_bill',
+                          },
+                          { columns    => [ 'vendpaynum' ],
+                            table      => 'vend_pay',
+                          },
+                        ],
+    },
     %{ tables_hashref_torrus() },
 
     # tables of ours for doing torrus virtual port combining
diff --git a/FS/FS/fiber_olt.pm b/FS/FS/fiber_olt.pm
new file mode 100644
index 0000000..d083e9e
--- /dev/null
+++ b/FS/FS/fiber_olt.pm
@@ -0,0 +1,114 @@
+package FS::fiber_olt;
+use base qw( FS::Record );
+
+use strict;
+use FS::Record qw( qsearch qsearchs );
+use FS::svc_fiber;
+
+=head1 NAME
+
+FS::fiber_olt - Object methods for fiber_olt records
+
+=head1 SYNOPSIS
+
+  use FS::fiber_olt;
+
+  $record = new FS::fiber_olt \%hash;
+  $record = new FS::fiber_olt { 'column' => 'value' };
+
+  $error = $record->insert;
+
+  $error = $new_record->replace($old_record);
+
+  $error = $record->delete;
+
+  $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::fiber_olt object represents an Optical Line Terminal that fiber
+connections (L<FS::svc_fiber>) connect to.  FS::fiber_olt inherits from
+FS::Record.  The following fields are currently supported:
+
+=over 4
+
+=item oltnum - primary key
+
+=item oltname - name of this device
+
+=item serial - serial number
+
+=item disabled - set to 'Y' to make this OLT unavailable for new connections
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new fiber_olt record.  To add it to the database, see L<"insert">.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'fiber_olt'; }
+
+=item insert
+
+Adds this record to the database.  If there is an error, returns the error,
+otherwise returns false.
+
+=item delete
+
+Delete this record from the database.
+
+=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.
+
+=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('oltnum')
+    || $self->ut_text('oltname')
+    || $self->ut_text('serial')
+    || $self->ut_flag('disabled')
+  ;
+  return $error if $error;
+
+  $self->SUPER::check;
+}
+
+# 3.x stub
+
+sub svc_fiber {
+  my $self = shift;
+  qsearch('svc_fiber', { 'oltnum' => $self->get('oltnum') });
+}
+
+=back
+
+=head1 SEE ALSO
+
+L<FS::svc_fiber>, L<FS::Record>
+
+=cut
+
+1;
+
diff --git a/FS/FS/svc_fiber.pm b/FS/FS/svc_fiber.pm
new file mode 100644
index 0000000..4515d01
--- /dev/null
+++ b/FS/FS/svc_fiber.pm
@@ -0,0 +1,330 @@
+package FS::svc_fiber;
+
+use strict;
+use base qw( FS::svc_Common );
+use FS::cust_svc;
+use FS::hardware_type;
+use FS::fiber_olt;
+use FS::Record 'dbh';
+
+=head1 NAME
+
+FS::svc_fiber - Object methods for svc_fiber records
+
+=head1 SYNOPSIS
+
+  use FS::table_name;
+
+  $record = new FS::table_name \%hash;
+  $record = new FS::table_name { 'column' => 'value' };
+
+  $error = $record->insert;
+
+  $error = $new_record->replace($old_record);
+
+  $error = $record->delete;
+
+  $error = $record->check;
+
+  $error = $record->suspend;
+
+  $error = $record->unsuspend;
+
+  $error = $record->cancel;
+
+=head1 DESCRIPTION
+
+An FS::svc_fiber object represents a fiber-to-the-premises service.  
+FS::svc_fiber inherits from FS::svc_Common.  The following fields are
+currently supported:
+
+=over 4
+
+=item svcnum - Primary key
+
+=item oltnum - The Optical Line Terminal this service connects to (see
+L<FS::fiber_olt>).
+
+=item shelf - The shelf number on the OLT.
+
+=item card - The card number on the OLT shelf.
+
+=item olt_port - The port number on that card.
+
+=item vlan - The VLAN number.
+
+=item signal - Measured signal strength in dB.
+
+=item speed_up - Measured uplink speed in Mbps.
+
+=item speed_down - Measured downlink speed in Mbps.
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new fiber service record.  To add it to the database, see L<"insert">.
+
+=cut
+
+sub table { 'svc_fiber'; }
+
+sub table_info {
+  {
+    'name' => 'Fiber',
+    'name_plural' => 'Fiber', # really the name of the ACL
+    'longname_plural' => 'Fiber services',
+    'sorts' => [ 'oltnum', ],
+    'display_weight' => 74,
+    'cancel_weight'  => 74,
+    'fields' => {
+      'oltnum'        => {
+                          'label'        => 'OLT',
+                          'type'         => 'select',
+                          'select_table' => 'fiber_olt',
+                          'select_key'   => 'oltnum',
+                          'select_label' => 'oltname',
+                          'disable_inventory' => 1,
+                         },
+      'shelf'         => {
+                          'label' => 'Shelf',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'card'          => {
+                          'label' => 'Card',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'olt_port'      => {
+                          'label' => 'GPON port',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      # ONT stuff
+      'ont_id'        => {
+                          'label' => 'ONT #',
+                          'disable_select'    => 1,
+                         },
+      'ont_typenum'   => {
+                          'label' => 'Device type',
+                          'type'  => 'select-hardware',
+                          'disable_select'    => 1,
+                          'disable_default'   => 1,
+                          'disable_inventory' => 1,
+                         },
+      'ont_serial'    => {
+                          'label' => 'Serial number',
+                          'disable_select'    => 1,
+                         },
+      'ont_port'      => {
+                          'label' => 'GE port',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'vlan'          => {
+                          'label' => 'VLAN #',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'signal'        => {
+                          'label' => 'Signal strength (dB)',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'speed_down'    => {
+                          'label' => 'Download speed (Mbps)',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'speed_up'      => {
+                          'label' => 'Upload speed (Mbps)',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+      'ont_install'   => {
+                          'label' => 'ONT install location',
+                          'type'  => 'text',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
+    },
+  };
+}
+
+=item search_sql STRING
+
+Class method which returns an SQL fragment to search for the given string.
+For svc_fiber, STRING can be a full or partial ONT serial number.
+
+=cut
+
+#or something more complicated if necessary
+sub search_sql {
+  my($class, $string) = @_;
+  $string = dbh->quote('%' . $string . '%');
+  "LOWER(svc_fiber.ont_serial) LIKE LOWER($string)";
+}
+
+=item label
+
+Returns a description of this fiber service containing the OLT name and
+port location, and the ONT serial number.
+
+=cut
+
+sub label {
+  my $self = shift;
+  $self->ont_serial . ' @ ' . $self->fiber_olt->oltname . ' ' .
+  join('-', $self->shelf, $self->card, $self->olt_port);
+}
+
+# nothing special for insert, delete, or replace
+
+=item insert
+
+Adds this record to the database.  If there is an error, returns the error,
+otherwise returns false.
+
+The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be 
+defined.  An FS::cust_svc record will be created and inserted.
+
+=item delete
+
+Delete this record from the database.
+
+=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.
+
+=item suspend
+
+Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
+
+=item unsuspend
+
+Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
+
+=item cancel
+
+Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
+
+=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 repalce methods.
+
+=cut
+
+sub check {
+  my $self = shift;
+
+  my $x = $self->setfixed;
+  return $x unless ref($x);
+  my $part_svc = $x;
+
+  my $error =
+       $self->ut_number('oltnum')
+    || $self->ut_numbern('shelf')
+    || $self->ut_numbern('card')
+    || $self->ut_numbern('olt_port')
+    || $self->ut_number('ont_id')
+    || $self->ut_number('ont_typenum')
+    || $self->ut_alphan('ont_serial')
+    || $self->ut_alphan('ont_port')
+    || $self->ut_numbern('vlan')
+    || $self->ut_snumbern('signal')
+    || $self->ut_numbern('speed_up')
+    || $self->ut_numbern('speed_down')
+    || $self->ut_textn('ont_install')
+  ;
+  return $error if $error;
+
+  $self->SUPER::check;
+}
+
+=item ont_description
+
+Returns the description of the ONT hardware, if there is one.
+
+=cut
+
+sub ont_description {
+  my $self = shift;
+  $self->ont_typenum ? $self->hardware_type->description : '';
+}
+
+=item search HASHREF
+
+Returns a qsearch hash expression to search for parameters specified in
+HASHREF.
+
+Parameters are those in L<FS::svc_Common/search>, plus:
+
+ont_typenum - the ONT L<FS::hardware_type> key
+
+oltnum - the OLT L<FS::fiber_olt> key
+
+shelf, card, olt_port - the OLT port location fields
+
+vlan - the VLAN number
+
+ont_serial - the ONT serial number
+
+=cut
+
+sub _search_svc {
+  my ($class, $params, $from, $where) = @_;
+
+  # make this simple: all of these are numeric fields, except that 0 means null
+  foreach my $field (qw(ont_typenum oltnum shelf olt_port card vlan)) {
+    if ( $params->{$field} =~ /^(\d+)$/ ) {
+      push @$where, "COALESCE($field,0) = $1";
+    }
+  }
+  if ( length($params->{ont_serial}) ) {
+    my $string = dbh->quote('%'.$params->{ont_serial}.'%');
+    push @$where, "LOWER(ont_serial) LIKE LOWER($string)";
+  }
+
+}
+
+# 3.x stub
+
+sub fiber_olt {
+  my $self = shift;
+  $self->get('oltnum') ? FS::fiber_olt->by_key($self->get('oltnum')) : '';
+}
+
+#stub still needed under 4.x+
+
+sub hardware_type {
+  my $self = shift;
+  $self->ont_typenum ? FS::hardware_type->by_key($self->ont_typenum) : '';
+}
+
+=back
+
+=head1 SEE ALSO
+
+L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
+L<FS::cust_pkg>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/MANIFEST b/FS/MANIFEST
index b3679b5..838c7e6 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -800,3 +800,5 @@ FS/report_batch.pm
 t/report_batch.t
 FS/password_history.pm
 t/password_history.t
+FS/fiber_olt.pm
+t/fiber_olt.t
diff --git a/FS/t/fiber_olt.t b/FS/t/fiber_olt.t
new file mode 100644
index 0000000..4caada1
--- /dev/null
+++ b/FS/t/fiber_olt.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::fiber_olt;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/fiber_olt.html b/httemplate/browse/fiber_olt.html
new file mode 100644
index 0000000..bffd5f2
--- /dev/null
+++ b/httemplate/browse/fiber_olt.html
@@ -0,0 +1,11 @@
+<& elements/browse-simple.html,
+  'table'               => 'fiber_olt',
+  'title'               => 'Fiber service OLTs',
+  'menubar'             => [ ],
+  'name_singular'       => 'OLT',
+  'acl'                 => 'Configuration',
+# overrides
+  'disabled_statuspos' => 3,
+  'header' => [ '#',      'Name',     'Serial' ],
+  'fields' => [ 'oltnum', 'oltname',  'serial' ],
+&>
diff --git a/httemplate/edit/fiber_olt.html b/httemplate/edit/fiber_olt.html
new file mode 100644
index 0000000..ab7d2f0
--- /dev/null
+++ b/httemplate/edit/fiber_olt.html
@@ -0,0 +1,24 @@
+<& elements/edit.html,
+  'popup'         => 1,
+  'table'         => 'fiber_olt',
+  'name_singular' => 'OLT',
+  'labels'        => \%labels,
+  'fields'        => \@fields,
+&>
+<%init>
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my @fields = (
+  'oltname',
+  'serial',
+  { field => 'disabled', type => 'checkbox', value => 'Y' }
+);
+
+my %labels = (
+  'oltnum' => '',
+  'oltname' => 'Name',
+  'serial'  => 'Serial',
+  'disabled' => 'Disabled',
+);
+</%init>
diff --git a/httemplate/edit/process/fiber_olt.html b/httemplate/edit/process/fiber_olt.html
new file mode 100644
index 0000000..c8c4af4
--- /dev/null
+++ b/httemplate/edit/process/fiber_olt.html
@@ -0,0 +1,11 @@
+<& elements/process.html,
+  'table'         => 'fiber_olt',
+  'viewall_dir'   => 'browse',
+  'popup_reload'  => 'Updating',
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/edit/process/svc_fiber.html b/httemplate/edit/process/svc_fiber.html
new file mode 100644
index 0000000..815a8ee
--- /dev/null
+++ b/httemplate/edit/process/svc_fiber.html
@@ -0,0 +1,11 @@
+<& elements/svc_Common.html,
+    table       => 'svc_fiber',
+    edit_ext    => 'html',
+    redirect    => popurl(3)."view/svc_fiber.cgi?",
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+</%init>
diff --git a/httemplate/edit/svc_fiber.html b/httemplate/edit/svc_fiber.html
new file mode 100644
index 0000000..e07caa1
--- /dev/null
+++ b/httemplate/edit/svc_fiber.html
@@ -0,0 +1,36 @@
+<& elements/svc_Common.html,
+  'table'             => 'svc_fiber',
+  'fields'            => \@fields,
+&>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+my $conf = new FS::Conf;
+
+my @fields = (
+  { field     => 'oltnum',
+    type      => 'select-table',
+    table     => 'fiber_olt',
+    name_col  => 'oltname',
+    hashref   => { disabled => '' },
+    disable_empty => 1,
+  },
+  { field     => 'shelf' },
+  { field     => 'card'  },
+  { field     => 'olt_port' },
+  { field     => 'ont_id'   },
+  { field     => 'ont_typenum',
+    type      => 'select-hardware_type'
+  },
+  { field     => 'ont_serial' },
+  { field     => 'ont_port' },
+  { field     => 'vlan' },
+  { field     => 'signal' },
+  { field     => 'speed_down' },
+  { field     => 'speed_up' },
+  { field     => 'ont_install', size => 50 },
+);
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index fd77d9d..f4aeec8 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -226,10 +226,12 @@ foreach my $svcdb ( FS::part_svc->svc_tables() ) {
       ];
   }
 
+  if ( $curuser->access_right("Services: $name: Advanced search")
+    && $svcdb =~ /^svc_(acct|broadband|hardware|phone|fiber)$/ ) {
+
     $report_svc{"Advanced $lcsname reports"} = 
-        [ $fsurl."search/report_$svcdb.html", '' ]
-      if $svcdb =~ /^svc_(acct|broadband|hardware|phone)$/
-      && $curuser->access_right("Services: $name: Advanced search");
+      [ $fsurl."search/report_$svcdb.html", '' ]
+  }
 
   if ( $svcdb eq 'svc_phone' ) {
 
@@ -572,6 +574,10 @@ tie my %config_circuit, 'Tie::IxHash',
   'Termination types' => [ $fsurl.'browse/circuit_termination.html',  '' ],
 ;
 
+tie my %config_fiber, 'Tie::IxHash',
+  'OLTs' => [ $fsurl.'browse/fiber_olt.html', '' ],
+;
+
 tie my %config_export_svc, 'Tie::IxHash', ();
 if ( $curuser->access_right('Configuration') ) {
   $config_export_svc{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ];
@@ -592,6 +598,8 @@ $config_export_svc{'Alarm'} = [ \%config_alarm, '' ]
   if $curuser->access_right(['Alarm configuration', 'Alarm global configuration']);
 $config_export_svc{'Circuits'} = [ \%config_circuit, '' ]
   if $curuser->access_right('Configuration');
+$config_export_svc{'Fiber'} = [ \%config_fiber, '' ]
+  if $curuser->access_right('Configuration');
 $config_export_svc{'Hardware types'} = [ $fsurl.'browse/hardware_class.html', 'Set up hardware type catalog' ]
   if $curuser->access_right('Configuration');
 
diff --git a/httemplate/search/report_svc_fiber.html b/httemplate/search/report_svc_fiber.html
new file mode 100755
index 0000000..d563c53
--- /dev/null
+++ b/httemplate/search/report_svc_fiber.html
@@ -0,0 +1,47 @@
+<& /elements/header.html, $title &>
+
+<FORM ACTION="svc_fiber.html" METHOD="GET">
+
+  <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+    <TR>
+      <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH>
+    </TR>
+
+    <& /elements/tr-select-table.html,
+      label     => 'OLT',
+      table     => 'fiber_olt',
+      name_col  => 'oltname',
+    &>
+    <& /elements/tr-input-text.html, field => 'shelf', label => 'Shelf' &>
+    <& /elements/tr-input-text.html, field => 'card',  label => 'Card' &>
+    <& /elements/tr-input-text.html, field => 'olt_port', label => 'Port' &>
+
+    <& /elements/tr-td-label.html, label => 'ONT model' &>
+      <TD>
+      <& /elements/select-hardware_type.html,
+          'empty_label' => '(all)'
+       &>
+      </TD>
+    </TR>
+
+    <& /elements/tr-input-text.html, field => 'ont_serial', label => 'Serial number' &>
+    <& /elements/tr-input-text.html, field => 'vlan', label => 'VLAN' &>
+  </TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="Search">
+
+</FORM>
+
+<& /elements/footer.html &>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Services: Fiber');
+
+my $title = 'Search Fiber Services';
+
+my @olts = qsearch('fiber_olt', {});
+
+</%init>
+
diff --git a/httemplate/search/svc_fiber.html b/httemplate/search/svc_fiber.html
new file mode 100644
index 0000000..0cb735c
--- /dev/null
+++ b/httemplate/search/svc_fiber.html
@@ -0,0 +1,69 @@
+<& elements/svc_Common.html,
+  'title'       => 'Fiber Search Results',
+  'name'        => 'fiber services',
+  'query'       => $query,
+  'count_query' => $query->{'count_query'},
+  'redirect'    => $link,
+  'header'      => [ '#',
+                     'OLT',
+                     'Shelf/Card/Port',
+                     'ONT',
+                     'Model',
+                     'Serial',
+                     FS::UI::Web::cust_header($cgi->param('cust_fields')),
+                   ],
+  'fields'      => [ 'svcnum',
+                     'oltname',
+                     sub { my $svc = shift;
+                           join('-', $svc->shelf, $svc->card, $svc->olt_port)
+                     },
+                     'ont_id',
+                     'ont_description',
+                     'ont_serial',
+                     \&FS::UI::Web::cust_fields,
+                   ],
+  'links'       => [ $link,
+                     '',
+                     '',
+                     $link,
+                     $link,
+                     $link,
+                     FS::UI::Web::cust_links($cgi->param('cust_fields')),
+                   ],
+  'align'       => 'rlllll'.  FS::UI::Web::cust_aligns(),
+  'color'       => [ 
+                     ('') x 6,
+                     FS::UI::Web::cust_colors(),
+                   ],
+  'style'       => [ 
+                     ('') x 6,
+                     FS::UI::Web::cust_styles(),
+                   ],
+
+&>
+<%init>
+
+die "access denied" unless
+  $FS::CurrentUser::CurrentUser->access_right([ 'Services: Fiber',
+                                                'List services'
+                                              ]);
+
+my $conf = new FS::Conf;
+
+my %search_hash;
+if ( $cgi->param('magic') eq 'unlinked' ) {
+  %search_hash = ( 'unlinked' => 1 );
+} else {
+  foreach (qw( custnum agentnum svcpart cust_fields
+               ont_typenum oltnum shelf olt_port card vlan )) {
+    $search_hash{$_} = $cgi->param($_) if defined($cgi->param($_));
+  }
+}
+
+my $query = FS::svc_fiber->search(\%search_hash);
+$query->{addl_from} .= ' LEFT JOIN fiber_olt USING (oltnum) ';
+$query->{select} .= ', oltname';
+
+my $link = [ $p.'view/svc_fiber.cgi?', 'svcnum' ];
+
+</%init>
diff --git a/httemplate/view/svc_fiber.cgi b/httemplate/view/svc_fiber.cgi
new file mode 100644
index 0000000..ce9c03d
--- /dev/null
+++ b/httemplate/view/svc_fiber.cgi
@@ -0,0 +1,34 @@
+<& elements/svc_Common.html,
+  'table'       => 'svc_fiber',
+  'fields'      => \@fields,
+  'labels'      => \%labels,
+  'edit_url'    => $fsurl.'edit/svc_fiber.html?',
+&>
+<%init>
+
+my @fields = (
+  { field     => 'oltnum',
+    type      => 'select-table',
+    table     => 'fiber_olt',
+    name_col  => 'oltname',
+  },
+  'shelf',
+  'card',
+  'olt_port',
+  'ont_id',
+  'ont_description',
+  'ont_serial',
+  'ont_port',
+  'vlan',
+  'signal',
+  'speed_down',
+  'speed_up',
+  'ont_install',
+);
+
+my $fields = FS::svc_fiber->table_info->{'fields'};
+my %labels = map { $_ => $fields->{$_}{'label'} } keys %$fields;
+
+$labels{'ont_description'} = 'ONT model';
+
+</%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/AccessRight.pm                               |    4 +-
 FS/FS/Mason.pm                                     |    2 +
 FS/FS/Schema.pm                                    |  119 +++++++
 eg/table_template.pm => FS/FS/fiber_olt.pm         |   60 ++--
 FS/FS/svc_fiber.pm                                 |  330 ++++++++++++++++++++
 FS/MANIFEST                                        |    2 +
 FS/t/{ConfItem.t => fiber_olt.t}                   |    2 +-
 httemplate/browse/fiber_olt.html                   |   11 +
 .../edit/{circuit_provider.html => fiber_olt.html} |   15 +-
 .../process/{circuit_type.html => fiber_olt.html}  |    2 +-
 .../process/{svc_hardware.html => svc_fiber.html}  |    9 +-
 httemplate/edit/svc_fiber.html                     |   36 +++
 httemplate/elements/menu.html                      |   14 +-
 httemplate/search/report_svc_fiber.html            |   47 +++
 httemplate/search/svc_fiber.html                   |   69 ++++
 httemplate/view/svc_fiber.cgi                      |   34 ++
 16 files changed, 709 insertions(+), 47 deletions(-)
 copy eg/table_template.pm => FS/FS/fiber_olt.pm (57%)
 create mode 100644 FS/FS/svc_fiber.pm
 copy FS/t/{ConfItem.t => fiber_olt.t} (84%)
 create mode 100644 httemplate/browse/fiber_olt.html
 copy httemplate/edit/{circuit_provider.html => fiber_olt.html} (63%)
 copy httemplate/edit/process/{circuit_type.html => fiber_olt.html} (84%)
 copy httemplate/edit/process/{svc_hardware.html => svc_fiber.html} (51%)
 create mode 100644 httemplate/edit/svc_fiber.html
 create mode 100755 httemplate/search/report_svc_fiber.html
 create mode 100644 httemplate/search/svc_fiber.html
 create mode 100644 httemplate/view/svc_fiber.cgi




More information about the freeside-commits mailing list