From fd9c79fa7f245d87495572a6c426dad6d56ae6da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 7 Mar 2018 17:53:15 +0100 Subject: [PATCH] Fix: use getEntity if no rowid to compare --- htdocs/compta/bank/class/account.class.php | 4 +--- htdocs/compta/facture/class/paymentterm.class.php | 6 +++--- htdocs/core/class/commoninvoice.class.php | 4 +--- htdocs/core/class/html.form.class.php | 8 ++++---- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 2cba05f0bac..719a48c3e3c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -399,8 +399,6 @@ class Account extends CommonObject */ function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') { - global $conf; - // Deprecatîon warning if (is_numeric($oper)) { dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); @@ -416,7 +414,7 @@ class Account extends CommonObject { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE id=".$oper; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (".getEntity('c_paiement').")"; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index b0ee10aa19b..ffe50e86ee4 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -102,7 +102,7 @@ class PaymentTerm // extends CommonObject $sql.= "decalage"; $sql.= ") VALUES ("; $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; - $sql.= " ".(! isset($this->entity)?$conf->entity:"'".$this->db->escape($this->entity)."'").","; + $sql.= " ".(! isset($this->entity)?getEntity('c_payment_term'):"'".$this->db->escape($this->entity)."'").","; $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql.= " ".(! isset($this->sortorder)?'NULL':"'".$this->db->escape($this->sortorder)."'").","; $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").","; @@ -222,7 +222,7 @@ class PaymentTerm // extends CommonObject */ function getDefaultId() { - global $conf, $langs; + global $langs; $ret=0; @@ -230,7 +230,7 @@ class PaymentTerm // extends CommonObject $sql.= " t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; $sql.= " WHERE t.code = 'RECEP'"; - $sql.= " AND t.entity = " . $conf->entity; + $sql.= " AND t.entity IN (".getEntity('c_payment_term').")"; dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 97762482685..595105c5695 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -595,8 +595,6 @@ abstract class CommonInvoice extends CommonObject */ function calculate_date_lim_reglement($cond_reglement=0) { - global $conf; - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; @@ -606,7 +604,7 @@ abstract class CommonInvoice extends CommonObject $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; else { - $sqltemp.= " WHERE c.entity = ".$conf->entity; + $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3c4df109818..785685e9011 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2784,7 +2784,7 @@ class Form */ function load_cache_conditions_paiements() { - global $conf, $langs; + global $langs; $num = count($this->cache_conditions_paiements); if ($num > 0) return 0; // Cache already loaded @@ -2793,7 +2793,7 @@ class Form $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term'; - $sql.= " WHERE entity = " . $conf->entity; + $sql.= " WHERE entity IN (".getEntity('c_payment_term').")"; $sql.= " AND active > 0"; $sql.= " ORDER BY sortorder"; @@ -2997,7 +2997,7 @@ class Form */ function load_cache_types_paiements() { - global $conf, $langs; + global $langs; $num=count($this->cache_types_paiements); if ($num > 0) return $num; // Cache already loaded @@ -3008,7 +3008,7 @@ class Form $sql = "SELECT id, code, libelle as label, type, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql.= " WHERE entity = ".$conf->entity; + $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; //if ($active >= 0) $sql.= " AND active = ".$active; $resql = $this->db->query($sql);