From fe48342aaf283d200fdc834b503a64649e0b96d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 May 2012 10:37:03 +0200 Subject: [PATCH] Fix: Check for duplicate must ignore spaces before and after --- htdocs/societe/soc.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index f79e031c927..12f0b0e34a3 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -198,15 +198,18 @@ if (empty($reshook)) $action = ($action=='add'?'create':'edit'); } + // Check for duplicate prof id for ($i = 1; $i < 3; $i++) { - $slabel="idprof".$i; - if (($_POST[$slabel] && $object->id_prof_verifiable($i))) + $slabel="idprof".$i; + $_POST[$slabel]=trim($_POST[$slabel]); + $vallabel=$_POST[$slabel]; + if ($vallabel && $object->id_prof_verifiable($i)) { - if($object->id_prof_exists($i,$_POST["$slabel"],$object->id)) + if($object->id_prof_exists($i,$vallabel,$object->id)) { $langs->load("errors"); - $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $_POST[$slabel]); + $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); $action = ($action=='add'?'create':'edit'); } }