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_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 before 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 # the new method can be inherited from FS::Record, if a table method is defined
112 sub table { 'part_svc_link'; }
116 Adds this record to the database. If there is an error, returns the error,
117 otherwise returns false.
121 Delete this record from the database.
123 =item replace OLD_RECORD
125 Replaces the OLD_RECORD with this one in the database. If there is an error,
126 returns the error, otherwise returns false.
130 Checks all fields to make sure this is a valid record. If there is
131 an error, returns the error, otherwise returns false. Called by the insert
140 $self->ut_numbern('svclinknum')
141 #|| $self->ut_textn('linkname')
142 || $self->ut_number('src_svcpart')
143 || $self->ut_number('dst_svcpart')
144 || $self->ut_text('link_type')
145 || $self->ut_enum('disabled', [ '', 'Y' ])
147 return $error if $error;
154 Returns an extended description of this dependency, including. Exact wording
155 depends on I<link_type>.
162 my $src = $self->src_part_svc->svc;
163 my $dst = $self->dst_part_svc->svc;
165 #maybe sub-classes with overrides at some point
166 # (and hooks each place we have manual checks for the various rules)
167 # but this will do for now
169 $self->link_type eq 'part_pkg_restrict'
170 and return "In package definitions, $dst is required when $src is included";
172 $self->link_type eq 'part_pkg_restrict_soft'
173 and return "In package definitions, $dst is suggested when $src is included";
175 $self->link_type eq 'cust_svc_provision_restrict'
176 and return "Require $dst provisioning before $src";
178 $self->link_type eq 'cust_svc_unprovision_restrict'
179 and return "Require $dst unprovisioning before $src";
181 $self->link_type eq 'cust_svc_unprovision_cascade'
182 and return "Automatically unprovision $dst when $src is unprovisioned";
184 $self->link_type eq 'cust_svc_suspend_cascade'
185 and return "Suspend $dst before $src";
187 warn "WARNING: unknown part_svc_link.link_type ". $self->link_type. "\n";
188 return "$src (unknown link_type ". $self->link_type. ") $dst";
194 Returns the source service definition, as an FS::part_svc object (see
201 qsearchs('part_svc', { svcpart=>$self->src_svcpart } );
206 Returns the source service definition name (part_svc.svc).
211 shift->src_part_svc->svc;
216 Returns the destination service definition, as an FS::part_svc object (see
223 qsearchs('part_svc', { svcpart=>$self->dst_svcpart } );
228 Returns the destination service definition name (part_svc.svc).
233 shift->dst_part_svc->svc;
242 L<FS::part_svc>, L<FS::Record>