From 920d94f9dbf29afe3e2c80d7ba6aa3d0854268ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Mar 2008 22:12:56 +0000 Subject: [PATCH] New: Add patch for pagination on member list --- htdocs/adherents/liste.php | 18 ++++++++++++------ htdocs/contact/index.php | 8 +++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index d924a855a7d..0ff21ed2fe7 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,15 +16,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/adherents/liste.php \ingroup adherent \brief Page listant les adhérents - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -98,6 +96,14 @@ if ($filter == 'outofdate') { $sql.=" AND datefin < sysdate()"; } +// Count total nb of records +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} +// Add order and limit $sql.= " ".$db->order($sortfield,$sortorder); $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); @@ -130,7 +136,7 @@ if ($result) if (isset($_GET["statut"])) $param.="&statut=".$_GET["statut"]; if (isset($_GET["search_nom"])) $param.="&search_nom=".$_GET["search_nom"]; if (isset($_GET["filter"])) $param.="&filter=".$_GET["filter"]; - print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num); + print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); print ""; @@ -255,7 +261,7 @@ if ($result) if ($num > $conf->liste_limit) { - print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num); + print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); } } else diff --git a/htdocs/contact/index.php b/htdocs/contact/index.php index 4dc47657106..a50c497c841 100644 --- a/htdocs/contact/index.php +++ b/htdocs/contact/index.php @@ -153,14 +153,16 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - +// Add order and limit if($_GET["view"] == "recent") { - $sql .= " ORDER BY p.datec DESC " . $db->plimit( $limit + 1, $offset); + $sql.= " ORDER BY p.datec DESC "; + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); } else { - $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1, $offset); + $sql.= " ORDER BY $sortfield $sortorder "; + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); } dolibarr_syslog("contact/index.php sql=".$sql);