Beispiel #1
0
 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.');
     }
 }
Beispiel #2
0
 public function executeOverallIndex(sfWebRequest $request)
 {
     $this->handleZoneParameters($request);
     $this->form = new RoomSearchForm($this->activity);
     $this->form->setIsActive(true);
     $formName = $this->form->getName();
     $this->getUser()->syncParameters($this, 'home', 'overallIndex', array($formName, 'displayPeriod'), $request);
     $this->getUser()->syncParameters($this, 'general', 'index', array('date'), $request);
     if (is_null($this->date)) {
         $this->date = time();
     } else {
         $this->date = strtotime($this->date);
     }
     if (is_null($this->displayPeriod)) {
         $this->displayPeriod = 'month';
     } else {
         $this->forward404Unless(in_array($this->displayPeriod, array('week', 'month')), sprintf('"%s" is not a valid value for displayPeriod', $this->displayPeriod));
     }
     $this->today = false;
     if ($this->displayPeriod == 'month') {
         if (date('m', $this->date) == date('m')) {
             $this->today = true;
         }
     } else {
         if (date('W', $this->date) == date('W')) {
             $this->today = true;
         }
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, RoomPeer::getSortAliases(), $this->sort_direction);
     $this->filtered = false;
     if (!is_null($this->{$formName})) {
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->filtered = true;
             $this->room_list = RoomPeer::searchRooms($this->activity->getId(), true, $this->form->getValue('namePattern'), $this->form->getValue('capacity'), $this->form->getValue('addressPattern'), $this->form->getValue('descriptionPattern'), $this->form->getFeaturesFieldsValues(), $c);
         }
     }
     if (!$this->filtered) {
         $this->room_list = RoomPeer::searchRooms($this->activity->getId(), true, null, null, null, null, null, $c);
         $this->count = 0;
     }
     $this->room_list = $this->person->filterAccessibleRooms($this->room_list);
     $this->count = count($this->room_list);
     $this->availability = RoomPeer::getAvailability($this->room_list, $this->activity->getId(), $this->person, $this->displayPeriod, $this->date);
     $this->checkFeatures();
 }