From 3a7708df98d9060fd5318535a62bddb7f4b0640c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 7 May 2007 12:47:22 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20recherche=20ajax=20sur=20la?= =?UTF-8?q?=20liste=20d=E9roulante=20des=20produits=20fournisseurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/facture/fiche.php | 1 + htdocs/fourn/fournisseur.facture.class.php | 1 - htdocs/html.form.class.php | 64 ++++++++++++++++++---- htdocs/product/ajaxproducts.php | 9 ++- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 161ef98dd10..edf07c59e09 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -612,6 +612,7 @@ else $sql .= ' ORDER BY dp DESC'; $result = $db->query($sql); + if ($result) { $num = $db->num_rows($result); diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 15253231801..97a2335cdc0 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -263,7 +263,6 @@ class FactureFournisseur extends Facture dolibarr_print_error($this->db); return -2; } - $this->db->free($resql); } else { diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index c6927f5ab3c..6b49f3b090b 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -811,14 +811,15 @@ class Form \param htmlname Nom de la zone select \param filtretype Pour filtre sur type de produit \param limit Limite sur le nombre de lignes retournées + \param price_level Niveau de prix en fonction du client */ function select_produits($selected='',$htmlname='productid',$filtretype='',$limit=20,$price_level=0) { - global $langs,$conf,$user; + global $langs,$conf; if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) { print $langs->trans("RefOrLabel").' : '; - print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'','ajaxworking'); + print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type=1','ajaxworking'); } else { @@ -832,6 +833,8 @@ class Form \param htmlname Nom de la zone select \param filtretype Pour filtre sur type de produit \param limit Limite sur le nombre de lignes retournées + \param price_level Niveau de prix en fonction du client + \param ajaxkeysearch Filtre des produits si ajax est utilisé */ function select_produits_do($selected='',$htmlname='productid',$filtretype='',$limit=20,$price_level=0,$ajaxkeysearch='') { @@ -896,8 +899,8 @@ class Form else { print ''; + print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&type=2','ajaxworking'); + } + else + { + $this->select_produits_fournisseurs_do($socid,$selected,$htmlname,$filtretype,$filtre); + } + } /** \brief Retourne la liste des produits de fournisseurs - \param socid Id société (0 pour aucun filtre) + \param socid Id société (0 pour aucun filtre) \param selected Produit présélectionné \param htmlname Nom de la zone select \param filtretype Pour filtre sur type de produit - \param limit Limite sur le nombre de lignes retournées \param filtre Pour filtre + \param ajaxkeysearch Filtre des produits si ajax est utilisé */ - function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='') + function select_produits_fournisseurs_do($socid,$selected='',$htmlname='productid',$filtretype='',$filtre='',$ajaxkeysearch='') { global $langs,$conf; @@ -980,6 +1003,7 @@ class Form if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype; if ($filtre) $sql.="$filtre"; + if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%'"; $sql.= " ORDER BY p.ref DESC"; dolibarr_syslog("Form::select_produits_fournisseurs sql=$sql",LOG_DEBUG); @@ -987,16 +1011,34 @@ class Form $result=$this->db->query($sql); if ($result) { - print ''; + print ''; + } + else + { + print ''; + if (! $selected) print ''; + else print ''; + } + $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); - + $opt = '