summaryrefslogtreecommitdiff
path: root/FS/FS/svc_cable.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-08-12 16:41:11 -0700
committerIvan Kohler <ivan@freeside.biz>2014-08-12 16:41:11 -0700
commit6f8edbafb0401dd2224d3698397bcb16ffad1580 (patch)
tree2e4dcefd3bec4c5ca746b5af7c7b47590dfb8413 /FS/FS/svc_cable.pm
parente03f1de6578f009f306d92ec713b533e799330cd (diff)
svc_cable unique serialnum and mac_addr, RT#
Diffstat (limited to 'FS/FS/svc_cable.pm')
-rw-r--r--FS/FS/svc_cable.pm23
1 files changed, 22 insertions, 1 deletions
diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm
index 4dd4543..122d8c6 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<hash> 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.