From 93a1e941a410f10c1c83c2b3e501546bfc6cf8ff Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 14 Nov 2018 15:34:39 +0100 Subject: [PATCH] FIX new method: override constants of current entity --- .../modules/facture/mod_facture_mercure.php | 67 +++++-------------- 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index e2e64988b4a..15a3d371915 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -141,55 +141,24 @@ class mod_facture_mercure extends ModeleNumRefFactures require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; - // Get Mask value - $mask = ''; - 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; - } - 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; - } - } - if (! $mask) - { - $this->error='NotConfigured'; - return 0; - } + // Get Mask value + $mask = ''; + if (is_object($invoice) && $invoice->type == 1) + { + $mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; + if (! $mask) + { + $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) + { + $this->error='NotConfigured'; + return 0; + } $where=''; //if ($facture->type == 2) $where.= " AND type = 2";