diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 97417bd8b9d..69816eb1660 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -996,7 +996,6 @@ class Facture extends CommonInvoice $this->close_code = ''; $this->close_note = ''; $this->products = $this->lines; // Tant que products encore utilise - $this->entity = $conf->entity; // Loop on each line of new invoice foreach($this->lines as $i => $line) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 222b3342d6f..5dbc1dd2b7a 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -151,8 +151,7 @@ class mod_facture_mars extends ModeleNumRefFactures */ function getNextValue($objsoc, $invoice, $mode='next') { - global $db, $conf; - + global $db; $prefix=$this->prefixinvoice; if ($invoice->type == 1) $prefix=$this->prefixreplacement; @@ -160,16 +159,12 @@ class mod_facture_mars extends ModeleNumRefFactures else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; - $entity = ((isset($$invoice->entity) && is_numeric($$invoice->entity)) ? $$invoice->entity : $conf->entity); - // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); if ($resql) @@ -192,9 +187,7 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index e24205cb2d6..3d323ba2c6b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -174,18 +174,12 @@ class mod_facture_terre extends ModeleNumRefFactures if ($invoice->type == 2) $prefix=$this->prefixcreditnote; else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else $prefix=$this->prefixinvoice; - - // D'abord on recupere la valeur max - $entity = ((isset($invoice->entity) && is_numeric($invoice->entity)) ? $invoice->entity : $conf->entity); - // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); if ($resql) @@ -208,9 +202,7 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; - else $sql.= " AND entity = $entity"; - + $sql.= " AND entity IN (".getEntity('invoicenumber').")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); if ($resql)