X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_cable.pm;h=944f781fd7e72c2ebf0f159991465b95e08af3a4;hb=bdb82505541105352ceeefb63aab40df7f25dc45;hp=4b423938902c9be3f745c52f32473899f6da8d69;hpb=0ef5486a7d1e3909d242d35792845783004a8344;p=freeside.git diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm index 4b4239389..944f781fd 100644 --- a/FS/FS/svc_cable.pm +++ b/FS/FS/svc_cable.pm @@ -56,7 +56,7 @@ points to. You can ask the object for a copy with the I method. sub table { 'svc_cable'; } -sub table_dupcheck_fields { ( 'mac_addr' ); } +sub table_dupcheck_fields { ( 'serialnum', 'mac_addr' ); } sub search_sql { my( $class, $string ) = @_; @@ -101,7 +101,7 @@ sub table_info { type => 'input-mac_addr', value_callback => sub { my $svc = shift; - join(':', $svc->mac_addr =~ /../g); + $svc->mac_addr_formatted('U',':'); }, }, ; @@ -128,7 +128,7 @@ sub label { my @label = (); push @label, 'MAC:'. $self->mac_addr_pretty if $self->mac_addr; - push @label, 'Serial#:'. $self->serialnum + push @label, 'Serial#'. $self->serialnum if $self->serialnum; return join(', ', @label); } @@ -171,6 +171,27 @@ sub check { $self->SUPER::check; } +sub _check_duplicate { + my $self = shift; + + # Not reliable checks because the table isn't locked, but that's why we have + # unique indices. These are just to give friendlier error messages. + + my @dup_mac; + @dup_mac = $self->find_duplicates('global', 'mac_addr'); + if ( @dup_mac ) { + return "MAC address in use (svcnum ".$dup_mac[0]->svcnum.")"; + } + + my @dup_serial; + @dup_serial = $self->find_duplicates('global', 'serialnum'); + if ( @dup_serial ) { + return "Serial number in use (svcnum ".$dup_serial[0]->svcnum.")"; + } + + ''; +} + =item cable_provider Returns the cable_provider object for this record.