5 use FS::Record qw( qsearch qsearchs );
9 @ISA = qw( FS::Record );
13 FS::agent - Object methods for agent records
19 $record = new FS::agent \%hash;
20 $record = new FS::agent { '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 object represents an agent. Every customer has an agent. Agents
33 can be used to track things like resellers or salespeople. FS::agent inherits
34 from FS::Record. The following fields are currently supported:
38 =item agemtnum - primary key (assigned automatically for new agents)
40 =item agent - Text name of this agent
42 =item typenum - Agent type. See L<FS::agent_type>
44 =item prog - For future use.
46 =item freq - For future use.
56 Creates a new agent. To add the agent to the database, see L<"insert">.
60 sub table { 'agent'; }
64 Adds this agent to the database. If there is an error, returns the error,
65 otherwise returns false.
69 Deletes this agent from the database. Only agents with no customers can be
70 deleted. If there is an error, returns the error, otherwise returns false.
77 return "Can't delete an agent with customers!"
78 if qsearch( 'cust_main', { 'agentnum' => $self->agentnum } );
83 =item replace OLD_RECORD
85 Replaces OLD_RECORD with this one in the database. If there is an error,
86 returns the error, otherwise returns false.
90 Checks all fields to make sure this is a valid agent. If there is an error,
91 returns the error, otherwise returns false. Called by the insert and replace
100 $self->ut_numbern('agentnum')
101 || $self->ut_text('agent')
102 || $self->ut_number('typenum')
103 || $self->ut_numbern('freq')
104 || $self->ut_textn('prog')
106 return $error if $error;
108 return "Unknown typenum!"
109 unless qsearchs( 'agent_type', { 'typenum' => $self->typenum } );
119 $Id: agent.pm,v 1.4 1998-12-30 00:30:44 ivan Exp $
125 L<FS::Record>, L<FS::agent_type>, L<FS::cust_main>, schema.html from the base
130 Class dealing with agent (resellers)
132 ivan@sisd.com 97-nov-13, 97-dec-10
134 pod, added check in ->delete ivan@sisd.com 98-sep-22