From 1e4b5426fa5d158fb4c30c7b7a0bf19191261fb8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 26 Oct 2007 11:12:13 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20modification=20sur=20les=20cat=E9gories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/categories/categorie.class.php | 14 ++--- htdocs/fourn/product/categorie.php | 4 +- htdocs/fourn/product/fiche.php | 82 +++++++++++++-------------- htdocs/fourn/product/liste.php | 4 +- 4 files changed, 51 insertions(+), 53 deletions(-) diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index e47b464a47a..aa7f4f5557c 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -2,9 +2,9 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005 Davoleau Brice * Copyright (C) 2005 Rodolphe Quiedeville - * Copyright (C) 2006 Regis Houssin + * Copyright (C) 2006-2007 Regis Houssin * Copyright (C) 2006 Laurent Destailleur - * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -743,10 +743,10 @@ class Categorie /** * get_primary_way() affiche le chemin le plus court pour se rendre à un produit */ - function get_primary_way($id) + function get_primary_way($id, $type="") { $primary_way = Array("taille"=>-1,"chemin"=>Array()); - $meres = $this->containing($id); + $meres = $this->containing($id,$type); foreach ($meres as $mere) { foreach ($mere->get_all_ways() as $way) @@ -765,10 +765,10 @@ class Categorie /** * print_primary_way() affiche le chemin le plus court pour se rendre à un produit */ - function print_primary_way($id, $sep= " >> ",$url) + function print_primary_way($id, $sep= " >> ", $url, $type="") { $primary_way = Array(); - $way = $this->get_primary_way($id); + $way = $this->get_primary_way($id,$type); $w = array(); foreach ($way as $cat) { @@ -778,7 +778,7 @@ class Categorie } else { - $w[] = "".$cat->label.""; + $w[] = "".$cat->label.""; } } diff --git a/htdocs/fourn/product/categorie.php b/htdocs/fourn/product/categorie.php index 1e8fd9b3a62..315378b3b20 100644 --- a/htdocs/fourn/product/categorie.php +++ b/htdocs/fourn/product/categorie.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Brice Davoleau - * Copyright (C) 2005 Regis Houssin + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -114,7 +114,7 @@ if ($_GET["id"]) print "
\n"; $c = new Categorie($db); - $cats = $c->containing($_REQUEST['id']); + $cats = $c->containing($_REQUEST['id'],"product"); if (sizeof($cats) > 0) { diff --git a/htdocs/fourn/product/fiche.php b/htdocs/fourn/product/fiche.php index c4c8c39d035..2f10ed56223 100644 --- a/htdocs/fourn/product/fiche.php +++ b/htdocs/fourn/product/fiche.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -281,18 +282,16 @@ else * Fiche produit */ if ($_GET["id"]) - { - - if ($_GET["action"] <> 're-edit') - { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - } - - if ( $product->id > 0 ) - { - - if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') + { + if ($_GET["action"] <> 're-edit') + { + $product = new Product($db); + $result = $product->fetch($_GET["id"]); + } + + if ( $product->id > 0 ) + { + if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') { /* * En mode visu @@ -306,15 +305,14 @@ else $h++; if($product->isproduct()) - { - if ($conf->stock->enabled) - { - $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; - $head[$h][1] = $langs->trans("Stock"); - $h++; - } - - } + { + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $h++; + } + } $head[$h][0] = DOL_URL_ROOT."/fourn/product/photos.php?id=".$product->id; $head[$h][1] = $langs->trans("Photos"); @@ -322,9 +320,9 @@ else //Affichage onglet Catégories if ($conf->categorie->enabled){ - $head[$h][0] = DOL_URL_ROOT."/fourn/product/categorie.php?id=".$product->id; - $head[$h][1] = $langs->trans('Categories'); - $h++; + $head[$h][0] = DOL_URL_ROOT."/fourn/product/categorie.php?id=".$product->id; + $head[$h][1] = $langs->trans('Categories'); + $h++; } $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; @@ -338,28 +336,28 @@ else print ''; if ($conf->categorie->enabled) - { - print ''; - print ''; - print ''; - } + { + print ''; + print ''; + print ''; + } print ""; print ''; print ''; print ''; print ''; diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php index e189796827d..512a36c6b2b 100644 --- a/htdocs/fourn/product/liste.php +++ b/htdocs/fourn/product/liste.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -83,7 +84,7 @@ $sql .= ", s.nom"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if ($catid) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc"; @@ -115,7 +116,6 @@ else } if($catid) { - $sql .= " AND cp.fk_product = p.rowid"; $sql .= " AND cp.fk_categorie = ".$catid; }
'; - $cat = new Categorie ($db); - $way = $cat->print_primary_way($product->id," > ",'fourn/product/liste.php'); - if ($way == "") - { - print "Ce produit n'appartient à aucune catégorie"; - } - else - { - print $langs->trans("Categorie")." : "; - print $way; - } - print '
'; + $cat = new Categorie ($db); + $way = $cat->print_primary_way($product->id," > ",'fourn/product/liste.php',"product"); + if ($way == "") + { + print "Ce produit n'appartient à aucune catégorie"; + } + else + { + print $langs->trans("Categorie")." : "; + print $way; + } + print '
'.$langs->trans("Ref").''.$product->ref.''; - print $product->getLibStatut(2); + print $product->getLibStatut(2); print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).'