use FS::password_history;
use FS::svc_fiber;
use FS::fiber_olt;
+ use FS::olt_site;
# Sammath Naur
if ( $FS::Mason::addl_handler_use ) {
'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, '', '',
'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', '', '', '', '',
use strict;
use FS::Record qw( qsearch qsearchs );
+use FS::olt_site;
=head1 NAME
=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
$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;
$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
--- /dev/null
+package FS::olt_site;
+
+use strict;
+use base qw( FS::Record );
+use FS::Record qw( qsearch qsearchs );
+
+=head1 NAME
+
+FS::olt_site - Object methods for olt_site records
+
+=head1 SYNOPSIS
+
+ use FS::olt_site;
+
+ $record = new FS::olt_site \%hash;
+ $record = new FS::olt_site { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+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 sitenum - primary key
+
+=item market - market designator, indicating the general area the site serves
+
+=item site - site designator
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new record. To add the record to the database, see L<"insert">.
+
+=cut
+
+sub table { 'olt_site'; }
+
+=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('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::Record>, L<FS::fiber_olt>
+
+=cut
+
+1;
+
'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 #',
=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
|| $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;
}
t/password_history.t
FS/fiber_olt.pm
t/fiber_olt.t
+FS/olt_site.pm
+t/olt_site.t
--- /dev/null
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::olt_site;
+$loaded=1;
+print "ok 1\n";
<& 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' ],
&>
--- /dev/null
+<& 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', ],
+&>
% $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
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' }
);
my %labels = (
'oltnum' => '',
'oltname' => 'Name',
+ 'sitenum' => 'Site',
'serial' => 'Serial',
'disabled' => 'Disabled',
);
--- /dev/null
+<& 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',
+ },
+&>
--- /dev/null
+<& elements/process.html,
+ table => 'olt_site',
+ viewall_dir => 'browse',
+&>
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>
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,
},
--- /dev/null
+<& /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>
<%init>
my @fields = (
+ 'circuit_id',
{ field => 'oltnum',
type => 'select-table',
table => 'fiber_olt',
- name_col => 'oltname',
+ name_col => 'description',
},
'shelf',
'card',