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