diff --git a/include/class.pagenate.php b/include/class.pagenate.php index 69368393e431e4d9edb95da7940e90101d9c66b4..b20ad52a5da542faa088d21d31045a338761c313 100644 --- a/include/class.pagenate.php +++ b/include/class.pagenate.php @@ -25,10 +25,15 @@ class PageNate { function __construct($total,$page,$limit=20,$url='') { - $this->total = intval($total); $this->limit = max($limit, 1 ); $this->page = max($page, 1 ); $this->start = max((($page-1)*$this->limit),0); + $this->setURL($url); + $this->setTotal($total); + } + + function setTotal($total) { + $this->total = intval($total); $this->pages = ceil( $this->total / $this->limit ); if (($this->limit > $this->total) || ($this->page>ceil($this->total/$this->limit))) { @@ -37,7 +42,6 @@ class PageNate { if (($this->limit-1)*$this->start > $this->total) { $this->start -= $this->start % $this->limit; } - $this->setURL($url); } function setURL($url='',$vars='') { @@ -160,5 +164,9 @@ class PageNate { return $qs->limit($end-$start)->offset($start); } + function paginateSimple(QuerySet $qs) { + return $qs->limit($this->getLimit() + $this->slack)->offset($this->getStart()); + } + } ?> diff --git a/include/staff/templates/queue-tickets.tmpl.php b/include/staff/templates/queue-tickets.tmpl.php index 212f725410fc3649063ee4ffa5ddad3ad10dc5d7..22475ec6f301f1140b9c24c37b77454d7bde9179 100644 --- a/include/staff/templates/queue-tickets.tmpl.php +++ b/include/staff/templates/queue-tickets.tmpl.php @@ -91,10 +91,11 @@ if (!$sorted && isset($sort['queuesort'])) { // Apply pagination $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; +$pageNav = new Pagenate(PHP_INT_MAX, $page, PAGE_LIMIT); +$tickets = $pageNav->paginateSimple($tickets); $count = $tickets->total(); -$pageNav = new Pagenate($count, $page, PAGE_LIMIT); +$pageNav->setTotal($count); $pageNav->setURL('tickets.php', $args); -$tickets = $pageNav->paginate($tickets); ?> <!-- SEARCH FORM START --> @@ -211,7 +212,7 @@ if ( $canManageTickets = $thisstaff->canManageTickets(); if ($canManageTickets) { ?> <th style="width:12px"></th> -<?php +<?php } foreach ($columns as $C) { $heading = Format::htmlchars($C->getLocalHeading()); @@ -234,9 +235,9 @@ foreach ($columns as $C) { foreach ($tickets as $T) { echo '<tr>'; if ($canManageTickets) { ?> - <td><input type="checkbox" class="ckb" name="tids[]" + <td><input type="checkbox" class="ckb" name="tids[]" value="<?php echo $T['ticket_id']; ?>" /></td> -<?php +<?php } foreach ($columns as $C) { list($contents, $styles) = $C->render($T);