3de8feeed17e39da1ac2994f482fd1acf5fd2ae4
[freeside.git] / FS / FS / access_groupagent.pm
1 package FS::access_groupagent;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::agent;
7
8 @ISA = qw(FS::Record);
9
10 =head1 NAME
11
12 FS::access_groupagent - Object methods for access_groupagent records
13
14 =head1 SYNOPSIS
15
16   use FS::access_groupagent;
17
18   $record = new FS::access_groupagent \%hash;
19   $record = new FS::access_groupagent { 'column' => 'value' };
20
21   $error = $record->insert;
22
23   $error = $new_record->replace($old_record);
24
25   $error = $record->delete;
26
27   $error = $record->check;
28
29 =head1 DESCRIPTION
30
31 An FS::access_groupagent object represents an group reseller virtualization.  FS::access_groupagent inherits from
32 FS::Record.  The following fields are currently supported:
33
34 =over 4
35
36 =item groupagentnum - primary key
37
38 =item groupnum - 
39
40 =item agentnum - 
41
42
43 =back
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new HASHREF
50
51 Creates a new group reseller virtualization.  To add the record to the database, see L<"insert">.
52
53 Note that this stores the hash reference, not a distinct copy of the hash it
54 points to.  You can ask the object for a copy with the I<hash> method.
55
56 =cut
57
58 # the new method can be inherited from FS::Record, if a table method is defined
59
60 sub table { 'access_groupagent'; }
61
62 =item insert
63
64 Adds this record to the database.  If there is an error, returns the error,
65 otherwise returns false.
66
67 =cut
68
69 # the insert method can be inherited from FS::Record
70
71 =item delete
72
73 Delete this record from the database.
74
75 =cut
76
77 # the delete method can be inherited from FS::Record
78
79 =item replace OLD_RECORD
80
81 Replaces the OLD_RECORD with this one in the database.  If there is an error,
82 returns the error, otherwise returns false.
83
84 =cut
85
86 # the replace method can be inherited from FS::Record
87
88 =item check
89
90 Checks all fields to make sure this is a valid group reseller virtualization.  If there is
91 an error, returns the error, otherwise returns false.  Called by the insert
92 and replace methods.
93
94 =cut
95
96 # the check method should currently be supplied - FS::Record contains some
97 # data checking routines
98
99 sub check {
100   my $self = shift;
101
102   my $error = 
103     $self->ut_numbern('groupagentnum')
104     || $self->ut_foreign_key('groupnum', 'access_group', 'groupnum')
105     || $self->ut_foreign_key('agentnum', 'agent',        'agentnum')
106   ;
107   return $error if $error;
108
109   $self->SUPER::check;
110 }
111
112 =item agent
113
114 Returns the associated FS::agent object.
115
116 =cut
117
118 sub agent {
119   my $self = shift;
120   qsearchs('agent', { 'agentnum' => $self->agentnum } );
121 }
122
123 =back
124
125 =head1 BUGS
126
127 =head1 SEE ALSO
128
129 L<FS::Record>, schema.html from the base documentation.
130
131 =cut
132
133 1;
134