Skip to content
Snippets Groups Projects
Commit 756ca449 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Qual: Ajax code is simpler and now works with IE6

parent c2969658
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,10 @@
* \version $Id$
*/
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
// This is to make Dolibarr working with Plesk
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
......
......@@ -248,7 +248,7 @@ class Form
}
print ajax_indicator($htmlname,'working');
print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','');
print ajax_autocompleter($pays_id,'pays',DOL_URL_ROOT.'/societe/ajaxcountries.php','');
}
else
{
......@@ -495,7 +495,7 @@ class Form
//$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"';
$htmloption='';
print '<!-- Input text for third party with Ajax.Autocompleter (select_societes) -->'."\n";
print "\n".'<!-- Input text for third party with Ajax.Autocompleter (select_societes) -->'."\n";
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding">';
if ($socid == 0)
......@@ -507,7 +507,7 @@ class Form
{
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$obj->nom.'" '.$htmloption.' />';
}
print ajax_autocompleter(($socid?$socid:-1),$htmlname,'/societe/ajaxcompanies.php?filter='.urlencode($filter), '');
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '');
print '</td>';
print '<td class="nobordernopadding" align="left" width="16">';
print ajax_indicator($htmlname,'working');
......@@ -771,18 +771,17 @@ class Form
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
{
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding" width="80" nowrap="nowrap">';
print '<table class="nobordernopadding" width="100%"><tr class="nocellnopadd">';
print '<td class="nobordernopadding" nowrap="nowrap" width="80">';
print $langs->trans("RefOrLabel").':</td>';
print '<td class="nobordernopadding" align="left" width="16">';
print '<td class="nobordernopadding" width="16">';
print ajax_indicator($htmlname,'working'); // Indicator is et here
print '</td>';
print '<td align="left"><input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'"> ';
print '</td>';
print '<td><input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'"></td>';
print '</tr>';
print '<tr class="nocellnopadd">';
print '<td class="nobordernopadding" colspan="3">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,''); // Indicator is '' to disable it as it is alreay output
print ajax_updater($htmlname,'keysearch',DOL_URL_ROOT.'/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,''); // Indicator is '' to disable it as it is alreay output
print '</td></tr>';
print '</table>';
}
......@@ -999,7 +998,7 @@ class Form
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
{
print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&socid='.$socid.'&type='.$filtertype.'&mode=2','working');
print ajax_updater($htmlname,'keysearch',DOL_URL_ROOT.'/product/ajaxproducts.php','&socid='.$socid.'&type='.$filtertype.'&mode=2','working');
}
else
{
......
......@@ -474,7 +474,7 @@ class FormCompany
$javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&amp;".$htmlname."=\' + document.getElementById(\'newcompany_id\').value;";
$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"';
print '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n";
print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n";
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
print '<td class="nobordernopadding">';
if ($obj->rowid == 0)
......
......@@ -31,7 +31,7 @@ function ajax_indicator($htmlname,$indicator='working')
}
/**
* \brief Recupere la valeur d'un champ, effectue un traitement Ajax et affiche le resultat
* \brief Get value of a field, do Ajax process and show result
* \param htmlname nom et id du champ
* \param keysearch nom et id complementaire du champ de collecte
* \param url chemin du fichier de reponse : /chemin/fichier.php
......@@ -136,7 +136,7 @@ function ajax_autocompleter($selected='',$htmlname,$url,$indicator='working')
paramName: \''.$htmlname.'\',
indicator: \'indicator'.$htmlname.'\',
afterUpdateElement: ac_return
});';
});'; // Note: The ac_return will fill value inside the field htmlname (param of Autocompleter constructor) and htmlname_id (function ac_return)
$script.= '</script>';
return $script;
......
......@@ -585,14 +585,9 @@ function newpopup(url,title) {
Licence: GPL
==================================================================*/
function ac_return(field, item){
// on met en place l'expression rgulire
var regex = new RegExp('[0123456789]*-idcache', 'i');
// on l'applique au contenu
var idCache = regex.exec($(item).innerHTML);
//on rcupre l'id
id = idCache[0].replace('-idcache', '');
// et on l'affecte au champ cach
$(field.name+'_id').value = id;
/*alert('id='+field.name+'-'+item.id);*/
$(field.name+'_id').value = item.id;
/*alert('after='+$(field.name+'_id').value);*/
}
/*=================================================================
......@@ -601,9 +596,9 @@ function ac_return(field, item){
Author: Regis Houssin
Licence: GPL
==================================================================*/
function ac_delay(funct,delay) {
// dlai exprim en millisecondes avant le dclenchement de l'action
setTimeout(funct,delay);
function ac_delay(funct,delay) {
/* delay before action start */
setTimeout(funct,delay);
}
/*=================================================================
......
......@@ -167,9 +167,9 @@ if ($conf->file->main_force_https)
// Chargement des includes complementaires de presentation
if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); // Need 11ko memory (11ko in 2.2)
if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); // Need 690ko memory (800ko in 2.2)
if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php'); // Need 20ko memory
if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); // Need 10ko memory (11ko in 2.2)
if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); // Need 660ko memory (800ko in 2.2)
if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php'); // Need 22ko memory
//stopwithmem();
// If install or upgrade process not done or not completely finished, we call the install page.
......
......@@ -24,7 +24,10 @@
* \version $Id$
*/
define('NOTOKENRENEWAL',1); // Disables token renewal
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
require('../main.inc.php');
......
......@@ -24,7 +24,10 @@
* \version $Id$
*/
define('NOTOKENRENEWAL',1); // Disables token renewal
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
require('../main.inc.php');
......@@ -53,9 +56,9 @@ if (! empty($_POST['newcompany']) || ! empty($_POST['socid']) || ! empty($_POST[
print '<ul>';
while ($company = $db->fetch_object($resql))
{
print '<li>';
print '<li id="'.$company->rowid.'">';
print $company->nom;
print '<span id="object" class="informal" style="display:none">'.$company->rowid.'-idcache</span>';
//print '<span id="object" class="informal" style="display:none">'.$company->rowid.'-idcache</span>';
print '</li>';
}
print '</ul>';
......
......@@ -23,7 +23,10 @@
* \version $Id$
*/
define('NOTOKENRENEWAL',1); // Disables token renewal
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
require('../main.inc.php');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment