Fix: uniformize json with search company
Fix: search product with jQuery
This commit is contained in:
parent
cfa3e3c9cf
commit
c1b8055538
@ -564,7 +564,7 @@ class Form
|
|||||||
{
|
{
|
||||||
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" />';
|
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" />';
|
||||||
}
|
}
|
||||||
print ajax_autocompleter(($socid?$socid:-1),$htmlname,'socname',DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '');
|
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -862,11 +862,11 @@ class Form
|
|||||||
if ($conf->global->MAIN_USE_NEW_JQUERY)
|
if ($conf->global->MAIN_USE_NEW_JQUERY)
|
||||||
{
|
{
|
||||||
// mode=1 means customers products
|
// mode=1 means customers products
|
||||||
print ajax_autocompleter2('',$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 '<div class="ui-widget">';
|
print '<div class="ui-widget">';
|
||||||
print '<label for="'.$htmlname.'free">'.$langs->trans("RefOrLabel").':</label>';
|
print '<label for="search_'.$htmlname.'">'.$langs->trans("RefOrLabel").':</label>';
|
||||||
print '<input id="'.$htmlname.'free" />';
|
print '<input id="search_'.$htmlname.'" />';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -545,7 +545,7 @@ class FormCompany
|
|||||||
{
|
{
|
||||||
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" '.$htmloption.' />';
|
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" '.$htmloption.' />';
|
||||||
}
|
}
|
||||||
print ajax_autocompleter(($socid?$socid:-1),$htmlname,'socname',DOL_URL_ROOT.'/societe/ajaxcompanies.php','');
|
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php','');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -80,7 +80,7 @@ function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
|
|||||||
* \param url chemin du fichier de reponse : /chemin/fichier.php
|
* \param url chemin du fichier de reponse : /chemin/fichier.php
|
||||||
* \return string script complet
|
* \return string script complet
|
||||||
*/
|
*/
|
||||||
function ajax_autocompleter($selected='',$htmlname,$valname,$url)
|
function ajax_autocompleter($selected='',$htmlname,$url,$option='')
|
||||||
{
|
{
|
||||||
$script='';
|
$script='';
|
||||||
|
|
||||||
@ -90,10 +90,10 @@ function ajax_autocompleter($selected='',$htmlname,$valname,$url)
|
|||||||
$script.= 'jQuery(document).ready(function() {
|
$script.= 'jQuery(document).ready(function() {
|
||||||
jQuery("input#search_'.$htmlname.'").autocomplete({
|
jQuery("input#search_'.$htmlname.'").autocomplete({
|
||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
jQuery.get("'.$url.'", { '.$htmlname.': request.term }, function(data){
|
jQuery.get("'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){
|
||||||
response( jQuery.map( data, function( item ) {
|
response( jQuery.map( data, function( item ) {
|
||||||
var label = item.'.$valname.'.toString().replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>");
|
var label = item.label.toString().replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>");
|
||||||
return { label: label, value: item.'.$valname.', id: item.'.$htmlname.'}
|
return { label: label, value: item.value, id: item.key}
|
||||||
}));
|
}));
|
||||||
}, "json");
|
}, "json");
|
||||||
},
|
},
|
||||||
|
|||||||
@ -50,16 +50,16 @@ $langs->load("main");
|
|||||||
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
|
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
|
||||||
top_httphead();
|
top_httphead();
|
||||||
|
|
||||||
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||||
|
|
||||||
//print '<body class="nocellnopadd">'."\n";
|
//print '<body class="nocellnopadd">'."\n";
|
||||||
|
|
||||||
dol_syslog(join(',',$_POST));
|
dol_syslog(join(',',$_POST));
|
||||||
|
|
||||||
if (! isset($_GET['keysearch']) && ! isset($_GET['term'])) return;
|
if (! isset($_GET['keysearch']) && ! isset($_GET['idprod'])) return;
|
||||||
|
|
||||||
// When used from jQuery, the search term is added as GET param "term".
|
// When used from jQuery, the search term is added as GET param "term".
|
||||||
$searchkey=isset($_GET['keysearch'])?$_GET['keysearch']:$_GET['term'];
|
$searchkey=isset($_GET['keysearch'])?$_GET['keysearch']:$_GET['idprod'];
|
||||||
$outjson=isset($_GET['outjson'])?$_GET['outjson']:0;
|
$outjson=isset($_GET['outjson'])?$_GET['outjson']:0;
|
||||||
|
|
||||||
// Get list of product.
|
// Get list of product.
|
||||||
|
|||||||
@ -80,8 +80,9 @@ if (! empty($_GET['newcompany']) || ! empty($_GET['socid']) || ! empty($_GET['id
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
while ($row = $db->fetch_array($resql)) {
|
while ($row = $db->fetch_array($resql)) {
|
||||||
$row_array['socname'] = $row['nom'];
|
$row_array['label'] = $row['nom'];
|
||||||
$row_array['socid'] = $row['rowid'];
|
$row_array['value'] = $row['nom'];
|
||||||
|
$row_array['key'] = $row['rowid'];
|
||||||
|
|
||||||
array_push($return_arr,$row_array);
|
array_push($return_arr,$row_array);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user