mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-10 03:28:18 +01:00
FIX: Pre selected value was not used on supplier list ouput
This commit is contained in:
@@ -2058,16 +2058,26 @@ class Form
|
||||
global $langs,$conf;
|
||||
global $price_level, $status, $finished;
|
||||
|
||||
$selected_input_value='';
|
||||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
|
||||
{
|
||||
if ($selected > 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
$producttmpselect = new Product($this->db);
|
||||
$producttmpselect->fetch($selected);
|
||||
$selected_input_value=$producttmpselect->ref;
|
||||
unset($producttmpselect);
|
||||
}
|
||||
|
||||
if (!empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
|
||||
{
|
||||
print '<input type="hidden" id="idprod" name="idprod" value="0" />';
|
||||
}
|
||||
// mode=2 means suppliers products
|
||||
$urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished;
|
||||
print ajax_autocompleter('', $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
||||
print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'">';
|
||||
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
||||
print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2089,7 +2099,7 @@ class Form
|
||||
* @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
|
||||
* @param string $filtre Pour filtre sql
|
||||
* @param string $filterkey Filtre des produits
|
||||
* @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell
|
||||
* @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell (not used here, a filter on tobuy is already hard coded in request)
|
||||
* @param int $outputmode 0=HTML select string, 1=Array
|
||||
* @param int $limit Limit of line number
|
||||
* @return array Array of keys for json
|
||||
|
||||
@@ -136,6 +136,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
minLength: '.$minLength.',
|
||||
select: function( event, ui ) { // Function ran once new value has been selected into javascript combo
|
||||
console.log("Call change on input '.$htmlname.' because of select definition of autocomplete select call on input#search_'.$htmlname.'");
|
||||
console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective");
|
||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
||||
// Disable an element
|
||||
if (options.option_disabled) {
|
||||
@@ -179,7 +180,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log("ajax_autocompleter new value selected, we trigger change on original component");
|
||||
console.log("ajax_autocompleter new value selected, we trigger change on original component so field #search_'.$htmlname.'");
|
||||
$("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code.
|
||||
}
|
||||
,delay: 500
|
||||
|
||||
Reference in New Issue
Block a user