function populate()
 {
     $po_obj = new DataObject('po_no_auth_user');
     $po_obj->idField = 'id';
     $po_obj->identifierField = 'order_number';
     $po_col = new DataObjectCollection($po_obj);
     $po_col->setParams();
     $sh = new SearchHandler($po_col, false);
     $sh->setFields(array('id', 'order_number', 'supplier', 'status'));
     $sh->addConstraint(new Constraint('status', '!=', 'X'));
     $this->setSearchLimit($sh);
     $sh->setOrderby(array('order_date', 'due_date', 'order_number'));
     $po_col->load($sh);
     $this->contents = $po_col;
 }
Example #2
0
 public function index(DataObjectCollection $collection, $sh = '', &$c_query = null)
 {
     showtime('start-controller-index');
     $collection->setParams();
     if (!$sh instanceof SearchHandler) {
         $sh = $this->setSearchHandler($collection);
     }
     showtime('sh-extracted');
     if (isset($this->search) && !isset($this->_data['orderby']) && !isset($this->_data['page'])) {
         $cc = $this->search->toConstraintChain();
         $sh->addConstraintChain($cc);
         $sh->save();
         // cache the search string
         $search_string_array = array('fop' => $this->search->toString('fop'), 'html' => $this->search->toString('html'));
         $_SESSION['search_strings'][EGS_USERNAME][$sh->search_id] = $search_string_array;
     }
     // Need to set the orderby of the collection in the searchhandler?
     // But if this is set in the collection, seems to take it
     // so why not here?
     showtime('pre-load');
     $collection->load($sh, $c_query);
     $this->view->set('total_records', $collection->total_records);
     $this->view->set('num_records', $collection->num_records);
     $this->view->set('num_pages', $collection->num_pages);
     $this->view->set('cur_page', $collection->cur_page);
     showtime('post-load');
     $this->view->set(strtolower($collection->getModelName()) . 's', $collection);
     if (isset($this->_data['json'])) {
         $this->view->set('echo', $collection->toJSON());
     }
     if ($this->_templateName === false) {
         $this->_templateName = $this->getTemplateName('index');
     }
     showtime('end-controller-index');
 }