X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsvc_cable.pm;h=01c5de760420721107731465b27064e1f44bcfe7;hp=3a1dc5ae9b75047e948a75eb8c136ce3ac3d5088;hb=389b6f1116c3309c2ee57a6c295ed1a793503095;hpb=32072dbf59a054529f5304574c0f56f9567d14d0 diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm index 3a1dc5ae9..01c5de760 100644 --- a/FS/FS/svc_cable.pm +++ b/FS/FS/svc_cable.pm @@ -1,5 +1,5 @@ package FS::svc_cable; -use base qw( FS::svc_MAC_Mixin +use base qw( FS::MAC_Mixin FS::svc_Common ); #FS::device_Common @@ -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 ) = @_; @@ -98,7 +98,7 @@ sub table_info { type => 'input-mac_addr', value_callback => sub { my $svc = shift; - join(':', $svc->mac_addr =~ /../g); + $svc->mac_addr_formatted('U',':'); }, }, ; @@ -160,14 +160,39 @@ sub check { || $self->ut_foreign_keyn('providernum', 'cable_provider', 'providernum') || $self->ut_alphan('ordernum') || $self->ut_foreign_key('modelnum', 'cable_model', 'modelnum') - || $self->ut_alpha('serialnum') - || $self->ut_mac_addr('mac_addr') + || $self->ut_alphan('serialnum') + || $self->ut_mac_addrn('mac_addr') ; return $error if $error; $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. + + if ( $self->mac_addr ) { + my @dup_mac; + @dup_mac = $self->find_duplicates('global', 'mac_addr'); + if ( @dup_mac ) { + return "MAC address in use (svcnum ".$dup_mac[0]->svcnum.")"; + } + } + + if ( $self->serialnum ) { + 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.