From d8754400d81731c8ec63cdcc85291485b7f27dc7 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Sun, 29 Jul 2007 10:32:07 +0000
Subject: [PATCH] Gestion generique de la navigation Fiche suivante-Precedente

---
 htdocs/adherents/adherent.class.php | 10 ++++++----
 htdocs/adherents/fiche.php          |  2 +-
 htdocs/html.form.class.php          |  7 ++++---
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php
index 69fd84b29f7..b0a4ffae858 100644
--- a/htdocs/adherents/adherent.class.php
+++ b/htdocs/adherents/adherent.class.php
@@ -51,6 +51,7 @@ class Adherent
 	var $error;
 	var $errors=array();
 	
+	var $ref;
 	var $prenom;
 	var $nom;
 	var $fullname;
@@ -686,7 +687,7 @@ class Adherent
 	
 	
 	/**
-	*		\brief      Fonction qui r�cup�re l'adh�rent en donnant son login
+	*		\brief      Fonction qui r�cup�re l'adh�rent depuis son login
 	*		\param	    login		login de l'adh�rent
 	*/
 	function fetch_login($login)
@@ -744,6 +745,7 @@ class Adherent
             {
                 $obj = $this->db->fetch_object($resql);
 
+		$this->ref            = $obj->rowid;
                 $this->id             = $obj->rowid;
                 $this->prenom         = $obj->prenom;
                 $this->nom            = $obj->nom;
@@ -1915,7 +1917,7 @@ class Adherent
 	*      \param      filter      filtre
 	*      \return     int         <0 si ko, >0 si ok
 	*/
-	function load_previous_next_id($filter='')
+	function load_previous_next_ref($filter='')
 	{
 		$sql = "SELECT MAX(rowid)";
 		$sql.= " FROM ".MAIN_DB_PREFIX."adherent";
@@ -1928,7 +1930,7 @@ class Adherent
 			return -1;
 		}
 		$row = $this->db->fetch_row($result);
-		$this->id_previous = $row[0];
+		$this->ref_previous = $row[0];
 		
 		$sql = "SELECT MIN(rowid)";
 		$sql.= " FROM ".MAIN_DB_PREFIX."adherent";
@@ -1941,7 +1943,7 @@ class Adherent
 			return -2;
 		}
 		$row = $this->db->fetch_row($result);
-		$this->id_next = $row[0];
+		$this->ref_next = $row[0];
 	}
 
 	
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index b7ad7137750..a2dd613afb9 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -882,7 +882,7 @@ if ($rowid && $action != 'edit')
     // Ref
     print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
 	print '<td class="valeur" colspan="2">';
-	print $html->showrefnav($adh);
+	print $html->showrefnav($adh,'rowid');
 	print '</td></tr>';
 
     // Nom
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 6a4014ef317..84f7f0c0e5f 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -3326,15 +3326,16 @@ class Form
     /**
      *    \brief      Affiche tableau avec ref et bouton navigation pour un objet metier
      *    \param      object	Objet a afficher
+     *    \param      paramid   Nom du parametre a utiliser pour nommer id dans liens URL
      *	  \return     string    Portion HTML avec ref + boutons nav
      */
-	function showrefnav($object)
+	function showrefnav($object,$paramid='ref')
 	{
 		$ret='';
 
           $object->load_previous_next_ref($object->next_prev_filter);
-          $previous_ref = $object->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.urlencode($object->ref_previous).'">'.img_previous().'</a>':'';
-          $next_ref     = $object->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.urlencode($object->ref_next).'">'.img_next().'</a>':'';
+          $previous_ref = $object->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_previous).'">'.img_previous().'</a>':'';
+          $next_ref     = $object->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_next).'">'.img_next().'</a>':'';
 
 		if ($previous_ref || $next_ref) $ret.='<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
 		$ret.=$object->getNomUrl(0);
-- 
GitLab