public static function GetRoom() { $c = new Criteria(); $c->add(RoomPeer::STATUS, Constant::RECORD_STATUS_ACTIVE); $rooms = RoomPeer::doSelect($c); return $rooms; }
public function executeList() { $c = new Criteria(); $c->add(RoomPeer::STATUS, Constant::BED_DELETE, Criteria::NOT_EQUAL); $c->addAscendingOrderByColumn(RoomPeer::TITLE); $this->rooms = RoomPeer::doSelect($c); }
/** * Description : List the user's room * * @param String email : User id * @return : Collection of rooms */ public function listRoons() { try { $criteria = new Criteria(); $criteria->addAscendingOrderByColumn('ROOM_ID'); return RoomPeer::doSelect($criteria); } catch (Exception $e) { return array(); } }
public function executeIndex(sfWebRequest $request) { $this->form = new RoomSearchForm(); $formName = $this->form->getName(); $this->step = sfConfig::get('app_max_rooms_on_roomlist'); $this->getUser()->syncParameters($this, 'room', 'index', array('offset', 'limit', $this->form->getName(), 'sort_column', 'sort_direction'), $request); if (is_null($this->sort_column)) { $this->sort_column = 'name'; $this->sort_direction = 'up'; } if (is_null($this->offset)) { $this->offset = 0; } if (is_null($this->limit) || $this->limit <= 0) { $this->limit = $this->step; } $c = new Criteria(); SortCriteria::addSortCriteria($c, $this->sort_column, RoomPeer::getSortAliases(), $this->sort_direction); if (!is_null($this->{$formName})) { $this->filtered = true; $this->form->bind($this->{$formName}, $request->getFiles($formName)); if ($this->form->isValid()) { $this->room_list = RoomPeer::searchRooms($this->form->getValue('Activity_id'), $this->form->getValue('is_active'), $this->form->getValue('namePattern'), $this->form->getValue('capacity'), $this->form->getValue('addressPattern'), $this->form->getValue('descriptionPattern'), $this->form->getFeaturesFieldsValues(), $c); $this->count = count($this->room_list); $this->room_list = array_slice($this->room_list, $this->offset, $this->limit); } else { $this->setTemplate('search'); } } else { $c->setOffset($this->offset); if ($this->limit >= 0) { $c->setLimit($this->limit); } $this->filtered = false; $this->room_list = RoomPeer::doSelect($c); $this->count = RoomPeer::doCount(new Criteria()); } if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) { $this->forward404('Invalid offset/count values.'); } }
public static function getOccupancy($zone, $activities, $begin_date, $end_date) { $begin_date_str = date('Y-m-d', $begin_date); $end_date_str = date('Y-m-d', $end_date); /*print('Begin date: '.$begin_date_str.'<br>'); print('End date: '.$end_date_str.'<br>');*/ if (!is_null($zone)) { $zone = ZonePeer::retrieveByPk($zone); //print('Zone is not null: '.$zone.' - Getting rooms....'.'<br>'); $rooms = $zone->getRooms($activities); } else { //print('Zone is null !'.'<br>'); $c = new Criteria(); if (!empty($activities)) { $c->addJoin(RoomHasActivityPeer::ROOM_ID, RoomPeer::ID); $c->addAnd(RoomHasActivityPeer::ACTIVITY_ID, $activities, Criteria::IN); } $rooms = RoomPeer::doSelect($c); } /*print('All Rooms To Check:'.'<br>'); print_r ($rooms); print('<br>');*/ $report = array(); foreach ($rooms as $room) { // Occupancy //print('Processing room: '.$room.'<br>'); $c = new Criteria(); $c->addJoin(ReservationPeer::ROOMPROFILE_ID, RoomprofilePeer::ID); $c->addJoin(RoomprofilePeer::ROOM_ID, RoomPeer::ID); $c->add(RoomPeer::ID, $room->getId(), Criteria::EQUAL); $c->addAnd(ReservationPeer::DATE, $begin_date_str, Criteria::GREATER_EQUAL); $c->addAnd(ReservationPeer::DATE, $end_date_str, Criteria::LESS_THAN); // We only keep finished reservation ? //$c->addAnd(ReservationPeer::STATUS, Reservation::BLOCKED, Criteria::EQUAL); if (!empty($activities)) { $c->addAnd(ReservationPeer::ACTIVITY_ID, $activities, Criteria::IN); } $c->clearSelectColumns(); $c->addSelectColumn('SUM(' . ReservationPeer::DURATION . ')'); $c->setLimit(1); //print ('SQL Command: '.$c->toString().'<br>'); $stmt = ReservationPeer::doSelectStmt($c); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $occupancy_time = $row[0]; } //print('Ocupancy time: '.$occupancy_time.'<br>'); $total_time = 0; // Total time => Total number of opening hours in minutes during the begin and end date for ($date = $begin_date; $date < $end_date; $date = strtotime('+1 day', $date)) { $total_time += $room->getOpeningDuration(date('N', $date) - 1); } //print('Total door opening duration: '.$total_time.'<br>'); if ($total_time <= 0) { continue; } // Results $report[$room->getId()] = array('room' => $room, 'occupancy_time' => $occupancy_time, 'total_time' => $total_time, 'ratio' => $total_time > 0 ? $occupancy_time / $total_time : null); } /*print('Final report:'.'<br>'); print_r ($report); print('<br>');*/ return $report; }
/** * 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(RoomPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(RoomPeer::DATABASE_NAME); $criteria->add(RoomPeer::ID, $pks, Criteria::IN); $objs = RoomPeer::doSelect($criteria, $con); } return $objs; }
public function getDirectRooms($activities = null, $c = null) { if (is_null($c)) { $c = new Criteria(); } $c->addAnd(ZoneHasRoomPeer::ZONE_ID, $this->getId(), Criteria::EQUAL); if (!empty($activities)) { if (!is_array($activities)) { $activities = array($activities); } $c->addJoin(RoomHasActivityPeer::ROOM_ID, ZoneHasRoomPeer::ROOM_ID); $c->addAnd(RoomHasActivityPeer::ACTIVITY_ID, $activities, Criteria::IN); } $c->addJoin(RoomPeer::ID, ZoneHasRoomPeer::ROOM_ID, Criteria::LEFT_JOIN); $c->addAscendingOrderByColumn(RoomPeer::NAME); return RoomPeer::doSelect($c); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this User has previously * been saved, it will retrieve related Rooms from storage. * If this User is new, it will return * an empty collection or the current collection, the criteria * is ignored on a new object. * * @param Connection $con * @param Criteria $criteria * @throws PropelException */ public function getRooms($criteria = null, $con = null) { // include the Peer class include_once 'src/model/whiteboard/om/BaseRoomPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collRooms === null) { if ($this->isNew()) { $this->collRooms = array(); } else { $criteria->add(RoomPeer::USER_ID, $this->getUserId()); RoomPeer::addSelectColumns($criteria); $this->collRooms = RoomPeer::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(RoomPeer::USER_ID, $this->getUserId()); RoomPeer::addSelectColumns($criteria); if (!isset($this->lastRoomCriteria) || !$this->lastRoomCriteria->equals($criteria)) { $this->collRooms = RoomPeer::doSelect($criteria, $con); } } } $this->lastRoomCriteria = $criteria; return $this->collRooms; }