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 = '