From e21c82d60bdfd91b3ab73f35005abb5f17ca179f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jun 2006 23:55:33 +0000 Subject: [PATCH] =?UTF-8?q?Quelques=20am=E9lioration=20sur=20fonction=20se?= =?UTF-8?q?lection=20produit=20ajax:=20Look:=20On=20supprime=20espace=20en?= =?UTF-8?q?combrant=20sous=20la=20liste.=20Fix:=20Correction=20probl=E8me?= =?UTF-8?q?=20de=20gestion=20des=20accents=20Fix:=20Produits=20en=20double?= =?UTF-8?q?s=20selon=20activation=20et=20droits=20de=20categories=20New:?= =?UTF-8?q?=20Affiche=20message=20si=20aucun=20=E9l=E9ment=20trouv=E9=20Lo?= =?UTF-8?q?ok:=20Agrandissement=20zone=20de=20saisie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/ajaxresponse.php | 15 ++- htdocs/comm/propal.php | 2 +- htdocs/html.form.class.php | 110 +++++++++++++--------- htdocs/includes/modules/modUser.class.php | 2 +- htdocs/langs/en_US/products.lang | 17 +++- htdocs/langs/en_US/users.lang | 1 + htdocs/langs/fr_FR/products.lang | 5 +- htdocs/langs/fr_FR/users.lang | 1 + 8 files changed, 101 insertions(+), 52 deletions(-) diff --git a/htdocs/ajaxresponse.php b/htdocs/ajaxresponse.php index a07a686b658..8a821eb46f6 100644 --- a/htdocs/ajaxresponse.php +++ b/htdocs/ajaxresponse.php @@ -25,8 +25,19 @@ \version $Revision$ */ -require('./pre.inc.php'); +require('./main.inc.php'); + +$langs->load("products"); + +//header("Content-type: text/html; charset=UTF-8"); +header("Content-type: text/html; charset=iso-8859-1"); +print ''; +print "\n"; +print "\n"; + $form = new Form($db); $form->select_produits_do("",$_GET["htmlname"],"","",$_GET["price_level"],$_GET["keyref"],$_GET["keylabel"]); - + +print ""; +print ""; ?> diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 8501aa2d41e..18ea7c2649f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1236,7 +1236,7 @@ if ($_GET['propalid'] > 0) { $html->select_produits('','idprod','',$conf->produit->limit_size); } - print '
'; + if (! $conf->use_ajax) print '
'; print ''; print ''; print ' '; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 3c3609479d7..3b932c31301 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -704,20 +704,16 @@ class Form if($conf->use_ajax) { print ''; - print $langs->trans("Ref").' '; - print $langs->trans("Label").''; + print $langs->trans("Ref").':   '; + print $langs->trans("Label").':'; print ''; print ''; - print ''; - print '
'; - print '
'; + print '
'; } else { @@ -736,16 +732,22 @@ class Form function select_produits_do($selected='',$htmlname='productid',$filtretype='',$limit=20,$price_level=0,$ajaxkeyref='',$ajaxkeylabel='') { global $langs,$conf,$user; - - $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p "; - if ($conf->categorie->enabled && !$user->rights->categorie->voir) + $user->getrights("categorie"); + + $sql = "SELECT "; + 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 c ON cp.fk_categorie = c.rowid"; + $sql.="DISTINCT"; + } + $sql.= " p.rowid, p.label, p.ref, p.price, p.duration"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p "; + if ($conf->categorie->enabled && ! $user->rights->categorie->voir) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; + $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) + if ($conf->categorie->enabled && ! $user->rights->categorie->voir) { $sql.= ' AND IFNULL(c.visible,1)=1'; } @@ -755,48 +757,61 @@ class Form $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"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_det as d "; - $sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'"; - $sqld.= " ORDER BY p.nbvente DESC"; - - // inutile de faire la requete si l'option n'est pas active - if ($conf->global->MAIN_MULTILANGS) - { - $resultd = $this->db->query($sqld); - if ( $resultd ) $objtp = $this->db->fetch_object($resultd); - } + $result=$this->db->query($sql); + if (! $result) dolibarr_print_error($this->db); + + // Multilang : on construit une liste des traductions des produits listés + if ($conf->global->MAIN_MULTILANGS) + { + $sqld = "SELECT d.fk_product, d.label"; + $sqld.= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_det as d "; + $sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'"; + $sqld.= " ORDER BY p.nbvente DESC"; + $resultd = $this->db->query($sqld); + if ( $resultd ) $objtp = $this->db->fetch_object($resultd); + } if ($result) { - if($conf->use_ajax) - print ''; - print ""; - $num = $this->db->num_rows($result); + + if ($conf->use_ajax) + { + if (! $num) + { + print $langs->trans("NoProductMatching").' '; + } +// else +// { + print ''; + print ""; + } + $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); - // Multilangs : modification des donnée si une traduction existe + // Multilangs : modification des donnée si une traduction existe if ($conf->global->MAIN_MULTILANGS) + { if ( $objp->rowid == $objtp->fk_product ) // si on a une traduction { if ( $objtp->label != '') $objp->label = $objtp->label; if ( $resultd ) $objtp = $this->db->fetch_object($resultd); // on charge la traduction suivante } - $opt = '