1 package FS::part_svc_link;
2 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
9 FS::part_svc_link - Object methods for part_svc_link records
13 use FS::part_svc_link;
15 $record = new FS::part_svc_link \%hash;
16 $record = new FS::part_svc_link { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::part_svc_link object represents an service definition dependency.
29 FS::part_svc_link inherits from FS::Record. The following fields are currently
46 Empty for global dependencies, or agentnum (see L<FS::agent>) for
47 agent-specific dependencies
51 Source service definition (see L<FS::part_svc>)
55 Destination service definition (see L<FS::part_svc>)
65 # XXX false laziness w/edit/part_svc_link.html
67 =item part_pkg_restrict
69 In package defintions, require the destination service definition when the
70 source service definition is included
72 =item part_pkg_restrict_soft
74 Soft order block: in package definitions, suggest the destination service definition when the source service definition is included
76 =item cust_svc_provision_restrict
78 Require the destination service to be provisioned before the source service
80 =item cust_svc_unprovision_restrict
82 Require the destination service to be unprovisioned before the source service
84 =item cust_svc_unprovision_cascade
86 Automatically unprovision the destination service when the source service is
89 =item cust_svc_suspend_cascade
91 Suspend the destination service after the source service
103 Creates a new record. To add the record to the database, see L<"insert">.
105 Note that this stores the hash reference, not a distinct copy of the hash it
106 points to. You can ask the object for a copy with the I<hash> method.
110 sub table { 'part_svc_link'; }
112 =item by_agentnum AGENTNUM, KEY => VALUE, ...
114 Alternate search consructor. Given an agentnum then a list of keys and values,
115 searches for part_svc_link records with the given agentnum (or no agentnum).
117 Additional keys and values are searched for in the part_pkg_link table
118 (typically src_svcpart and link_type).
123 my( $class, $agentnum, %opt ) = @_;
125 qsearch({ 'table' => 'part_svc_link', #$class->table,
129 ? "AND ( agentnum IS NULL OR agentnum = $agentnum )"
130 : 'AND agentnum IS NULL',
137 Adds this record to the database. If there is an error, returns the error,
138 otherwise returns false.
142 Delete this record from the database.
144 =item replace OLD_RECORD
146 Replaces the OLD_RECORD with this one in the database. If there is an error,
147 returns the error, otherwise returns false.
151 Checks all fields to make sure this is a valid record. If there is
152 an error, returns the error, otherwise returns false. Called by the insert
161 $self->ut_numbern('svclinknum')
162 #|| $self->ut_textn('linkname')
163 || $self->ut_number('src_svcpart')
164 || $self->ut_number('dst_svcpart')
165 || $self->ut_text('link_type')
166 || $self->ut_enum('disabled', [ '', 'Y' ])
168 return $error if $error;
175 Returns an extended description of this dependency, including. Exact wording
176 depends on I<link_type>.
183 my $src = $self->src_part_svc->svc;
184 my $dst = $self->dst_part_svc->svc;
186 #maybe sub-classes with overrides at some point
187 # (and hooks each place we have manual checks for the various rules)
188 # but this will do for now
190 my $l = $self->link_type;
192 $l eq 'part_pkg_restrict'
193 and return "In package definitions, $dst is required when $src is included";
195 $l eq 'part_pkg_restrict_soft'
196 and return "In package definitions, $dst is suggested when $src is included";
198 $l eq 'cust_svc_provision_restrict'
199 and return "Require $dst provisioning before $src";
201 $l eq 'cust_svc_unprovision_restrict'
202 and return "Require $dst unprovisioning before $src";
204 $l eq 'cust_svc_unprovision_cascade'
205 and return "Automatically unprovision $dst when $src is unprovisioned";
207 $l eq 'cust_svc_suspend_cascade'
208 and return "Suspend $dst after $src";
210 warn "WARNING: unknown part_svc_link.link_type $l\n";
211 return "$src (unknown link_type $l) $dst";
217 Returns the source service definition, as an FS::part_svc object (see
224 qsearchs('part_svc', { svcpart=>$self->src_svcpart } );
229 Returns the source service definition name (part_svc.svc).
234 shift->src_part_svc->svc;
239 Returns the destination service definition, as an FS::part_svc object (see
246 qsearchs('part_svc', { svcpart=>$self->dst_svcpart } );
251 Returns the destination service definition name (part_svc.svc).
256 shift->dst_part_svc->svc;
265 L<FS::part_svc>, L<FS::Record>