/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->_scrollingStyle = new \Zend\Paginator\ScrollingStyle\Elastic(); $this->_paginator = \Zend\Paginator\Paginator::factory(range(1, 101)); $this->_paginator->setItemCountPerPage(5); $this->_paginator->setPageRange(5); }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Sliding(); $this->_paginator = Zend_Paginator::factory(range(1, 101)); $this->_paginator->setItemCountPerPage(10); $this->_paginator->setPageRange(5); }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Jumping(); $this->_paginator = Zend_Paginator::factory(range(1, 101)); $this->_paginator->setItemCountPerPage(10); $this->_paginator->setPageRange(10); $this->_expectedRange = array_combine(range(1, 10), range(1, 10)); }
/** * Get current items to display on current page * @access public * @return object ArrayIterator */ public function getCurrentItems() { $this->_paginator->setItemCountPerPage($this->_itemCountPerPage); $this->_paginator->setCurrentPageNumber($this->_currentPage); if ($this->_currentItems === null) { $this->_currentItems = $this->_paginator->getCurrentItems(); } return $this->_currentItems; }
/** * Lists all servicePacks matching a criteria */ public function indexAction() { // Check permissions $sp = new ServicePackModel(); $this->_helper->allowed('list', $sp); // Pagination $params = $this->_getPaginatorParams(); // Filters $filters = $this->_mapToFilter($this->_getFilterParams()); $this->_checkFilterParams($filters, ServicePackFilterFields::getWhiteList()); $filterList = $this->_spSrv->buildFilterList($filters); $this->_helper->filterNotAllowedFilters('filter_by', $filterList); // Search $spList = $this->_spSrv->listAll($filterList, $params); if ($spList) { $list = array(); foreach ($spList->getItems() as $item) { try { $this->_helper->allowed('read', $item); $this->_helper->filterNotAllowedFields('read_field', $item); $list[] = $item; } catch (Exception $e) { // Do nothing } } // Simulate pagination $it = new ArrayIterator($list); $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Iterator($it)); $paginator->setItemCountPerPage($params['count']); // Result $iterator = $paginator->getItemsByPage($params['page']); $this->view->servicePacks = iterator_to_array($iterator, false); } }
public function indexAction() { /** * Form cadastro */ $formPropostaCadastro = new Form_Site_PropostaCadastro(); $formPropostaCadastro->submit->setLabel("CADASTRAR"); //$formPropostaCadastro->proposta_numero->setValue($this->getNumeroProposta()); $this->view->formPropostaCadastro = $formPropostaCadastro; /** * Busca as propostas */ $page = $this->getRequest()->getParam('page', 1); //get curent page param, default 1 if param not available. $modelProposta = new Model_DbTable_Proposta(); $data = $modelProposta->getQuery(); $adapter = new Zend_Paginator_Adapter_DbSelect($data); //adapter $paginator = new Zend_Paginator($adapter); // setup Pagination $paginator->setItemCountPerPage(Zend_Registry::get("config")->resource->rowspage); // Items perpage, in this example is 10 $paginator->setCurrentPageNumber($page); // current page //Zend_Paginator::setDefaultScrollingStyle('Sliding'); //Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/pagination.phtml'); $this->view->propostas = $paginator; }
public static function fetchAllPage($role, $page = 1, $perpage = 30) { if ($role != 0 && $role != 1 && $role != 2 && $role != 3) { return array(); } $select = self::select(); if ($role != 0) { $select->where('urole = ?', $role)->order('ctime desc'); } $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page); $data = $paginator->getCurrentItems(); $pages = $paginator->count(); $orders = array(); if (count($data) > 0) { foreach ($data as $da) { $orderModel = new Application_Model_O_MemberCardOrder(); $orderModel->setId($da->id)->setOrder_id($da->order_id)->setUid($da->uid)->setUrole($da->urole)->setMember_card_id($da->member_card_id)->setTotal_price($da->total_price)->setPayment_status($da->payment_status)->setRemark($da->remark)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status); array_push($orders, $orderModel); } } $res = array('orders' => $orders, 'pages' => $pages); return $res; }
public function getAll($active = false, $lng = 'nl', $paginator = true, $pindex = 1, $perpage = 25, $cache = true) { if ($cache == true) { $cacheId = $this->generateCacheId(get_class($this) . '_' . __FUNCTION__, func_get_args()); $cache = Zend_Registry::get('cache'); if (true == ($result = $cache->load($cacheId))) { return $result; } } $db = Zend_Registry::get('db'); $select = $db->select()->from(array('n' => 'News'), array('*'))->joinLeft(array('t' => 'NewsTsl', array('lng', 'title', 'summary', 'content', 'url', 'seo_keywords', 'seo_title', 'seo_description', 'active')), 'n.nid = t.nid')->where('t.lng = ?', $lng); if ($active) { $select->where('t.active = 1')->where('n.date_published <= NOW()')->where('n.date_expired > NOW() OR n.date_expired is NULL')->order('n.date_message DESC')->order('n.date_published DESC'); } else { $select->order('n.date_published DESC')->order('n.date_created DESC'); } if ($paginator === true) { $adapter = new Base_PaginatorAdapter($select); $adapter->setMapper($this->_mapper); $data = new Zend_Paginator($adapter); $data->setCurrentPageNumber((int) $pindex); $data->setItemCountPerPage((int) $perpage); } else { $results = $db->fetchAll($select); $data = $this->_mapper->mapAll($results); } if ($cache == true) { $cacheTags = $this->generateCacheTags(get_class($this) . '_' . __FUNCTION__); $cache->save($data, $cacheId, $cacheTags); } return $data; }
public static function fetchByType($type = 1, $page = 1, $perpage = 30) { if ($type != 0 && $type != 1 && $type != 2) { return array(); } $select = self::select(); if ($type != 0) { $select->where('type = ?', $type); } $select->order('sort asc'); $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page); $data = $paginator->getCurrentItems(); $pages = $paginator->count(); $destinations = array(); if (count($data) > 0) { foreach ($data as $da) { $destinationModel = new Application_Model_O_Destination(); $destinationModel->setId($da->id)->setCity($da->city)->setType($da->type)->setLongitude($da->longitude)->setLatitude($da->latitude)->setImg($da->img)->setSort($da->sort)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status); array_push($destinations, $destinationModel); } } $res = array('destinations' => $destinations, 'pages' => $pages); return $res; }
public function listAction() { // create search form $searchForm = new Admin_Form_RouteSearch(); $searchForm->setAction('/admin/route/list')->setMethod('post'); $this->view->searchForm = $searchForm; // get params from request $sorter = $this->_request->getParam('sorter', null); $filter = $this->_request->getParam('filter', null); $filterText = $this->_request->getParam('filterText', null); // populate them to form $searchForm->getElement('sorter')->setValue($sorter); $searchForm->getElement('filter')->setValue($filter); $searchForm->getElement('filterText')->setValue($filterText); // list route $routeModel = new Admin_Model_Route(); $routeAdapter = $routeModel->getRoutePaginatorAdapter($filter, $filterText, $sorter); if ($routeAdapter) { $paginator = new Zend_Paginator($routeAdapter); $page = $this->_request->getParam('page', 1); $paginator->setItemCountPerPage(5); $paginator->setCurrentPageNumber($page); $paginator->setPageRange(8); $this->view->paginator = $paginator; } }
/** * gets a listing of products based on category * * (main method used in product listings) * * @param $categoryId category ID (can be more than one) * @param null $paged current page (null, no pagination; not null contains the current page) * @param null $order order clause * @return Zend_Db_Table_Rowset_Abstract|Zend_Paginator */ public function getProductByCategory($categoryId, $paged = null, $order = null) { // creating the select statement // using the IN clause is suitable as $categoryId is an array of categories $select = $this->select()->from('product')->where('categoryId IN (?)', $categoryId); // ordering according to order clause // (e.g., array('name ASC', 'price DESC') if (is_array($order) === true) { $select->order($order); } // paginating the result if ($paged !== null) { // adapter to configure the paginator instance $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); // select statement that calculates the total amount of rows returned by the main statement $count = clone $select; // reseting the cloned statement $count->reset(Zend_Db_Select::COLUMNS); $count->reset(Zend_Db_Select::FROM); // creating the count expression with Zend_Db_Expr $count->from('product', new Zend_Db_Expr('COUNT(*) as `zend_paginator_row_count`')); // setting the count statement in the adapter $adapter->setRowCount($count); // creating the zend paginator instance using the adapter $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage(5)->setCurrentPageNumber((int) $paged); return $paginator; } return $this->fetchAll($select); }
public function indexAction() { $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Pickup Groups"))); $db = Zend_Registry::get('db'); $select = $db->select()->from("pickup_group"); if ($this->_request->getPost('filtro')) { $field = mysql_escape_string($this->_request->getPost('campo')); $query = mysql_escape_string($this->_request->getPost('filtro')); $select->where("`{$field}` like '%{$query}%'"); } $page = $this->_request->getParam('page'); $this->view->page = isset($page) && is_numeric($page) ? $page : 1; $this->view->filtro = $this->_request->getParam('filtro'); $paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($this->view->page); $paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit); $this->view->pickupgroups = $paginator; $this->view->pages = $paginator->getPages(); $this->view->URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/"; $this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/"; $opcoes = array("ds_name" => $this->view->translate("Name")); // Formulário de filtro. $filter = new Snep_Form_Filter(); $filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index'); $filter->setValue($this->_request->getPost('campo')); $filter->setFieldOptions($opcoes); $filter->setFieldValue($this->_request->getPost('filtro')); $filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}"); $this->view->form_filter = $filter; $this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add", "display" => $this->view->translate("Add Pickup Group"), "css" => "include")); }
/** * List all Contacts */ public function indexAction() { $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Contacts"))); $this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName(); $db = Zend_Registry::get('db'); $select = $db->select()->from(array("n" => "contact"), array("n.id_contact as id", "n.ds_name as name", "n.ds_city as city", "n.ds_state as state", "n.ds_cep as cep", "n.ds_phone as phone", "n.ds_cell_phone as cellphone", "g.ds_name as group"))->join(array("g" => "contact_group"), 'n.id_contact_group = g.id_contact_group', array())->order('n.id_contact'); if ($this->_request->getPost('filtro')) { $field = pg_escape_string($this->_request->getPost('campo')); $query = pg_escape_string($this->_request->getPost('filtro')); $select->where("{$field} like '%{$query}%'"); } $page = $this->_request->getParam('page'); $this->view->page = isset($page) && is_numeric($page) ? $page : 1; $this->view->filtro = $this->_request->getParam('filtro'); $paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($this->view->page); $paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit); $this->view->contacts = $paginator; $this->view->pages = $paginator->getPages(); $this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/"; /*Opcoes do Filtro*/ $opcoes = array("n.ds_name" => $this->view->translate("Name"), "n.ds_city" => $this->view->translate("City"), "n.ds_state" => $this->view->translate("State"), "n.ds_cep" => $this->view->translate("ZIP Code"), "n.ds_phone" => $this->view->translate("Phone"), "n.ds_cell_phone" => $this->view->translate("Cellphone")); $filter = new Snep_Form_Filter(); $filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index'); $filter->setValue($this->_request->getPost('campo')); $filter->setFieldOptions($opcoes); $filter->setFieldValue($this->_request->getPost('filtro')); $filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}"); $this->view->form_filter = $filter; $this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add/", "display" => $this->view->translate("Add Contact"), "css" => "include"), array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/multi-remove/", "display" => $this->view->translate("Remove Multiple"), "css" => "exclude"), array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/import/", "display" => $this->view->translate("Import CSV"), "css" => "import"), array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/export/", "display" => $this->view->translate("Export CSV"), "css" => "export")); }
public static function fetchByType($type = 1, $filter, $order, $page = 1) { if ($type != 1 && $type != 2 && $type != 3) { return array(); } $select = self::select(); $select->where('type = ?', $type)->where('status =1'); if ($filter == 1 || $filter == 2) { $select->where('location_type = ?', $filter); } if ($order == 1) { $select->order('adult_dprice desc'); } elseif ($order == 2) { $select->order('adult_dprice asc'); } elseif ($order == 3) { $select->order('sales desc'); } elseif ($order == 4) { $select->order('sales asc'); } $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage(10)->setCurrentPageNumber($page); $data = $paginator->getCurrentItems(); $pages = $paginator->count(); $travels = array(); if (count($data) > 0) { foreach ($data as $da) { $travelModel = new Application_Model_O_Travel(); $travelModel->setId($da->id)->setType($da->type)->setLocation_type($da->location_type)->setAdult_oprice($da->adult_oprice)->setAdult_dprice($da->adult_dprice)->setChild_oprice($da->child_oprice)->setChild_dprice($da->child_dprice)->setArea($da->area)->setSales($da->sales)->setTitle($da->title)->setSubtitle($da->subtitle)->setImg($da->img)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status); array_push($travels, $travelModel); } } $res = array('travels' => $travels, 'pages' => $pages); return $res; }
/** * Consulta notas para exportar RPS */ public function rpsConsultarAction() { parent::noTemplate(); $aParametros = $this->getRequest()->getParams(); /** * Verifica se foi informado mês e ano da competência */ if (!empty($aParametros['mes_competencia']) && !empty($aParametros['ano_competencia'])) { $oContribuinte = $this->_session->contribuinte; $sCodigosContribuintes = implode(',', $oContribuinte->getContribuintes()); $oPaginatorAdapter = new DBSeller_Controller_Paginator(Contribuinte_Model_Nota::getQuery(), 'Contribuinte_Model_Nota', 'Contribuinte\\Nota'); /** * Monta a query de consulta */ $oPaginatorAdapter->where("e.id_contribuinte in ({$sCodigosContribuintes})"); $oPaginatorAdapter->andWhere("e.mes_comp = {$aParametros['mes_competencia']}"); $oPaginatorAdapter->andWhere("e.ano_comp = {$aParametros['ano_competencia']}"); if (!empty($aParametros['numero_rps'])) { $oPaginatorAdapter->andWhere("e.nota = {$aParametros['numero_rps']}"); } $oPaginatorAdapter->orderBy('e.nota', 'DESC'); /** * Monta a paginação do GridPanel */ $oResultado = new Zend_Paginator($oPaginatorAdapter); $oResultado->setItemCountPerPage(10); $oResultado->setCurrentPageNumber($this->_request->getParam('page')); foreach ($oResultado as $oNota) { $oNota->oContribuinte = $oContribuinte; $oNota->lNaoGeraGuia = !$oNota->getEmite_guia(); $oNota->lGuiaEmitida = Contribuinte_Model_Guia::existeGuia($oContribuinte, $oNota->getMes_comp(), $oNota->getAno_comp(), Contribuinte_Model_Guia::$DOCUMENTO_ORIGEM_NFSE); /** * Informações da nota substituta */ $oNota->oNotaSubstituida = NULL; if ($oNota->getIdNotaSubstituida()) { $oNota->oNotaSubstituida = Contribuinte_Model_Nota::getById($oNota->getIdNotaSubstituida()); } /** * Informações da nota substituta */ $oNota->oNotaSubstituta = NULL; if ($oNota->getIdNotaSubstituta()) { $oNota->oNotaSubstituta = Contribuinte_Model_Nota::getById($oNota->getIdNotaSubstituta()); } } /** * Valores da pesquisa para montar a paginação */ if (is_array($aParametros)) { foreach ($aParametros as $sParametro => $sParametroValor) { if ($sParametroValor) { $sParametroValor = str_replace('/', '-', $sParametroValor); $this->view->sBusca .= "{$sParametro}/{$sParametroValor}/"; } } } $this->view->oDadosNota = $oResultado; } }
public function selectAll($pageNumber = 1, $filter = array()) { $db = $this->siteDbAdapter->select()->from($this->tablename); foreach ($filter as $key => $val) { if ($val) { if (is_int($val)) { $db->where($key . ' = ?', $val); } else { $db->where($key . ' LIKE ?', '%' . $val . '%'); } } } $db->order('log_date DESC'); $adapter = new Zend_Paginator_Adapter_DbSelect($db); $paginator = new Zend_Paginator($adapter); $paginator->setCurrentPageNumber($pageNumber); $paginator->setItemCountPerPage($this->countPerPage); $paginator->setPageRange($this->pageRange); return $paginator; /* $select = $this->siteDbAdapter->select(); $select->from($this->tablename); $select->order(array('log_id')); $log = $this->siteDbAdapter->fetchAll($select->__toString()); return $log; */ }
/** * @param string $modelName * @param array $options * @param Doctrine_Query_Abstract $query * @return string */ public function modelList($modelName, array $options = array(), Doctrine_Query_Abstract $query = null) { $options = array_merge(self::$_defaultOptions, $options); if (!$options['paginationScript']) { $options['paginationScript'] = 'partials/pagination.phtml'; } $table = Doctrine_Core::getTable($modelName); if (!$query) { $query = $table->createQuery(); } $adapter = new FansubCMS_Paginator_Adapter_Doctrine($query); $paginator = new Zend_Paginator($adapter); $front = Zend_Controller_Front::getInstance(); $request = $front->getRequest(); $currentPage = $request->getParam('page', 1); $paginator->setCurrentPageNumber($currentPage); $paginator->setItemCountPerPage($options['itemsPerPage']); if (!isset($options['listScript'])) { $options['listScript'] = 'partials/table.phtml'; } if (!isset($options['showFieldNames'])) { $fieldNames = $this->getAutoFieldNames($table); } else { $fieldNames = $options['showFieldNames']; } return $this->view->partial($options['listScript'], array('modelName' => $modelName, 'paginator' => $paginator, 'currentPage' => $currentPage, 'options' => $options, 'fieldNames' => $fieldNames)); }
public function indexAction() { // @todo localização das datas na listagem da view $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Users"))); $this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName(); $db = Zend_Registry::get('db'); $select = $db->select()->from("user"); if ($this->_request->getPost('filtro')) { $field = mysql_escape_string($this->_request->getPost('campo')); $query = mysql_escape_string($this->_request->getPost('filtro')); $select->where("{$field} LIKE '%{$query}%'"); } $page = $this->_request->getParam('page'); $this->view->page = isset($page) && is_numeric($page) ? $page : 1; $this->view->filtro = $this->_request->getParam('filtro'); $paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($this->view->page); $paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit); $this->view->users = $paginator; $this->view->pages = $paginator->getPages(); $this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/"; $opcoes = array('ds_login' => $this->view->translate('Name'), 'ds_mail' => $this->view->translate('E-mail')); $this->view->active = array(1 => $this->view->translate('Yes'), 0 => $this->view->translate('No')); $filter = new Snep_Form_Filter(); $filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index'); $filter->setValue($this->_request->getPost('campo')); $filter->setFieldOptions($opcoes); $filter->setFieldValue($this->_request->getPost('filtro')); $filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}"); $this->view->form_filter = $filter; $this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add/", "display" => $this->view->translate("Add User"), "css" => "include")); }
public function indexAction() { $modelos = Modelo::findModelos()->getData(); $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($modelos)); $paginator->setItemCountPerPage(20)->setPageRange(5)->setCurrentPageNumber($this->_request->getParam('page', 1)); $this->view->modelos = $paginator; }
public function indexAction() { $this->getFrontController()->getRequest()->setParams($_GET); $params = $this->getAllParams(); unset($params['module'], $params['controller'], $params['action'], $params['page'], $params['_sf'], $params['_so']); $sortField = $this->_getParam('_sf', ''); $sortOrder = $this->_getParam('_so', ''); $pageNumber = $this->_getParam('page', 1); $qry = VAR_tableQueryClass::create(); if ($sortField) { $qry->orderBy($sortField, $sortOrder); } if (count($params) > 0) { foreach ($params as $param => $value) { $name = VAR_tablePeerClass::translateFieldName($param, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME); $qry->filterBy($name, $value); } } $pager = $qry->paginate($pageNumber, 20); $paginator = new Zend_Paginator(new Dfi_Paginator_Adapter_PropelPager($pager)); $paginator->setItemCountPerPage(20)->setCurrentPageNumber($pageNumber); $this->view->assign(array('paginator' => $paginator, 'sortField' => $sortField, 'sortOrder' => $sortOrder, 'pageNumber' => $pageNumber, 'pager' => $pager)); foreach ($this->getAllParams() as $paramName => $paramValue) { // prepend 'param' to avoid error of setting private/protected members $this->view->assign('param' . $paramName, $paramValue); } }
public static function fetchByDepartmentHospital($department, $hospital, $sort, $page) { $select = self::select(); if ($department) { $select->where("department like '%{$department}%'")->orWhere("special like '%{$department}%'"); } if ($hospital) { $select->where('hospital = ?', $hospital); } if ($sort == 1) { //asc $select->order('reservation_number asc'); } elseif ($sort == 2) { //desc $select->order('reservation_number desc'); } $select->where('status = 1'); $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage(10)->setCurrentPageNumber($page); $data = $paginator->getCurrentItems(); $pages = $paginator->count(); $doctors = array(); if (count($data) > 0) { foreach ($data as $da) { $doctorModel = new Application_Model_O_Doctor(); $doctorModel->setId($da->id)->setName($da->name)->setAvatar($da->avatar)->setSex($da->sex)->setBirthday($da->birthday)->setEmail($da->email)->setPasswd($da->passwd)->setPhone($da->phone)->setDepartment($da->department)->setPoint($da->point)->setCity($da->city)->setCertified($da->certified)->setSpecial($da->special)->setCountry($da->country)->setIntroduction($da->introduction)->setHospital($da->hospital)->setArea($da->area)->setQualification($da->qualification)->setReservation_fee($da->reservation_fee)->setReservation_number($da->reservation_number)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status); array_push($doctors, $doctorModel); } } $res = array('doctors' => $doctors, 'pages' => $pages); return $res; }
/** * Consulta as guias dos contribuintes por competência */ public function consultarAction() { parent::noTemplate(); $aParametros = $this->getRequest()->getParams(); /** * Verifica se foi informado mês e ano da competência */ if (!empty($aParametros['mes_competencia']) && !empty($aParametros['ano_competencia'])) { $iMesCompetencia = str_pad($aParametros['mes_competencia'], 2, '0', STR_PAD_LEFT); $iAnoCompetencia = $aParametros['ano_competencia']; $aGuiasCompetencia = Contribuinte_Model_Competencia::getByGuiasContribuinteAndCompetencia($iMesCompetencia, $iAnoCompetencia); $oPaginatorAdapter = new DBSeller_Controller_PaginatorArray($aGuiasCompetencia); $oPaginator = new Zend_Paginator($oPaginatorAdapter); $oPaginator->setItemCountPerPage(10); $oPaginator->setCurrentPageNumber($this->_request->getParam('page')); /** * Valores da pesquisa para montar a paginação */ if (is_array($aParametros)) { foreach ($aParametros as $sParametro => $sParametroValor) { if ($sParametroValor) { $sParametroValor = str_replace('/', '-', $sParametroValor); $this->view->sBusca .= "{$sParametro}/{$sParametroValor}/"; } } } $this->view->oGuiasCompetencia = $oPaginator; } }
public function getAll($lng, $paginator = true, $pindex = 1, $perpage = 25, $cache = true) { if ($cache == true) { $cacheId = $this->generateCacheId(get_class($this) . '_' . __FUNCTION__, func_get_args()); $cache = Zend_Registry::get('cache'); if (true == ($result = $cache->load($cacheId))) { return $result; } } $db = Zend_Registry::get('db'); $select = $db->select()->from(array('a' => 'ContentBlocks'), array('a.*'))->join(array('t' => 'ContentBlocksTsl'), 'a.id = t.b_id', array('t.*'))->where('t.lng = ?', $lng); $results = $db->fetchAll($select); if ($paginator === true) { $adapter = new Base_PaginatorAdapter($select); $adapter->setMapper($this->_mapper); $data = new Zend_Paginator($adapter); $data->setCurrentPageNumber((int) $pindex); $data->setItemCountPerPage((int) $perpage); } else { $results = $db->fetchAll($select); $data = $this->_mapper->mapAll($results); } if ($cache == true) { $cacheTags = $this->generateCacheTags(get_class($this) . '_' . __FUNCTION__); $cache->save($data, $cacheId, $cacheTags); } return $data; }
public function getAll($paginator = true, $pindex = 1, $perpage = 25, $cache = true) { if ($cache == true) { $cacheId = $this->generateCacheId(get_class($this) . '_' . __FUNCTION__, func_get_args()); $cache = Zend_Registry::get('cache'); if (true == ($result = $cache->load($cacheId))) { return $result; } } $db = Zend_Registry::get('db'); $select = $db->select()->from(array('a' => 'Sheets'), array('*'))->join(array('t' => 'SheetsTsl'), 'a.id = t.s_id', array('lng', 'name', 't_desc', 't_file'))->join(array('ty' => 'SheetsSubtype'), 'a.subtype = ty.subtype_id', array())->join(array('tyt' => 'SheetsSubtypeTsl'), 'ty.subtype_id = tyt.subtype_id', array('name as subtypename'))->join(array('st' => 'SheetsType'), 'a.type = st.type_id', array())->join(array('stt' => 'SheetsTypeTsl'), 'st.type_id = stt.type_id', array('name as typename'))->where('t.lng = ?', $_SESSION['System']['lng'])->where('tyt.lng = ?', $_SESSION['System']['lng'])->where('stt.lng = ?', $_SESSION['System']['lng'])->order('st.position ASC')->order('ty.position ASC')->order('a.place ASC'); if ($paginator === true) { $adapter = new Base_PaginatorAdapter($select); $adapter->setMapper($this->_mapper); $data = new Zend_Paginator($adapter); $data->setCurrentPageNumber((int) $pindex); $data->setItemCountPerPage((int) $perpage); } else { $results = $db->fetchAll($select); $data = $this->_mapper->mapAll($results); } if ($cache == true) { $cacheTags = $this->generateCacheTags(get_class($this) . '_' . __FUNCTION__); $cache->save($data, $cacheId, $cacheTags); } return $data; }
public function getAll($lng = 'nl', $active = false, $paginator = true, $pindex = 1, $perpage = 25, $cache = true) { if ($cache == true) { $cacheId = $this->generateCacheId(get_class($this) . '_' . __FUNCTION__, func_get_args()); $cache = Zend_Registry::get('cache'); if (true == ($result = $cache->load($cacheId))) { return $result; } } $db = Zend_Registry::get('db'); $select = $db->select()->from(array('a' => 'WebTv'), array('*'))->join(array('t' => 'WebTvTsl'), 'a.id = t.webtv_id', array('url', 'lng', 'title', 'description', 'active'))->where('t.lng = ?', $lng)->order('a.date_published DESC'); if ($active) { $select->where('t.active = 1')->where('a.date_published <= CURDATE()'); } if ($paginator === true) { $adapter = new Base_PaginatorAdapter($select); $adapter->setMapper($this->_mapper); $data = new Zend_Paginator($adapter); $data->setCurrentPageNumber((int) $pindex); $data->setItemCountPerPage((int) $perpage); } else { $results = $db->fetchAll($select); $data = $this->_mapper->mapAll($results); } if ($cache == true) { $cacheTags = $this->generateCacheTags(get_class($this) . '_' . __FUNCTION__); $cache->save($data, $cacheId, $cacheTags); } return $data; }
public function getAll($paginator = true, $pindex = 1, $perpage = 25, $cache = true) { if ($cache == true) { $cacheId = 'SxModule_Pageform_Subscription_Meta_getAll_' . sha1(var_export($paginator, true) . '_' . var_export($pindex, true) . '_' . var_export($perpage, true)); $cache = Zend_Registry::get('cache'); if (true == ($result = $cache->load($cacheId))) { return $result; } } $db = Zend_Registry::get('db'); $select = $db->select()->from(array('i' => $this->_tablename()), array('*')); if ($paginator === true) { $adapter = new Base_PaginatorAdapter($select); $adapter->setMapper($this->_mapper); $data = new Zend_Paginator($adapter); $data->setCurrentPageNumber((int) $pindex); $data->setItemCountPerPage((int) $perpage); } else { $results = $db->fetchAll($select); $data = $this->_mapper->mapAll($results); } if ($cache == true) { $cacheTags = array('SxModule_Pageform_Subscription_Meta', 'SxModule_Pageform_Subscription_Meta_getAll', 'SxModule_Pageform_Subscription', 'SxModule_Pageform'); $cache->save($data, $cacheId, $cacheTags); } return $data; }
public function indexAction() { $galerias = Galeria::findGaleriasActive()->getData(); $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($galerias)); $paginator->setItemCountPerPage(20)->setPageRange(5)->setCurrentPageNumber($this->_request->getParam('page', 1)); $this->view->galerias = $paginator; }
public function indexAction() { $query = trim($this->getRequest()->getQuery('q', '')); $this->view->query = $query; if (!empty($query)) { $count = 10; $page = (int) $this->getRequest()->getQuery('p', 1); if ($page < 1) { $page = 1; } // Prepare the common options $options = array('market' => 'en-GB'); // We want web and image search results $sources = array('web' => array('count' => $count, 'offset' => $count * ($page - 1))); // Adjust the query to only search the noginn.com domain $query .= ' site:noginn.com'; // Perform the search! $bing = new Noginn_Service_Bing('__APP_ID__'); $result = $bing->search($query, $sources, $options); $webResults = $result->getSource('web'); $this->view->webResults = $webResults; // Paginate the results $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($webResults->getTotal())); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($count); $this->view->paginator = $paginator; } }
public function indexAction() { $model = new Application_Model_Clientes(); $request = $this->_request; $filter = $request->getParam('filter'); $like = NULL; if ($request->isPost()) { $data = $request->getPost(); $like = $data['search']; $this->view->data = $data; } if (is_null($filter)) { $filter = 1; } // Recuperando dados do clientes baseado no Perfil ativo. if (in_array(CURRENT_USER_ROLE, $this->_acl['fullControl'])) { $select = $model->selectAll($filter, $like); } else { $ids = implode(',', $this->_ids); $select = $model->selectByUsersIds($filter, $ids, $like); } $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select)); $paginator->setItemCountPerPage($this->_custom['itemCountPerPage'])->setCurrentPageNumber($this->_getParam('page', 1)); $this->view->paginator = $paginator; $this->view->messages = $this->_FlashMessenger->getMessages($this->_controllerName); $this->view->barTitle = "Clientes"; }
/** * List all Queues */ public function indexAction() { $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Queues"))); $this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName(); $db = Zend_Registry::get('db'); $select = $db->select()->from("queue"); if ($this->_request->getPost('filtro')) { $field = mysql_escape_string($this->_request->getPost('campo')); $query = mysql_escape_string($this->_request->getPost('filtro')); $select->where("{$field} LIKE '%{$query}%'"); } $page = $this->_request->getParam('page'); $this->view->page = isset($page) && is_numeric($page) ? $page : 1; $this->view->filtro = $this->_request->getParam('filtro'); $paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($this->view->page); $paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit); $this->view->queues = $paginator; $this->view->pages = $paginator->getPages(); $this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/"; $opcoes = array("name" => $this->view->translate("Name"), "musiconhold" => $this->view->translate("Audio Class"), "strategy" => $this->view->translate("Strategy"), "servicelevel" => $this->view->translate("SLA"), "timeout" => $this->view->translate("Timeout")); $filter = new Snep_Form_Filter(); $filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index'); $filter->setValue($this->_request->getPost('campo')); $filter->setFieldOptions($opcoes); $filter->setFieldValue($this->_request->getPost('filtro')); $filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}"); $this->view->form_filter = $filter; $this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add/", "display" => $this->view->translate("Add Queue"), "css" => "include")); }