[freeside-commits] branch FREESIDE_4_BRANCH updated. e838c55613ee0159315543e0ecfb1e0e39158168

Mark Wells mark at 420.am
Thu Mar 10 01:49:20 PST 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  e838c55613ee0159315543e0ecfb1e0e39158168 (commit)
       via  595998d86ea3e75efa16eba5d7f1319394cf62b2 (commit)
       via  5a9a411b980edea1b0f9690fc92e3b93574ee974 (commit)
      from  efad6767531821f6796e193a53aed4d2981cb983 (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 e838c55613ee0159315543e0ecfb1e0e39158168
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Mar 10 01:47:43 2016 -0800

    OLT edit fixes, #35260

diff --git a/httemplate/browse/fiber_olt.html b/httemplate/browse/fiber_olt.html
index 2355ec0..ec64768 100644
--- a/httemplate/browse/fiber_olt.html
+++ b/httemplate/browse/fiber_olt.html
@@ -6,6 +6,6 @@
   'acl'                 => 'Configuration',
 # overrides
   'disabled_statuspos' => 3,
-  'header' => [ '#',      'Site',             'Name',     'Serial' ],
-  'fields' => [ 'oltnum', 'site_description', 'oltname',  'serial' ],
+  'header' => [ '#',      'Name',     'Serial', 'Site',             ],
+  'fields' => [ 'oltnum', 'oltname',  'serial', 'site_description', ],
 &>
diff --git a/httemplate/edit/process/olt_site.html b/httemplate/edit/process/olt_site.html
index f328cfe..8d048a2 100644
--- a/httemplate/edit/process/olt_site.html
+++ b/httemplate/edit/process/olt_site.html
@@ -1,4 +1,11 @@
 <& elements/process.html, 
-    table       => 'olt_site',
-    viewall_dir => 'browse',
+    table         => 'olt_site',
+    viewall_dir   => 'browse',
+    popup_reload  => 'Updating',
 &>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>

commit 595998d86ea3e75efa16eba5d7f1319394cf62b2
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Mar 10 01:38:41 2016 -0800

    allow null fiber_olt.sitenum, #35260

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 97ef89c..3b1bc0e 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -6927,7 +6927,7 @@ sub tables_hashref {
       'columns' => [
         'oltnum',   'serial', '',       '', '', '',
         'oltname', 'varchar', '',  $char_d, '', '',
-        'sitenum',     'int', '',       '', '', '',
+        'sitenum',     'int', 'NULL',   '', '', '',
         'serial',  'varchar', '',  $char_d, '', '',
         'disabled',   'char', 'NULL',    1, '', '',
       ],

commit 5a9a411b980edea1b0f9690fc92e3b93574ee974
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Mar 10 01:20:21 2016 -0800

    add svc_fiber circuit id field, OLT sites, and other improvements, #35260

diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index ff0baee..3a00f42 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -408,6 +408,7 @@ if ( -e $addl_handler_use_file ) {
   use FS::password_history;
   use FS::svc_fiber;
   use FS::fiber_olt;
+  use FS::olt_site;
   # Sammath Naur
 
   if ( $FS::Mason::addl_handler_use ) {
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index aa0bcd7..97ef89c 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -6899,8 +6899,9 @@ sub tables_hashref {
         'ont_typenum',    'int', 'NULL',      '', '', '',
         'ont_serial', 'varchar', 'NULL', $char_d, '', '',
         'ont_port',   'varchar', 'NULL',      16, '', '',
+        'circuit_id', 'varchar', 'NULL', $char_d, '', '',
         'vlan',           'int', 'NULL',      '', '', '',
-        'signal',         'int', 'NULL',      '', '', '',
+        'signal',     'decimal', 'NULL',  '10,2', '', '',
         'speed_up',       'int', 'NULL',      '', '', '',
         'speed_down',     'int', 'NULL',      '', '', '',
         'ont_install','varchar', 'NULL', $char_d, '', '',
@@ -6926,14 +6927,35 @@ sub tables_hashref {
       'columns' => [
         'oltnum',   'serial', '',       '', '', '',
         'oltname', 'varchar', '',  $char_d, '', '',
+        'sitenum',     'int', '',       '', '', '',
         'serial',  'varchar', '',  $char_d, '', '',
         'disabled',   'char', 'NULL',    1, '', '',
       ],
       'primary_key' => 'oltnum',
       'unique' => [ ],
       'index'  => [ ],
+      'foreign_keys' => [
+                          { columns => [ 'sitenum' ],
+                            table   => 'olt_site',
+                          },
+                        ],
     },
 
+    'olt_site' => {
+      'columns' => [
+        'sitenum',  'serial', '',      '', '', '',
+        'market',  'varchar', '', $char_d, '', '',
+        'site',    'varchar', '', $char_d, '', '',
+      ],
+      'primary_key' => 'sitenum',
+      'unique' => [ [ 'market', 'site' ] ],
+      'index' => [ ],
+    },
+
+
+
+
+
     'vend_main' => {
       'columns' => [
         'vendnum',   'serial',     '',      '', '', '',
diff --git a/FS/FS/fiber_olt.pm b/FS/FS/fiber_olt.pm
index a0de38d..a9a46ef 100644
--- a/FS/FS/fiber_olt.pm
+++ b/FS/FS/fiber_olt.pm
@@ -3,6 +3,7 @@ use base qw( FS::Record );
 
 use strict;
 use FS::Record qw( qsearch qsearchs );
+use FS::olt_site;
 
 =head1 NAME
 
@@ -37,6 +38,8 @@ FS::Record.  The following fields are currently supported:
 
 =item serial - serial number
 
+=item sitenum - the L<FS::olt_site> where this OLT is installed
+
 =item disabled - set to 'Y' to make this OLT unavailable for new connections
 
 =back
@@ -87,6 +90,7 @@ sub check {
     $self->ut_numbern('oltnum')
     || $self->ut_text('oltname')
     || $self->ut_text('serial')
+    || $self->ut_foreign_keyn('sitenum', 'olt_site', 'sitenum')
     || $self->ut_flag('disabled')
   ;
   return $error if $error;
@@ -94,11 +98,37 @@ sub check {
   $self->SUPER::check;
 }
 
+=item site_description
+
+Returns the OLT's site description.
+
+=cut
+
+sub site_description {
+  my $self = shift;
+  return '' if !$self->sitenum;
+  my $olt_site = FS::olt_site->by_key($self->sitenum);
+  return $olt_site->description;
+}
+
+=item description
+
+Returns the OLT's site name and unit name.
+
+=cut
+
+sub description {
+  my $self = shift;
+  my $desc = $self->oltname;
+  $desc = $self->site_description . '/' . $desc if $self->sitenum;
+  return $desc;
+}
+
 =back
 
 =head1 SEE ALSO
 
-L<FS::svc_fiber>, L<FS::Record>
+L<FS::svc_fiber>, L<FS::olt_site>, L<FS::Record>
 
 =cut
 
diff --git a/FS/FS/fiber_olt.pm b/FS/FS/olt_site.pm
similarity index 57%
copy from FS/FS/fiber_olt.pm
copy to FS/FS/olt_site.pm
index a0de38d..1c826f8 100644
--- a/FS/FS/fiber_olt.pm
+++ b/FS/FS/olt_site.pm
@@ -1,19 +1,19 @@
-package FS::fiber_olt;
-use base qw( FS::Record );
+package FS::olt_site;
 
 use strict;
+use base qw( FS::Record );
 use FS::Record qw( qsearch qsearchs );
 
 =head1 NAME
 
-FS::fiber_olt - Object methods for fiber_olt records
+FS::olt_site - Object methods for olt_site records
 
 =head1 SYNOPSIS
 
-  use FS::fiber_olt;
+  use FS::olt_site;
 
-  $record = new FS::fiber_olt \%hash;
-  $record = new FS::fiber_olt { 'column' => 'value' };
+  $record = new FS::olt_site \%hash;
+  $record = new FS::olt_site { 'column' => 'value' };
 
   $error = $record->insert;
 
@@ -25,19 +25,17 @@ FS::fiber_olt - Object methods for fiber_olt records
 
 =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
+An FS::olt_site object represents a central office housing Optical Line
+Terminals (L<FS::fiber_olt>). FS::olt_site inherits from
 FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item oltnum - primary key
+=item sitenum - primary key
 
-=item oltname - name of this device
+=item market - market designator, indicating the general area the site serves
 
-=item serial - serial number
-
-=item disabled - set to 'Y' to make this OLT unavailable for new connections
+=item site - site designator
 
 =back
 
@@ -47,13 +45,11 @@ FS::Record.  The following fields are currently supported:
 
 =item new HASHREF
 
-Creates a new fiber_olt record.  To add it to the database, see L<"insert">.
+Creates a new record.  To add the record 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'; }
+sub table { 'olt_site'; }
 
 =item insert
 
@@ -84,21 +80,25 @@ sub check {
   my $self = shift;
 
   my $error = 
-    $self->ut_numbern('oltnum')
-    || $self->ut_text('oltname')
-    || $self->ut_text('serial')
-    || $self->ut_flag('disabled')
+    $self->ut_numbern('sitenum')
+    || $self->ut_text('market')
+    || $self->ut_text('site')
   ;
   return $error if $error;
 
   $self->SUPER::check;
 }
 
+sub description {
+  my $self = shift;
+  return $self->market . '/' . $self->site;
+}
+
 =back
 
 =head1 SEE ALSO
 
-L<FS::svc_fiber>, L<FS::Record>
+L<FS::Record>, L<FS::fiber_olt>
 
 =cut
 
diff --git a/FS/FS/svc_fiber.pm b/FS/FS/svc_fiber.pm
index c4036dc..c604943 100644
--- a/FS/FS/svc_fiber.pm
+++ b/FS/FS/svc_fiber.pm
@@ -108,6 +108,13 @@ sub table_info {
                           'disable_inventory' => 1,
                           'disable_select'    => 1,
                          },
+      # ODN circuit
+      'circuit_id'    => {
+                          'label' => 'ODN circuit',
+                          'type'  => 'input-fiber_circuit',
+                          'disable_inventory' => 1,
+                          'disable_select'    => 1,
+                         },
       # ONT stuff
       'ont_id'        => {
                           'label' => 'ONT #',
@@ -180,15 +187,14 @@ sub search_sql {
 
 =item label
 
-Returns a description of this fiber service containing the OLT name and
-port location, and the ONT serial number.
+Returns a description of this fiber service containing the circuit ID
+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);
+  $self->ont_serial . ' @ ' . $self->circuit_id;
 }
 
 # nothing special for insert, delete, or replace
@@ -247,13 +253,15 @@ sub check {
     || $self->ut_alphan('ont_serial')
     || $self->ut_alphan('ont_port')
     || $self->ut_numbern('vlan')
-    || $self->ut_snumbern('signal')
+    || $self->ut_sfloatn('signal')
     || $self->ut_numbern('speed_up')
     || $self->ut_numbern('speed_down')
     || $self->ut_textn('ont_install')
   ;
   return $error if $error;
 
+  $self->set('signal', sprintf('%.2f', $self->get('signal')));
+
   $self->SUPER::check;
 }
 
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 176fe78..9b30672 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -862,3 +862,5 @@ FS/password_history.pm
 t/password_history.t
 FS/fiber_olt.pm
 t/fiber_olt.t
+FS/olt_site.pm
+t/olt_site.t
diff --git a/FS/t/olt_site.t b/FS/t/olt_site.t
new file mode 100644
index 0000000..d475da1
--- /dev/null
+++ b/FS/t/olt_site.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::olt_site;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/fiber_olt.html b/httemplate/browse/fiber_olt.html
index bffd5f2..2355ec0 100644
--- a/httemplate/browse/fiber_olt.html
+++ b/httemplate/browse/fiber_olt.html
@@ -1,11 +1,11 @@
 <& elements/browse-simple.html,
   'table'               => 'fiber_olt',
   'title'               => 'Fiber service OLTs',
-  'menubar'             => [ ],
+  'menubar'             => [ 'View sites' => 'olt_site.html' ],
   'name_singular'       => 'OLT',
   'acl'                 => 'Configuration',
 # overrides
   'disabled_statuspos' => 3,
-  'header' => [ '#',      'Name',     'Serial' ],
-  'fields' => [ 'oltnum', 'oltname',  'serial' ],
+  'header' => [ '#',      'Site',             'Name',     'Serial' ],
+  'fields' => [ 'oltnum', 'site_description', 'oltname',  'serial' ],
 &>
diff --git a/httemplate/browse/olt_site.html b/httemplate/browse/olt_site.html
new file mode 100644
index 0000000..ea2e7de
--- /dev/null
+++ b/httemplate/browse/olt_site.html
@@ -0,0 +1,12 @@
+<& elements/browse-simple.html,
+  'table'               => 'olt_site',
+  'title'               => 'Fiber OLT markets and sites',
+  'menubar'             => [ 'View OLTs' => 'fiber_olt.html' ],
+  'name_singular'       => 'site',
+  'acl'                 => 'Configuration',
+# overrides
+  'disabled_statuspos' => '',
+  'disableable'        => 0,
+  'header' => [ '#',      'Market', 'Site', ],
+  'fields' => [ 'sitenum', 'market', 'site', ],
+&>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index c6d4553..bbc9797 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -362,7 +362,7 @@ Example:
 %   $include_common{$_} = $f->{$_} foreach grep exists($f->{$_}),
 %     qw( js_only html_only select_only layers_only cell_style ),#selectlayers,?
 %     qw( empty_label ),                                   # select-*
-%     qw( value_col compare_sub order_by ),                # select-table
+%     qw( value_col compare_sub order_by addl_from ), # select-table
 %     qw( table name_col ),                           #(select,checkboxes)-table
 %     qw( target_table link_table ),                       #checkboxes-table
 %     qw( hashref agent_virt agent_null agent_null_right ),#*-table
diff --git a/httemplate/edit/fiber_olt.html b/httemplate/edit/fiber_olt.html
index ab7d2f0..8cbcbb5 100644
--- a/httemplate/edit/fiber_olt.html
+++ b/httemplate/edit/fiber_olt.html
@@ -11,6 +11,14 @@ die "access denied"
 
 my @fields = (
   'oltname',
+  {
+    field       => 'sitenum',
+    type        => 'select-table',
+    table       => 'olt_site',
+    name_col    => 'description',
+    order_by    => 'ORDER BY market, site',
+    empty_label => ' ',
+  },
   'serial',
   { field => 'disabled', type => 'checkbox', value => 'Y' }
 );
@@ -18,6 +26,7 @@ my @fields = (
 my %labels = (
   'oltnum' => '',
   'oltname' => 'Name',
+  'sitenum' => 'Site',
   'serial'  => 'Serial',
   'disabled' => 'Disabled',
 );
diff --git a/httemplate/edit/olt_site.html b/httemplate/edit/olt_site.html
new file mode 100644
index 0000000..c243bab
--- /dev/null
+++ b/httemplate/edit/olt_site.html
@@ -0,0 +1,20 @@
+<& elements/edit.html,
+  popup => 1,
+  name_singular => 'OLT site',
+  table         => 'olt_site',
+  viewall_dir   => 'browse',
+  fields        => [
+                     { field => 'market',
+                       type => 'text',
+                       size => 4,
+                     },
+                     { field => 'site',
+                       type => 'text',
+                       size => 4,
+                     },
+                   ],
+  labels        => { 'market'    => 'Market',
+                     'site'      => 'Site',
+                     'sitenum'   => 'Site',
+                   },
+&>
diff --git a/httemplate/edit/process/olt_site.html b/httemplate/edit/process/olt_site.html
new file mode 100644
index 0000000..f328cfe
--- /dev/null
+++ b/httemplate/edit/process/olt_site.html
@@ -0,0 +1,4 @@
+<& elements/process.html, 
+    table       => 'olt_site',
+    viewall_dir => 'browse',
+&>
diff --git a/httemplate/edit/process/svc_fiber.html b/httemplate/edit/process/svc_fiber.html
index 815a8ee..3dabede 100644
--- a/httemplate/edit/process/svc_fiber.html
+++ b/httemplate/edit/process/svc_fiber.html
@@ -2,10 +2,22 @@
     table       => 'svc_fiber',
     edit_ext    => 'html',
     redirect    => popurl(3)."view/svc_fiber.cgi?",
+    precheck_callback => $precheck_callback,
 &>
 <%init>
 
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
 
+my $precheck_callback = sub {
+  my $cgi = shift;
+  # recombine fdu/fat/subfat/port
+  my $circuit_id = $cgi->param('circuit_id_fdu') . '/' .
+                   $cgi->param('circuit_id_fat') . $cgi->param('circuit_id_subfat') . '/' .
+                   $cgi->param('circuit_id_port');
+  $cgi->param('circuit_id', $circuit_id);
+  $cgi->delete(qw( circuit_id_fdu circuit_id_fat circuit_id_subfat circuit_id_port ));
+  '';
+};
+
 </%init>
diff --git a/httemplate/edit/svc_fiber.html b/httemplate/edit/svc_fiber.html
index e07caa1..982b0bf 100644
--- a/httemplate/edit/svc_fiber.html
+++ b/httemplate/edit/svc_fiber.html
@@ -10,10 +10,15 @@ die "access denied"
 my $conf = new FS::Conf;
 
 my @fields = (
+  { field     => 'circuit_id',
+    type      => 'input-fiber_circuit',
+  },
   { field     => 'oltnum',
     type      => 'select-table',
     table     => 'fiber_olt',
-    name_col  => 'oltname',
+    name_col  => 'description',
+    addl_from => 'LEFT JOIN olt_site USING (sitenum)',
+    order_by  => 'ORDER BY market, site, oltname',
     hashref   => { disabled => '' },
     disable_empty => 1,
   },
diff --git a/httemplate/elements/tr-input-fiber_circuit.html b/httemplate/elements/tr-input-fiber_circuit.html
new file mode 100644
index 0000000..fb6462b
--- /dev/null
+++ b/httemplate/elements/tr-input-fiber_circuit.html
@@ -0,0 +1,31 @@
+<& /elements/tr-td-label.html, %opt &>
+  <td>
+    <table class="inv">
+      <tr>
+        <th>FDU#</th>
+        <td><input name="<% $field %>_fdu" value="<% $fdu |h %>" SIZE="1"></td>
+        <th>FAT#</th>
+        <td><input name="<% $field %>_fat" value="<% $fat |h %>" SIZE="1">
+            <input name="<% $field %>_subfat" value="<% $subfat |h %>" SIZE="1">
+        </td>
+        <th>Port#</th>
+        <td><input name="<% $field %>_port" value="<% $port |h %>" SIZE="1"></td>
+      </tr>
+    </table>
+  </td>
+</tr>
+<%doc>
+Supports a circuit ID of the form
+FDU# (digit), FAT# (digit), SubFAT (letter), Port# (numeric)
+May support other formats in the future, or just a free text field.
+</%doc>
+<%init>
+my %opt = @_;
+my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value};
+my ($fdu, $fat, $port) = split('/', $value);
+my $subfat = '';
+if ( $fat =~ /[A-Z]$/i ) {
+  $subfat = substr($fat, -1, 1, '');
+}
+my $field = $opt{'field'} || 'circuit_id';
+</%init>
diff --git a/httemplate/view/svc_fiber.cgi b/httemplate/view/svc_fiber.cgi
index ce9c03d..80a8338 100644
--- a/httemplate/view/svc_fiber.cgi
+++ b/httemplate/view/svc_fiber.cgi
@@ -7,10 +7,11 @@
 <%init>
 
 my @fields = (
+  'circuit_id',
   { field     => 'oltnum',
     type      => 'select-table',
     table     => 'fiber_olt',
-    name_col  => 'oltname',
+    name_col  => 'description',
   },
   'shelf',
   'card',

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

Summary of changes:
 FS/FS/Mason.pm                                  |    1 +
 FS/FS/Schema.pm                                 |   24 +++++++++++++++-
 FS/FS/fiber_olt.pm                              |   32 ++++++++++++++++++++-
 FS/FS/{circuit_provider.pm => olt_site.pm}      |   35 +++++++++++++----------
 FS/FS/svc_fiber.pm                              |   18 ++++++++----
 FS/MANIFEST                                     |    2 ++
 FS/t/{ConfItem.t => olt_site.t}                 |    2 +-
 httemplate/browse/fiber_olt.html                |    6 ++--
 httemplate/browse/olt_site.html                 |   12 ++++++++
 httemplate/edit/elements/edit.html              |    2 +-
 httemplate/edit/fiber_olt.html                  |    9 ++++++
 httemplate/edit/olt_site.html                   |   20 +++++++++++++
 httemplate/edit/process/olt_site.html           |   11 +++++++
 httemplate/edit/process/svc_fiber.html          |   12 ++++++++
 httemplate/edit/svc_fiber.html                  |    7 ++++-
 httemplate/elements/tr-input-fiber_circuit.html |   31 ++++++++++++++++++++
 httemplate/view/svc_fiber.cgi                   |    3 +-
 17 files changed, 198 insertions(+), 29 deletions(-)
 copy FS/FS/{circuit_provider.pm => olt_site.pm} (63%)
 copy FS/t/{ConfItem.t => olt_site.t} (84%)
 create mode 100644 httemplate/browse/olt_site.html
 create mode 100644 httemplate/edit/olt_site.html
 create mode 100644 httemplate/edit/process/olt_site.html
 create mode 100644 httemplate/elements/tr-input-fiber_circuit.html




More information about the freeside-commits mailing list