4 use base qw( FS::svc_Common );
5 #use FS::Record qw( qsearch qsearchs );
10 FS::svc_port - Object methods for svc_port records
16 $record = new FS::svc_port \%hash;
17 $record = new FS::svc_port { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
27 $error = $record->suspend;
29 $error = $record->unsuspend;
31 $error = $record->cancel;
35 An FS::svc_port object represents a router port. FS::table_name inherits from
36 FS::svc_Common. The following fields are currently supported:
42 =item serviceid - Torrus serviceid (in srvexport and reportfields tables)
52 Creates a new port. To add the port to the database, see L<"insert">.
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to. You can ask the object for a copy with the I<hash> method.
59 sub table { 'svc_port'; }
64 #'name_plural' => 'Ports', #optional,
65 #'longname_plural' => 'Ports', #optional
66 'sorts' => [ 'svcnum', 'serviceid' ], # optional sort field (or arrayref of sort fields, main first)
67 'display_weight' => 75,
68 'cancel_weight' => 10,
70 'serviceid' => 'Torrus serviceid',
75 =item search_sql STRING
77 Class method which returns an SQL fragment to search for the given string.
81 #or something more complicated if necessary
83 my($class, $string) = @_;
84 $class->search_sql_field('serviceid', $string);
89 Returns a meaningful identifier for this port
95 $self->serviceid; #or something more complicated if necessary
100 Adds this record to the database. If there is an error, returns the error,
101 otherwise returns false.
103 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
104 defined. An FS::cust_svc record will be created and inserted.
112 $error = $self->SUPER::insert;
113 return $error if $error;
120 Delete this record from the database.
128 $error = $self->SUPER::delete;
129 return $error if $error;
135 =item replace OLD_RECORD
137 Replaces the OLD_RECORD with this one in the database. If there is an error,
138 returns the error, otherwise returns false.
143 my ( $new, $old ) = ( shift, shift );
146 $error = $new->SUPER::replace($old);
147 return $error if $error;
154 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
158 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
162 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
166 Checks all fields to make sure this is a valid port. If there is
167 an error, returns the error, otherwise returns false. Called by the insert
175 my $x = $self->setfixed;
176 return $x unless ref($x);
179 my $error = $self->ut_textn('serviceid'); #too lenient?
180 return $error if $error;
187 Returns a PNG graph for this port.
195 my $serviceid = $self->serviceid;
206 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
207 L<FS::cust_pkg>, schema.html from the base documentation.