revert getNextValue function + createfromclone entity

This commit is contained in:
atm-quentin 2018-11-13 12:32:24 +01:00
parent c18f486179
commit 70fdff5c27
3 changed files with 5 additions and 21 deletions

View File

@ -996,7 +996,6 @@ class Facture extends CommonInvoice
$this->close_code = ''; $this->close_code = '';
$this->close_note = ''; $this->close_note = '';
$this->products = $this->lines; // Tant que products encore utilise $this->products = $this->lines; // Tant que products encore utilise
$this->entity = $conf->entity;
// Loop on each line of new invoice // Loop on each line of new invoice
foreach($this->lines as $i => $line) foreach($this->lines as $i => $line)

View File

@ -151,8 +151,7 @@ class mod_facture_mars extends ModeleNumRefFactures
*/ */
function getNextValue($objsoc, $invoice, $mode='next') function getNextValue($objsoc, $invoice, $mode='next')
{ {
global $db, $conf; global $db;
$prefix=$this->prefixinvoice; $prefix=$this->prefixinvoice;
if ($invoice->type == 1) $prefix=$this->prefixreplacement; 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 if ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice; else $prefix=$this->prefixinvoice;
$entity = ((isset($$invoice->entity) && is_numeric($$invoice->entity)) ? $$invoice->entity : $conf->entity);
// D'abord on recupere la valeur max // D'abord on recupere la valeur max
$posindice=8; $posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber').")";
else $sql.= " AND entity = $entity";
$resql=$db->query($sql); $resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
if ($resql) if ($resql)
@ -192,9 +187,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref"; $sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber').")";
else $sql.= " AND entity = $entity";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)

View File

@ -174,18 +174,12 @@ class mod_facture_terre extends ModeleNumRefFactures
if ($invoice->type == 2) $prefix=$this->prefixcreditnote; if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
else if ($invoice->type == 3) $prefix=$this->prefixdeposit; else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice; 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 // D'abord on recupere la valeur max
$posindice=8; $posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber').")";
else $sql.= " AND entity = $entity";
$resql=$db->query($sql); $resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
if ($resql) if ($resql)
@ -208,9 +202,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref"; $sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber').")";
else $sql.= " AND entity = $entity";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)