FIX new method: override constants of current entity

This commit is contained in:
Regis Houssin 2018-11-14 15:34:39 +01:00
parent 2bc25fc008
commit 93a1e941a4

View File

@ -145,46 +145,15 @@ class mod_facture_mercure extends ModeleNumRefFactures
$mask = ''; $mask = '';
if (is_object($invoice) && $invoice->type == 1) if (is_object($invoice) && $invoice->type == 1)
{ {
$constant = 'FACTURE_MERCURE_MASK_REPLACEMENT_'.$invoice->entity;
if (! empty($conf->global->$constant)) {
$mask = $conf->global->$constant; // for multicompany proposal sharing
} else {
$mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; $mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
}
if (! $mask) if (! $mask)
{ {
$constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity;
if (! empty($conf->global->$constant)) {
$mask = $conf->global->$constant; // for multicompany proposal sharing
} else {
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
}
}
}
else if (is_object($invoice) && $invoice->type == 2){
$constant = 'FACTURE_MERCURE_MASK_CREDIT_'.$invoice->entity;
if (! empty($conf->global->$constant)) {
$mask = $conf->global->$constant; // for multicompany proposal sharing
} else {
$mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
}
}
else if (is_object($invoice) && $invoice->type == 3){
$constant = 'FACTURE_MERCURE_MASK_DEPOSIT_'.$invoice->entity;
if (! empty($conf->global->$constant)) {
$mask = $conf->global->$constant; // for multicompany proposal sharing
} else {
$mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
}
}
else {
$constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity;
if (! empty($conf->global->$constant)) {
$mask = $conf->global->$constant; // for multicompany proposal sharing
} else {
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
} }
} }
else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
if (! $mask) if (! $mask)
{ {
$this->error='NotConfigured'; $this->error='NotConfigured';