diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 35c468eb7c2..68158abadd9 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -1707,6 +1707,41 @@ class Adherent } } + /** + * \brief Charge les propriétés id_previous et id_next + * \param filter filtre + * \return int <0 si ko, >0 si ok + */ + function load_previous_next_id($filter='') + { + $sql = "SELECT MAX(rowid)"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent"; + $sql.= " WHERE rowid < '".addslashes($this->id)."'"; + if (isset($filter)) $sql.=" AND ".$filter; + $result = $this->db->query($sql) ; + if (! $result) + { + $this->error=$this->db->error(); + return -1; + } + $row = $this->db->fetch_row($result); + $this->id_previous = $row[0]; + + $sql = "SELECT MIN(rowid)"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent"; + $sql.= " WHERE rowid > '".addslashes($this->id)."'"; + if (isset($filter)) $sql.=" AND ".$filter; + $result = $this->db->query($sql) ; + if (! $result) + { + $this->error=$this->db->error(); + return -2; + } + $row = $this->db->fetch_row($result); + $this->id_next = $row[0]; + } + + /** * \brief Initialise le membre avec valeurs fictives aléatoire */ diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 1821f84d411..f6a4403d2fd 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -183,11 +183,21 @@ $head = member_prepare_head($adh); dolibarr_fiche_head($head, 'subscription', $langs->trans("Member")); +$result=$adh->load_previous_next_id($adh->next_prev_filter); +if ($result < 0) dolibarr_print_error($db,$adh->error); +$previous_id = $adh->id_previous?'id_previous).'">'.img_previous().'':''; +$next_id = $adh->id_next?'id_next).'">'.img_next().'':''; + print '