From d4ceeed0570fb10d95adeb115cbe127461bda1db Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 30 Mar 2011 12:48:08 +0200 Subject: Pagination in clients --- application/modules/user/controllers/ClientController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'application/modules/user/controllers/ClientController.php') diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index 023de4a..7d0e7e7 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -48,7 +48,7 @@ class User_ClientController extends Zend_Controller_Action $clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID()); #print_a($clientsInGroup); - $perpage = 5; + $perpage = 10; $req_page = $this->_request->getParam('page'); $all = count($clientsInGroup); $numpages = ceil($all/$perpage); @@ -56,12 +56,11 @@ class User_ClientController extends Zend_Controller_Action $req_page = 0; if($req_page >= $numpages) $req_page = $numpages-1; - $startitem = $req_page * $perpage; - $this->pagination = array('max' => $numpages, 'selected' => $req_page); + $startitem = $req_page * $perpage; - print_a($all,$numpages,$startitem,$req_page); - $pagination = new Pbs_Pagination(); - $this->pagination = $pagination->pagination('/user/client/index',$req_page,$numpages); + $pagination = new Pbs_Pagination(); + $str = $pagination->pagination('/user/client/index',$req_page,$numpages); + $this->view->pagination = $str; $this->view->clients = array_slice($clientsInGroup,$startitem,$perpage); } @@ -80,8 +79,7 @@ class User_ClientController extends Zend_Controller_Action $this->view->addclient = $addclient; } else{ - $addclient = new user_Form_Client(array('buttontext' => 'Create Client'),$_POST); - print_a($_POST); + $addclient = new user_Form_Client(array('buttontext' => 'Create Client'),$_POST); if ($addclient->isValid($_POST) || ($mac != '' && $hh != '') ) { $client = new Application_Model_Client($_POST); $mac = ($mac!='')?$mac:$_POST['macadress']; -- cgit v1.2.3-55-g7522 From be4fb92647714849e5523468691a5a46ae27a30d Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 30 Mar 2011 13:13:37 +0200 Subject: Pagination & sortierung in Filter --- application/models/FilterMapper.php | 5 ++++- application/modules/user/controllers/ClientController.php | 7 +++---- application/modules/user/controllers/FilterController.php | 2 +- application/modules/user/controllers/PoolController.php | 14 +++++++++++++- application/modules/user/views/scripts/pool/index.phtml | 5 +++-- 5 files changed, 24 insertions(+), 9 deletions(-) (limited to 'application/modules/user/controllers/ClientController.php') diff --git a/application/models/FilterMapper.php b/application/models/FilterMapper.php index 0bb4bc3..d4b8d54 100644 --- a/application/models/FilterMapper.php +++ b/application/models/FilterMapper.php @@ -5,13 +5,16 @@ class Application_Model_FilterMapper protected $_dbTable; - public function findBy($criteria, $value) + public function findBy($criteria, $value, $order='',$sort='') { try{ $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->getDbTable()->select() ->from($this->_dbTable) ->where($criteria . ' = ?', $value); + if($order != '' && $sort != ''){ + $select->order(array("$order $sort")); + } $stmt = $select->query(); $result = $stmt->fetchAll(); return $result; diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index 7d0e7e7..b9399b2 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -47,7 +47,7 @@ class User_ClientController extends Zend_Controller_Action $clientMapper = new Application_Model_ClientMapper(); $clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID()); - #print_a($clientsInGroup); + $perpage = 10; $req_page = $this->_request->getParam('page'); $all = count($clientsInGroup); @@ -58,9 +58,8 @@ class User_ClientController extends Zend_Controller_Action $req_page = $numpages-1; $startitem = $req_page * $perpage; - $pagination = new Pbs_Pagination(); - $str = $pagination->pagination('/user/client/index',$req_page,$numpages); - $this->view->pagination = $str; + $pagination = new Pbs_Pagination(); + $this->view->pagination = $pagination->pagination('/user/client/index',$req_page,$numpages); $this->view->clients = array_slice($clientsInGroup,$startitem,$perpage); } diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php index bf04f23..9c53bcd 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -46,7 +46,7 @@ class User_FilterController extends Zend_Controller_Action $this->view->notification = $pbsNotifier->notify('modify',$result); } - $filters = $this->filterMapper->findBy('groupID',$this->membership->getGroupID()); + $filters = $this->filterMapper->findBy('groupID',$this->membership->getGroupID(),'priority','DESC'); foreach($filters as $filter){ $ff = new Application_Model_Filter(); $ff->setOptions($filter); diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php index 15a3f1e..ab6a078 100644 --- a/application/modules/user/controllers/PoolController.php +++ b/application/modules/user/controllers/PoolController.php @@ -62,7 +62,19 @@ class User_PoolController extends Zend_Controller_Action $ff->setID($pool['poolID']); $yourpools[] = $ff; } - $this->view->pools = $yourpools; + $perpage = 5; + $req_page = $this->_request->getParam('page'); + $all = count($yourpools); + $numpages = ceil($all/$perpage); + if($req_page < 0 || !is_numeric($req_page) ) + $req_page = 0; + if($req_page >= $numpages) + $req_page = $numpages-1; + $startitem = $req_page * $perpage; + + $pagination = new Pbs_Pagination(); + $this->view->pagination = $pagination->pagination('/user/pool/index',$req_page,$numpages); + $this->view->pools = array_slice($yourpools,$startitem,$perpage); // Get all Clients from this group $clientmapper = new Application_Model_ClientMapper(); diff --git a/application/modules/user/views/scripts/pool/index.phtml b/application/modules/user/views/scripts/pool/index.phtml index 2890768..7e6e400 100644 --- a/application/modules/user/views/scripts/pool/index.phtml +++ b/application/modules/user/views/scripts/pool/index.phtml @@ -89,8 +89,9 @@ - - + + pagination; ?> + freeclients) && count($this->freeclients)>0): ?>

Free clients

-- cgit v1.2.3-55-g7522