X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_cable.pm;h=726e6c370c3b3f81e0c21977674d2339e92abd65;hb=311711639b41a5b307243d99c1aefceadcc97548;hp=1980c0ee90d7b8afd287b5a728262303c30dd803;hpb=b46a09ef4cce4ddbd404e6e6347baffde8170716;p=freeside.git diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm index 1980c0ee9..726e6c370 100644 --- a/FS/FS/svc_cable.pm +++ b/FS/FS/svc_cable.pm @@ -1,9 +1,12 @@ package FS::svc_cable; -use base qw( FS::svc_Common ); #qw( FS::device_Common FS::svc_Common ); +use base qw( FS::svc_MAC_Mixin + FS::svc_Common + ); #FS::device_Common use strict; use Tie::IxHash; use FS::Record qw( qsearchs ); # qw( qsearch qsearchs ); +use FS::cable_provider; use FS::cable_model; =head1 NAME @@ -72,24 +75,35 @@ sub search_sql { sub table_info { tie my %fields, 'Tie::IxHash', - 'svcnum' => 'Service', - 'modelnum' => { label => 'Model', - type => 'select-cable_model', - disable_inventory => 1, - disable_select => 1, - value_callback => sub { - my $svc = shift; - $svc->cable_model->model_name; - }, - }, - 'serialnum' => 'Serial number', - 'mac_addr' => { label => 'MAC address', - type => 'input-mac_addr', - value_callback => sub { - my $svc = shift; - join(':', $svc->mac_addr =~ /../g); - }, - }, + 'svcnum' => 'Service', + 'providernum' => { label => 'Provider', + type => 'select-cable_provider', + disable_inventory => 1, + disable_select => 1, + value_callback => sub { + my $svc = shift; + my $p = $svc->cable_provider; + $p ? $p->provider : ''; + }, + }, + 'ordernum' => 'Order number', #XXX "Circuit ID/Order number" + 'modelnum' => { label => 'Model', + type => 'select-cable_model', + disable_inventory => 1, + disable_select => 1, + value_callback => sub { + my $svc = shift; + $svc->cable_model->model_name; + }, + }, + 'serialnum' => 'Serial number', + 'mac_addr' => { label => 'MAC address', + type => 'input-mac_addr', + value_callback => sub { + my $svc = shift; + join(':', $svc->mac_addr =~ /../g); + }, + }, 'svcnum' => 'Service', ; { @@ -103,6 +117,22 @@ sub table_info { }; } +=item label + +Returns the MAC address and serial number. + +=cut + +sub label { + my $self = shift; + my @label = (); + push @label, 'MAC:'. $self->mac_addr_pretty + if $self->mac_addr; + push @label, 'Serial#:'. $self->serialnum + if $self->serialnum; + return join(', ', @label); +} + =item insert Adds this record to the database. If there is an error, returns the error, @@ -130,6 +160,8 @@ sub check { my $error = $self->ut_numbern('svcnum') + || $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') @@ -138,6 +170,17 @@ sub check { $self->SUPER::check; } + +=item cable_provider + +Returns the cable_provider object for this record. + +=cut + +sub cable_provider { + my $self = shift; + qsearchs('cable_provider', { 'providernum'=>$self->providernum } ); +} =item cable_model