1 package FS::agent_type;
4 use vars qw(@ISA @EXPORT_OK);
6 use FS::Record qw(qsearch fields);
8 @ISA = qw(FS::Record Exporter);
9 @EXPORT_OK = qw(fields);
13 FS::agent_type - Object methods for agent_type records
19 $record = create FS::agent_type \%hash;
20 $record = create FS::agent_type { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::agent_type object represents an agent type. Every agent (see
33 L<FS::agent>) has an agent type. Agent types define which packages (see
34 L<FS::part_pkg>) may be purchased by customers (see L<FS::cust_main>), via
35 FS::type_pkgs records (see L<FS::type_pkgs>). FS::agent_type inherits from
36 FS::Record. The following fields are currently supported:
40 =item typenum - primary key (assigned automatically for new agent types)
42 =item atype - Text name of this agent type
52 Creates a new agent type. To add the agent type to the database, see
58 my($proto,$hashref)=@_;
60 #now in FS::Record::new
62 #foreach $field (fields('agent_type')) {
63 # $hashref->{$field}='' unless defined $hashref->{$field};
66 $proto->new('agent_type',$hashref);
72 Adds this agent type to the database. If there is an error, returns the error,
73 otherwise returns false.
86 Deletes this agent type from the database. Only agent types with no agents
87 can be deleted. If there is an error, returns the error, otherwise returns
94 return "Can't delete an agent_type with agents!"
95 if qsearch('agent',{'typenum' => $self->typenum});
99 =item replace OLD_RECORD
101 Replaces OLD_RECORD with this one in the database. If there is an error,
102 returns the error, otherwise returns false.
108 return "(Old) Not a agent_type record!" unless $old->table eq "agent_type";
109 return "Can't change typenum!"
110 unless $old->getfield('typenum') eq $new->getfield('typenum');
117 Checks all fields to make sure this is a valid agent type. If there is an
118 error, returns the error, otherwise returns false. Called by the insert and
125 return "Not a agent_type record!" unless $self->table eq "agent_type";
127 $self->ut_numbern('typenum')
128 or $self->ut_text('atype');
136 It doesn't properly override FS::Record yet.
140 L<FS::Record>, L<FS::agent>, L<FS::type_pkgs>, L<FS::cust_main>,
141 L<FS::part_pkg>, schema.html from the base documentation.
145 Class for the different sets of allowable packages you can assign to an
148 ivan@sisd.com 97-nov-13
150 ut_ FS::Record methods
151 ivan@sisd.com 97-dec-10
153 Changed 'type' to 'atype' because Pg6.3 reserves the type word
154 bmccane@maxbaud.net 98-apr-3
156 pod, added check in delete ivan@sisd.com 98-sep-21