}
function pagination() {
- $offset = 0;
+ $offset = 1;
$per_page = $GLOBALS['default_page_size'];
parse_str($_SERVER['QUERY_STRING'], $params);
- if (array_key_exists('page', $params)) if (is_numeric($params['page'])) $offset = $params['page'] - 1;
+ if (array_key_exists('page', $params)) if (is_numeric($params['page'])) $offset = $params['page'];
if (array_key_exists('size', $params)) if (is_numeric($params['size'])) $per_page = $params['size'];
return array($offset, $per_page);
if (! $pager->haveToPaginate()) return;
list($offset, $per_page) = pagination();
- $offset++;
-
- $links = array();
$pages = ceil($pager->getNbResults() / $per_page);
$pages++;
+ $links = array();
$links[] = page_link('First', 1, $offset, $pages, $per_page);
$links[] = page_link('Previous', $offset - 1, $offset, $pages, $per_page);
foreach ($pager->getLinks($n) as $link) $links[] = page_link($link, $link, $offset, $pages, $per_page);
# XXX: Doesn't work.
#if (isset($state_mask)) $q->useOrderStateQuery()->addSelectQuery($latest_state, 'latestState')->where("order_id=latestState.order_id")->where("state & $state_mask")->endUse();
if (isset($state_mask)) $q->filterById($order_ids);
- $orders = $q->orderByDate('desc')->paginate($offset, $per_page);
+ $orders = $q->orderByDate('desc')->orderById('desc')->paginate($offset, $per_page);
if (count($orders)) {
foreach ($orders as $order) {
echo "<br>\n" . get_order_summary($order) . "<br>\n";