1 package FS::sched_avail;
2 use base qw( FS::Record );
5 #use FS::Record qw( qsearch qsearchs );
9 FS::sched_avail - Object methods for sched_avail records
15 $record = new FS::sched_avail \%hash;
16 $record = new FS::sched_avail { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::sched_avail object represents an availability period/interval.
29 FS::sched_avail inherits from FS::Record. The following fields are currently
67 Creates a new period. To add the period to the database, see L<"insert">.
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.
74 sub table { 'sched_avail'; }
78 Adds this record to the database. If there is an error, returns the error,
79 otherwise returns false.
83 Delete this record from the database.
85 =item replace OLD_RECORD
87 Replaces the OLD_RECORD with this one in the database. If there is an error,
88 returns the error, otherwise returns false.
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
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')
109 return $error if $error;
120 sub stime_pretty { shift->_time_pretty('stime', @_); }
121 sub etime_pretty { shift->_time_pretty('etime', @_); }
124 my( $self, $field ) = @_;
126 pretty_time( $self->$field() );
133 return 'Midnight' if $t == 0 || $t == 1440;
134 return 'Noon' if $t == 720;
136 my $h = int( $t / 60 );
140 if ( $h == 0 || $h == 24 ) { $h = 12; }
141 elsif ( $h == 12 ) { $ap = 'PM'; }
142 elsif ( $h > 12 ) { $ap = 'PM'; $h -= 12; }
144 sprintf('%02d:%02d'." $ap", $h, $m);
154 L<FS::sched_item>, L<FS::Record>