diff options
| author | michael pereira | 2011-03-30 13:17:55 +0200 |
|---|---|---|
| committer | michael pereira | 2011-03-30 13:17:55 +0200 |
| commit | 0345ce59cf877538eaa30cc76ad597287e18be59 (patch) | |
| tree | 51ba16d887488ae5b10a985f315d6efa085f284c /application | |
| parent | findBy Methode angepasst (diff) | |
| parent | Pagination & sortierung in Filter (diff) | |
| download | pbs2-0345ce59cf877538eaa30cc76ad597287e18be59.tar.gz pbs2-0345ce59cf877538eaa30cc76ad597287e18be59.tar.xz pbs2-0345ce59cf877538eaa30cc76ad597287e18be59.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application')
6 files changed, 28 insertions, 15 deletions
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 023de4a..b9399b2 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -47,8 +47,8 @@ class User_ClientController extends Zend_Controller_Action $clientMapper = new Application_Model_ClientMapper(); $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,10 @@ 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(); + $this->view->pagination = $pagination->pagination('/user/client/index',$req_page,$numpages); $this->view->clients = array_slice($clientsInGroup,$startitem,$perpage); } @@ -80,8 +78,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']; 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/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml index dd791ad..dd7aad2 100644 --- a/application/modules/user/views/scripts/client/index.phtml +++ b/application/modules/user/views/scripts/client/index.phtml @@ -36,7 +36,7 @@ </tr> <?php endforeach ?> </table> - + <?php echo $this->pagination; ?> <?php else: ?> <p>There are no clients to display.</p> <?php endif;?> 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 @@ </tr> <?php endif;?> <?php endforeach ?> - </table> - + </table> + <?php echo $this->pagination; ?> + <?php if (isset($this->freeclients) && count($this->freeclients)>0): ?> <h2>Free clients</h2> <table > |
