$properties has_many ResourceRequestProperty * @property SimpleORMapCollection $appointments has_many ResourceRequestAppointment * @property Room $room belongs_to Room * @property Resource $resource belongs_to Resource * @property ResourceCategory|null $category belongs_to ResourceCategory * @property User $user belongs_to User * @property User $last_modifier belongs_to User * @property Course $course belongs_to Course * @property SeminarCycleDate $cycle belongs_to SeminarCycleDate * @property CourseDate $date belongs_to CourseDate * @property mixed $seats additional field * @property mixed $room_type additional field * @property mixed $booking_plan_is_public additional field */ class RoomRequest extends ResourceRequest { protected static function configure($config = []) { $config['belongs_to']['room'] = [ 'class_name' => Room::class, 'foreign_key' => 'resource_id', 'assoc_func' => 'find' ]; $required_properties = [ 'seats', 'room_type', 'booking_plan_is_public' ]; $config['additional_fields'] = []; foreach ($required_properties as $property) { $config['additional_fields'][$property] = [ 'get' => 'getProperty', 'set' => 'setProperty' ]; } parent::configure($config); } public function checkOpen($also_change = false) { $db = DBManager::get(); $existing_assign = false; //a request for a date is easy... if ($this->termin_id) { $query = sprintf("SELECT id FROM resource_bookings WHERE range_id = %s ", $db->quote($this->termin_id)); $existing_assign = $db->query($query)->fetchColumn(); //metadate request } elseif ($this->metadate_id) { $query = sprintf("SELECT count(termin_id)=count(resource_bookings.id) FROM termine LEFT JOIN resource_bookings ON(termin_id=resource_bookings.range_id) WHERE metadate_id=%s", $db->quote($this->metadate_id)); //seminar request } else { $query = sprintf("SELECT count(termin_id)=count(resource_bookings.id) FROM termine LEFT JOIN resource_bookings ON(termin_id=resource_bookings.range_id) WHERE range_id='%s' AND date_typ IN" . getPresenceTypeClause(), $this->course_id); } if ($query) { $existing_assign = $db->query($query)->fetchColumn(); } if ($existing_assign && $also_change) { $this->closed = 1; $this->store(); } return (bool)$existing_assign; } }