From 09013c7e1c4c3f5e1fd641bcb668c51b842d9cbe Mon Sep 17 00:00:00 2001 From: Sof Date: Thu, 12 Feb 2015 13:00:22 +0100 Subject: [PATCH] FIX : Let ability to use IDPROF verifications even if new entry is "private" We do not check for duplicate or empty id_prof fields while inserting a new entry when verifications options are set to "ON" in the third party configuration panel. --- htdocs/societe/soc.php | 44 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index d0d9c9cbb47..23d9aa2d8e1 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -242,30 +242,34 @@ if (empty($reshook)) } // Check for duplicate or mandatory prof id - for ($i = 1; $i < 5; $i++) + // Only for companies + if (!($object->particulier || $private)) { - $slabel="idprof".$i; - $_POST[$slabel]=trim($_POST[$slabel]); - $vallabel=$_POST[$slabel]; - if ($vallabel && $object->id_prof_verifiable($i)) - { - if($object->id_prof_exists($i,$vallabel,$object->id)) + for ($i = 1; $i < 5; $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,$vallabel,$object->id)) + { + $langs->load("errors"); + $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); + $action = (($action=='add'||$action=='create')?'create':'edit'); + } + } + + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); - $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); - $action = (($action=='add'||$action=='create')?'create':'edit'); + $error++; + $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); + $action = (($action=='add'||$action=='create')?'create':'edit'); } - } - - $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; - - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) - { - $langs->load("errors"); - $error++; - $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = (($action=='add'||$action=='create')?'create':'edit'); - } + } } }