mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-21 08:51:24 +01:00
Mise en function de ajax.updater et ajax.autocompleter
This commit is contained in:
@@ -406,13 +406,9 @@ class Form
|
|||||||
{
|
{
|
||||||
print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />';
|
print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />';
|
||||||
}
|
}
|
||||||
print '<span id="indicator" style="display: none">'.img_gif('Working...','ajaxworking').'</span>';
|
|
||||||
print '<input type="hidden" name="pays_id" id="pays_id" value="'.$pays_id.'" />';
|
print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','ajaxworking');
|
||||||
print '</div>';
|
|
||||||
print '<div id="hint" class="autocomplete"></div>';
|
|
||||||
print '<script type="text/javascript">';
|
|
||||||
print 'new Ajax.Autocompleter(\'pays\',\'hint\',\''.DOL_URL_ROOT.'/societe/ajaxcountries.php\',{method: \'post\',paramName: \'pays\',afterUpdateElement: ac_return});';
|
|
||||||
print '</script>';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -821,14 +817,8 @@ class Form
|
|||||||
global $langs,$conf,$user;
|
global $langs,$conf,$user;
|
||||||
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
|
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
|
||||||
{
|
{
|
||||||
print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="'.$htmlname.'" id="'.$htmlname.'">';
|
print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'">';
|
||||||
print '<span id="indicator" style="display: none">'.img_gif('Working...','ajaxworking').'</span>';
|
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'','ajaxworking');
|
||||||
print '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
|
|
||||||
print '<script type="text/javascript">';
|
|
||||||
print 'var url = \''.DOL_URL_ROOT.'/product/ajaxproducts.php\';';
|
|
||||||
print 'new Form.Element.Observer($("'.$htmlname.'"), 1, function(){var myAjax = new Ajax.Updater( {success: \'ajdynfield'.$htmlname.'\'}, url, {method: \'get\', parameters: "keysearch="+$("'.$htmlname.'").value+"&htmlname='.$htmlname.'&price_level='.$price_level.'"});});';
|
|
||||||
print '</script>';
|
|
||||||
print '<div class="notopnoleftnoright" id="ajdynfield'.$htmlname.'"></div>';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
If scriptaculous files are replaced by new version, following changes must be done:
|
|
||||||
|
|
||||||
* Edit prototype.js to set:
|
|
||||||
***************************
|
|
||||||
|
|
||||||
Ajax.Responders.register({
|
|
||||||
onCreate: function() {
|
|
||||||
$('indicator').show( );
|
|
||||||
Ajax.activeRequestCount++;
|
|
||||||
},
|
|
||||||
onComplete: function() {
|
|
||||||
$('indicator').hide( );
|
|
||||||
Ajax.activeRequestCount--;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -793,11 +793,9 @@ Object.extend(Ajax.Responders, Enumerable);
|
|||||||
|
|
||||||
Ajax.Responders.register({
|
Ajax.Responders.register({
|
||||||
onCreate: function() {
|
onCreate: function() {
|
||||||
$('indicator').show( );
|
|
||||||
Ajax.activeRequestCount++;
|
Ajax.activeRequestCount++;
|
||||||
},
|
},
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
$('indicator').hide( );
|
|
||||||
Ajax.activeRequestCount--;
|
Ajax.activeRequestCount--;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2598,5 +2598,66 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
|
|||||||
return $nbOpenDay;
|
return $nbOpenDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief R<>cup<75>re la valeur d'un champ, effectue un traitement Ajax et affiche le r<>sultat
|
||||||
|
\param htmlname nom et id du champ
|
||||||
|
\param keysearch nom et id compl<70>mentaire du champ de collecte
|
||||||
|
\param url chemin du fichier de r<>ponse : /chemin/fichier.php
|
||||||
|
\param option champ suppl<70>mentaire de recherche dans les param<61>tres
|
||||||
|
\param indicator nom de l'image gif
|
||||||
|
\return script script complet
|
||||||
|
*/
|
||||||
|
function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='ajaxworking')
|
||||||
|
{
|
||||||
|
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
|
||||||
|
$script.= '<span id="indicator'.$htmlname.'" style="display: none">'.img_gif('Working...',$indicator).'</span>';
|
||||||
|
$script.= '<script type="text/javascript">';
|
||||||
|
$script.= 'Ajax.Responders.register({
|
||||||
|
onCreate: function() {
|
||||||
|
$(\'indicator'.$htmlname.'\').show( );
|
||||||
|
},
|
||||||
|
onComplete: function() {
|
||||||
|
$(\'indicator'.$htmlname.'\').hide( );
|
||||||
|
}
|
||||||
|
});';
|
||||||
|
$script.= 'new Form.Element.Observer($("'.$keysearch.$htmlname.'"), 1,
|
||||||
|
function(){
|
||||||
|
var myAjax = new Ajax.Updater( {
|
||||||
|
success: \'ajdynfield'.$htmlname.'\'},
|
||||||
|
\''.DOL_URL_ROOT.$url.'\', {
|
||||||
|
method: \'get\',
|
||||||
|
parameters: "'.$keysearch.'="+$("'.$keysearch.$htmlname.'").value+"&htmlname='.$htmlname.$option.'"
|
||||||
|
});
|
||||||
|
});';
|
||||||
|
$script.= '</script>';
|
||||||
|
$script.= '<div class="notopnoleftnoright" id="ajdynfield'.$htmlname.'"></div>';
|
||||||
|
|
||||||
|
return $script;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief R<>cup<75>re la valeur d'un champ, effectue un traitement Ajax et affiche le r<>sultat
|
||||||
|
\param htmlname nom et id du champ
|
||||||
|
\param url chemin du fichier de r<>ponse : /chemin/fichier.php
|
||||||
|
\param indicator nom de l'image gif
|
||||||
|
\return script script complet
|
||||||
|
*/
|
||||||
|
function ajax_autocompleter($selected='',$htmlname,$url,$indicator='ajaxworking')
|
||||||
|
{
|
||||||
|
$script.= '<span id="indicator'.$htmlname.'" style="display: none">'.img_gif('Working...',$indicator).'</span>';
|
||||||
|
$script.= '<input type="hidden" name="'.$htmlname.'_id" id="'.$htmlname.'_id" value="'.$selected.'" />';
|
||||||
|
$script.= '</div>';
|
||||||
|
$script.= '<div id="result'.$htmlname.'" class="autocomplete"></div>';
|
||||||
|
$script.= '<script type="text/javascript">';
|
||||||
|
$script.= 'new Ajax.Autocompleter(\''.$htmlname.'\',\'result'.$htmlname.'\',\''.DOL_URL_ROOT.$url.'\',{
|
||||||
|
method: \'post\',
|
||||||
|
paramName: \''.$htmlname.'\',
|
||||||
|
indicator: \'indicator'.$htmlname.'\',
|
||||||
|
afterUpdateElement: ac_return
|
||||||
|
});';
|
||||||
|
$script.= '</script>';
|
||||||
|
|
||||||
|
return $script;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -426,7 +426,6 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
|
|||||||
|
|
||||||
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
|
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
|
||||||
$form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':'');
|
$form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':'');
|
||||||
if ($conf->use_javascript && $conf->use_ajax) print '<div id="hint"></div>';//utile pour afficher la recherche des pays avec ajax
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||||
|
|||||||
Reference in New Issue
Block a user