X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsvc_cable.pm;h=122d8c6af21f10f7a03b089b9dad8b93078c5943;hp=4dd4543519ed60eda560086ce1f1fe8f3051f81d;hb=6f8edbafb0401dd2224d3698397bcb16ffad1580;hpb=e03f1de6578f009f306d92ec713b533e799330cd diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm index 4dd454351..122d8c6af 100644 --- a/FS/FS/svc_cable.pm +++ b/FS/FS/svc_cable.pm @@ -53,7 +53,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 ) = @_; @@ -168,6 +168,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.