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;
121 # not compatible w/5.004_04 (fixed in 5.004_05)
122 foreach ( $self->pkgpart ) { $pkgpart{$_}++; }
128 Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this agent type.
134 qsearch('type_pkgs', { 'typenum' => $self->typenum } );
139 Returns the pkgpart of all package definitions (see L<FS::part_pkg>) for this
146 map $_->pkgpart, $self->type_pkgs;
153 $Id: agent_type.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
159 L<FS::Record>, L<FS::agent>, L<FS::type_pkgs>, L<FS::cust_main>,
160 L<FS::part_pkg>, schema.html from the base documentation.