default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / FS / FS / svc_group.pm
1 package FS::svc_group;
2 use base qw( FS::svc_Common );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6 #use FS::cust_svc;
7
8 =head1 NAME
9
10 FS::svc_group - Object methods for svc_group records
11
12 =head1 SYNOPSIS
13
14   use FS::svc_group;
15
16   $record = new FS::svc_group \%hash;
17   $record = new FS::svc_group { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27   $error = $record->suspend;
28
29   $error = $record->unsuspend;
30
31   $error = $record->cancel;
32
33 =head1 DESCRIPTION
34
35 An FS::svc_group object represents a group.  FS::svc_group inherits from
36 FS::svc_Common.  The following fields are currently supported:
37
38 =over 4
39
40 =item max_accounts - Maximum number of group members
41
42 =back
43
44 =head1 METHODS
45
46 =over 4
47
48 =item new HASHREF
49
50 Creates a new group.  To add the group to the database, see L<"insert">.
51
52 Note that this stores the hash reference, not a distinct copy of the hash it
53 points to.  You can ask the object for a copy with the I<hash> method.
54
55 =cut
56
57 sub table { 'svc_group'; }
58
59 sub table_info {
60   {
61     'name' => 'Group',
62     'name_plural' => 'Groups', #optional,
63     'longname_plural' => 'Groups', #optional
64     'sorts' => 'svcnum', # optional sort field (or arrayref of sort fields, main first)
65     'display_weight' => 100,
66     'cancel_weight'  => 100,
67     'fields' => {
68       'svcnum'       => { label => 'Service' },
69       'max_accounts' => { 
70                            'label'     => 'Maximum number of accounts',
71                            'type'      => 'text',
72                            'disable_inventory' => 1,
73                          },
74
75     },
76   };
77 }
78
79 =item search_sql STRING
80
81 Class method which returns an SQL fragment to search for the given string.
82
83 =cut
84
85 #if we only have a quantity, then there's nothing to search on
86 #sub search_sql {
87 #  my($class, $string) = @_;
88 #  $class->search_sql_field('somefield', $string);
89 #}
90
91
92 =item label
93
94 Returns a meaningful identifier for this group
95
96 =cut
97
98 sub label {
99   my $self = shift;
100   $self->svcnum; #i guess?
101 }
102
103 =item insert
104
105 Adds this record to the database.  If there is an error, returns the error,
106 otherwise returns false.
107
108 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be 
109 defined.  An FS::cust_svc record will be created and inserted.
110
111 =cut
112
113 #sub insert {
114 #  my $self = shift;
115 #  my $error;
116 #
117 #  $error = $self->SUPER::insert;
118 #  return $error if $error;
119 #
120 #  '';
121 #}
122
123 =item delete
124
125 Delete this record from the database.
126
127 =cut
128
129 #sub delete {
130 #  my $self = shift;
131 #  my $error;
132 #
133 #  $error = $self->SUPER::delete;
134 #  return $error if $error;
135 #
136 #  '';
137 #}
138
139
140 =item replace OLD_RECORD
141
142 Replaces the OLD_RECORD with this one in the database.  If there is an error,
143 returns the error, otherwise returns false.
144
145 =cut
146
147 #sub replace {
148 #  my ( $new, $old ) = ( shift, shift );
149 #  my $error;
150 #
151 #  $error = $new->SUPER::replace($old);
152 #  return $error if $error;
153 #
154 #  '';
155 #}
156
157 =item suspend
158
159 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
160
161 =item unsuspend
162
163 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
164
165 =item cancel
166
167 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
168
169 =item check
170
171 Checks all fields to make sure this is a valid group.  If there is
172 an error, returns the error, otherwise returns false.  Called by the insert
173 and repalce methods.
174
175 =cut
176
177 sub check {
178   my $self = shift;
179
180   my $x = $self->setfixed;
181   return $x unless ref($x);
182   my $part_svc = $x;
183
184   my $error =  $self->ut_numbern('svcnum')
185             || $self->ut_number('max_accounts');
186   return $error if $error;
187
188   $self->SUPER::check;
189 }
190
191 =back
192
193 =head1 BUGS
194
195 =head1 SEE ALSO
196
197 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
198 L<FS::cust_pkg>, schema.html from the base documentation.
199
200 =cut
201
202 1;
203