예제 #1
0
 protected function getCurrentDisplayFilter($ids = null)
 {
     //unset($this->_session->filter);
     $date = date('Y-m-d');
     $placeHolder = array('providerId' => 'placeHolderId', 'roomId' => 0, 'dateFilter' => $date);
     if (isset($this->_session->filter)) {
         $columns = $this->_session->filter->columns;
         $ctr = count($columns);
         if ($ctr > 1) {
             if (isset($columns[0])) {
                 unset($this->_session->filter->columns[0]);
                 // remove placeholder column
                 unset($columns[0]);
             }
             if (!is_array($ids)) {
                 $ids = array($ids);
             }
             foreach ($ids as $id) {
                 $id = (int) $id;
                 if ($id > 0 && !isset($this->_session->filter->columns[$id])) {
                     $filterState = new FilterState();
                     $filterState->filterStateId = $id;
                     $filterState->populate();
                     $this->_session->filter->columns[$id] = $filterState->toArray();
                 }
             }
         } else {
             if ($ids !== null && $ids == 0 && !isset($columns[$ids])) {
                 $this->_session->filter->columns[$ids] = $placeHolder;
             }
         }
         return $this->_session->filter;
     }
     $filter = new StdClass();
     $filter->date = $date;
     $filter->start = self::FILTER_TIME_START;
     $filter->end = self::FILTER_TIME_END;
     $filter->columns = array();
     // retrieve from database
     $filterStateIterator = new FilterStateIterator();
     $filters = array();
     $filters['tabName'] = self::TAB_NAME;
     $filters['userId'] = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $filterStateIterator->setFilters($filters);
     foreach ($filterStateIterator as $state) {
         $filter->columns[$state->filterStateId] = $state->toArray();
     }
     if (!count($filter->columns) > 0) {
         $filter->columns[] = $placeHolder;
     }
     // save to session
     $this->_session->filter = $filter;
     return $filter;
 }
 protected function getCurrentDisplayFilter()
 {
     //unset($this->_session->filter);
     if (isset($this->_session->filter)) {
         return $this->_session->filter;
     }
     $filter = new StdClass();
     $filter->date = date('Y-m-d');
     $filter->increment = 15;
     $filter->start = '07:00';
     $filter->end = '17:00';
     $filter->columns = array();
     // retrieve from database
     $filterStateIterator = new FilterStateIterator();
     $filters = array();
     $filters['tabName'] = Menu::getCurrentlySelectedActivityGroup();
     $filterStateIterator->setFilters($filters);
     foreach ($filterStateIterator as $state) {
         //$filter->columns[] = array('providerId' => $state->providerId,'roomId'=>$state->roomId);
         $filter->columns[] = $state->toArray();
     }
     if (!count($filter->columns) > 0) {
         $filter->columns[] = array('providerId' => 'placeHolderId');
     }
     // save to session
     $this->_session->filter = $filter;
     return $filter;
 }