4 use vars qw(@ISA @EXPORT_OK);
6 use FS::Record qw(fields hfields);
8 @ISA = qw(FS::Record Exporter);
9 @EXPORT_OK = qw(hfields fields);
13 FS::part_svc - Object methods for part_svc objects
19 $record = create FS::part_referral \%hash
20 $record = create FS::part_referral { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::part_svc represents a service definition. FS::part_svc inherits from
33 FS::Record. The following fields are currently supported:
37 =item svcpart - primary key (assigned automatically for new service definitions)
39 =item svc - text name of this service definition
41 =item svcdb - table used for this service. See L<FS::svc_acct>,
42 L<FS::svc_domain>, and L<FS::svc_acct_sm>, among others.
44 =item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
46 =item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null, `D' for default, or `F' for fixed
56 Creates a new service definition. To add the service definition to the
57 database, see L<"insert">.
62 my($proto,$hashref)=@_;
64 #now in FS::Record::new
66 #foreach $field (fields('part_svc')) {
67 # $hashref->{$field}='' unless defined $hashref->{$field};
70 $proto->new('part_svc',$hashref);
75 Adds this service definition to the database. If there is an error, returns
76 the error, otherwise returns false.
89 Currently unimplemented.
94 return "Can't (yet?) delete service definitions.";
95 # maybe check & make sure the svcpart isn't in cust_svc or (in any packages)?
101 =item replace OLD_RECORD
103 Replaces OLD_RECORD with this one in the database. If there is an error,
104 returns the error, otherwise returns false.
110 return "(Old) Not a part_svc record!" unless $old->table eq "part_svc";
111 return "Can't change svcpart!"
112 unless $old->getfield('svcpart') eq $new->getfield('svcpart');
113 return "Can't change svcdb!"
114 unless $old->getfield('svcdb') eq $new->getfield('svcdb');
121 Checks all fields to make sure this is a valid service definition. If there is
122 an error, returns the error, otherwise returns false. Called by the insert
129 return "Not a part_svc record!" unless $self->table eq "part_svc";
130 my($recref) = $self->hashref;
133 return $error if $error=
134 $self->ut_numbern('svcpart')
135 || $self->ut_text('svc')
136 || $self->ut_alpha('svcdb')
139 my(@fields) = eval { fields($recref->{svcdb}) }; #might die
140 return "Unknown svcdb!" unless @fields;
144 svc_acct svc_acct_sm svc_charge svc_domain svc_wo
146 my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
151 foreach $row (@rows) {
152 unless ( $svcdb eq $recref->{svcdb} ) {
153 $recref->{$svcdb.'__'.$row}='';
154 $recref->{$svcdb.'__'.$row.'_flag'}='';
157 $recref->{$svcdb.'__'.$row.'_flag'} =~ /^([DF]?)$/
158 or return "Illegal flag for $svcdb $row";
159 $recref->{$svcdb.'__'.$row.'_flag'} = $1;
161 # $recref->{$svcdb.'__'.$row} =~ /^(.*)$/ #not restrictive enough?
162 # or return "Illegal value for $svcdb $row";
163 # $recref->{$svcdb.'__'.$row} = $1;
165 return $error if $error=$self->ut_anything($svcdb.'__'.$row);
177 It doesn't properly override FS::Record yet.
179 Delete is unimplemented.
183 L<FS::Record>, L<FS::part_pkg>, L<FS::pkg_svc>, L<FS::cust_svc>,
184 L<FS::svc_acct>, L<FS::svc_acct_sm>, L<FS::svc_domain>, schema.html from the
189 ivan@sisd.com 97-nov-14
191 data checking/untainting calls into FS::Record added
192 ivan@sisd.com 97-dec-6
194 pod ivan@sisd.com 98-sep-21