From 0eca8982ecf9e7adccb718e63d4bad2f43cb099b Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Mon, 12 Feb 2007 12:50:33 +0000
Subject: [PATCH] =?UTF-8?q?Fix:=20ajout=20traitement=20pour=20la=20liste?=
 =?UTF-8?q?=20d=E9roulante=20des=20pays=20dans=20configuration->societe?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/admin/company.php   | 16 +---------------
 htdocs/html.form.class.php | 12 +++++++++---
 htdocs/lib/lib_head.js     |  6 ++++++
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 13f49552dc0..44b90d0d79b 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -115,20 +115,6 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
   /**
    * Edition des param�tres
    */
-  if ($conf->use_javascript)
-    {
-      print '
-        <script language="javascript" type="text/javascript">
-        <!--
-        function save_refresh()
-        {
-        	document.form_index.action.value="updateedit";
-        	document.form_index.submit();
-        }
-        -->
-        </script>
-        ';
-    }
     
   print '<form enctype="multipart/form-data" method="post" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
   print '<input type="hidden" name="action" value="update">';
@@ -155,7 +141,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
   
   $var=!$var;
   print '<tr '.$bc[$var].'><td>'.$langs->trans("Country").'</td><td>';
-  $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',($conf->use_javascript?' onChange="save_refresh()"':''));
+  $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',($conf->use_javascript?' onChange="company_save_refresh()"':''));
   print '</td></tr>';
   
   $var=!$var;
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 0ce30b18155..613da1f37ba 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -327,15 +327,21 @@ class Form
 				$pays_id = $obj->rowid?$obj->rowid:'';
 				
 				// On applique un delai d'execution pour le bon fonctionnement
-				$mode = substr($htmloption,-9,6);
-				if ($mode == 'create')
+				$mode_create = substr($htmloption,-9,6);
+				$mode_edit = substr($htmloption,-7,4);
+				$mode_company = substr($htmloption,-10,7);
+				if ($mode_create == 'create')
 				{
 					$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_create()\',\'500\')"';
 				}
-				else
+				else if ($mode_edit == 'edit')
 				{
 					$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_edit()\',\'500\')"';
 				}
+				else if ($mode_company == 'refresh')
+				{
+					$htmloption = 'onChange="ac_delay(\'company_save_refresh()\',\'500\')"';
+				}
 				
 				print '<div>';
 				print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />';
diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js
index c9296e110df..3a13eaa2874 100644
--- a/htdocs/lib/lib_head.js
+++ b/htdocs/lib/lib_head.js
@@ -35,6 +35,12 @@ function autofilltownfromzip_save_refresh_create()
     document.formsoc.submit();
 }
 
+function company_save_refresh()
+{
+    document.form_index.action.value="updateedit";
+    document.form_index.submit();
+}
+
 
 
 /*=================================================================
-- 
GitLab