From 5790b7e604bfd2cbf3230cd1a907d2e60a21d169 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 10 Jul 2011 17:28:09 +0000 Subject: [PATCH] Fix: missing htmlname in ajax response --- htdocs/core/class/html.form.class.php | 6 +++--- htdocs/product/ajaxproducts.php | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4863b52689e..7e97abed808 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -31,7 +31,7 @@ * \file htdocs/core/class/html.form.class.php * \ingroup core * \brief File of class with all html predefined components - * \version $Id: html.form.class.php,v 1.187 2011/07/10 16:50:40 eldy Exp $ + * \version $Id: html.form.class.php,v 1.188 2011/07/10 17:28:09 hregis Exp $ */ @@ -876,7 +876,7 @@ class Form $selected_input_value=$product->ref; } // mode=1 means customers products - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); if (! $hidelabel) print $langs->trans("RefOrLabel").' : '; print ''; print '
'; @@ -1117,7 +1117,7 @@ class Form if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) { // mode=2 means suppliers products - print ajax_autocompleter('', $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); + print ajax_autocompleter('', $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); print $langs->trans("RefOrLabel").' : '; print '
'; } diff --git a/htdocs/product/ajaxproducts.php b/htdocs/product/ajaxproducts.php index 829e470ac2d..dc92b76134c 100644 --- a/htdocs/product/ajaxproducts.php +++ b/htdocs/product/ajaxproducts.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2007-2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ /** * \file htdocs/product/ajaxproducts.php * \brief File to return Ajax response on product list request - * \version $Id$ + * \version $Id: ajaxproducts.php,v 1.36 2011/07/10 17:28:10 hregis Exp $ */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal @@ -55,34 +55,34 @@ top_httphead(); //print ''."\n"; dol_syslog(join(',',$_GET)); +//print_r($_GET); -$match = preg_grep('/(idprod[0-9]+)/',array_keys($_GET)); +if (! isset($_GET['htmlname'])) return; + +$htmlname = $_GET['htmlname']; +$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); sort($match); $idprod = $match[0]; -//print $_GET[$idprod]; -if (! isset($_GET['idprod']) && ! isset($_GET[$idprod]) && ! isset($_GET['idprodfournprice'])) return; +if (! isset($_GET[$htmlname]) && ! isset($_GET[$idprod])) return; // When used from jQuery, the search term is added as GET param "term". $searchkey=$_GET[$idprod]; -if (empty($searchkey)) $searchkey=$_GET['idprod']; -if (empty($searchkey)) $searchkey=$_GET['idprodfournprice']; +if (empty($searchkey)) $searchkey=$_GET[$htmlname]; $outjson=isset($_GET['outjson'])?$_GET['outjson']:0; // Get list of product. -//var_dump($_GET); exit; -//print $_GET["price_level"]; exit; $status=-1; if (isset($_GET['status'])) $status=$_GET['status']; $form = new Form($db); if (empty($_GET['mode']) || $_GET['mode'] == 1) { - $arrayresult=$form->select_produits_do("",$_GET["htmlname"],$_GET["type"],"",$_GET["price_level"],$searchkey,$status,2,$outjson); + $arrayresult=$form->select_produits_do("",$htmlname,$_GET["type"],"",$_GET["price_level"],$searchkey,$status,2,$outjson); } if ($_GET['mode'] == 2) { - $arrayresult=$form->select_produits_fournisseurs_do($_GET["socid"],"",$_GET["htmlname"],$_GET["type"],"",$searchkey,$status,$outjson); + $arrayresult=$form->select_produits_fournisseurs_do($_GET["socid"],"",$htmlname,$_GET["type"],"",$searchkey,$status,$outjson); } $db->close();