From 10bcacc8317850a489b60042bd55fcda314a3c82 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Nov 2007 13:21:03 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20bug=20sur=20la=20cr=E9ation=20des=20cat?= =?UTF-8?q?=E9gories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/categories/categorie.class.php | 8 ++++---- htdocs/categories/categorie.php | 19 ++++++++++++------- htdocs/fourn/stats.php | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 1585fe481e3..8303c339605 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -326,7 +326,7 @@ class Categorie } /** - * Ajout d'un produit à la catégorie + * Ajout d'un objet à la catégorie * retour : 1 : OK * -1 : erreur SQL * -2 : id non renseign @@ -338,7 +338,7 @@ class Categorie return -2; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$type.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".($type=='fournisseur'?'societe':$type).")"; $sql .= " VALUES (".$this->id.", ".$obj->id.")"; if ($this->db->query($sql)) @@ -362,7 +362,7 @@ class Categorie { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type; $sql .= " WHERE fk_categorie = ".$this->id; - $sql .= " AND fk_".$type." = ".$obj->id; + $sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id; if ($this->db->query($sql)) { @@ -868,7 +868,7 @@ class Categorie $sql = "SELECT ct.fk_categorie"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid"; - $sql.= " WHERE ct.fk_".$type." = ".$id." AND c.type = ".$typeid; + $sql.= " WHERE ct.fk_".($type=='fournisseur'?'societe':$type)." = ".$id." AND c.type = ".$typeid; $res = $this->db->query ($sql); if ($res) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 9651c3a5f99..2b369424e09 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -34,11 +34,14 @@ require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); $langs->load("categories"); +$user->getrights(); + $mesg=isset($_GET["mesg"])?'
'.$_GET["mesg"].'
':''; if ($_REQUEST["socid"]) { - $type = 'societe'; + if ($_REQUEST["typeid"] == 1) $type = 'fournisseur'; + if ($_REQUEST["typeid"] == 2) $type = 'societe'; $objectid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; } else if ($_REQUEST["id"] || $_REQUEST["ref"]) @@ -186,11 +189,11 @@ if ($_GET["socid"]) if ($mesg) print($mesg); - if ($soc->client) formCategory($db,$soc,$type,2); + if ($soc->client) formCategory($db,$soc,'societe',2); if ($soc->client && $soc->fournisseur) print '

'; - if ($soc->fournisseur) formCategory($db,$soc,$type,1); + if ($soc->fournisseur) formCategory($db,$soc,'fournisseur',1); } else if ($_GET["id"] || $_GET["ref"]) { @@ -262,11 +265,11 @@ function formCategory($db,$object,$type,$typeid) if ($typeid == 0) $title = $langs->trans("ProductsCategoriesShort"); if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort"); if ($typeid == 2) $title = $langs->trans("CustomersCategoriesShort"); - if ($type == 'societe') + if ($type == 'societe' || $type == 'fournisseur') { $nameId = 'socid'; } - else + else if ($type == 'product') { $nameId = 'id'; } @@ -277,6 +280,7 @@ function formCategory($db,$object,$type,$typeid) print '
'; print_fiche_titre($title); print '
'; + print ''; print ''; print '
'; print $langs->trans("ClassifyInCategory").' '; @@ -318,9 +322,10 @@ function formCategory($db,$object,$type,$typeid) // Lien supprimer print ''; - if ($user->rights->$type->creer) + $module = ($type=='fournisseur'?'societe':$type); + if ($user->rights->$module->creer) { - print ""; + print ""; print img_delete($langs->trans("DeleteFromCat")).' '; print $langs->trans("DeleteFromCat").""; } diff --git a/htdocs/fourn/stats.php b/htdocs/fourn/stats.php index 79bb7e3dbfc..a43e5bf0528 100644 --- a/htdocs/fourn/stats.php +++ b/htdocs/fourn/stats.php @@ -96,7 +96,7 @@ if ($search_ville) } $sql .= " AND ca.year > (date_format(now(),'%Y') - 5)"; -$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); +$sql .= " ORDER BY ".$sortfield $sortorder $db->plimit($conf->liste_limit+1, $offset); dolibarr_syslog("fourn/stats.php sql=".$sql); $resql = $db->query($sql);