New: Can choose number of characters to trigger autocompletion for companies.

This commit is contained in:
Laurent Destailleur 2010-10-22 08:11:51 +00:00
parent fe93194056
commit 3990d8d153
5 changed files with 33 additions and 23 deletions

View File

@ -464,7 +464,12 @@ if (! $conf->use_javascript_ajax)
else
{
print '<td width="60" align="right">';
print $html->selectyesno("activate_COMPANY_USE_SEARCH_TO_SELECT",$conf->global->COMPANY_USE_SEARCH_TO_SELECT,1);
$arrval=array('0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
);
print $html->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT",$arrval,$conf->global->COMPANY_USE_SEARCH_TO_SELECT);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td>";

View File

@ -2284,7 +2284,7 @@ class Form
{
print $this->selectcurrency($selected,$htmlname);
}
/**
* \brief Retourne la liste des devises, dans la langue de l'utilisateur
* \param selected code devise pre-selectionne
@ -2295,7 +2295,7 @@ class Form
{
global $conf,$langs,$user;
$langs->load("dict");
$out='';
if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite
@ -2862,18 +2862,18 @@ class Form
/**
* \brief Show a select form from an array
* \param htmlname Nom de la zone select
* \param array Tableau de key+valeur
* \param id Preselected key
* \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
* \param key_in_label 1 pour afficher la key dans la valeur "[key] value"
* \param value_as_key 1 to use value as key
* \param option Valeur de l'option en fonction du type choisi
* \param translate Traduire la valeur
* \param maxlen Length maximum for labels
* \param disabled Html select box is disabled
* \return string HTML select string
* Show a select form from an array
* @param htmlname Name of html select area
* @param array Array with key+value
* @param id Preselected key
* @param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
* @param key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param value_as_key 1 to use value as key
* @param option Valeur de l'option en fonction du type choisi
* @param translate Traduire la valeur
* @param maxlen Length maximum for labels
* @param disabled Html select box is disabled
* @return string HTML select string
*/
function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0)
{

View File

@ -45,7 +45,8 @@ ErrorDecimalLargerThanAreForbidden=Error, a precision higher than <b>%s</b> is n
DictionnarySetup=Dictionary setup
DisableJavascript=Disable JavaScript and Ajax functions
ConfirmAjax=Use Ajax confirmation popups
UseSearchToSelectCompany=Use a search form to choose a company (instead of using a list box).<br>Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant SOCIETE_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
UseSearchToSelectCompany=Use autocompletion fields to choose third parties (instead of using a list box).<br><br>Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant SOCIETE_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
NumberOfKeyToSearch=Nbr of characters to trigger search: %s
ViewFullDateActions=Show full dates actions in the third sheet
NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
JavascriptDisabled=JavaScript disabled

View File

@ -45,7 +45,8 @@ ErrorDecimalLargerThanAreForbidden= Erreur, les précisions supérieures à <b>%
DictionnarySetup= Dictionnaires
DisableJavascript= Désactiver les fonctions Javascript et Ajax
ConfirmAjax= Utiliser les popups de confirmation Ajax
UseSearchToSelectCompany= Utiliser un formulaire de recherche pour le choix d'un tiers (plutôt qu'une liste déroulante).<br>Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine.
UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).<br><br>Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine.
NumberOfKeyToSearch=Nb caractères déclenchant la recherche: %s
ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers
NotAvailableWhenAjaxDisabled= Non disponible quand Ajax désactivé
JavascriptDisabled= Javascript désactivé

View File

@ -35,6 +35,9 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='')
{
global $conf;
if (empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) return "COMPANY_USE_SEARCH_TO_SELECT is empty. This should not happens";
if (! is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) return "COMPANY_USE_SEARCH_TO_SELECT is not a numeric. This should not happens";
$script='';
$script.= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
@ -63,7 +66,7 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='')
}, "json");
},
dataType: "json",
minLength: 2,
minLength: '.$conf->global->COMPANY_USE_SEARCH_TO_SELECT.',
select: function( event, ui ) {
jQuery("#'.$htmlname.'").val(ui.item.id);
}
@ -89,7 +92,7 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='')
function ajax_multiautocompleter($htmlname,$fields,$url,$option='')
{
$script='';
$fields = php2js($fields);
$script.= '<script type="text/javascript">';
@ -97,7 +100,7 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='')
var fields = '.$fields.';
var length = fields.length;
//alert(fields + " " + length);
jQuery("input#'.$htmlname.'").autocomplete({
dataType: "json",
minLength: 2,
@ -121,13 +124,13 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='')
});
},
select: function( event, ui ) {
// TODO move this to specific request
// TODO move this to specific request
if (ui.item.states) {
jQuery("#departement_id").html(ui.item.states);
}
for (i=0;i<length;i++) {
//alert(fields[i] + " = " + ui.item[fields[i]]);
if (ui.item[fields[i]]) {
if (ui.item[fields[i]]) {
jQuery("#" + fields[i]).val(ui.item[fields[i]]);
}
}
@ -175,7 +178,7 @@ function ajax_dialog($title,$message,$w=350,$h=150)
}
/**
*
*
* Enter description here ...
* @param unknown_type $var
*/