5 use FS::Record qw( fields );
11 FS::part_svc - Object methods for part_svc objects
17 $record = new FS::part_referral \%hash
18 $record = new FS::part_referral { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::part_svc represents a service definition. FS::part_svc inherits from
31 FS::Record. The following fields are currently supported:
35 =item svcpart - primary key (assigned automatically for new service definitions)
37 =item svc - text name of this service definition
39 =item svcdb - table used for this service. See L<FS::svc_acct>,
40 L<FS::svc_domain>, and L<FS::svc_acct_sm>, among others.
42 =item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
44 =item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null, `D' for default, or `F' for fixed
54 Creates a new service definition. To add the service definition to the
55 database, see L<"insert">.
59 sub table { 'part_svc'; }
63 Adds this service definition to the database. If there is an error, returns
64 the error, otherwise returns false.
68 Currently unimplemented.
73 return "Can't (yet?) delete service definitions.";
74 # check & make sure the svcpart isn't in cust_svc or pkg_svc (in any packages)?
77 =item replace OLD_RECORD
79 Replaces OLD_RECORD with this one in the database. If there is an error,
80 returns the error, otherwise returns false.
85 my ( $new, $old ) = ( shift, shift );
87 return "Can't change svcdb!"
88 unless $old->svcdb eq $new->svcdb;
90 $new->SUPER::replace( $old );
95 Checks all fields to make sure this is a valid service definition. If there is
96 an error, returns the error, otherwise returns false. Called by the insert
103 my $recref = $self->hashref;
107 $self->ut_numbern('svcpart')
108 || $self->ut_text('svc')
109 || $self->ut_alpha('svcdb')
111 return $error if $error;
113 my @fields = eval { fields( $recref->{svcdb} ) }; #might die
114 return "Unknown svcdb!" unless @fields;
118 svc_acct svc_acct_sm svc_domain
120 my @rows = map { /^${svcdb}__(.*)$/; $1 }
124 foreach my $row (@rows) {
125 unless ( $svcdb eq $recref->{svcdb} ) {
126 $recref->{$svcdb.'__'.$row}='';
127 $recref->{$svcdb.'__'.$row.'_flag'}='';
130 $recref->{$svcdb.'__'.$row.'_flag'} =~ /^([DF]?)$/
131 or return "Illegal flag for $svcdb $row";
132 $recref->{$svcdb.'__'.$row.'_flag'} = $1;
134 my $error = $self->ut_anything($svcdb.'__'.$row);
135 return $error if $error;
147 $Id: part_svc.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
151 Delete is unimplemented.
153 The list of svc_* tables is hardcoded. When svc_acct_pop is renamed, this
158 L<FS::Record>, L<FS::part_pkg>, L<FS::pkg_svc>, L<FS::cust_svc>,
159 L<FS::svc_acct>, L<FS::svc_acct_sm>, L<FS::svc_domain>, schema.html from the