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 else
{ {
print '<td width="60" align="right">'; 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 '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td>"; print "</td>";

View File

@ -2862,18 +2862,18 @@ class Form
/** /**
* \brief Show a select form from an array * Show a select form from an array
* \param htmlname Nom de la zone select * @param htmlname Name of html select area
* \param array Tableau de key+valeur * @param array Array with key+value
* \param id Preselected key * @param id Preselected key
* \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon * @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 key_in_label 1 pour afficher la key dans la valeur "[key] value"
* \param value_as_key 1 to use value as key * @param value_as_key 1 to use value as key
* \param option Valeur de l'option en fonction du type choisi * @param option Valeur de l'option en fonction du type choisi
* \param translate Traduire la valeur * @param translate Traduire la valeur
* \param maxlen Length maximum for labels * @param maxlen Length maximum for labels
* \param disabled Html select box is disabled * @param disabled Html select box is disabled
* \return string HTML select string * @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) 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 DictionnarySetup=Dictionary setup
DisableJavascript=Disable JavaScript and Ajax functions DisableJavascript=Disable JavaScript and Ajax functions
ConfirmAjax=Use Ajax confirmation popups 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 ViewFullDateActions=Show full dates actions in the third sheet
NotAvailableWhenAjaxDisabled=Not available when Ajax disabled NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
JavascriptDisabled=JavaScript disabled JavascriptDisabled=JavaScript disabled

View File

@ -45,7 +45,8 @@ ErrorDecimalLargerThanAreForbidden= Erreur, les précisions supérieures à <b>%
DictionnarySetup= Dictionnaires DictionnarySetup= Dictionnaires
DisableJavascript= Désactiver les fonctions Javascript et Ajax DisableJavascript= Désactiver les fonctions Javascript et Ajax
ConfirmAjax= Utiliser les popups de confirmation 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 ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers
NotAvailableWhenAjaxDisabled= Non disponible quand Ajax désactivé NotAvailableWhenAjaxDisabled= Non disponible quand Ajax désactivé
JavascriptDisabled= Javascript désactivé JavascriptDisabled= Javascript désactivé

View File

@ -35,6 +35,9 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='')
{ {
global $conf; 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='';
$script.= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />'; $script.= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
@ -63,7 +66,7 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='')
}, "json"); }, "json");
}, },
dataType: "json", dataType: "json",
minLength: 2, minLength: '.$conf->global->COMPANY_USE_SEARCH_TO_SELECT.',
select: function( event, ui ) { select: function( event, ui ) {
jQuery("#'.$htmlname.'").val(ui.item.id); jQuery("#'.$htmlname.'").val(ui.item.id);
} }