New: Can choose number of character before triggering Ajax

autocomplete of product search.
This commit is contained in:
eldy 2011-10-03 22:48:10 +02:00
parent 38c828ceb4
commit 98ab396837
3 changed files with 37 additions and 28 deletions

View File

@ -907,14 +907,15 @@ class Form
/**
* Return list of products for customer in Ajax if Ajax activated or go to select_produits_do
*
* @param selected Preselected products
* @param htmlname Name of HTML seletc field (must be unique in page)
* @param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param limit Limit on number of returned lines
* @param price_level Level of price to show
* @param status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param finished 2=all, 1=finished, 0=raw material
* @param $selected_input_value Value of preselected input text (with ajax)
* @param int $selected Preselected products
* @param string $htmlname Name of HTML seletc field (must be unique in page)
* @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param int $limit Limit on number of returned lines
* @param int $price_level Level of price to show
* @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param int $finished 2=all, 1=finished, 0=raw material
* @param string $selected_input_value Value of preselected input text (with ajax)
* @return void
*/
function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='',$hidelabel=0)
{
@ -947,16 +948,16 @@ class Form
/**
* Return list of products for a customer
*
* @param selected Preselected product
* @param htmlname Name of select html
* @param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param limit Limite sur le nombre de lignes retournees
* @param price_level Level of price to show
* @param filterkey Filter on product
* @param status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param finished Filter on finished field: 2=No filter
* @param disableout Disable print output
* @return array Array of keys for json
* @param int $selected Preselected product
* @param string $htmlname Name of select html
* @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param int $limit Limite sur le nombre de lignes retournees
* @param int $price_level Level of price to show
* @param string $filterkey Filter on product
* @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param int $finished Filter on finished field: 2=No filter
* @param int $disableout Disable print output
* @return array Array of keys for json
*/
function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$disableout=0)
{
@ -976,16 +977,16 @@ class Form
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'";
}
$sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')';
if($finished == 0)
if ($finished == 0)
{
$sql.= " AND p.finished = ".$finished;
}
elseif($finished == 1)
elseif ($finished == 1)
{
$sql.= " AND p.finished = ".$finished;
if ($status >= 0) $sql.= " AND p.tosell = ".$status;
}
elseif($status >= 0)
elseif ($status >= 0)
{
$sql.= " AND p.tosell = ".$status;
}

View File

@ -49,7 +49,7 @@ ConfirmAjax= Utiliser les popups de confirmation Ajax
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.
ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer
SearchFilter=Options des filtres de recherche
NumberOfKeyToSearch=Nb caractères déclenchant la recherche: %s
NumberOfKeyToSearch=Nb carac. déclenchant 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

@ -5,7 +5,7 @@
* Copyright (C) 2007 Auguria SARL <info@auguria.org>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -33,12 +33,16 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
$langs->load("admin");
// Security check
if (!$user->admin)
accessforbidden();
if (! $user->admin) accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
/*
* Actions
*/
if ($action == 'nbprod')
{
$res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $value,'chaine',0,'',$conf->entity);
@ -50,7 +54,7 @@ else if ($action == 'multiprix_num')
if ($action == 'multiprix')
{
$multiprix = GETPOST("activate_multiprix");
$res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $multiprix,'chaine',0,'',$conf->entity);
$res =dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "5",'chaine',0,'',$conf->entity);
}
@ -81,7 +85,6 @@ else if ($action == 'set')
$res = dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $ecotaxe,'chaine',0,'',$conf->entity);
}*/
if($action)
{
if (! $res > 0) $error++;
@ -190,7 +193,12 @@ if (! $conf->use_javascript_ajax)
else
{
print '<td width="60" align="right">';
print $html->selectyesno("activate_usesearchtoselectproduct",$conf->global->PRODUIT_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_usesearchtoselectproduct",$arrval,$conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td>";