From 7a6672433ee07c1b472287a6e1534e9e18281745 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Apr 2006 13:34:35 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20On=20affiche=20aussi=20les=20produits=20?= =?UTF-8?q?qui=20ne=20sont=20pas=20dans=20des=20cat=E9gories=20cach=E9es.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/html.form.class.php | 10 +++++----- htdocs/includes/boxes/box_services_vendus.php | 16 +++++++--------- htdocs/product/liste.php | 15 +++------------ 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 8c45d79ea9f..fd92d3f6b6f 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -613,20 +613,20 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX."product as p "; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; - $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql.= " WHERE p.envente = 1"; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= " AND cp.fk_product = p.rowid"; - $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype; $sql.= " ORDER BY p.nbvente DESC"; if ($limit) $sql.= " LIMIT $limit"; - + $result=$this->db->query($sql); + if (! $result) dolibarr_print_error($this->db); // Multilang : on construit une liste des traductions des produits listés $sqld = "SELECT d.fk_product, d.label"; diff --git a/htdocs/includes/boxes/box_services_vendus.php b/htdocs/includes/boxes/box_services_vendus.php index 39b799e12f5..08c72fa6c8d 100644 --- a/htdocs/includes/boxes/box_services_vendus.php +++ b/htdocs/includes/boxes/box_services_vendus.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2005-2006 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,6 @@ * * $Id$ * $Source$ - * */ /** @@ -69,17 +68,16 @@ class box_services_vendus extends ModeleBoxes { if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - if ($conf->categorie->enabled && !$user->rights->categorie->voir) - { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; - $sql .= ", ".MAIN_DB_PREFIX."categorie as ca"; - } + if ($conf->categorie->enabled && !$user->rights->categorie->voir) + { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as ca ON cp.fk_categorie = ca.rowid"; + } $sql .= " WHERE s.idp = c.fk_soc AND c.rowid = cd.fk_contrat AND cd.fk_product = p.rowid"; if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= " AND cp.fk_product = p.rowid"; - $sql .= " AND cp.fk_categorie = ca.rowid AND ca.visible = 1"; + $sql.= ' AND IFNULL(ca.visible,1)=1'; } if($user->societe_id) { diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 03d5559936d..720dfa23028 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -79,15 +79,10 @@ $title=$langs->trans("ProductsAndServices"); $sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,'; $sql.= ' p.duration, p.envente as statut'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // '.MAIN_DB_PREFIX.'product_det as d'; //en attendant le debugage - if ($catid || ($conf->categorie->enabled && !$user->rights->categorie->voir)) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -} - -if ($conf->categorie->enabled && !$user->rights->categorie->voir) -{ - $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } if ($_GET["fourn_id"] > 0) @@ -116,17 +111,13 @@ if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0) { $sql .= " AND p.envente = ".$_GET["envente"]; } -if($catid || ($conf->categorie->enabled && !$user->rights->categorie->voir)) -{ - $sql .= " AND cp.fk_product = p.rowid"; -} if($catid) { $sql .= " AND cp.fk_categorie = ".$catid; } if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } if ($fourn_id > 0) {