1 package FS::sched_avail;
2 use base qw( FS::Record );
5 #use FS::Record qw( qsearch qsearchs );
10 FS::sched_avail - Object methods for sched_avail records
16 $record = new FS::sched_avail \%hash;
17 $record = new FS::sched_avail { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::sched_avail object represents an availability period/interval.
30 FS::sched_avail inherits from FS::Record. The following fields are currently
68 Creates a new period. To add the period to the database, see L<"insert">.
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.
75 sub table { 'sched_avail'; }
79 Adds this record to the database. If there is an error, returns the error,
80 otherwise returns false.
84 Delete this record from the database.
86 =item replace OLD_RECORD
88 Replaces the OLD_RECORD with this one in the database. If there is an error,
89 returns the error, otherwise returns false.
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
103 $self->ut_numbern('availnum')
104 || $self->ut_foreign_key('itemnum', 'sched_item', 'itemnum')
105 || $self->ut_number('wday')
106 || $self->ut_number('stime')
107 || $self->ut_number('etime')
108 || $self->ut_numbern('override_date')
110 return $error if $error;
121 sub stime_pretty { shift->_time_pretty('stime', @_); }
122 sub etime_pretty { shift->_time_pretty('etime', @_); }
125 my( $self, $field ) = @_;
127 pretty_time( $self->$field() );
134 return 'Midnight' if $t == 0 || $t == 1440;
135 return 'Noon' if $t == 720;
137 my $h = int( $t / 60 );
141 if ( $h == 0 || $h == 24 ) { $h = 12; }
142 elsif ( $h == 12 ) { $ap = 'PM'; }
143 elsif ( $h > 12 ) { $ap = 'PM'; $h -= 12; }
145 sprintf('%02d:%02d'." $ap", $h, $m);
155 L<FS::sched_item>, L<FS::Record>