Dbut ajout de l'autocompltion ajax sur la liste droulante des pays
This commit is contained in:
parent
603bf98509
commit
2ca1d314d5
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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
|
||||
@ -21,7 +22,7 @@
|
||||
|
||||
/**
|
||||
\file htdocs/ajaxresponse.php
|
||||
\brief Fichier de reponse sur evenement ajax pour generation liste produits
|
||||
\brief Fichier de reponse sur evenement Ajax
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
@ -36,8 +37,33 @@ print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ww
|
||||
print "\n<html>";
|
||||
print "\n<body>";
|
||||
|
||||
$form = new Form($db);
|
||||
$form->select_produits_do("",$_GET["htmlname"],"","",$_GET["price_level"],$_GET["keyref"],$_GET["keylabel"]);
|
||||
// Generation liste de produits
|
||||
if(isset($_GET['keyref']) && !empty($_GET['keyref']) || isset($_GET['keylabel']) && !empty($_GET['keylabel']))
|
||||
{
|
||||
$form = new Form($db);
|
||||
$form->select_produits_do("",$_GET["htmlname"],"","",$_GET["price_level"],$_GET["keyref"],$_GET["keylabel"]);
|
||||
}
|
||||
|
||||
if(isset($_POST['search']) && !empty($_POST['search']))
|
||||
{
|
||||
print 'hello world';
|
||||
$sql = "SELECT rowid, code, libelle, active";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
|
||||
$sql.= " WHERE active = 1 AND libelle LIKE '%" . $_POST['search'] . "%'";
|
||||
$sql.= " ORDER BY code ASC;";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
print '<ul>';
|
||||
while($data = mysql_fetch_assoc($resql))
|
||||
{
|
||||
print '<li>'.stripslashes($data['libelle']).'</li>';
|
||||
}
|
||||
print '</ul>';
|
||||
}
|
||||
}
|
||||
|
||||
print "</body>";
|
||||
print "</html>";
|
||||
|
||||
@ -320,36 +320,50 @@ class Form
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
if ($conf->use_ajax && $conf->global->CODE_DE_TEST == 1)
|
||||
{
|
||||
$foundselected=false;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($selected && $selected != '-1' && ($selected == $obj->rowid || $selected == $obj->code))
|
||||
{
|
||||
$foundselected=true;
|
||||
print '<option value="'.$obj->rowid.'" selected="true">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">';
|
||||
}
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
||||
if ($obj->code) { print $obj->code . ' - '; }
|
||||
print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:' '));
|
||||
print '</option>';
|
||||
$i++;
|
||||
}
|
||||
print '<div>';
|
||||
print '<input type="text" id="search" name="search" />';
|
||||
print '</div>';
|
||||
print '<div id="hint"></div>';
|
||||
print '<script type="text/javascript">';
|
||||
print 'new Ajax.Autocompleter(\'search\',\'hint\',\''.DOL_URL_ROOT.'/ajaxresponse.php\');';
|
||||
print '</script>';
|
||||
}
|
||||
print '</select>';
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($this->db);
|
||||
else
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
$foundselected=false;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($selected && $selected != '-1' && ($selected == $obj->rowid || $selected == $obj->code))
|
||||
{
|
||||
$foundselected=true;
|
||||
print '<option value="'.$obj->rowid.'" selected="true">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">';
|
||||
}
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
||||
if ($obj->code) { print $obj->code . ' - '; }
|
||||
print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:' '));
|
||||
print '</option>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -717,21 +731,21 @@ class Form
|
||||
{
|
||||
global $langs,$conf,$user;
|
||||
if ($conf->use_ajax && $conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
|
||||
{
|
||||
print $langs->trans("Ref").':<input type="text" size="8" name="ajkeyref'.$htmlname.'" id="ajkeyref'.$htmlname.'"> ';
|
||||
print $langs->trans("Label").':<input type="text" size="16" name="ajkeylabel'.$htmlname.'" id="ajkeylabel'.$htmlname.'">';
|
||||
print '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
|
||||
print '<script type="text/javascript">';
|
||||
print 'var url = \''.DOL_URL_ROOT.'/ajaxresponse.php\';';
|
||||
print 'new Form.Element.Observer($("ajkeyref'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keyref="+$("ajkeyref'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print 'new Form.Element.Observer($("ajkeylabel'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keylabel="+$("ajkeylabel'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print '</script>';
|
||||
print '<div class="notopnoleftnoright" id="ajdynfield'.$htmlname.'"></div>';
|
||||
}
|
||||
{
|
||||
print $langs->trans("Ref").':<input type="text" size="8" name="ajkeyref'.$htmlname.'" id="ajkeyref'.$htmlname.'"> ';
|
||||
print $langs->trans("Label").':<input type="text" size="16" name="ajkeylabel'.$htmlname.'" id="ajkeylabel'.$htmlname.'">';
|
||||
print '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
|
||||
print '<script type="text/javascript">';
|
||||
print 'var url = \''.DOL_URL_ROOT.'/ajaxresponse.php\';';
|
||||
print 'new Form.Element.Observer($("ajkeyref'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keyref="+$("ajkeyref'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print 'new Form.Element.Observer($("ajkeylabel'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keylabel="+$("ajkeylabel'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
||||
print '</script>';
|
||||
print '<div class="notopnoleftnoright" id="ajdynfield'.$htmlname.'"></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->select_produits_do($selected,$htmlname,$filtretype,$limit,$price_level);
|
||||
}
|
||||
{
|
||||
$this->select_produits_do($selected,$htmlname,$filtretype,$limit,$price_level);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -524,6 +524,8 @@ function top_htmlhead($head, $title="", $target="")
|
||||
{
|
||||
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/lib/prototype.js"></script>'."\n";
|
||||
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js"></script>'."\n";
|
||||
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/effects.js"></script>'."\n";
|
||||
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/controls.js"></script>'."\n";
|
||||
}
|
||||
|
||||
print "</head>\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user