diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 85bcf2c68fa8e..04951cbb6cd4b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -392,21 +392,22 @@ // Check parameters - // Check for mandatory prof id - for($i = 1; $i < 6; $i ++) + // Check for mandatory prof id (but only if country is than than ours) + if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { - $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; - $idprof = 'idprof' . $i; - if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) - { - if (! $error) - $langs->load("errors"); - $error ++; - - setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors'); - } + for ($i = 1; $i <= 6; $i++) + { + $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; + $idprof = 'idprof' . $i; + if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) + { + if (! $error) $langs->load("errors"); + $error++; + setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors'); + } + } } - + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 85eacc443413b..012aaf374e28f 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -396,7 +396,7 @@ // Only for companies if (!($object->particulier || $private)) { - for ($i = 1; $i < 5; $i++) + for ($i = 1; $i <= 6; $i++) { $slabel="idprof".$i; $_POST[$slabel]=trim($_POST[$slabel]); @@ -411,15 +411,18 @@ } } - $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'); - } + // Check for mandatory prof id (but only if country is than than ours) + if ($mysoc->country_id > 0 && $object->country_id == $mysoc->country_id) + { + $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'); + } + } } } }