function getReservations($userid, $start, $end)
 {
     $return = array();
     $values = array($userid, $userid);
     $query = 'SELECT r.*, rem.reminder_time, rem.reminderid, ru.* FROM ' . $this->get_table(TBL_RESERVATIONS) . ' r' . ' INNER JOIN ' . $this->get_table(TBL_RESERVATION_USERS) . ' ru ON r.resid = ru.resid' . ' LEFT JOIN ' . $this->get_table(TBL_REMINDERS) . ' rem ON r.resid = rem.resid AND rem.memberid = ?' . ' WHERE ru.memberid = ? AND ru.invited = 0';
     if ($start != null) {
         $values[] = $start->date;
         $values[] = $start->date;
         $values[] = $start->time;
         $query .= ' AND (r.start_date >= ? OR (r.start_date = ? AND r.starttime >= ?))';
     }
     if ($end != null) {
         $values[] = $end->date;
         $values[] = $end->date;
         $values[] = $end->time;
         $query .= ' AND (r.end_date <= ? OR (r.end_date = ? AND r.endtime <= ?))';
     }
     $result = $this->db->query($query, $values);
     $this->check_for_error($result);
     while ($rs = $result->fetchRow()) {
         $res = new ReservationResult();
         $res->id = $rs['resid'];
         $res->start_date = $rs['start_date'];
         $res->end_date = $rs['end_date'];
         $res->start = $rs['starttime'];
         $res->end = $rs['endtime'];
         $res->resource = new Resource($rs['machid']);
         $res->resource->db = null;
         $res->created = $rs['created'];
         $res->modified = $rs['modified'];
         $res->parentid = $rs['parentid'];
         $res->summary = $rs['summary'];
         $res->scheduleid = $rs['scheduleid'];
         $res->is_pending = $rs['is_pending'];
         $res->is_participant = $rs['owner'] == 0;
         $reminder = new Reminder($rs['reminderid']);
         $reminder->set_reminder_time($rs['reminder_time']);
         $res->reminderid = $rs['reminderid'];
         $res->reminder_minutes_prior = $reminder->getMinutuesPrior($res);
         $users = $this->get_res_users($res->id);
         for ($i = 0; $i < count($users); $i++) {
             if ($users[$i]['owner'] == 1) {
                 $res->user = new User($users[$i]['memberid']);
                 $res->user->db = null;
                 break;
             } else {
                 $res->users[] = $users[$i];
             }
         }
         $res->resources = $this->get_sup_resources($res->id);
         $return[] = $res;
     }
     $result->free();
     return $return;
 }
Пример #2
0
 /**
  * Loads all reservation properties from the database
  * @param none
  */
 function load_by_id()
 {
     $res = $this->db->get_reservation($this->id, Auth::getCurrentID());
     // Get values from DB
     if (!$res) {
         // Quit if reservation doesnt exist
         CmnFns::do_error_box($this->db->get_err());
     }
     $this->start_date = $res['start_date'];
     $this->end_date = $res['end_date'];
     $this->start = $res['starttime'];
     $this->end = $res['endtime'];
     $this->resource = new Resource($res['machid']);
     $this->created = $res['created'];
     $this->modified = $res['modified'];
     $this->parentid = $res['parentid'];
     $this->summary = htmlspecialchars($res['summary']);
     $this->scheduleid = $res['scheduleid'];
     $this->is_blackout = $res['is_blackout'];
     $this->is_pending = $res['is_pending'];
     $this->allow_participation = $res['allow_participation'];
     $this->allow_anon_participation = $res['allow_anon_participation'];
     $this->is_participant = $res['participantid'] != null;
     $reminder = new Reminder($res['reminderid']);
     $reminder->set_reminder_time($res['reminder_time']);
     $this->reminderid = $res['reminderid'];
     $this->reminder_minutes_prior = $reminder->getMinutuesPrior($this);
     $this->users = $this->db->get_res_users($this->id);
     // Store the memberid of the owner
     for ($i = 0; $i < count($this->users); $i++) {
         if ($this->users[$i]['owner'] == 1) {
             $this->user = new User($this->users[$i]['memberid']);
         } else {
             if ($this->users[$i]['invited'] == 1) {
                 $this->invited_users[] = $this->users[$i];
             } else {
                 $this->participating_users[] = $this->users[$i];
             }
         }
     }
     $this->resources = $this->db->get_sup_resources($this->id);
 }