delete fees, RT#81713
[freeside.git] / FS / FS / svc_port.pm
1 package FS::svc_port;
2 use base qw( FS::svc_Torrus_Mixin FS::svc_Common );
3
4 use strict;
5 #use vars qw( $DEBUG $me );
6
7 #$DEBUG = 0;
8 #$me = '[FS::svc_port]';
9
10 =head1 NAME
11
12 FS::svc_port - Object methods for svc_port records
13
14 =head1 SYNOPSIS
15
16   use FS::svc_port;
17
18   $record = new FS::svc_port \%hash;
19   $record = new FS::svc_port { 'column' => 'value' };
20
21   $error = $record->insert;
22
23   $error = $new_record->replace($old_record);
24
25   $error = $record->delete;
26
27   $error = $record->check;
28
29   $error = $record->suspend;
30
31   $error = $record->unsuspend;
32
33   $error = $record->cancel;
34
35 =head1 DESCRIPTION
36
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:
39
40 =over 4
41
42 =item svcnum - 
43
44 =item serviceid - Torrus serviceid (in srvexport and reportfields tables)
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new port.  To add the port to the database, see L<"insert">.
55
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.
58
59 =cut
60
61 sub table { 'svc_port'; }
62
63 sub table_info {
64   {
65     'name' => '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,
72     'fields' => {
73       'svcnum'    => 'Service',
74       'serviceid' => 'Torrus serviceid',
75     },
76   };
77 }
78
79 =item search_sql STRING
80
81 Class method which returns an SQL fragment to search for the given string.
82
83 =cut
84
85 #or something more complicated if necessary
86 sub search_sql {
87   my($class, $string) = @_;
88   $class->search_sql_field('serviceid', $string);
89 }
90
91 =item label
92
93 Returns a meaningful identifier for this port
94
95 =cut
96
97 sub label {
98   my $self = shift;
99   $self->serviceid; #or something more complicated if necessary
100 }
101
102 =item insert
103
104 Adds this record to the database.  If there is an error, returns the error,
105 otherwise returns false.
106
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.
109
110 =item delete
111
112 Delete this record from the database.
113
114 =item replace OLD_RECORD
115
116 Replaces the OLD_RECORD with this one in the database.  If there is an error,
117 returns the error, otherwise returns false.
118
119 =item suspend
120
121 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
122
123 =item unsuspend
124
125 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
126
127 =item cancel
128
129 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
130
131 =item check
132
133 Checks all fields to make sure this is a valid port.  If there is
134 an error, returns the error, otherwise returns false.  Called by the insert
135 and repalce methods.
136
137 =cut
138
139 sub check {
140   my $self = shift;
141
142   my $x = $self->setfixed;
143   return $x unless ref($x);
144   my $part_svc = $x;
145
146   my $error = $self->ut_textn('serviceid'); #too lenient?
147   return $error if $error;
148
149   $self->SUPER::check;
150 }
151
152 =back
153
154 =head1 BUGS
155
156 =head1 SEE ALSO
157
158 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
159 L<FS::cust_pkg>, schema.html from the base documentation.
160
161 =cut
162
163 1;
164