Beispiel #1
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();
 }