From a149fc493f62f31e3806f353dde0c4dc812be6b2 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 2 Jul 2014 08:18:15 +0200 Subject: Fix pagination in the package request list This was not implemented properly in commit 8260111 (Add a package request list, 2014-06-24). Signed-off-by: Lukas Fleischer --- web/lib/pkgreqfuncs.inc.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'web/lib/pkgreqfuncs.inc.php') diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 852554b..a79677e 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -2,12 +2,26 @@ include_once("config.inc.php"); include_once("pkgbasefuncs.inc.php"); +/** + * Get the number of package requests + * + * @return int The total number of package requests + */ +function pkgreq_count() { + $dbh = DB::connect(); + $q = "SELECT COUNT(*) FROM PackageRequests"; + return $dbh->query($q)->fetchColumn(); +} + /** * Get a list of all package requests * + * @param int $offset The index of the first request to return + * @param int $limit The maximum number of requests to return + * * @return array List of pacakge requests with details */ -function pkgreq_list() { +function pkgreq_list($offset, $limit) { $dbh = DB::connect(); $q = "SELECT PackageRequests.ID, "; @@ -20,7 +34,8 @@ function pkgreq_list() { $q.= "FROM PackageRequests INNER JOIN RequestTypes ON "; $q.= "RequestTypes.ID = PackageRequests.ReqTypeID "; $q.= "INNER JOIN Users ON Users.ID = PackageRequests.UsersID "; - $q.= "ORDER BY Status ASC, RequestTS DESC"; + $q.= "ORDER BY Status ASC, RequestTS DESC "; + $q.= "LIMIT " . $limit . " OFFSET " . $offset; return $dbh->query($q)->fetchAll(); } -- cgit v1.2.3-70-g09d2