2 use base qw( FS::svc_Common ); #qw( FS::device_Common FS::svc_Common );
6 use FS::Record qw( qsearchs ); # qw( qsearch qsearchs );
7 use FS::cable_provider;
12 FS::svc_cable - Object methods for svc_cable records
18 $record = new FS::svc_cable \%hash;
19 $record = new FS::svc_cable { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::svc_cable object represents a cable subscriber. FS::svc_cable inherits
32 from FS::Record. The following fields are currently supported:
48 Creates a new record. To add the record to the database, see L<"insert">.
50 Note that this stores the hash reference, not a distinct copy of the hash it
51 points to. You can ask the object for a copy with the I<hash> method.
55 sub table { 'svc_cable'; }
57 sub table_dupcheck_fields { ( 'mac_addr' ); }
60 my( $class, $string ) = @_;
61 if ( $string =~ /^([A-F0-9]{12})$/i ) {
62 $class->search_sql_field('mac_addr', uc($string));
63 } elsif ( $string =~ /^(([A-F0-9]{2}:){5}([A-F0-9]{2}))$/i ) {
65 $class->search_sql_field('mac_addr', uc($string) );
66 } elsif ( $string =~ /^(\w+)$/ ) {
67 $class->search_sql_field('serialnum', $1);
75 tie my %fields, 'Tie::IxHash',
76 'svcnum' => 'Service',
77 'providernum' => { label => 'Provider',
78 type => 'select-cable_provider',
79 disable_inventory => 1,
81 value_callback => sub {
83 my $p = $svc->cable_provider;
84 $p ? $p->provider : '';
87 'ordernum' => 'Order number', #XXX "Circuit ID/Order number"
88 'modelnum' => { label => 'Model',
89 type => 'select-cable_model',
90 disable_inventory => 1,
92 value_callback => sub {
94 $svc->cable_model->model_name;
97 'serialnum' => 'Serial number',
98 'mac_addr' => { label => 'MAC address',
99 type => 'input-mac_addr',
100 value_callback => sub {
102 join(':', $svc->mac_addr =~ /../g);
104 }, 'svcnum' => 'Service',
108 'name' => 'Cable Subscriber',
109 #'name_plural' => '', #optional,
110 #'longname_plural' => '', #optional
111 'fields' => \%fields,
112 'sorts' => [ 'svcnum', 'serialnum', 'mac_addr', ],
113 'display_weight' => 54,
114 'cancel_weight' => 70, #? no deps, so
120 Adds this record to the database. If there is an error, returns the error,
121 otherwise returns false.
125 Delete this record from the database.
127 =item replace OLD_RECORD
129 Replaces the OLD_RECORD with this one in the database. If there is an error,
130 returns the error, otherwise returns false.
134 Checks all fields to make sure this is a valid record. If there is
135 an error, returns the error, otherwise returns false. Called by the insert
144 $self->ut_numbern('svcnum')
145 || $self->ut_foreign_keyn('providernum', 'cable_provider', 'providernum')
146 || $self->ut_alphan('ordernum')
147 || $self->ut_foreign_key('modelnum', 'cable_model', 'modelnum')
148 || $self->ut_alpha('serialnum')
149 || $self->ut_mac_addr('mac_addr')
151 return $error if $error;
158 Returns the cable_provider object for this record.
164 qsearchs('cable_provider', { 'providernum'=>$self->providernum } );
169 Returns the cable_model object for this record.
175 qsearchs('cable_model', { 'modelnum'=>$self->modelnum } );
184 L<FS::Record>, schema.html from the base documentation.