function get_reservations($from, $to) { $qb = org_openpsa_calendar_event_resource_dba::new_query_builder(); // Find all events that occur during [$from, $end] $qb->begin_group("OR"); // The event begins during [$from, $to] $qb->begin_group("AND"); $qb->add_constraint("event.start", ">=", $from); $qb->add_constraint("event.start", "<=", $to); $qb->end_group(); // The event begins before and ends after [$from, $to] $qb->begin_group("AND"); $qb->add_constraint("event.start", "<=", $from); $qb->add_constraint("event.end", ">=", $to); $qb->end_group(); // The event ends during [$from, $to] $qb->begin_group("AND"); $qb->add_constraint("event.end", ">=", $from); $qb->add_constraint("event.end", "<=", $to); $qb->end_group(); $qb->end_group(); $qb->add_constraint('resource', '=', $this->id); $qb->add_order('event.start'); return $qb->execute(); }
/** * Fills $this->participants and $this->resources */ private function _get_em() { if (!$this->id) { return; } //Create shorthand references to the arrays wanted $part =& $this->participants; $res =& $this->resources; //Reset to empty arrays $res = array(); $part = array(); // Participants $mc = org_openpsa_calendar_event_member_dba::new_collector('eid', $this->id); $members = $mc->get_values('uid'); if (!empty($members)) { foreach ($members as $member) { $part[$member] = true; } } // Resources $mc2 = org_openpsa_calendar_event_resource_dba::new_collector('event', $this->id); $resources = $mc2->get_values('resource'); if (!empty($resources)) { foreach ($resources as $resource) { $res[$resource] = true; } } return true; }
private function _load_resources() { $ret = array(); if (!empty($this->_event->resources)) { $qb = org_openpsa_calendar_event_resource_dba::new_query_builder(); $this->_add_event_constraints($qb, 'event'); reset($this->_event->resources); $qb->begin_group('OR'); foreach ($this->_event->resources as $resource => $bool) { $qb->add_constraint('resource', '=', $resource); } $qb->end_group(); $ret = $qb->execute(); } return $ret; }