2 use base qw( FS::MAC_Mixin
11 FS::svc_cable - Object methods for svc_cable records
17 $record = new FS::svc_cable \%hash;
18 $record = new FS::svc_cable { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::svc_cable object represents a cable subscriber. FS::svc_cable inherits
31 from FS::Record. The following fields are currently supported:
47 Creates a new record. To add the record to the database, see L<"insert">.
49 Note that this stores the hash reference, not a distinct copy of the hash it
50 points to. You can ask the object for a copy with the I<hash> method.
54 sub table { 'svc_cable'; }
56 sub table_dupcheck_fields { ( 'mac_addr' ); }
59 my( $class, $string ) = @_;
60 if ( $string =~ /^([A-F0-9]{12})$/i ) {
61 $class->search_sql_field('mac_addr', uc($string));
62 } elsif ( $string =~ /^(([A-F0-9]{2}:){5}([A-F0-9]{2}))$/i ) {
64 $class->search_sql_field('mac_addr', uc($string) );
65 } elsif ( $string =~ /^(\w+)$/ ) {
66 $class->search_sql_field('serialnum', $1);
74 tie my %fields, 'Tie::IxHash',
75 'svcnum' => 'Service',
76 'providernum' => { label => 'Provider',
77 type => 'select-cable_provider',
78 disable_inventory => 1,
80 value_callback => sub {
82 my $p = $svc->cable_provider;
83 $p ? $p->provider : '';
86 'ordernum' => 'Order number', #XXX "Circuit ID/Order number"
87 'modelnum' => { label => 'Model',
88 type => 'select-cable_model',
89 disable_inventory => 1,
91 value_callback => sub {
93 $svc->cable_model->model_name;
96 'serialnum' => 'Serial number',
97 'mac_addr' => { label => 'MAC address',
98 type => 'input-mac_addr',
99 value_callback => sub {
101 join(':', $svc->mac_addr =~ /../g);
107 'name' => 'Cable Subscriber',
108 #'name_plural' => '', #optional,
109 #'longname_plural' => '', #optional
110 'fields' => \%fields,
111 'sorts' => [ 'svcnum', 'serialnum', 'mac_addr', ],
112 'display_weight' => 54,
113 'cancel_weight' => 70, #? no deps, so
119 Returns the MAC address and serial number.
126 push @label, 'MAC:'. $self->mac_addr_pretty
128 push @label, 'Serial#'. $self->serialnum
130 return join(', ', @label);
135 Adds this record to the database. If there is an error, returns the error,
136 otherwise returns false.
140 Delete this record from the database.
142 =item replace OLD_RECORD
144 Replaces the OLD_RECORD with this one in the database. If there is an error,
145 returns the error, otherwise returns false.
149 Checks all fields to make sure this is a valid record. If there is
150 an error, returns the error, otherwise returns false. Called by the insert
159 $self->ut_numbern('svcnum')
160 || $self->ut_foreign_keyn('providernum', 'cable_provider', 'providernum')
161 || $self->ut_alphan('ordernum')
162 || $self->ut_foreign_key('modelnum', 'cable_model', 'modelnum')
163 || $self->ut_alpha('serialnum')
164 || $self->ut_mac_addr('mac_addr')
166 return $error if $error;
173 Returns the cable_provider object for this record.
177 Returns the cable_model object for this record.
185 L<FS::Record>, schema.html from the base documentation.