FIX Can't create thirdparty or validate invoice if profid is mandatory

and profid does not exists for other countries

Conflicts:
	htdocs/compta/facture.php
This commit is contained in:
Laurent Destailleur 2016-06-15 18:21:58 +02:00
parent db2269b9dd
commit 630a063283
2 changed files with 27 additions and 23 deletions

View File

@ -390,18 +390,19 @@ if (empty($reshook))
// Check parameters // Check parameters
// Check for mandatory prof id // Check for mandatory prof id (but only if country is than than ours)
for($i = 1; $i < 6; $i ++) if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id)
{
for ($i = 1; $i <= 6; $i++)
{ {
$idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY';
$idprof = 'idprof' . $i; $idprof = 'idprof' . $i;
if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory))
{ {
if (! $error) if (! $error) $langs->load("errors");
$langs->load("errors"); $error++;
$error ++; setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors');
}
setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors');
} }
} }

View File

@ -363,7 +363,7 @@ if (empty($reshook))
// Only for companies // Only for companies
if (!($object->particulier || $private)) if (!($object->particulier || $private))
{ {
for ($i = 1; $i < 5; $i++) for ($i = 1; $i <= 6; $i++)
{ {
$slabel="idprof".$i; $slabel="idprof".$i;
$_POST[$slabel]=trim($_POST[$slabel]); $_POST[$slabel]=trim($_POST[$slabel]);
@ -378,8 +378,10 @@ if (empty($reshook))
} }
} }
// 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'; $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) if (! $vallabel && ! empty($conf->global->$idprof_mandatory))
{ {
$langs->load("errors"); $langs->load("errors");
@ -390,6 +392,7 @@ if (empty($reshook))
} }
} }
} }
}
if (! $error) if (! $error)
{ {