diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3490b381483efdfd599c3b7a3b7a9022aae3a8a0..87079e105fc5a06587c04d2667eee2c4a2724d68 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -860,7 +860,7 @@ class Form if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) { // mode=1 means customers products - print ajax_autocompleter('',$htmlname,DOL_URL_ROOT.'/product/ajaxproducts.php','outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,''); + print ajax_autocompleter('',$htmlname,DOL_URL_ROOT.'/product/ajaxproducts.php','outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished); print $langs->trans("RefOrLabel").' : <input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'">'; print '<br>'; } @@ -985,6 +985,7 @@ class Form $label=$objp->label; if (! empty($objp->label_translated)) $label=$objp->label_translated; + if ($filterkey && $filterkey != '') $label=preg_replace('/('.preg_quote($filterkey).')/i','<strong>$1</strong>',$label,1); $outkey=$objp->rowid; $outref=$objp->ref; @@ -1004,7 +1005,10 @@ class Form } $opt.= '>'; $opt.= $langs->convToOutputCharset($objp->ref).' - '.$langs->convToOutputCharset(dol_trunc($label,32)).' - '; - $outval.=$objp->ref.' - '.dol_trunc($label,32).' - '; + + $objRef = $objp->ref; + if ($filterkey && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i','<strong>$1</strong>',$objRef,1); + $outval.=$objRef.' - '.dol_trunc($label,32).' - '; $found=0; $currencytext=$langs->trans("Currency".$conf->monnaie); @@ -1123,7 +1127,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,''); + print ajax_autocompleter('',$htmlname,DOL_URL_ROOT.'/product/ajaxproducts.php','outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished); print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="search_'.$htmlname.'" id="search_'.$htmlname.'">'; print '<br>'; } @@ -1223,11 +1227,18 @@ class Form if ($selected == $objp->idprodfournprice) $opt.= ' selected="true"'; if ($objp->fprice == '') $opt.=' disabled="disabled"'; $opt.= '>'; + + $objRef = $objp->ref; + if ($filterkey && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i','<strong>$1</strong>',$objRef,1); + $objRefFourn = $objp->ref_fourn; + if ($filterkey && $filterkey != '') $objRefFourn=preg_replace('/('.preg_quote($filterkey).')/i','<strong>$1</strong>',$objRefFourn,1); + $label = $objp->label; + if ($filterkey && $filterkey != '') $label=preg_replace('/('.preg_quote($filterkey).')/i','<strong>$1</strong>',$label,1); $opt.=$langs->convToOutputCharset($objp->ref).' ('.$langs->convToOutputCharset($objp->ref_fourn).') - '; - $outval.=$objp->ref.' ('.$objp->ref_fourn.') - '; + $outval.=$objRef.' ('.$objRefFourn.') - '; $opt.=$langs->convToOutputCharset(dol_trunc($objp->label,18)).' - '; - $outval.=dol_trunc($objp->label,18).' - '; + $outval.=dol_trunc($label,18).' - '; if ($objp->fprice != '') // Keep != '' { diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index e7d7ef6d7ad7ec71f1c1a089ea13f2fa2b800697..fb516b31290ee91cf12fcd3a9c6f3044bbb47d5f 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -606,7 +606,24 @@ class FormCompany } print "</select>\n"; } - + + /** + * Retourne la liste deroulante des codes postaux et des villes associƩes + */ + function select_zipcode($selected='',$htmlname='zipcode') + { + print ajax_autocompleter('',$htmlname,DOL_URL_ROOT.'/societe/ajaxziptown.php','',0)."\n"; + print '<input id="'.$htmlname.'" type="text" name="'.$htmlname.'" size="6" value="'.$selected.'">'."\n"; + } + + /** + * Retourne la liste deroulante des villes et des codes postaux associƩs + */ + function select_town($selected='',$htmlname='town') + { + print ajax_autocompleter('',$htmlname,DOL_URL_ROOT.'/societe/ajaxziptown.php','',0)."\n"; + print '<input id="'.$htmlname.'" type="text" name="'.$htmlname.'" value="'.$selected.'">'."\n"; + } } diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index f71ddf88836b1970413c4a80510d89f11686cd45..dc3c857e4c6eaff5d8a41e7f4d036f673209f1c0 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -90,7 +90,6 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='') $script.= '<script type="text/javascript">'; $script.= 'jQuery(document).ready(function() { - var cache = {}; jQuery("input#search_'.$htmlname.'").blur(function() { //console.log(this.value.length); if (this.value.length == 0) @@ -101,33 +100,19 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='') }); jQuery("input#search_'.$htmlname.'").autocomplete({ source: function( request, response ) { - if (this.length == 0) { - jQuery(this).flushCache(); - } - if (cache.term == request.term && cache.content) { - response(cache.content); - return; - } - /*if (new RegExp(cache.term).test(request.term) && cache.content && cache.content.length < 13) { - response(jQuery.ui.autocomplete.filter(cache.content, request.term)); - return; - }*/ jQuery.get("'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){ - cache.term = request.term; - cache.content = data; response( jQuery.map( data, function( item ) { if (data.length == 1) { jQuery("#search_'.$htmlname.'").val(item.value); jQuery("#'.$htmlname.'").val(item.key); } var label = item.label.toString(); - //label = label.replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>"); return { label: label, value: item.value, id: item.key} })); }, "json"); }, dataType: "json", - minLength: '.$conf->global->COMPANY_USE_SEARCH_TO_SELECT.', + minLength: 2, select: function( event, ui ) { jQuery("#'.$htmlname.'").val(ui.item.id); } diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index 0b36ad4d7770c2e10b908812adb1cbe6ce93a482..ba01899019c59c821f7516ab87188020f49c9308 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -93,7 +93,7 @@ if (! empty($_GET['newcompany']) || ! empty($_GET['socid']) || ! empty($_GET['id while ($row = $db->fetch_array($resql)) { $label=$row['nom']; - if ($socid) $label=preg_replace('/('.preg_quote($socid).')/','<strong>$1</strong>',$label,1); + if ($socid) $label=preg_replace('/('.preg_quote($socid).')/i','<strong>$1</strong>',$label,1); $row_array['label'] = $label; $row_array['value'] = $row['nom']; $row_array['key'] = $row['rowid'];