4 use vars qw(@ISA @EXPORT_OK);
6 use FS::Record qw(fields qsearchs);
8 @ISA = qw(FS::Record Exporter);
9 @EXPORT_OK = qw(fields);
13 FS::type_pkgs - Object methods for type_pkgs records
19 $record = create FS::type_pkgs \%hash;
20 $record = create FS::type_pkgs { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::type_pkgs record links an agent type (see L<FS::agent_type>) to a
33 billing item definition (see L<FS::part_pkg>). FS::type_pkgs inherits from
34 FS::Record. The following fields are currently supported:
38 =item typenum - Agent type, see L<FS::agent_type>
40 =item pkgpart - Billing item definition, see L<FS::part_pkg>
50 Create a new record. To add the record to the database, see L<"insert">.
55 my($proto,$hashref)=@_;
57 #now in FS::Record::new
59 #foreach $field (fields('type_pkgs')) {
60 # $hashref->{$field}='' unless defined $hashref->{$field};
63 $proto->new('type_pkgs',$hashref);
69 Adds this record to the database. If there is an error, returns the error,
70 otherwise returns false.
83 Deletes this record from the database. If there is an error, returns the
84 error, otherwise returns false.
94 =item replace OLD_RECORD
96 Replaces OLD_RECORD with this one in the database. If there is an error,
97 returns the error, otherwise returns false.
103 return "(Old) Not a type_pkgs record!" unless $old->table eq "type_pkgs";
111 Checks all fields to make sure this is a valid record. If there is an error,
112 returns the error, otherwise returns false. Called by the insert and replace
119 return "Not a type_pkgs record!" unless $self->table eq "type_pkgs";
120 my($recref) = $self->hashref;
122 $recref->{typenum} =~ /^(\d+)$/ or return "Illegal typenum";
123 $recref->{typenum} = $1;
124 return "Unknown typenum"
125 unless qsearchs('agent_type',{'typenum'=>$recref->{typenum}});
127 $recref->{pkgpart} =~ /^(\d+)$/ or return "Illegal pkgpart";
128 $recref->{pkgpart} = $1;
129 return "Unknown pkgpart"
130 unless qsearchs('part_pkg',{'pkgpart'=>$recref->{pkgpart}});
139 Defines the relation between agent types and pkgparts
140 (Which pkgparts can the different [types of] agents sell?)
142 ivan@sisd.com 97-nov-13
144 change to ut_ FS::Record, fixed bugs
145 ivan@sisd.com 97-dec-10