1 package FS::part_svc_link;
2 use base qw( FS::Record );
5 use FS::Record qw( qsearchs ); # 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_svc_restrict
69 In package defintions, require the destination service definition when the
70 source service definition is included
72 =item part_svc_restrict_soft
74 Soft order block: in package definitions, warn if the destination service
75 definition is included without the source service definition
77 =item cust_svc_provision_restrict
79 Require the destination service to be provisioned before the source service
81 =item cust_svc_unprovision_restrict
83 Require the destination service to be unprovisioned before the source service
85 =item cust_svc_unprovision_cascade
87 Automatically unprovision the destination service when the source service is
90 =item cust_svc_suspend_cascade
92 Suspend the destination service before the source service
104 Creates a new record. To add the record to the database, see L<"insert">.
106 Note that this stores the hash reference, not a distinct copy of the hash it
107 points to. You can ask the object for a copy with the I<hash> method.
111 # the new method can be inherited from FS::Record, if a table method is defined
113 sub table { 'part_svc_link'; }
117 Adds this record to the database. If there is an error, returns the error,
118 otherwise returns false.
122 Delete this record from the database.
124 =item replace OLD_RECORD
126 Replaces the OLD_RECORD with this one in the database. If there is an error,
127 returns the error, otherwise returns false.
131 Checks all fields to make sure this is a valid record. If there is
132 an error, returns the error, otherwise returns false. Called by the insert
141 $self->ut_numbern('svclinknum')
142 #|| $self->ut_textn('linkname')
143 || $self->ut_number('src_svcpart')
144 || $self->ut_number('dst_svcpart')
145 || $self->ut_text('link_type')
146 || $self->ut_enum('disabled', [ '', 'Y' ])
148 return $error if $error;
155 Returns an extended description of this dependency, including. Exact wording
156 depends on I<link_type>.
163 my $src = $self->src_part_svc->svc;
164 my $dst = $self->dst_part_svc->svc;
166 #maybe sub-classes with overrides at some point
167 # (and hooks each place we have manual checks for the various rules)
168 # but this will do for now
170 $self->link_type eq 'part_svc_restrict'
171 and return "In package definitions, $dst is required when $src is included";
173 $self->link_type eq 'part_svc_restrict_soft'
174 and return "In package definitions, $dst is suggested when $src is included";
176 $self->link_type eq 'cust_svc_provision_restrict'
177 and return "Require $dst provisioning before $src";
179 $self->link_type eq 'cust_svc_unprovision_restrict'
180 and return "Require $dst unprovisioning before $src";
182 $self->link_type eq 'cust_svc_unprovision_cascade'
183 and return "Automatically unprovision $dst when $src is unprovisioned";
185 $self->link_type eq 'cust_svc_suspend_cascade'
186 and return "Suspend $dst before $src";
188 warn "WARNING: unknown part_svc_link.link_type ". $self->link_type. "\n";
189 return "$src (unknown link_type ". $self->link_type. ") $dst";
195 Returns the source service definition, as an FS::part_svc object (see
202 qsearchs('part_svc', { svcpart=>$self->src_svcpart } );
207 Returns the source service definition name (part_svc.svc).
212 shift->src_part_svc->svc;
217 Returns the destination service definition, as an FS::part_svc object (see
225 qsearchs('part_svc', { svcpart=>$self->dst_svcpart } );
230 Returns the destination service definition name (part_svc.svc).
235 shift->src_part_svc->svc;
244 L<FS::part_svc>, L<FS::Record>