/** * * @return \Zend\Http\Response */ public function csvAction() { $lsOrder = $this->request('ord', $this->_sGridOrder); $lsOrderCol = $this->request('col', $this->_sGridOrderCol); $lsQuery = $this->request('q', ''); $lsField = $this->request('f', ''); $lsField = isset($this->_aSearchFields[$lsField]) ? $lsField : $this->_sSearchFieldDefault; $lsWhere = ''; if ($this->_bSearch && !empty($lsQuery)) { $loSearch = new Search(); $loSearch->set('sSearchFields', $lsField); $lsWhere .= $loSearch->createRLikeQuery('"' . $lsQuery . '"', 'r'); } $laParams = array('status' => 0, 'active' => 1, 'rows' => 0, 'page' => 0, 'col' => $lsOrderCol, 'ord' => $lsOrder, 'q' => $lsQuery, 'where' => $lsWhere); return $this->csv($laParams); }
/** * * @param int $pnStatus * @param bool $pbActive * @param string $psBack * @param string $psFolderTitle * @return string|\Onion\View\Model\ViewModel */ public function gridx($pnStatus = 0, $pbActive = 1, $psBack = 'index', $psFolderTitle = null) { $loGrid = Application::factory('User\\Grid\\UserGrid'); $lnPage = $this->request('p', 0); $lnRows = $this->request('rows', $loGrid->get('numRows')); $lsOrder = $this->request('ord', $loGrid->get('order')); $lsOrderCol = $this->request('col', $loGrid->get('orderCol')); $lsQuery = $this->request('q', ''); $lsField = $this->request('f', ''); $lsField = $loGrid->isSearchField($lsField) ? $lsField : $loGrid->get('searchFieldDefault'); $lsWhere = ''; if ($loGrid->get('showSearch') && !empty($lsQuery)) { $loSearch = new Search(); $loSearch->set('sSearchFields', $lsField); $lsWhere .= $loSearch->createRLikeQuery('"' . $lsQuery . '"', 'r'); } $laParams = array('status' => $pnStatus, 'active' => $pbActive, 'rows' => $lnRows, 'page' => $lnPage, 'col' => $lsOrderCol, 'ord' => $lsOrder, 'q' => $lsQuery, 'where' => $lsWhere); if (method_exists($this, 'gridBeforeSelect')) { $laParams = $this->gridBeforeSelect($laParams); } $laResult = $this->getEntityManager()->getRepository($this->_sEntityExtended)->getList($laParams, $lbCache = false); if (method_exists($this, 'gridAfterSelect')) { $laResult = $this->gridAfterSelect($laResult); } $laMessages = $this->flashMessenger()->getMessages(); $loGrid->setData($laResult['resultSet'])->setTotalResults($laResult['totalCount'])->setBackTo($psBack)->setMessages($laMessages)->setNumRows($lnRows)->setSearchFieldDefault($lsField)->setSearchQuery($lsQuery)->setOrder($lsOrder)->setOrderCol($lsOrderCol)->setCurrentPage($lnPage); $lsGrid = $loGrid->render($this->_sRoute, $psFolderTitle); if (method_exists($this, 'gridAfterRender')) { $lsGrid = $this->gridAfterRender($lsGrid); } $loView = new ViewModel(); if ($this->isXmlHttpRequest()) { $loView->setTerminal(true); // desabilita o layout $loResponse = $this->getResponse(); $loResponse->setStatusCode(200); $loResponse->setContent($lsGrid); return $loResponse; } else { $loView->setVariables(array('lsGrid' => $lsGrid, 'lsFolder' => '', 'lsTitleP' => ''), true); } return $loView; }