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