コード例 #1
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(CloseperiodPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(CloseperiodPeer::DATABASE_NAME);
         $criteria->add(CloseperiodPeer::ID, $pks, Criteria::IN);
         $objs = CloseperiodPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #2
0
ファイル: RoomPeer.php プロジェクト: jfesquet/tempos
 public static function getGantt($room_list, $activityId, $person, $timestamp)
 {
     $now = time();
     $room_id_list = PropelLogic::getIdList($room_list);
     // Get the day start
     $dayStart = ReservationPeer::getDayStart($timestamp);
     // We get all the reservations for the current room list in the week containing the given timestamp.
     $c = ReservationPeer::getDayCriteria($timestamp);
     $c->addJoin(ReservationPeer::ROOMPROFILE_ID, RoomprofilePeer::ID);
     $c->addAnd(RoomprofilePeer::ROOM_ID, $room_id_list, Criteria::IN);
     $c->addAscendingOrderByColumn(ReservationPeer::DATE);
     $reservations = ReservationPeer::doSelect($c);
     // We get all the day periods for the current room list.
     $dayOfWeek = date('N', $timestamp) - 1;
     $c = new Criteria();
     $c->addAnd(DayperiodPeer::ROOM_ID, $room_id_list, Criteria::IN);
     $c->addAnd(DayperiodPeer::DAY_OF_WEEK, $dayOfWeek, Criteria::EQUAL);
     $c->addAscendingOrderByColumn(DayperiodPeer::START);
     $dayPeriods = DayperiodPeer::doSelect($c);
     // We get all the close periods for the current room list.
     $c = CloseperiodPeer::getDayCriteria($timestamp);
     $c->addAnd(CloseperiodPeer::ROOM_ID, $room_id_list, Criteria::IN);
     $c->addAscendingOrderByColumn(CloseperiodPeer::START);
     $c->addAscendingOrderByColumn(CloseperiodPeer::STOP);
     $closePeriods = CloseperiodPeer::doSelect($c);
     // We build the availability array
     $startIndex = 48;
     $stopIndex = 0;
     $result = array();
     foreach ($room_list as $room) {
         $room_id = $room->getId();
         $result[$room_id] = array();
         $result[$room_id]['room'] = $room;
         for ($i = 0; $i < 48; ++$i) {
             $result[$room_id][$i] = array();
             $tst = strtotime(date('Y-m-d H:i:s', $dayStart) . ' + ' . $i * 30 . ' minute');
             $value = RoomPeer::COMPLETE;
             foreach ($dayPeriods as $dayPeriod) {
                 if ($dayPeriod->getRoomId() == $room_id) {
                     if ($dayPeriod->matchTimestamp($tst)) {
                         if ($startIndex > $i) {
                             $startIndex = $i;
                         }
                         if ($stopIndex <= $i) {
                             $stopIndex = $i + 1;
                         }
                         $value = RoomPeer::FREE;
                         break;
                     }
                 }
             }
             foreach ($closePeriods as $closePeriod) {
                 if ($closePeriod->getRoomId() == $room_id) {
                     if ($closePeriod->matchTimestamp($tst)) {
                         $value = RoomPeer::COMPLETE;
                         break;
                     }
                 }
                 if (strtotime($closePeriod->getStart()) > $tst) {
                     break;
                 }
             }
             if ($value != RoomPeer::COMPLETE) {
                 if ($tst < $now) {
                     $value = RoomPeer::PAST;
                 } else {
                     $maximumTimestamp = $person->getMaximumDate($activityId, $room_id);
                     if ($maximumTimestamp <= $tst || !$person->hasSubscription($activityId, $room_id, $tst)) {
                         $value = RoomPeer::TOOFAR;
                     } else {
                         foreach ($reservations as $reservation) {
                             if ($reservation->getRoomprofile()->getRoomId() == $room_id) {
                                 if ($reservation->matchTimestamp($tst)) {
                                     $value = RoomPeer::COMPLETE;
                                     break;
                                 }
                             }
                             if (strtotime($reservation->getDate()) > $tst) {
                                 break;
                             }
                         }
                     }
                 }
             }
             $result[$room_id][$i]['value'] = $value;
             $result[$room_id][$i]['timestamp'] = $tst;
             $result[$room_id][$i]['room'] = $room;
             $result['timestamps'][$i] = $tst;
         }
     }
     $result['startIndex'] = $startIndex;
     $result['stopIndex'] = $stopIndex;
     return $result;
 }
コード例 #3
0
ファイル: BaseRoom.php プロジェクト: jfesquet/tempos
 /**
  * Gets an array of Closeperiod objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this Room has previously been saved, it will retrieve
  * related Closeperiods from storage. If this Room is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array Closeperiod[]
  * @throws     PropelException
  */
 public function getCloseperiods($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(RoomPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCloseperiods === null) {
         if ($this->isNew()) {
             $this->collCloseperiods = array();
         } else {
             $criteria->add(CloseperiodPeer::ROOM_ID, $this->id);
             CloseperiodPeer::addSelectColumns($criteria);
             $this->collCloseperiods = CloseperiodPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(CloseperiodPeer::ROOM_ID, $this->id);
             CloseperiodPeer::addSelectColumns($criteria);
             if (!isset($this->lastCloseperiodCriteria) || !$this->lastCloseperiodCriteria->equals($criteria)) {
                 $this->collCloseperiods = CloseperiodPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastCloseperiodCriteria = $criteria;
     return $this->collCloseperiods;
 }