From 94cb055eab22b64b4bb9a6b973c8555facd10d0b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 19 Feb 2006 18:14:41 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20navigation=20next=20et=20preview=20sur?= =?UTF-8?q?=20l'onglet=20cat=E9gorie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/categories/categorie.class.php | 29 +++++++++++++++++++++++++++ htdocs/product/categorie.php | 10 ++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index d6cb6df2bb2..51b0b76ee23 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -670,6 +670,35 @@ class Categorie } } + /** + * Retourne les catégories contenant le produit $ref + */ + function containing_ref ($ref) + { + $cats = array (); + + $sql = "SELECT c.fk_categorie, c.fk_product, p.rowid, p.label"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie_product as c, ".MAIN_DB_PREFIX."product as p"; + $sql.= " WHERE p.label = '".$ref."' AND c.fk_product = p.rowid"; + + $res = $this->db->query ($sql); + + if ($res) + { + while ($cat = $this->db->fetch_array ($res)) + { + $cats[] = new Categorie ($this->db, $cat['fk_categorie']); + } + + return $cats; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + /** * Retourne les catégories dont le nom correspond ŕ $nom * ajoute des wildcards sauf si $exact = true diff --git a/htdocs/product/categorie.php b/htdocs/product/categorie.php index 9b3e996f59c..55abdec5146 100644 --- a/htdocs/product/categorie.php +++ b/htdocs/product/categorie.php @@ -149,8 +149,16 @@ if ($_GET["id"] || $_GET["ref"]) print ''; $c = new Categorie($db); - $cats = $c->containing($_REQUEST['id']); + if ($_GET["id"]) + { + $cats = $c->containing($_REQUEST['id']); + } + else + { + $cats = $c->containing_ref($_REQUEST['ref']); + } + if (sizeof($cats) > 0) { print "Vous avez stocké le produit dans les catégorie suivantes:

";