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

@ -141,55 +141,24 @@ class mod_facture_mercure extends ModeleNumRefFactures
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
// Get Mask value // Get Mask value
$mask = ''; $mask = '';
if (is_object($invoice) && $invoice->type == 1) if (is_object($invoice) && $invoice->type == 1)
{ {
$constant = 'FACTURE_MERCURE_MASK_REPLACEMENT_'.$invoice->entity; $mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
if (! empty($conf->global->$constant)) { if (! $mask)
$mask = $conf->global->$constant; // for multicompany proposal sharing {
} else { $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
$mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; }
} }
if (! $mask) 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;
$constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity; else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
if (! empty($conf->global->$constant)) { if (! $mask)
$mask = $conf->global->$constant; // for multicompany proposal sharing {
} else { $this->error='NotConfigured';
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; return 0;
} }
}
}
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;
}
}
if (! $mask)
{
$this->error='NotConfigured';
return 0;
}
$where=''; $where='';
//if ($facture->type == 2) $where.= " AND type = 2"; //if ($facture->type == 2) $where.= " AND type = 2";