1 package FS::agent_type;
5 use FS::Record qw( qsearch );
9 @ISA = qw( FS::Record );
13 FS::agent_type - Object methods for agent_type records
19 $record = new FS::agent_type \%hash;
20 $record = new FS::agent_type { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
30 $hashref = $record->pkgpart_hashref;
31 #may purchase $pkgpart if $hashref->{$pkgpart};
33 @type_pkgs = $record->type_pkgs;
35 @pkgparts = $record->pkgpart;
39 An FS::agent_type object represents an agent type. Every agent (see
40 L<FS::agent>) has an agent type. Agent types define which packages (see
41 L<FS::part_pkg>) may be purchased by customers (see L<FS::cust_main>), via
42 FS::type_pkgs records (see L<FS::type_pkgs>). FS::agent_type inherits from
43 FS::Record. The following fields are currently supported:
47 =item typenum - primary key (assigned automatically for new agent types)
49 =item atype - Text name of this agent type
59 Creates a new agent type. To add the agent type to the database, see
64 sub table { 'agent_type'; }
68 Adds this agent type to the database. If there is an error, returns the error,
69 otherwise returns false.
73 Deletes this agent type from the database. Only agent types with no agents
74 can be deleted. If there is an error, returns the error, otherwise returns
82 return "Can't delete an agent_type with agents!"
83 if qsearch( 'agent', { 'typenum' => $self->typenum } );
88 =item replace OLD_RECORD
90 Replaces OLD_RECORD with this one in the database. If there is an error,
91 returns the error, otherwise returns false.
95 Checks all fields to make sure this is a valid agent type. If there is an
96 error, returns the error, otherwise returns false. Called by the insert and
104 $self->ut_numbern('typenum')
105 or $self->ut_text('atype');
109 =item pkgpart_hashref
111 Returns a hash reference. The keys of the hash are pkgparts. The value is
112 true iff this agent may purchase the specified package definition. See
117 sub pkgpart_hashref {
120 $pkgpart{$_}++ foreach $self->pkgpart;
126 Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this agent type.
132 qsearch('type_pkgs', { 'typenum' => $self->typenum } );
137 Returns the pkgpart of all package definitions (see L<FS::part_pkg>) for this
144 map $_->pkgpart, $self->type_pkgs;
151 $Id: agent_type.pm,v 1.3 1999-07-20 10:37:05 ivan Exp $
157 L<FS::Record>, L<FS::agent>, L<FS::type_pkgs>, L<FS::cust_main>,
158 L<FS::part_pkg>, schema.html from the base documentation.
162 Class for the different sets of allowable packages you can assign to an
165 ivan@sisd.com 97-nov-13
167 ut_ FS::Record methods
168 ivan@sisd.com 97-dec-10
170 Changed 'type' to 'atype' because Pg6.3 reserves the type word
171 bmccane@maxbaud.net 98-apr-3
173 pod, added check in delete ivan@sisd.com 98-sep-21
175 $Log: agent_type.pm,v $
176 Revision 1.3 1999-07-20 10:37:05 ivan
177 cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
178 prepare for a signup server
180 Revision 1.2 1998/12/29 11:59:35 ivan
181 mostly properly OO, some work still to be done with svc_ stuff