From 2ffa73660a469f3b4dddc8cd6e8292f4a9a488b3 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 21 May 2012 09:21:03 +0200
Subject: [PATCH] Better error management

---
 htdocs/admin/company.php | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index ba3ee9a04a0..1cb0eb49773 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -52,13 +52,15 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
     require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
 
     $tmparray=getCountry(GETPOST('country_id','int'),'all',$db,$langs,0);
+    if (! empty($tmparray['id']))
+    {
+        $mysoc->country_id   =$tmparray['id'];
+        $mysoc->country_code =$tmparray['code'];
+        $mysoc->country_label=$tmparray['label'];
 
-    $mysoc->country_id=GETPOST('country_id','int');
-    $mysoc->country_code =$tmparray['code'];
-    $mysoc->country_label=$tmparray['label'];
-
-    $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $s,'chaine',0,'',$conf->entity);
+        $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
+        dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $s,'chaine',0,'',$conf->entity);
+    }
 
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"],'chaine',0,'',$conf->entity);
-- 
GitLab