Exemple #1
0
    public function indexAction() {
        // Don't render this if not authorized
        $viewer = Engine_Api::_()->user()->getViewer();
        if (!Engine_Api::_()->core()->hasSubject()) {
            return $this->setNoRender();
        }

        // Get subject and check auth
        $subject = Engine_Api::_()->core()->getSubject();
        if (!$subject->authorization()->isAllowed($viewer, 'view')) {
            return $this->setNoRender();
        }

        // Get paginator
        $profile_owner_id = $subject->getIdentity();
        $playlistTable = Engine_Api::_()->getItemTable('ynvideo_playlist');
        $select = $playlistTable->select();
        $select->where('user_id = ?', $profile_owner_id);
        $select->where('search = 1');
        $this->view->paginator = $paginator = Zend_Paginator::factory($select);
        
        // Set item count per page and current page number
        $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 10));
        $paginator->setCurrentPageNumber($this->_getParam('page', 1));
        
        // Do not render if nothing to show
        if ($paginator->getTotalItemCount() <= 0) {
            return $this->setNoRender();
        } else {
            $this->_childCount = $paginator->getTotalItemCount();
        }
    }
 /**
  * The default action - show the home page
  */
 public function indexAction()
 {
     $loai = $this->_getParam('loai', 'dhsg');
     $table = Khcn_Api::_()->getDbTable('he_cao_hoc', 'default');
     $this->view->he_cao_hoc = $he_cao_hoc = $table->fetchRow($table->select()->where('name = ?', $loai));
     if (!$he_cao_hoc) {
         $this->_redirect('index');
     }
     // TODO Auto-generated {0}::indexAction() default action
     $params = array('trang_thai' => true, 'limit' => 20, 'he_cao_hoc' => $he_cao_hoc->getIdentity());
     $danhSach = Khcn_Api::_()->getDbTable('lich_hoc', 'default')->getPaginator($params);
     $paginator = Zend_Paginator::factory($danhSach);
     $currentPage = 1;
     //Check if the user is not on page 1
     $page = $this->_getParam('page');
     if (!empty($page)) {
         //Where page is the current page
         $currentPage = $this->_getParam('page');
     }
     //Set the properties for the pagination
     $paginator->setItemCountPerPage(15);
     $paginator->setPageRange(10);
     $paginator->setCurrentPageNumber($currentPage);
     Zend_Paginator::setDefaultScrollingStyle('Sliding');
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml');
     $paginator->setView($this->view);
     $this->view->paginator = $paginator;
 }
 public function listAction()
 {
     $elementSetName = $this->_getParam('elset');
     $elementName = $this->_getParam('elname');
     $curPage = $this->_getParam('page');
     $elementTextTable = $this->getDb()->getTable('ElementText');
     $el = $this->getDb()->getTable('Element')->findByElementSetNameAndElementName($this->_unslugify($elementSetName), $this->_unslugify($elementName));
     //$elTexts = $this->getDb()->getTable('ElementText')->findByElement($el->id);
     $select = $elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text');
     $elTexts = $elementTextTable->fetchObjects($select);
     //$sortedTexts = $elTexts->getSelect()->findByElement($el->id)->order('text');
     $totalCategories = count($elTexts);
     release_object($el);
     // set-up pagination routine
     $paginationUrl = $this->getRequest()->getBaseUrl() . '/categories/list/' . $elementSetName . '/' . $elementName . "/";
     /*
     $pageAdapter = new Zend_Paginator_Adapter_DbSelect($elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text'));
     */
     $paginator = Zend_Paginator::factory($select);
     $paginator->setItemCountPerPage(20);
     //$totalCategories = count($paginator);
     $paginator->setCurrentPageNumber($curPage);
     $this->view->paginator = $paginator;
     //Serve up the pagination
     // add other pagination items
     $pagination = array('page' => $curPage, 'per_page' => 20, 'total_results' => $totalCategories, 'link' => $paginationUrl);
     Zend_Registry::set('pagination', $pagination);
     //$this->view->assign(array('texts'=>$elTexts, 'elset'=>$elementSetName, 'elname'=>$elementName, 'total_results'=>$totalCategories));
     $this->view->assign(array('elset' => $elementSetName, 'elname' => $elementName, 'total_results' => $totalCategories));
 }
Exemple #4
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $viewer = Engine_Api::_()->user()->getViewer();
     if (!Engine_Api::_()->core()->hasSubject()) {
         return $this->setNoRender();
     }
     // Get subject and check auth
     $subject = Engine_Api::_()->core()->getSubject('group');
     if (!$subject->authorization()->isAllowed($viewer, 'view')) {
         return $this->setNoRender();
     }
     // Get paginator
     $table = Engine_Api::_()->getItemTable('advgroup_topic');
     $select = $table->select()->where('group_id = ?', Engine_Api::_()->core()->getSubject()->getIdentity())->order('post_count DESC');
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 5));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Do not render if nothing to show and not viewer
     if ($paginator->getTotalItemCount() <= 0 && !$viewer->getIdentity()) {
         return $this->setNoRender();
     }
     $this->view->canPost = Engine_Api::_()->authorization()->isAllowed($subject, $viewer, 'comment');
     // Add count to title if configured
     //    if( $this->_getParam('titleCount', false) && $paginator->getTotalItemCount() > 0 ) {
     //      $this->_childCount = $paginator->getTotalItemCount();
     //    }
 }
 public function indexAction()
 {
     $this->view->Title = "Group User Manager";
     $this->view->headTitle($this->view->Title, true);
     $tbl_group = new Manager_Model_group();
     if ($this->_request->getPost('keyword') != NULL) {
         $keyword = $this->_request->getParam('keyword');
         $this->view->keyword = $keyword;
         $listArticles = $tbl_group->searchkq($keyword);
         $currentPage = 1;
         $i = $this->_getParam('page', 1);
         if (!empty($i)) {
             $currentPage = $i;
         }
         $paginator = Zend_Paginator::factory($listArticles);
         $paginator->setItemCountPerPage(45)->setPageRange(5)->setCurrentPageNumber($currentPage);
         $this->view->paginator = $paginator;
     } else {
         $listArticles = $tbl_group->get_info();
         $currentPage = 1;
         $i = $this->_getParam('page', 1);
         if (!empty($i)) {
             $currentPage = $i;
         }
         $paginator = Zend_Paginator::factory($listArticles);
         $paginator->setItemCountPerPage(45)->setPageRange(45)->setCurrentPageNumber($currentPage);
         $this->view->paginator = $paginator;
     }
 }
Exemple #6
0
	public function fetchAllJoin($key,$condition)
	{
		$select = $this->select()
						->setIntegrityCheck(false)
						->from(array('v' => 've_verecords'))
						->join(array('e'=>'em_contacts'),'e.contactId = v.contactId',array('contactName'))
						->join(array('h'=>'ve_vehicles'),'h.veId = v.veId');
		if($condition[1] != null)
		{
			if($condition[1] == 'plateNo')
			{
				$select->where('h.plateNo like ?','%'.$key.'%');
				}
				elseif($condition[1] == 'date')
				{
					$select->where('startDate <= ?',$key)
						->where('endDate >= ?',$key);
					}
					elseif($condition[1] == 'contactName')
					{
						$select->where('e.contactName like ?','%'.$key.'%');
							}
			}
		if($condition[0] != null)
		{
			$select->where('v.projectId = ?', $condition[0]);
			}
			else
			{
				$select->where('v.prjFlag = 0');
				}
		$paginator = Zend_Paginator::factory($select);
		return $paginator;
		}
Exemple #7
0
 public function indexAction()
 {
     // Should we consider creation or modified recent?
     $recentType = $this->_getParam('recentType', 'creation');
     if (!in_array($recentType, array('creation', 'modified'))) {
         $recentType = 'creation';
     }
     $this->view->recentType = $recentType;
     $this->view->recentCol = $recentCol = $recentType . '_date';
     // Get paginator
     $table = Engine_Api::_()->getItemTable('video');
     $select = $table->select()->where('search = ?', 1)->where('status = ?', 1);
     if ($recentType == 'creation') {
         // using primary should be much faster, so use that for creation
         $select->order('video_id DESC');
     } else {
         $select->order($recentCol . ' DESC');
     }
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 4));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Hide if nothing to show
     if ($paginator->getTotalItemCount() <= 0) {
         return $this->setNoRender();
     }
 }
 public function indexAction()
 {
     //    	$this->view->headMeta()->appendName('description', '');
     //     	$this->view->headLink()->prependStylesheet($this->view->baseUrl('/modules/default/css/file.css'));
     //     	$this->view->headScript()->prependFile($this->view->baseUrl('/js/file.js'));
     $this->view->breadcrumb = array($this->title => 'gestao/contato');
     if ($this->getRequest()->isPost()) {
         $this->view->date = $date = $this->getRequest()->getPost('date');
         $this->view->dateEnd = $dateEnd = $this->getRequest()->getPost('dateEnd');
         if (!empty($date)) {
             $dateArray = explode('-', $date);
             $date = $dateArray[2] . '-' . $dateArray[1] . '-' . $dateArray[0];
         } else {
             $date = null;
         }
         if (!empty($dateEnd)) {
             $dateArray = explode('-', $dateEnd);
             $dateEnd = $dateArray[2] . '-' . $dateArray[1] . '-' . $dateArray[0];
         } else {
             $dateEnd = null;
         }
         $rs = $this->_service->getAll($date, $dateEnd);
     } else {
         $rs = $this->_service->getAll();
     }
     $rs = $rs ? $rs : array();
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($rs);
     $paginator->setItemCountPerPage(20);
     $paginator->setCurrentPageNumber($page);
     $this->view->rs = $paginator;
 }
Exemple #9
0
 public function indexAction()
 {
     // Check subject
     if (!Engine_Api::_()->core()->hasSubject('video')) {
         return $this->setNoRender();
     }
     $this->view->subject = $subject = Engine_Api::_()->core()->getSubject('video');
     // Set default title
     if (!$this->getElement()->getTitle()) {
         $this->getElement()->setTitle('People Also Liked');
     }
     // Get likes
     $itemTable = Engine_Api::_()->getItemTable($subject->getType());
     $likesTable = Engine_Api::_()->getDbtable('likes', 'core');
     $likesTableName = $likesTable->info('name');
     $select = $itemTable->select()->distinct(true)->from($itemTable)->joinLeft($likesTableName, $likesTableName . '.resource_id=video_id', null)->joinLeft($likesTableName . ' as l2', $likesTableName . '.poster_id=l2.poster_id', null)->where($likesTableName . '.poster_type = ?', 'user')->where('l2.poster_type = ?', 'user')->where($likesTableName . '.resource_type = ?', $subject->getType())->where('l2.resource_type = ?', $subject->getType())->where($likesTableName . '.resource_id != ?', $subject->getIdentity())->where('l2.resource_id = ?', $subject->getIdentity())->where('search = ?', true)->where('video_id != ?', $subject->getIdentity());
     // Get paginator
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 4));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Hide if nothing to show
     if ($paginator->getTotalItemCount() <= 0) {
         return $this->setNoRender();
     }
 }
Exemple #10
0
 public function indexAction()
 {
     // Should we consider views or comments popular?
     $popularType = $this->_getParam('popularType', 'comment');
     if (!in_array($popularType, array('comment', 'view'))) {
         $popularType = 'comment';
     }
     $this->view->popularType = $popularType;
     $this->view->popularCol = $popularCol = $popularType . '_count';
     // Get paginator
     $parentTable = Engine_Api::_()->getItemTable('album');
     $parentTableName = $parentTable->info('name');
     $table = Engine_Api::_()->getItemTable('album_photo');
     $tableName = $table->info('name');
     $select = $table->select()->from($tableName)->joinLeft($parentTableName, $parentTableName . '.album_id=' . $tableName . '.album_id', null)->where($parentTableName . '.search = ?', true)->order($popularCol . ' DESC');
     // Create new array filtering out private albums
     $viewer = Engine_Api::_()->user()->getViewer();
     $photo_select = $select;
     $new_select = array();
     $i = 0;
     foreach ($photo_select->getTable()->fetchAll($photo_select) as $photo) {
         if (Engine_Api::_()->authorization()->isAllowed($photo, $viewer, 'view')) {
             $new_select[$i++] = $photo;
         }
     }
     $this->view->paginator = $paginator = Zend_Paginator::factory($new_select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 4));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Do not render if nothing to show
     if ($paginator->getTotalItemCount() <= 0) {
         return $this->setNoRender();
     }
 }
Exemple #11
0
 public function indexAction()
 {
     $entries = new Entry();
     // test memcached
     if (extension_loaded('memcache')) {
         $mem = new Memcache();
         $mem->addServer('localhost', 11211);
         $result = $mem->get('indexContent');
         if (!$result) {
             $result = $entries->fetchLatest(100);
             $mem->set('indexContent', $result, 0, 4);
         }
     } else {
         $result = $entries->fetchLatest(100);
     }
     if ($result) {
         $this->view->entries = $result;
         // Zend_Paginator
         $page = $this->_request->getParam('page', 1);
         $paginator = Zend_Paginator::factory($result);
         $paginator->setItemCountPerPage(4);
         $paginator->setCurrentPageNumber($page);
         $this->view->paginator = $paginator;
     }
 }
 /**
  * @param $data data in to be shown on view
  */
 public function direct($currentPage, $data)
 {
     $paginator = Zend_Paginator::factory($data);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($currentPage);
     return $paginator;
 }
Exemple #13
0
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_All();
     $this->_paginator = Zend_Paginator::factory(range(1, 101));
     $this->_paginator->setItemCountPerPage(10);
 }
 public function doSearchAction()
 {
     $keyword = $this->_getParam("keyword");
     if ($keyword) {
         $perPage = 20;
         $curPage = (int) $this->_getParam('page');
         $start = 0;
         if ($curPage > 0) {
             $start = ($curPage - 1) * $perPage;
         }
         $searchObj = new VC_Business_Search();
         $result = $searchObj->searchProcess($this->userId, $keyword, array('count' => $perPage, 'offset' => $start));
         //var_dump($result);die;
         $result['numFound'] = (int) $result['numFound'];
         if ($result['numFound'] > $perPage) {
             $paginator = Zend_Paginator::factory($result['numFound']);
             $paginator->setItemCountPerPage($perPage);
             $paginator->setCurrentPageNumber($curPage);
             $this->view->paginator = $paginator;
         }
         $this->view->listArticle = $result['list'];
         $this->view->keyword = $keyword;
     } else {
         return $this->render("index");
     }
 }
Exemple #15
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
     if (!Engine_Api::_()->core()->hasSubject()) {
         return $this->setNoRender();
     }
     // Get subject and check auth
     $subject = Engine_Api::_()->core()->getSubject();
     if (!$subject->authorization()->isAllowed($viewer, 'view')) {
         return $this->setNoRender();
     }
     // Get paginator
     $table = Engine_Api::_()->getDbtable('links', 'core');
     $select = $table->select()->where('parent_type = ?', $subject->getType())->where('parent_id = ?', $subject->getIdentity())->where('search = ?', 1)->order('creation_date DESC');
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     $paginator->setCurrentPageNumber($this->_getParam('page'));
     // Do not render if nothing to show
     if ($paginator->getTotalItemCount() <= 0) {
         return $this->setNoRender();
     }
     // Add count to title if configured
     if ($this->_getParam('titleCount', false) && $paginator->getTotalItemCount() > 0) {
         $this->_childCount = $paginator->getTotalItemCount();
     }
 }
Exemple #16
0
 public function indexAction()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if ($request->isPost()) {
         $this->getElement()->clearDecorators();
     }
     $numberOfBooks = $this->_getParam('itemCountPerPage', 12);
     $bookTable = new Book_Model_DbTable_Books();
     $bookSelect = $bookTable->getSelect();
     $bookSelect->limit($numberOfBooks);
     $bookSelect->order('RAND()');
     $this->view->paginator = $paginator = Zend_Paginator::factory($bookSelect);
     if ($paginator->getTotalItemCount() == 0) {
         return $this->setNoRender();
     }
     if ($paginator->getTotalItemCount() == 0) {
         return $this->setNoRender();
     }
     $itemCountPerPage = $this->_getParam('itemCountPerPage', 12);
     if (empty($itemCountPerPage)) {
         $itemCountPerPage = 12;
     }
     $paginator->setItemCountPerPage($itemCountPerPage);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
 }
 public function indexAction()
 {
     $this->view->title = 'Loan Process';
     $storage = new Zend_Auth_Storage_Session();
     $data = $storage->read();
     if (!$data) {
         $this->_redirect('index/login');
     }
     $searchForm = $this->view->form = new Affidavit_Form_Search();
     if ($this->_request->isPost() && $this->_request->getPost('Submit')) {
         $formData = $this->_request->getPost();
         if ($searchForm->isValid($formData)) {
             $this->view->withdrawalamount = $this->_request->getParam('amount');
             $this->view->membercode = $this->_request->getParam('membercode');
             $result = $this->view->Dbobj->getMember($this->_request->getParam('membercode'));
             $page = $this->_getParam('page', 1);
             $paginator = Zend_Paginator::factory($result);
             // assign searched values for pagination
             $paginator->setItemCountPerPage($this->view->adm->paginator());
             $paginator->setCurrentPageNumber($page);
             $this->view->paginator = $paginator;
             $paginator->setItemCountPerPage($this->view->adm->paginator());
             $paginator->setCurrentPageNumber($page);
             $this->view->search = true;
         }
     }
 }
 public function showAction()
 {
     $perpage = 20;
     $pageno = $this->getRequest()->getParam('page', 1);
     $id = $this->getRequest()->getParam('id');
     if (!$id) {
         throw new Zend_Controller_Exception();
     }
     // get sub-activity info
     $mSubActivity = new Application_Model_SubActivity();
     $subActivity = $mSubActivity->getOneById($id);
     if (!$subActivity) {
         throw new Zend_Controller_Exception();
     } else {
         // get antique
         $condition = array('sub_id' => $id);
         $mAntique = new Application_Model_Antique();
         $mAntique->setWithPhoto()->setWithActivity()->setWithCompany();
         $rs = $mAntique->getSearch($condition, $perpage, ($pageno - 1) * $perpage, 'lotup');
         $this->view->antiques = $antiques = $rs['data'];
         $total = $rs['total'];
         // get activity
         $subActivity['activity'] = $antiques[0]['activity'];
         // get company
         $subActivity['company'] = $antiques[0]['company'];
     }
     $this->view->subActivity = $subActivity;
     $paginator = Zend_Paginator::factory(intval($total));
     $paginator->setDefaultItemCountPerPage($perpage);
     $paginator->setCurrentPageNumber($pageno);
     $this->view->paginator = $paginator;
 }
 function browseAction()
 {
     /*if ($this->getRequest()->isXmlHttpRequest())
       {
           $this->_helper->layout()->disableLayout();
       }*/
     $r = $this->getRequest();
     $limit = $r->getParam('limit') ? $r->getParam('limit') : 10;
     $this->view->limit = $limit;
     $itemsPerPage = $limit;
     $this->view->itemsPerPage = $itemsPerPage;
     //$offset = ($r->getParam('offset'))?$r->getParam('offset'):0;
     //$this->view->offset = $offset;
     $pageIndex = $r->getParam('page', 1);
     $offset = $pageIndex > 0 ? ($pageIndex - 1) * $itemsPerPage : 0;
     $commentList = App_Model_Show_Comment::show()->fetchComment($offset, $limit);
     $this->view->commentList = $commentList;
     $numOfRows = (new App_Model_Db_Table_Comment())->fetchAll()->count();
     //$totalItems = App_Model_Show_Comment::show()->getNumOfComment();
     $paginator = Zend_Paginator::factory($numOfRows);
     $paginator->setCurrentPageNumber($pageIndex);
     $paginator->setItemCountPerPage($itemsPerPage);
     $this->view->assign('perpage', $itemsPerPage);
     //$this->view->assign('totalItems',$totalItems);
     $this->view->assign('paginator', $paginator);
     $this->view->assign('currentPageNumber', $paginator->getCurrentPageNumber());
     //$this->_helper->layout()->headerTitle = "Comment";
 }
 public function indexAction()
 {
     $pageNumber = $this->_getParam('page');
     $currentPolling = $this->_getParam('currentPolling');
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         if (!empty($post['delete'])) {
             foreach ($post['delete'] as $key => $id) {
                 $this->tbl_polling->find($id)->current()->delete();
             }
         }
     }
     if (null == $currentPolling) {
         $active_polling = $this->tbl_polling->getActivePolling();
         if (sizeof($active_polling)) {
             $currentPolling = $active_polling->polling_id;
         }
     }
     if (null != $currentPolling) {
         $result = $this->tbl_answer->getAllWithResult($currentPolling);
         $this->view->currentPollingResult = $result->toArray();
     }
     $polling = $this->tbl_polling->getAll();
     $paginator = Zend_Paginator::factory($polling);
     $paginator->setCurrentPageNumber($pageNumber);
     $this->view->paginator = $paginator;
 }
 public function hinhAnhAction()
 {
     $params = $this->_getAllParams();
     $table = Khcn_Api::_()->getDbTable('hinh_anh', 'default');
     $select = $table->select();
     if (empty($params['order'])) {
         $params['order'] = 'id';
     }
     if (empty($params['direction'])) {
         $params['direction'] = 'DESC';
     }
     $select->order($params['order'] . ' ' . $params['direction']);
     $hinhAnhs = $table->fetchAll($select);
     $this->view->filterValues = $params;
     // TODO Auto-generated {0}::indexAction() default action
     $paginator = Zend_Paginator::factory($hinhAnhs);
     $currentPage = 1;
     //Check if the user is not on page 1
     $page = $this->_getParam('page');
     if (!empty($page)) {
         //Where page is the current page
         $currentPage = $this->_getParam('page');
     }
     //Set the properties for the pagination
     $paginator->setItemCountPerPage(10);
     $paginator->setPageRange(5);
     $paginator->setCurrentPageNumber($currentPage);
     Zend_Paginator::setDefaultScrollingStyle('Sliding');
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml');
     $paginator->setView($this->view);
     $this->view->paginator = $paginator;
 }
 public function recordsAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $loan = new Front_Model_DbTable_Loan();
     $sort_column = $this->_getParam('sortname', 'Ma_tai_san');
     # this will default to undefined
     $sort_order = $this->_getParam('sortorder', 'desc');
     # this will default to undefined
     $page = $this->_getParam('page', 1);
     $limit = $this->_getParam('rp', 10);
     $offset = ($page - 1) * $limit;
     $search_column = $this->_getParam('qtype', 'Ma_tai_san');
     $search_for = $this->_getParam('query', '');
     $select = $loan->select()->order("{$sort_column} {$sort_order}")->limit($limit, $offset);
     if (!empty($search_column) && !empty($search_for)) {
         $select->where($search_column . ' LIKE ?', '%' . $search_for . '%');
     }
     $pager = Zend_Paginator::factory($select);
     $pager->setCurrentPageNumber($page);
     $pager->setItemCountPerPage($limit);
     $records = $pager->getIterator();
     foreach ($records as $record) {
         //If cell's elements have named keys, they must match column names
         //Only cell's with named keys and matching columns are order independent.
         $rows[] = array('id' => $record['Ma_tai_san'], 'cell' => $record->toArray());
     }
     $this->getResponse()->setHeader('Content-Type', 'application/json');
     $jsonData = array('page' => $page, 'total' => $pager->getTotalItemCount(), 'rows' => $rows);
     echo Zend_Json::encode($jsonData);
 }
Exemple #23
0
 public function getPaginator($Select, $nPage)
 {
     $Paginator = Zend_Paginator::factory($Select);
     $Paginator->setItemCountPerPage($this->getPageSize());
     $Paginator->setCurrentPageNumber($nPage);
     return $Paginator;
 }
 /** Get all publications
  * @param string $sort field to sort by
  * @param string $params['title'] title of book
  * @param string $params['authorEditor'] author or editor name
  * @param string $params['pubYear'] year of publishing
  * @param string $params['place'] place of publication
  * @param integer $params['page'] page to retrieve
  * @return array
  */
 public function getPublications($sort, $params)
 {
     $refs = $this->getAdapter();
     $select = $refs->select()->from($this->_name)->order($sort);
     if (isset($params['title']) && $params['title'] != "") {
         $title = strip_tags($params['title']);
         $select->where('title LIKE ?', '%' . $title . '%');
     }
     if (isset($params['authorEditor']) && $params['authorEditor'] != "") {
         $author = strip_tags($params['authorEditor']);
         $select->where('authors LIKE ?', '%' . $author . '%');
     }
     if (isset($params['pubYear']) && $params['pubYear'] != "") {
         $pubYear = strip_tags($params['pubYear']);
         $select->where('publication_year = ?', $pubYear);
     }
     if (isset($params['place']) && $params['place'] != "") {
         $place = strip_tags($params['place']);
         $select->where('publication_place LIKE ?', '%' . $place . '%');
     }
     $paginator = Zend_Paginator::factory($select);
     $cache = Zend_registry::get('cache');
     if (isset($params['page']) && $params['page'] != "") {
         $paginator->setCurrentPageNumber((int) $params['page']);
     }
     $paginator->setItemCountPerPage(20)->setPageRange(10);
     return $paginator;
 }
 public function indexAction()
 {
     // Initialize select
     $table = Engine_Api::_()->getDbtable('services', 'storage');
     $select = $table->select();
     // Get paginator
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($this->_getParam('page'));
     // Get service types
     $serviceTypesTable = Engine_Api::_()->getDbtable('serviceTypes', 'storage');
     $serviceTypes = array();
     foreach ($paginator as $item) {
         if (empty($serviceTypes[$item->servicetype_id])) {
             $serviceTypes[$item->servicetype_id] = $serviceTypesTable->find($item->servicetype_id)->current();
         }
     }
     $this->view->serviceTypes = $serviceTypes;
     // Get number of files and size used for each service?
     $serviceFileInfo = array();
     $filesTable = Engine_Api::_()->getItemTable('storage_file');
     foreach ($paginator as $item) {
         $serviceFileInfo[$item->service_id] = $filesTable->select()->from($filesTable, array(new Zend_Db_Expr('COUNT(file_id) as count'), new Zend_Db_Expr('SUM(size) as size')))->where('service_id = ?', $item->service_id)->query()->fetch();
     }
     $this->view->serviceFileInfo = $serviceFileInfo;
     // Get active transfers?
     $jobsTable = Engine_Api::_()->getDbtable('jobs', 'core');
     $this->view->activeJobs = $activeJobs = $jobsTable->getActiveJobs(array('jobtype' => 'storage_transfer'));
 }
 public function indexAction()
 {
     $this->enableLayout();
     // get a list of news objects and order them by date
     $blogList = new Object\BlogArticle\Listing();
     $blogList->setOrderKey("date");
     $blogList->setOrder("DESC");
     $conditions = [];
     if ($this->getParam("category")) {
         $conditions[] = "categories LIKE " . $blogList->quote("%," . (int) $this->getParam("category") . ",%");
     }
     if ($this->getParam("archive")) {
         $conditions[] = "DATE_FORMAT(FROM_UNIXTIME(date), '%Y-%c') = " . $blogList->quote($this->getParam("archive"));
     }
     if (!empty($conditions)) {
         $blogList->setCondition(implode(" AND ", $conditions));
     }
     $paginator = \Zend_Paginator::factory($blogList);
     $paginator->setCurrentPageNumber($this->getParam('page'));
     $paginator->setItemCountPerPage(5);
     $this->view->articles = $paginator;
     // get all categories
     $categories = Object\BlogCategory::getList();
     // this is an alternative way to get an object list
     $this->view->categories = $categories;
     // archive information, we have to do this in pure SQL
     $db = \Pimcore\Db::get();
     $ranges = $db->fetchCol("SELECT DATE_FORMAT(FROM_UNIXTIME(date), '%Y-%c') as ranges FROM object_5 GROUP BY DATE_FORMAT(FROM_UNIXTIME(date), '%b-%Y') ORDER BY ranges ASC");
     $this->view->archiveRanges = $ranges;
 }
 public function genformAction()
 {
     $generic = new Model_Generic();
     $table = $this->_getParam('tbl');
     /***$protected_tables = array("users","merchandisers","outlets","agents","activity_logs","users_access");
     
     		if(in_array($table,$protected_tables) && $authsession->user_access != 1){
     			$this->_redirect('/index/');
     			//$this->view->disable_input = 1;
     		}
     
     		if(in_array($table,$protected_tables)){
     			$this->view->disable_input = 1;
     		}***/
     //process form
     if ($_POST) {
         $data = $_POST;
         $save = $generic->insertData($table, $data);
         $this->view->saveMsg = array('success', 'Successfully Saved.');
         $this->_redirect('/encoder/genform/tbl/' . $table);
     }
     $list = $generic->getData($table, null, "ID", null);
     $paginator = Zend_Paginator::factory($list);
     $curPage = $this->_getParam('page', 1);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($curPage);
     $this->view->list = $paginator;
     $this->view->table = $table;
     $generic_call = $generic->genericForm($table);
     $this->view->genform = $generic_call;
 }
Exemple #28
0
 public function indexAction()
 {
     $this->view->messages = $this->_flashMessenger->getMessages();
     $this->_helper->layout->disableLayout();
     if ($this->sessCompanyInfo->parent_id != 0) {
         $this->_redirect('company/access/index/tab_ajax/group/');
     }
     $GroupList = $this->modelGroup->getGroupList($this->sessCompanyInfo->id);
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($GroupList);
     $paginator->setItemCountPerPage(PUBLISHER_PAGING_SIZE);
     //$paginator->setItemCountPerPage(2);
     $paginator->setCurrentPageNumber($page);
     $this->view->totalCount = count($GroupList);
     $this->view->pageSize = PUBLISHER_PAGING_SIZE;
     //$this->view->pageSize=2;
     $this->view->page = $page;
     $this->view->GroupList = $paginator;
     $sessionMsg = new Zend_Session_Namespace('step1Msg');
     if (isset($sessionMsg) && !empty($sessionMsg)) {
         $this->view->formData = $sessionMsg->formData;
         $this->view->formErrors = $sessionMsg->formErrors;
         $this->view->errorMessage = $sessionMsg->errorMessage;
         Zend_Session::namespaceUnset('step1Msg');
     }
 }
Exemple #29
0
 public function indexAction()
 {
     if (!$this->_helper->requireUser->isValid()) {
         return;
     }
     $viewer = Engine_Api::_()->user()->getViewer();
     $table = Engine_Api::_()->getItemTable('ynsocialads_campaign');
     $select = $table->select()->where('user_id = ?', $viewer->getIdentity());
     $this->view->form = $form = new Ynsocialads_Form_Campaigns_Search();
     $form->populate($this->_getAllParams());
     $values = $form->getValues();
     $this->view->formValues = $values;
     if ($values['status'] == 'All') {
         $statusArr = array('active', 'deleted');
     } else {
         $statusArr = array($values['status']);
     }
     if ($values['title'] != null) {
         $select = $select->where('title LIKE ?', '%' . $values['title'] . '%');
     }
     $select = $select->where('status IN (?)', $statusArr);
     $campaigns = $table->fetchAll($select);
     $page = $this->_getParam('page', 1);
     $this->view->paginator = $paginator = Zend_Paginator::factory($campaigns);
     $this->view->paginator->setItemCountPerPage(10);
     $this->view->paginator->setCurrentPageNumber($page);
     $this->view->formStatistic = $formStatistic = new Ynsocialads_Form_Campaigns_Statistics();
     $this->_helper->content->setEnabled();
 }
 public function indexAction()
 {
     // TODO Auto-generated {0}::indexAction() default action\
     $this->view->form = $form = new Admin_Form_FilterGV();
     $params = Default_Model_Functions::filterParams($this->_getAllParams());
     $_SESSION['filterGV'] = $_SERVER['QUERY_STRING'];
     if (empty($params['order'])) {
         $params['order'] = 'ho_ten';
     }
     if (empty($params['direction'])) {
         $params['direction'] = 'ASC';
     }
     $form->populate($params);
     $giangViens = $this->giang_vien->loc($params);
     if ($giangViens == null) {
         $_SESSION['msg'] = 'Không tìm thấy dữ liệu, vui lòng thử lại .';
         $_SESSION['type_msg'] = 'attention';
     }
     //Set the properties for the pagination
     $paginator = Zend_Paginator::factory($giangViens);
     $paginator->setItemCountPerPage(20);
     $paginator->setPageRange(10);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     Zend_Paginator::setDefaultScrollingStyle('Sliding');
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml');
     $paginator->setView($this->view);
     $this->view->paginator = $paginator;
     $this->view->filterValues = $params;
     $this->view->order = $params['order'];
     $this->view->direction = $params['direction'];
 }