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,21 +390,22 @@ 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)
{ {
$idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; for ($i = 1; $i <= 6; $i++)
$idprof = 'idprof' . $i; {
if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY';
{ $idprof = 'idprof' . $i;
if (! $error) if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory))
$langs->load("errors"); {
$error ++; if (! $error) $langs->load("errors");
$error++;
setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors'); setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors');
} }
}
} }
$qualified_for_stock_change = 0; $qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$qualified_for_stock_change = $object->hasProductsOrServices(2); $qualified_for_stock_change = $object->hasProductsOrServices(2);

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,15 +378,18 @@ if (empty($reshook))
} }
} }
$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; // Check for mandatory prof id (but only if country is than than ours)
if ($mysoc->country_id > 0 && $object->country_id == $mysoc->country_id)
if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) {
{ $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
$langs->load("errors"); if (! $vallabel && ! empty($conf->global->$idprof_mandatory))
$error++; {
$errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); $langs->load("errors");
$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');
}
}
} }
} }
} }