Le mardi 13 juin 2006 à 14:42 -0400, Christophe PEREZ a écrit :
Mais là, c'était juste pour test, car ce n'est sans aucun doute pas la
bonne méthode pour faire quelque chose de générique. C'était juste
pour
traquer le bug, qui sans nul doute est lié à cette multiplication de
code.
Je laisse le soin au concepteur de cette fonctionnalité ajax de faire
plus propre et de l'implémenter partout où il se doit ;-)
Dans l'élan, je suggérerais les modifications du patch joint.
À ne pas nécessairement prendre à la lettre, mais le fait de ramener le
chargement du js dans le main.inc.php, et la fonction publish_selvalue()
dans lib_head.js permet à priori de ne plus toucher aux différentes
pages/scripts php.
------------------------------------------------------------------------
--- /var/www/dolibarrcvs/htdocs/commande/fiche.php 2006-06-10
06:50:26.000000000 -0400
+++ /var/www/dolibarrnew/htdocs/commande/fiche.php 2006-06-13
18:26:02.000000000 -0400
@@ -580,19 +580,19 @@
print "</td></tr>";
// Adresse de livraison
- print '<tr><td
nowrap>'.$langs->trans('DeliveryAddress').'</td><td>';
+ print '<tr><td
nowrap="nowrap">'.$langs->trans('DeliveryAddress').'</td><td>';
$numaddress =
$html->select_adresse_livraison($soc->adresse_livraison_id,
$_GET['socidp'],'adresse_livraison_id');
if ($numaddress==0)
{
- print ' <a
href=../comm/adresse_livraison.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
+ print ' <a
href="../comm/adresse_livraison.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddAddress").'</a>';
}
print '</td></tr>';
// Conditions de réglement
- print '<tr><td
nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td>';
+ print '<tr><td
nowrap="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1);
print '</td></tr>';
@@ -870,7 +870,7 @@
// Ref commande client
print '<tr><td>';
- print '<table class="nobordernopadding"
width="100%"><tr><td nowrap>';
+ print '<table class="nobordernopadding" width="100%"><tr><td
nowrap="nowrap">';
print $langs->trans('RefCustomer').'</td><td
align="left">';
print '</td>';
if ($_GET['action'] != 'refcdeclient' && $commande->brouillon) print '<td align="right"><a
href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
@@ -1196,7 +1196,7 @@
print '</td>';
print '<td align="right"><input size="5" type="text"
class="flat" name="elprice" value="'.price($objp->subprice).'"></td>';
print '<td align="right"><input size="2" type="text"
class="flat" name="elqty" value="'.$objp->qty.'"></td>';
- print '<td align="right" nowrap><input size="1" type="text"
class="flat" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
+ print '<td align="right" nowrap="nowrap"><input size="1" type="text"
class="flat" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
print '<td align="center" colspan="4"><input type="submit"
class="button" name="save" value="'.$langs->trans('Save').'">';
print '<br /><input type="submit" class="button"
name="cancel" value="'.$langs->trans('Cancel').'"></td>';
print '</tr>';
@@ -1362,7 +1362,7 @@
print '</td>';
print '<td align="right"><input type="text" name="pu"
size="5"></td>';
print '<td align="right"><input type="text" name="qty" value="1"
size="2"></td>';
- print '<td align="right" nowrap><input type="text" name="remise_percent"
size="1" value="'.$soc->remise_client.'">%</td>';
+ print '<td align="right" nowrap="nowrap"><input type="text"
name="remise_percent" size="1" value="'.$soc->remise_client.'">%</td>';
print '<td align="center" colspan="4"><input type="submit"
class="button" value="'.$langs->trans('Add').'"></td>';
print '</tr>';
@@ -1386,7 +1386,7 @@
print '</td>';
print '<td> </td>';
print '<td align="right"><input type="text" size="2" name="qty"
value="1"></td>';
- print '<td align="right" nowrap><input type="text" size="1"
name="remise_percent" value="'.$soc->remise_client.'">%</td>';
+ print '<td align="right" nowrap="nowrap"><input type="text" size="1"
name="remise_percent" value="'.$soc->remise_client.'">%</td>';
print '<td align="center" colspan="4"><input type="submit"
class="button" value="'.$langs->trans('Add').'"></td>';
print '</tr>';
--- /var/www/dolibarrcvs/htdocs/html.form.class.php 2006-06-10 19:03:25.000000000 -0400
+++ /var/www/dolibarrnew/htdocs/html.form.class.php 2006-06-13
14:35:49.000000000 -0400
@@ -703,17 +703,12 @@
global $langs,$conf,$user;
if($conf->use_ajax)
{
- print '<script type="text/javascript"
src="'.DOL_URL_ROOT.'/lib/prototype.js"></script>';
print $langs->trans("Ref").'<input type="text" size="5"
name="ajkeyref'.$htmlname.'" id="ajkeyref'.$htmlname.'"> ';
print $langs->trans("Label").'<input type="text" size="5"
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 'function
publish_selvalue(obj){$("'.$htmlname.'").value =
obj.options[obj.selectedIndex].value;}';
- print '</script>';
- print '<script type="text/javascript">';
- print 'var url =
\''.DOL_URL_ROOT.'/ajaxresponse.php\';';
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 id="ajdynfield'.$htmlname.'">';
--- /var/www/dolibarrcvs/htdocs/lib/lib_head.js 2006-06-05 14:26:46.000000000
-0400
+++ /var/www/dolibarrnew/htdocs/lib/lib_head.js 2006-06-13 18:24:42.000000000
-0400
@@ -736,3 +736,4 @@
}
+function publish_selvalue(obj) { $(obj.name).value = obj.options[obj.selectedIndex].value; }
--- /var/www/dolibarrcvs/htdocs/main.inc.php 2006-06-08 15:53:55.000000000
-0400
+++ /var/www/dolibarrnew/htdocs/main.inc.php 2006-06-13 18:26:35.000000000
-0400
@@ -327,6 +327,10 @@
{
print '<script language="javascript" type="text/javascript"
src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>';
}
+ if ($conf->use_ajax)
+ {
+ print '<script type="text/javascript"
src="'.DOL_URL_ROOT.'/lib/prototype.js"></script>';
+ }
print "</head>\n";
}