6 use FS::Record qw(fields qsearchs);
8 @ISA = qw(FS::Record Exporter);
12 FS::cust_svc - Object method for cust_svc objects
18 $record = create FS::cust_svc \%hash
19 $record = create FS::cust_svc { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::cust_svc represents a service. FS::cust_svc inherits from FS::Record.
32 The following fields are currently supported:
36 =item svcnum - primary key (assigned automatically for new services)
38 =item pkgnum - Package (see L<FS::cust_pkg>)
40 =item svcpart - Service definition (see L<FS::part_svc>)
50 Creates a new service. To add the refund to the database, see L<"insert">.
51 Services are normally created by creating FS::svc_ objects (see
52 L<FS::svc_acct>, L<FS::svc_domain>, and L<FS::svc_acct_sm>, among others).
57 my($proto,$hashref)=@_;
59 #now in FS::Record::new
61 #foreach $field (fields('cust_svc')) {
62 # $hashref->{$field}='' unless defined $hashref->{$field};
65 $proto->new('cust_svc',$hashref);
70 Adds this service to the database. If there is an error, returns the error,
71 otherwise returns false.
84 Deletes this service from the database. If there is an error, returns the
85 error, otherwise returns false.
87 Called by the cancel method of the package (see L<FS::cust_pkg>).
97 =item replace OLD_RECORD
99 Replaces the OLD_RECORD with this one in the database. If there is an error,
100 returns the error, otherwise returns false.
106 return "(Old) Not a cust_svc record!" unless $old->table eq "cust_svc";
107 return "Can't change svcnum!"
108 unless $old->getfield('svcnum') eq $new->getfield('svcnum');
115 Checks all fields to make sure this is a valid service. If there is an error,
116 returns the error, otehrwise returns false. Called by the insert and
123 return "Not a cust_svc record!" unless $self->table eq "cust_svc";
124 my($recref) = $self->hashref;
126 $recref->{svcnum} =~ /^(\d*)$/ or return "Illegal svcnum";
127 $recref->{svcnum}=$1;
129 $recref->{pkgnum} =~ /^(\d*)$/ or return "Illegal pkgnum";
130 $recref->{pkgnum}=$1;
131 return "Unknown pkgnum" unless
132 ! $recref->{pkgnum} ||
133 qsearchs('cust_pkg',{'pkgnum'=>$recref->{pkgnum}});
135 $recref->{svcpart} =~ /^(\d+)$/ or return "Illegal svcpart";
136 $recref->{svcpart}=$1;
137 return "Unknown svcpart" unless
138 qsearchs('part_svc',{'svcpart'=>$recref->{svcpart}});
147 Behaviour of changing the svcpart of cust_svc records is undefined and should
148 possibly be prohibited, and pkg_svc records are not checked.
150 pkg_svc records are not checket in general (here).
154 L<FS::Record>, L<FS::cust_pkg>, L<FS::part_svc>, L<FS::pkg_svc>,
155 schema.html from the base documentation
159 ivan@voicenet.com 97-jul-10,14
161 no TableUtil, no FS::Lock ivan@sisd.com 98-mar-7
163 pod ivan@sisd.com 98-sep-21