X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_broadband.pm;h=bd7bf9b132f174c77242156858889732032a7884;hb=a354fed1dedc65cf62e63d940e1cfb9c4364e6d3;hp=87c73f2f0af7728f36c47046518c1d6a834bcab9;hpb=efa799391aeba085b65145428cab1cf1074d3f6d;p=freeside.git diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm index 87c73f2f0..bd7bf9b13 100755 --- a/FS/FS/svc_broadband.pm +++ b/FS/FS/svc_broadband.pm @@ -2,9 +2,11 @@ package FS::svc_broadband; use base qw( FS::svc_Radius_Mixin FS::svc_Tower_Mixin + FS::svc_Torrus_Mixin FS::svc_IP_Mixin + FS::MAC_Mixin FS::svc_Common - ); +); use strict; use vars qw($conf); @@ -101,18 +103,27 @@ sub table_info { 'display_weight' => 50, 'cancel_weight' => 70, 'ip_field' => 'ip_addr', + 'manual_require' => 1, 'fields' => { '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.', - 'blocknum' => - { 'label' => 'Address block', - 'type' => 'select', - 'select_table' => 'addr_block', - 'select_key' => 'blocknum', - 'select_label' => 'cidr', + 'description' => 'Descriptive label', + 'speed_up' => { + 'label' => 'Upload speed (Kbps)', + 'type' => 'fcc_477_speed', + 'def_info' => 'both upload and download speed must be set to FCC 477 information if using that modifier', + }, + 'speed_down' => { + 'label' => 'Download speed (Kbps)', + 'type' => 'fcc_477_speed', + 'def_info' => 'both upload and download speed must be set to FCC 477 information if using that modifier', + }, + 'ip_addr' => 'IP address', + 'blocknum' => { + 'label' => 'Address block', + 'type' => 'select', + 'select_table' => 'addr_block', + 'select_key' => 'blocknum', + 'select_label' => 'cidr', 'disable_inventory' => 1, }, 'plan_id' => 'Service Plan Id', @@ -131,9 +142,23 @@ sub table_info { #select_table => 'radius_group', #select_key => 'groupnum', #select_label => 'groupname', + disable_select => 1, disable_inventory => 1, multiple => 1, }, + 'radio_serialnum' => 'Radio Serial Number', + 'radio_location' => 'Radio Location', + 'poe_location' => 'POE Location', + 'rssi' => 'RSSI', + 'suid' => 'SUID', + 'shared_svcnum' => { label => 'Shared Service', + type => 'search-svc_broadband', + disable_inventory => 1, + }, + 'serviceid' => 'Torrus serviceid', #but is should be hidden + 'speed_test_up' => 'Speed test download (Kbps)', + 'speed_test_down' => 'Speed test upload (Kbps)', + 'speed_test_latency' => 'Speed test latency (ms)', }, }; } @@ -225,25 +250,42 @@ sub search_sql { my( $class, $string ) = @_; if ( $string =~ /^(\d{1,3}\.){3}\d{1,3}$/ ) { $class->search_sql_field('ip_addr', $string ); - }elsif ( $string =~ /^([a-fA-F0-9]{12})$/ ) { + } elsif ( $string =~ /^([A-F0-9]{12})$/i ) { $class->search_sql_field('mac_addr', uc($string)); - }elsif ( $string =~ /^(([a-fA-F0-9]{1,2}:){5}([a-fA-F0-9]{1,2}))$/ ) { - $class->search_sql_field('mac_addr', uc("$2$3$4$5$6$7") ); + } elsif ( $string =~ /^(([A-F0-9]{2}:){5}([A-F0-9]{2}))$/i ) { + $string =~ s/://g; + $class->search_sql_field('mac_addr', uc($string) ); + } elsif ( $string =~ /^(\d+)$/ ) { + my $table = $class->table; + "$table.svcnum = $1"; } else { '1 = 0'; #false } } +=item smart_search STRING + +=cut + +sub smart_search { + my( $class, $string ) = @_; + qsearch({ + 'table' => $class->table, #'svc_broadband', + 'hashref' => {}, + 'extra_sql' => 'WHERE '. $class->search_sql($string), + }); +} + =item label -Returns the IP address. +Returns the IP address, MAC address and description. =cut sub label { my $self = shift; my $label = 'IP:'. ($self->ip_addr || 'Unknown'); - $label .= '", MAC:'. $self->mac_addr + $label .= ', MAC:'. $self->mac_addr if $self->mac_addr; $label .= ' ('. $self->description. ')' if $self->description; @@ -311,7 +353,7 @@ sub check { # remove delimiters my $mac_addr = uc($self->get('mac_addr')); - $mac_addr =~ s/[-: ]//g; + $mac_addr =~ s/[\W_]//g; $self->set('mac_addr', $mac_addr); my $error = @@ -330,6 +372,13 @@ sub check { || $self->ut_sfloatn('altitude') || $self->ut_textn('vlan_profile') || $self->ut_textn('plan_id') + || $self->ut_alphan('radio_serialnum') + || $self->ut_textn('radio_location') + || $self->ut_textn('poe_location') + || $self->ut_snumbern('rssi') + || $self->ut_numbern('suid') + || $self->ut_foreign_keyn('shared_svcnum', 'svc_broadband', 'svcnum') + || $self->ut_textn('serviceid') #too lenient? ; return $error if $error; @@ -387,28 +436,17 @@ sub _check_duplicate { ''; } -=item mac_addr_formatted CASE DELIMITER - -Format the MAC address (for use by exports). If CASE starts with "l" -(for "lowercase"), it's returned in lowercase. DELIMITER is inserted -between octets. - -=cut - -sub mac_addr_formatted { - my $self = shift; - my ($case, $delim) = @_; - my $addr = $self->mac_addr; - $addr = lc($addr) if $case =~ /^l/i; - join( $delim || '', $addr =~ /../g ); -} - #class method sub _upgrade_data { my $class = shift; local($FS::svc_Common::noexport_hack) = 1; + # fix wrong-case MAC addresses + my $dbh = dbh; + $dbh->do('UPDATE svc_broadband SET mac_addr = UPPER(mac_addr);') + or die $dbh->errstr; + # set routernum to addr_block.routernum foreach my $self (qsearch('svc_broadband', { blocknum => {op => '!=', value => ''}, @@ -475,6 +513,11 @@ sub _upgrade_data { #next SVC; } + require FS::Misc::FixIPFormat; + FS::Misc::FixIPFormat::fix_bad_addresses_in_table( + 'svc_broadband', 'svcnum', 'ip_addr', + ); + ''; } @@ -497,4 +540,3 @@ FS::part_svc, schema.html from the base documentation. =cut 1; -