X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsvc_hardware.pm;h=69da0c7a46c77a6e9f75a81266c6ec7a35232e1c;hp=019a5646c7930622ebf3b00495f52cbf97b0c6e8;hb=25386efd0e3f725d6cef005eba729840d3b4b3cb;hpb=e63d638c6b7b2c9adedb43e0bd9afe4260714837 diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm index 019a5646c..69da0c7a4 100644 --- a/FS/FS/svc_hardware.pm +++ b/FS/FS/svc_hardware.pm @@ -214,6 +214,40 @@ sub check { $self->SUPER::check; } +#false laziness w/svc_cable +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->hw_addr ) { + my @dup_mac; + @dup_mac = $self->find_duplicates('global', 'hw_addr'); + if ( @dup_mac ) { + return "MAC address in use (svcnum ".$dup_mac[0]->svcnum.")"; + } + } + + if ( $self->ip_addr ) { + my @dup_ip; + @dup_ip = $self->find_duplicates('global', 'ip_addr'); + if ( @dup_ip ) { + return "IP address in use (svcnum ".$dup_ip[0]->svcnum.")"; + } + } + + if ( $self->serialnum ) { + my @dup_serial; + @dup_serial = $self->find_duplicates('global', 'typenum', 'serialnum'); + if ( @dup_serial ) { + return "Serial number in use (svcnum ".$dup_serial[0]->svcnum.")"; + } + } + + ''; +} + =item hardware_type Returns the L object associated with this installation.