本文整理汇总了PHP中Zend_Paginator::getTotalItemCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::getTotalItemCount方法的具体用法?PHP Zend_Paginator::getTotalItemCount怎么用?PHP Zend_Paginator::getTotalItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Paginator
的用法示例。
在下文中一共展示了Zend_Paginator::getTotalItemCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPaginationReturnModule
public function getPaginationReturnModule($query, $recordsperpage = 10, $pagenumber = 1, $api = null, $flag = null)
{
//echo "<b>api=$api</b><br>";
$obj_user = array();
$obj_create = new App_Model_Objcreation();
if ($query == "error") {
$obj_user = $obj_create->createObjfalse(3);
} else {
if ($query == "invalid") {
$obj_user = $obj_create->createObjfalse(4);
} else {
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($query));
$paginator->setItemCountPerPage($recordsperpage)->setCurrentPageNumber($pagenumber);
if ($paginator->getTotalItemCount()) {
if ($api == "category") {
$obj_user = $obj_create->createObjCategory($paginator);
} else {
if ($api == "subcategory") {
$obj_user = $obj_create->createObjSubCategory($paginator);
} else {
if ($api == "dealdet") {
$obj_user = $obj_create->createObjDealDetail($paginator, $flag);
} else {
$obj_user = $obj_create->createObj($paginator, $flag);
}
}
}
} else {
$obj_user = $obj_create->createObjfalse(1);
}
}
}
//end of else of if($category_result=="error")
return $obj_user;
}
示例2: getPages
/**
* Create the page object used in View - paginator method
* @access public
* @return object
*/
public function getPages()
{
$pages = new stdClass();
$pageCount = $this->_paginator->count();
$pages->pageCount = $pageCount;
$pages->itemCountPerPage = $this->_itemCountPerPage;
$pages->first = 1;
$pages->current = (int) $this->_currentPage;
$pages->last = $pageCount;
// Previous and next
if ($this->_currentPage - 1 > 0) {
$pages->previous = $this->_currentPage - 1;
}
if ($this->_currentPage + 1 <= $pageCount) {
$pages->next = $this->_currentPage + 1;
}
// Pages in range
$pageRange = $this->_paginator->getPageRange();
if ($pageRange > $pageCount) {
$pageRange = $pageCount;
}
$delta = ceil($pageRange / 2);
if ($this->_currentPage - $delta > $pageCount - $pageRange) {
$lowerBound = $pageCount - $pageRange + 1;
$upperBound = $pageCount;
} else {
if ($this->_currentPage - $delta < 0) {
$delta = $this->_currentPage;
}
$offset = $this->_currentPage - $delta;
$lowerBound = $offset + 1;
$upperBound = $offset + $pageRange;
}
$pages->pagesInRange = $this->_paginator->getPagesInRange($lowerBound, $upperBound);
$pages->firstPageInRange = min($pages->pagesInRange);
$pages->lastPageInRange = max($pages->pagesInRange);
// Item numbers
if ($this->_currentItems == null) {
$this->getCurrentItems();
}
if ($this->_currentItems !== null) {
$pages->currentItemCount = $this->_paginator->getCurrentItemCount();
$pages->itemCountPerPage = $this->_paginator->getItemCountPerPage();
$pages->totalItemCount = $this->_paginator->getTotalItemCount();
$pages->firstItemNumber = ($this->_currentPage - 1) * $this->_paginator->getItemCountPerPage() + 1;
$pages->lastItemNumber = $pages->firstItemNumber + $pages->currentItemCount - 1;
}
return $pages;
}
示例3: search
/**
* Returns a paginated list of all sites matching the given parameters.
*
* @param array $params
* @return array
*/
public static function search(array $params)
{
$siteDb = Yadda_Db_Table::getInstance('site');
$select = $siteDb->select()->setIntegrityCheck(false)->from('site')->joinLeft('deal', 'site.id = deal.site_id', array('latest_deal' => 'MAX(deal.created)'))->where('site.status = ?', 'active')->group('site.id')->order('site.name');
// fetch
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
$paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
$return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
$sites = new Zend_Db_Table_Rowset(array('table' => $siteDb, 'data' => (array) $paginator->getCurrentItems()));
foreach ($sites as $site) {
$return['results'][] = self::toArray($site);
}
return $return;
}
示例4: search
public static function search($params)
{
// build query
$subscriptionDb = Yadda_Db_Table::getInstance('subscription');
$select = $subscriptionDb->select()->setIntegrityCheck(false)->from('subscription')->joinLeft('user', 'subscription.user_id = user.id', array('user_email' => 'email'))->where('subscription.status = ?', 'active')->order('created DESC');
// fetch
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
$paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
$return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
$subscriptions = new Zend_Db_Table_Rowset(array('table' => $subscriptionDb, 'data' => (array) $paginator->getCurrentItems()));
foreach ($subscriptions as $subscription) {
$return['results'][] = self::toArray($subscription);
}
return $return;
}
示例5: search
/**
* Returns a paginated list of regions matching the given parameters.
*
* @param array $params
* @return array
*/
public static function search(array $params)
{
// build query
$regionDb = Yadda_Db_Table::getInstance('region');
$select = $regionDb->select()->from('region')->where('status = ?', 'active')->order('name');
// fetch
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
$paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
$return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
$regions = new Zend_Db_Table_Rowset(array('table' => $regionDb, 'data' => (array) $paginator->getCurrentItems()));
foreach ($regions as $region) {
$return['results'][] = self::toArray($region);
}
return $return;
}
示例6: testPaginator
public function testPaginator()
{
$countries = My_ShantyMongo_Country::all();
$this->assertEquals(239, $countries->count());
$paginator = new Zend_Paginator(new Shanty_Paginator_Adapter_Mongo($countries));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber(3);
$this->assertEquals(24, $paginator->count());
// Count pages
$this->assertEquals(239, $paginator->getTotalItemCount());
// count total items
$this->assertEquals(10, $paginator->getCurrentItemCount());
// count items on this page
$paginator->getCurrentItems()->rewind();
$firstItem = $paginator->getCurrentItems()->current();
$this->assertEquals($firstItem->code, 'BB');
$this->assertEquals($firstItem->name, 'Barbados');
}
示例7: consultarAction
/**
* Consulta os cancelamentos solicitados pelos contribuintes
*/
public function consultarAction()
{
if ($this->getRequest()->isPost()) {
parent::noTemplate();
$aSolicitacoes = array();
$aParametros = $this->getAllParams();
$iLimit = $aParametros['rows'];
$iPage = $aParametros['page'];
$aFiltros = array('rejeitado' => NULL, 'autorizado' => NULL);
$aOrdem = array('dt_solicitacao' => 'DESC');
$aSolicatacoesCancelamento = Contribuinte_Model_SolicitacaoCancelamento::getByAttributes($aFiltros, $aOrdem);
$oPaginatorAdapter = new DBSeller_Controller_PaginatorArray($aSolicatacoesCancelamento);
$aResultado = new Zend_Paginator($oPaginatorAdapter);
$aResultado->setItemCountPerPage($iLimit);
$aResultado->setCurrentPageNumber($iPage);
$iTotal = $aResultado->getTotalItemCount();
$iTotalPages = $aResultado->getPages()->pageCount;
foreach ($aResultado as $oSolicatacaoCancelamento) {
$sMotivo = $this->getMotivoDescricaoCancelamento($oSolicatacaoCancelamento->getMotivo());
$sData = $oSolicatacaoCancelamento->getDtSolicitacao()->format("d/m/Y");
$sRazaoSocial = $oSolicatacaoCancelamento->getNota()->getP_razao_social();
$sCpfCnpj = DBSeller_Helper_Number_Format::maskCPF_CNPJ($oSolicatacaoCancelamento->getNota()->getP_cnpjcpf());
$iNota = $oSolicatacaoCancelamento->getNota()->getNota();
// Montado objeto que será retorna à grid
$oSolicitacao = new StdClass();
$oSolicitacao->id = $oSolicatacaoCancelamento->getId();
$oSolicitacao->motivo_label = is_string($sMotivo) ? $sMotivo : "-";
$oSolicitacao->dt_solicitacao = $sData;
$oSolicitacao->nome_contribuinte = $sRazaoSocial;
$oSolicitacao->nota = $iNota;
$oSolicitacao->cnpj = $sCpfCnpj;
$aSolicitacoes[] = $oSolicitacao;
}
/**
* Parametros de retorno do AJAX
*/
$aRetornoJson = array('total' => $iTotalPages, 'page' => $iPage, 'records' => $iTotal, 'rows' => $aSolicitacoes);
echo $this->getHelper('json')->sendJson($aRetornoJson);
}
}
示例8: __construct
/**
* Constructor
*
* Registers form view helper as decorator
*
* @param mixed $options
* @return void
*/
public function __construct($select, $numberOfColumns, $itemViewscript = null, $options = null)
{
$this->_db = Zend_registry::get('db');
$_frontController = Zend_Controller_Front::getInstance();
$this->_request = $_frontController->getRequest();
if (null === $this->_view) {
require_once 'Zend/Controller/Action/HelperBroker.php';
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$this->_view = $viewRenderer->view;
}
if (!empty($options['paginationViewScript'])) {
$this->_view->assign('paginationViewScript', $options['paginationViewScript']);
} else {
$this->_view->assign('paginationViewScript', null);
}
$this->_view->assign('numberOfColumns', $numberOfColumns);
$this->_view->assign('itemViewScript', $itemViewscript);
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);
$_config = Zend_Registry::get('config');
$itemPerPage = 12;
if (!empty($_config->products->itemPerPage)) {
$itemPerPage = $_config->products->itemPerPage;
}
if (!empty($options['list_options']['perPage'])) {
$itemPerPage = $options['list_options']['perPage'];
}
if ($this->_request->getParam('perPage')) {
$itemPerPage = $this->_request->getParam('perPage') == 'all' ? $paginator->getTotalItemCount() : $this->_request->getParam('perPage');
}
$pageRange = 5;
if (!empty($_config->products->pageRange)) {
$pageRange = $_config->products->pageRange;
}
$paginator->setItemCountPerPage($itemPerPage);
$paginator->setCurrentPageNumber($this->_request->getParam('page'));
$paginator->setPageRange($pageRange);
$this->_view->assign('paginator', $paginator);
}
示例9: listarContasAction
/**
* Action responsável por listar as contas
*/
public function listarContasAction()
{
if ($this->getRequest()->isPost()) {
parent::noTemplate();
$aRecord = array();
$iLimit = $this->_request->getParam('rows');
$iPage = $this->_request->getParam('page');
$sSord = $this->_request->getParam('sord');
$oPaginatorAdapter = new DBSeller_Controller_Paginator(Contribuinte_Model_PlanoContaAbrasf::getQuery(), 'Contribuinte_Model_PlanoContaAbrasf', 'Contribuinte\\PlanoContaAbrasf');
/**
* Ordena os registros
*/
$oPaginatorAdapter->orderBy("e.id, e.conta_abrasf", $sSord);
/**
* Monta a paginação do GridPanel
*/
$oResultado = new Zend_Paginator($oPaginatorAdapter);
$oResultado->setItemCountPerPage($iLimit);
$oResultado->setCurrentPageNumber($iPage);
$iTotal = $oResultado->getTotalItemCount();
$iTotalPages = $iTotal > 0 && $iLimit > 0 ? ceil($iTotal / $iLimit) : 0;
foreach ($oResultado as $oPlanoContaAbrasf) {
$oDadosColuna = new StdClass();
$oDadosColuna->id = $oPlanoContaAbrasf->getId();
$oDadosColuna->conta_abrasf = $oPlanoContaAbrasf->getContaAbrasf();
$oDadosColuna->titulo_contabil_desc = $oPlanoContaAbrasf->getTituloContabilDesc();
$oDadosColuna->tributavel = $oPlanoContaAbrasf->getTributavel();
$oDadosColuna->obrigatorio = $oPlanoContaAbrasf->getObrigatorio();
$aRecord[] = $oDadosColuna;
}
/**
* Parametros de retorno do AJAX
*/
$aRetornoJson = array('total' => $iTotalPages, 'page' => $iPage, 'records' => $iTotal, 'rows' => $aRecord);
echo $this->getHelper('json')->sendJson($aRetornoJson);
}
}
示例10: _createGridData
/**
* Create the grid data structure
*
* @return object
*/
protected function _createGridData(Zend_Controller_Request_Abstract $request)
{
// Instantiate Zend_Paginator with the required data source adaptor
if (!$this->_paginator instanceof Zend_Paginator) {
$this->_paginator = new Zend_Paginator($this->_adapter);
$this->_paginator->setDefaultItemCountPerPage($request->getParam('rows', $this->_defaultItemCountPerPage));
}
// Filter items by supplied search criteria
if ($request->getParam('_search') == 'true') {
$filter = $this->_getFilterParams($request);
$this->_paginator->getAdapter()->filter($filter['field'], $filter['value'], $filter['expression'], $filter['options']);
}
// Sort items by the supplied column field
if ($request->getParam('sidx')) {
$this->_paginator->getAdapter()->sort($request->getParam('sidx'), $request->getParam('sord', 'asc'));
}
// Pass the current page number to paginator
$this->_paginator->setCurrentPageNumber($request->getParam('page', 1));
// Fetch a row of items from the adapter
$rows = $this->_paginator->getCurrentItems();
$grid = new stdClass();
$grid->page = $this->_paginator->getCurrentPageNumber();
$grid->total = $this->_paginator->getItemCountPerPage();
$grid->records = $this->_paginator->getTotalItemCount();
$grid->rows = array();
foreach ($rows as $k => $row) {
if (isset($row['id'])) {
$grid->rows[$k]['id'] = $row['id'];
}
$grid->rows[$k]['cell'] = array();
foreach ($this->_columns as $column) {
array_push($grid->rows[$k]['cell'], $column->cellValue($row));
}
}
return $grid;
}
示例11: __construct
//.........这里部分代码省略.........
$this->_view->assign('disable_export_to_excel', $options['disable-export-to-excel']);
} else {
$this->_view->assign('disable_export_to_excel', 'false');
}
if (!empty($options['enable-print'])) {
$this->_view->assign('enable_print', $options['enable-print']);
$this->_view->headScript()->appendFile($this->_view->locateFile('jquery.printElement.min.js'));
} else {
$this->_view->assign('enable_print', 'false');
}
if (!empty($options['filters'])) {
$this->_view->assign('filters', $options['filters']);
foreach ($options['filters'] as $key => $filter) {
$filter_val = $this->_request->getParam($key);
if (!empty($filter_val)) {
if ($filter['associatedTo'] != '') {
if (!empty($filter['kindOfFilter']) && $filter['kindOfFilter'] == 'list') {
$select->where("{$filter['associatedTo']} = '{$filter_val}'\r\n OR {$filter['associatedTo']} like '%{$filter_val}%'\r\n OR {$filter['associatedTo']} like '%,{$filter_val}'\r\n OR {$filter['associatedTo']} like '{$filter_val},%'\r\n OR {$filter['associatedTo']} like '%,{$filter_val},%'\r\n ");
} else {
$select->where("{$filter['associatedTo']} = ?", $filter_val);
}
}
}
}
} else {
$this->_view->assign('filters', array());
}
if (!empty($options['action_panel'])) {
if (!empty($options['action_panel'])) {
$field_list['action_panel'] = $options['action_panel'];
}
if (!empty($options['action_panel']['actions'])) {
$this->_view->assign('action_links', $options['action_panel']['actions']);
}
}
$this->_view->assign('field_list', $field_list);
if ($this->_request->getParam('order')) {
if (in_array($this->_request->getParam('order'), array_keys($field_list))) {
$direction = 'ASC';
if (in_array($this->_request->getParam('order-direction'), array('ASC', 'DESC'))) {
$direction = $this->_request->getParam('order-direction');
}
$select->order("{$this->_request->getParam('order')} {$direction}");
$this->_view->assign('order', $this->_request->getParam('order'));
$this->_view->assign('order_direction', $this->_request->getParam('order-direction'));
}
}
$searchfor = $this->_request->getParam('searchfor');
if ($searchfor) {
$searching_on = array();
$search_keywords = explode(' ', $searchfor);
foreach ($tables as $table => $columns) {
foreach ($columns as $column) {
$doSearch = true;
if (isset($options['onlyColumns'])) {
if (!in_array($column, $options['onlyColumns'])) {
$doSearch = false;
}
} else {
if (isset($options['excludedColums'])) {
if (in_array($column, $options['excludedColums'])) {
$doSearch = false;
}
}
}
if ($doSearch == true) {
array_push($searching_on, $this->_db->quoteInto("{$table}.{$column} LIKE ?", "%{$searchfor}%"));
foreach ($search_keywords as $keyword) {
array_push($searching_on, $this->_db->quoteInto("{$table}.{$column} LIKE ?", "%{$keyword}%"));
}
}
}
}
if (!empty($searching_on)) {
$select->where(implode(' OR ', $searching_on));
}
}
$this->_view->assign('searchfor', $searchfor);
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);
$_config = Zend_Registry::get('config');
$itemPerPage = 10;
if (!empty($_config->lists->itemPerPage)) {
$itemPerPage = $_config->lists->itemPerPage;
}
if (!empty($options['list_options']['perPage'])) {
$itemPerPage = $options['list_options']['perPage'];
}
if ($this->_request->getParam('perPage')) {
$itemPerPage = $this->_request->getParam('perPage') == 'all' ? $paginator->getTotalItemCount() : $this->_request->getParam('perPage');
}
$pageRange = 5;
if (!empty($_config->lists->pageRange)) {
$pageRange = $_config->lists->pageRange;
}
$paginator->setItemCountPerPage($itemPerPage);
$paginator->setCurrentPageNumber($this->_request->getParam('page'));
$paginator->setPageRange($pageRange);
$this->_view->assign('paginator', $paginator);
}
示例12: retornaContasGuiaDesif
/**
* Método para retornar os dados das contas em formato json para a DBJqGrid
*
* @param array $aParametros
* @param bool $bDetalhes
* @return array
*/
protected function retornaContasGuiaDesif(array $aParametros, $bDetalhes = FALSE)
{
$aRecord = array();
$iLimit = $aParametros['rows'];
$iPage = $aParametros['page'];
$sSord = $aParametros['sord'];
$oContribuinte = $this->_session->contribuinte;
$sCodigosContribuintes = NULL;
$oPaginatorAdapter = new DBSeller_Controller_Paginator(Contribuinte_Model_ImportacaoDesif::getQuery(), 'Contribuinte_Model_ImportacaoDesif', 'Contribuinte\\ImportacaoDesif');
foreach ($oContribuinte->getContribuintes() as $iIdContribuinte) {
if ($sCodigosContribuintes == NULL) {
$sCodigosContribuintes .= $iIdContribuinte;
} else {
$sCodigosContribuintes .= ',' . $iIdContribuinte;
}
}
$oPaginatorAdapter->where("e.contribuinte in ({$sCodigosContribuintes})");
if (isset($aParametros['id'])) {
$oPaginatorAdapter->andWhere("e.id = {$aParametros['id']}");
}
$oPaginatorAdapter->orderBy("e.competencia_inicial, e.competencia_final", $sSord);
/**
* Monta a paginação do GridPanel
*/
$oResultado = new Zend_Paginator($oPaginatorAdapter);
$oResultado->setItemCountPerPage($iLimit);
$oResultado->setCurrentPageNumber($iPage);
foreach ($oResultado as $oDesif) {
$aValores = Contribuinte_Model_ImportacaoDesif::getTotalReceitasGuia($oDesif->getId(), $bDetalhes);
/**
* Verifica se for para exibir as aliquotas detalhadas
*/
if ($bDetalhes) {
foreach ($aValores['aliquotas_issqn'] as $iAliqIssqn => $aReceitas) {
$aRecord[] = array('id_importacao_desif' => $oDesif->getId(), 'aliq_issqn' => DBSeller_Helper_Number_Format::toFloat($iAliqIssqn), 'total_receita' => DBSeller_Helper_Number_Format::toMoney($aReceitas['total_receita'], 2, 'R$ '), 'total_iss' => DBSeller_Helper_Number_Format::toMoney($aReceitas['total_iss'], 2, 'R$ '));
}
} else {
if ($aValores['total_receita'] > 0 && $aValores['total_iss'] > 0) {
$aRecord[] = array('id' => $oDesif->getId(), 'competencia_inicial' => $oDesif->getCompetenciaInicial(), 'competencia_final' => $oDesif->getCompetenciaFinal(), 'total_receita' => DBSeller_Helper_Number_Format::toMoney($aValores['total_receita'], 2, 'R$ '), 'total_iss' => DBSeller_Helper_Number_Format::toMoney($aValores['total_iss'], 2, 'R$ '), 'aValores' => $aValores);
}
}
}
$iTotal = $oResultado->getTotalItemCount();
$iTotalPages = $iTotal > 0 && $iLimit > 0 ? ceil($iTotal / $iLimit) : 0;
/**
* Parametros de retorno do AJAX
*/
$aRetornoJson = array('total' => $iTotalPages, 'page' => $iPage, 'records' => $iTotal, 'rows' => $aRecord);
return $aRetornoJson;
}
示例13: indexAction
//.........这里部分代码省略.........
}
$this->view->search = $filters;
// END:FILTERS
//BEGIN:SEARCH FORM
$formSearch = new Default_Form_FileManagerSearch();
$formSearch->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/file-manager-search.phtml'))));
$this->view->formSearch = $formSearch;
//END:SEARCH FORM
//BEGIN:FORM ADD
$replyId = $this->getRequest()->getParam('replyId');
$form = new Default_Form_FileManager();
$form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/file-manager.phtml'))));
$this->view->form = $form;
$formshare = new Default_Form_ShareFile();
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
if (!empty($post['action']) && $post['action'] == 'add') {
//if is valid save message
if ($form->isValid($this->getRequest()->getPost())) {
//BEGIN:SAVE ATTACHMENTS
if (!empty($post['galleryFiles']) && is_array($post['galleryFiles'])) {
foreach ($post['galleryFiles'] as $valuesGallery) {
$tmpFiles = new Default_Model_TempFiles();
if ($tmpFiles->find($valuesGallery)) {
$post = $this->getRequest()->getPost();
$gallery = new Default_Model_FileManager();
$gallery->setOptions($form->getValues());
$gallery->setType($tmpFiles->getFileType());
$gallery->setSize($tmpFiles->getFileSize());
$gallery->setModule('sharedfiles');
$gallery->setName($tmpFiles->getFileName());
$savedId = $gallery->save();
if ($savedId) {
$shared = new Default_Model_SharedList();
$shared->setIdUser(Zend_Registry::get('user')->getId());
$shared->setIdFile($savedId);
$shared->save();
}
//copy picture and crop
$tempFile = APPLICATION_PUBLIC_PATH . '/media/temps/' . $tmpFiles->getFileName();
$targetFile = APPLICATION_PUBLIC_PATH . '/media/files/' . $tmpFiles->getFileName();
@copy($tempFile, $targetFile);
@unlink($tempFile);
$tmpFiles->delete();
}
}
//END:SAVE ATTACHMENTS
$this->_flashMessenger->addMessage("<div class='success canhide'><p>Your file was succesfully uploaded.</p><a href='javascript:;'></a></div>");
} else {
$this->_flashMessenger->addMessage("<div class='failure canhide'><p>Error uploading file!</p><a href='javascript:;'></a></div>");
}
$this->_redirect(WEBROOT . 'file-manager');
}
}
if (!empty($post['action']) && $post['action'] == 'sharefile') {
//if is valid save shared file message
if ($formshare->isValid($this->getRequest()->getPost())) {
$model = new Default_Model_Messages();
$model->setOptions($formshare->getValues());
$model->setIdUserFrom(Zend_Registry::get('user')->getId());
$model->save();
//BEGIN:SAVE ATTACHMENTS
$shared = new Default_Model_SharedList();
$shared->setOptions($formshare->getValues());
//echo $formshare->getValue('idUserTo');
//die();//aici e ok
$shared->setIdUser($formshare->getValue('idUserTo'));
//aici nu seteaza
$shared->save();
//END:SAVE ATTACHMENTS
$this->_flashMessenger->addMessage("<div class='success canhide'><p>Your file was succesfully shared.</p><a href='javascript:;'></a></div>");
} else {
$this->_flashMessenger->addMessage("<div class='failure canhide'><p>Error sharing file!</p><a href='javascript:;'></a></div>");
}
$this->_redirect(WEBROOT . 'file-manager');
}
}
//END:FORM ADD
//BEGIN:LISTING
$model = new Default_Model_FileManager();
$select = $model->getMapper()->getDbTable()->select();
//if(!empty($type) && $type == 'sent'){ //sent
$select->from(array('sl' => 'shared_list'), array('sl.idUser', 'sl.created'))->joinLeft(array('uf' => 'uploaded_files'), 'uf.id = sl.idFile', array('uf.id', 'uf.name', 'uf.description', 'uf.type', 'uf.size'))->where('sl.idUser = ?', Zend_Registry::get('user')->getId())->where('NOT sl.deleted');
// }
if (!empty($searchTxt)) {
$select->where("uf.name LIKE ('%" . $searchTxt . "%') OR uf.description LIKE ('%" . $searchTxt . "%')");
}
$select->order('sl.created DESC')->setIntegrityCheck(false);
// pagination
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setPageRange(5);
Zend_Paginator::setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial(array('_pagination.phtml', $filters));
$this->view->result = $paginator;
$this->view->itemCountPerPage = $paginator->getItemCountPerPage();
$this->view->totalItemCount = $paginator->getTotalItemCount();
//END:LISTING
}
示例14: businessAction
/**
* Job basic for seo.
* show all the jobs in the city.
* @return unknown_type
*/
function businessAction()
{
//echo "jobs";
$this->view = $this->_setRequiredParamsToView($this->view);
$this->view->category = $this->_busType;
try {
$this->view->business = $this->getBusiness();
$this->view->form = $this->getForm($this->view->business, $this->view->location);
//$values['cat4'] = Location::getStateIdByName($this->view->location->getState());
// $values['cat5'] = Location::getCityIdByName($this->view->location->getCity());
$cat1 = $this->view->paramsHolder->cat1;
$additonalData = $this->_getAdditionalData($this->view);
$select = $this->view->business->search($this->view->location, $this->view->limit, $this->view->offset, $this->view->paramsHolder->query, $cat1, $this->view->paramsHolder->cat2, $this->view->paramsHolder->cat3, $this->view->paramsHolder->cat4, $this->view->paramsHolder->cat5, $additonalData);
if (!empty($select)) {
logfire('------select: ', $select->__toString());
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($this->view->limit);
$paginator->setCurrentPageNumber($this->view->offset);
Zend_Paginator::setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial('sitetemplate/_pagination.phtml');
$this->view->currentItemCount = $paginator->getCurrentItemCount();
$this->view->itemCount = $paginator->getTotalItemCount();
//echo '------currentItemCoutn: ' . $this->view->currentItemCount;
$paginator->setView($this->view);
$this->view->postings = $paginator;
/*
foreach($this->view->postings as $key=>$value)
{
print_r($value);break;
}
*/
}
} catch (Exception $e) {
echo $e;
}
//$this->renderScript('jobs/index.phtml');
// echo Tag::link('jobsbasic',$this->view->location->toStdClass(),'test');
}
示例15: indexAction
//.........这里部分代码省略.........
$params['fromDate'] = date("Y-m-d", strtotime($this->getRequest()->getParam('fromDate')));
}
if ($this->getRequest()->getParam('toDate')) {
$params['toDate'] = date("Y-m-d", strtotime($this->getRequest()->getParam('toDate')));
}
//BEGIN:SELECT EXPENSES
$conditions['pagination'] = true;
$expenses = new Default_Model_RecurrentExpenses();
$select = $expenses->getMapper()->getDbTable()->select()->from(array('p' => 'recurrent_expenses'), array('p.id', 'p.name', 'p.price', 'p.date', 'p.created', 'p.deleted'))->where('p.type=?', 0)->where('NOT p.deleted')->where('idMember=?', Zend_Registry::get('user')->getId());
if (!empty($params['nameSearch'])) {
$select->where('p.name LIKE ?', '%' . $params['nameSearch'] . '%');
}
if (!empty($params['idGroupSearch'])) {
$select->where('p.idGroup = ?', $params['idGroupSearch']);
}
if (!empty($params['fromDate'])) {
$select->where('p.date >= ?', $params['fromDate']);
}
if (!empty($params['toDate'])) {
$select->where('p.date <= ?', $params['toDate']);
}
$select->joinLeft(array('uf' => 'uploaded_files'), 'p.`id` = uf.`idMessage`', array('ufiles' => 'uf.id', 'recurrent' => 'uf.idUser'))->setIntegrityCheck(false);
$select->order(array('date DESC'));
$resultExpense = Needs_Tools::showRecurrentExpensesDashboardbyDate(!empty($params['fromDate']) ? $params['fromDate'] : date('Y-m-01'), !empty($params['toDate']) ? $params['toDate'] : date('Y-m-d'));
$this->view->resultExpense = $resultExpense;
//END:SELECT PROJECTS
$form = new Default_Form_RecurrentExpenses();
$form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/recurrent-expenses/add-expense.phtml'))));
$this->view->form = $form;
if ($this->getRequest()->isPost() && $this->getRequest()->getParam('control') == 'addExpense') {
if ($form->isValid($this->getRequest()->getPost())) {
$post = $this->getRequest()->getPost();
$model = new Default_Model_RecurrentExpenses();
$model->setOptions($form->getValues());
$model->setDate(date("Y-m-d", strtotime($post["date"])));
$model->setType('0');
$idGroup = $this->getRequest()->getParam('idGroup');
$model->setIdGroup($idGroup);
if ($expenseId = $model->save()) {
if (!empty($post['galleryFiles']) && is_array($post['galleryFiles'])) {
foreach ($post['galleryFiles'] as $valuesGallery) {
$tmpFiles = new Default_Model_TempFiles();
if ($tmpFiles->find($valuesGallery)) {
$post = $this->getRequest()->getPost();
$gallery = new Default_Model_FileManager();
$gallery->setOptions($form->getValues());
$gallery->setType($tmpFiles->getFileType());
$gallery->setSize($tmpFiles->getFileSize());
$gallery->setModule('sharedfiles');
$gallery->setIdMessage($expenseId);
$gallery->setIdUser(1);
$gallery->setName($tmpFiles->getFileName());
$savedId = $gallery->save();
if ($savedId) {
$shared = new Default_Model_SharedList();
$shared->setIdUser(Zend_Registry::get('user')->getId());
$shared->setIdFile($savedId);
$shared->save();
}
//copy picture and crop
$tempFile = APPLICATION_PUBLIC_PATH . '/media/temps/' . $tmpFiles->getFileName();
$targetFile = APPLICATION_PUBLIC_PATH . '/media/files/' . $tmpFiles->getFileName();
@copy($tempFile, $targetFile);
@unlink($tempFile);
$tmpFiles->delete();
}
}
//END:SAVE ATTACHMENTS
}
$idGroup = $this->getRequest()->getParam('idGroup');
$modelGroup = new Default_Model_ProductGroups();
$modelGroup->setIdProduct($expenseId);
$modelGroup->setIdGroup($idGroup);
$modelGroup->setRepeated(1);
$modelGroup->save();
//mesaj de succes
$this->_flashMessenger->addMessage("<div class='success canhide'><p>Recurrent expense was added successfully<a href='javascript:;'></a><p></div>");
} else {
//mesaj de eroare
$this->_flashMessenger->addMessage("<div class='failure canhide'><p>Recurrent expense was not added<a href='javascript:;'></a><p></div>");
}
//redirect
$this->_redirect(WEBROOT . 'recurrent-expenses');
}
}
$formsearch = new Default_Form_RecurrentExpenseSearch();
$formsearch->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/recurrent-expenses/expense-search.phtml'))));
$this->view->formsearch = $formsearch;
$this->view->search = $params;
// pagination
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setItemCountPerPage(15);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setPageRange(5);
Zend_Paginator::setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial(array('_pagination.phtml', $params));
$this->view->result = $paginator;
$this->view->itemCountPerPage = $paginator->getItemCountPerPage();
$this->view->totalItemCount = $paginator->getTotalItemCount();
}