2 use base qw( FS::svc_Torrus_Mixin FS::svc_Common );
5 #use vars qw( $DEBUG $me );
8 #$me = '[FS::svc_port]';
12 FS::svc_port - Object methods for svc_port records
18 $record = new FS::svc_port \%hash;
19 $record = new FS::svc_port { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
29 $error = $record->suspend;
31 $error = $record->unsuspend;
33 $error = $record->cancel;
37 An FS::svc_port object represents a router port. FS::table_name inherits from
38 FS::svc_Common. The following fields are currently supported:
44 =item serviceid - Torrus serviceid (in srvexport and reportfields tables)
54 Creates a new port. To add the port to the database, see L<"insert">.
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to. You can ask the object for a copy with the I<hash> method.
61 sub table { 'svc_port'; }
66 #'name_plural' => 'Ports', #optional,
67 #'longname_plural' => 'Ports', #optional
68 #'sorts' => [ 'svcnum', 'serviceid' ], # optional sort field (or arrayref of sort fields, main first)
69 'sorts' => [ 'serviceid' ], # optional sort field (or arrayref of sort fields, main first)
70 'display_weight' => 75,
71 'cancel_weight' => 10,
73 'svcnum' => 'Service',
74 'serviceid' => 'Torrus serviceid',
79 =item search_sql STRING
81 Class method which returns an SQL fragment to search for the given string.
85 #or something more complicated if necessary
87 my($class, $string) = @_;
88 $class->search_sql_field('serviceid', $string);
93 Returns a meaningful identifier for this port
99 $self->serviceid; #or something more complicated if necessary
104 Adds this record to the database. If there is an error, returns the error,
105 otherwise returns false.
107 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
108 defined. An FS::cust_svc record will be created and inserted.
116 $error = $self->SUPER::insert;
117 return $error if $error;
124 Delete this record from the database.
132 $error = $self->SUPER::delete;
133 return $error if $error;
139 =item replace OLD_RECORD
141 Replaces the OLD_RECORD with this one in the database. If there is an error,
142 returns the error, otherwise returns false.
147 my ( $new, $old ) = ( shift, shift );
150 $error = $new->SUPER::replace($old);
151 return $error if $error;
158 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
162 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
166 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
170 Checks all fields to make sure this is a valid port. If there is
171 an error, returns the error, otherwise returns false. Called by the insert
179 my $x = $self->setfixed;
180 return $x unless ref($x);
183 my $error = $self->ut_textn('serviceid'); #too lenient?
184 return $error if $error;
195 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
196 L<FS::cust_pkg>, schema.html from the base documentation.