diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0ef90e7da0a..b472d197657 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -380,6 +380,7 @@ if (empty($reshook)) } } else { $object->ref = GETPOST('ref'); + $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); $object->ref_client = GETPOST('ref_client'); $object->datep = $datep; $object->date_livraison = $date_delivery; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 871508f1aa4..f94ea38675a 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -874,6 +874,7 @@ class Propal extends CommonObject $now=dol_now(); // Clean parameters + if (empty($this->entity)) $this->entity = $conf->entity; if (empty($this->date)) $this->date=$this->datep; $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); if (empty($this->availability_id)) $this->availability_id=0; @@ -983,7 +984,7 @@ class Propal extends CommonObject $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".$conf->entity; + $sql.= ", ".$this->entity; $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index ee88cd95404..aae70adfb62 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -990,7 +990,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($bentityon) // only if entity enable $sql.= " AND entity IN (".getEntity($sharetable).")"; else if (! empty($forceentity)) - $sql.= " AND entity = ".(int) $forceentity; + $sql.= " AND entity IN (".$forceentity.")"; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; @@ -1039,7 +1039,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($bentityon) // only if entity enable $sql.= " AND entity IN (".getEntity($sharetable).")"; else if (! empty($forceentity)) - $sql.= " AND entity = ".(int) $forceentity; + $sql.= " AND entity IN (".$forceentity.")"; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; @@ -1095,7 +1095,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($bentityon) // only if entity enable $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; else if (! empty($forceentity)) - $sql.= " AND entity = ".(int) $forceentity; + $sql.= " AND entity IN (".$forceentity.")"; if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index ef91cf1d2f3..cb1638aec82 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -128,15 +128,12 @@ class mod_propale_marbre extends ModeleNumRefPropales { global $db,$conf; - // Use object entity ID - $entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity); - // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$entity; + $sql.= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")"; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 47f71b5ffed..c91f9eb529c 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -149,8 +149,8 @@ class mod_propale_saphir extends ModeleNumRefPropales return 0; } - // Use object entity ID - $entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity); + // Get entities + $entity = getEntity('proposalnumber', 1, $propal); $date = $propal->date; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9e790437cb7..23f8b09169d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -764,7 +764,7 @@ class User extends CommonObject // Recuperation des droits utilisateurs + recuperation des droits groupes // D'abord les droits utilisateurs - $sql = "SELECT r.module, r.perms, r.subperms"; + $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = ur.fk_id"; @@ -818,7 +818,7 @@ class User extends CommonObject } // Maintenant les droits groupes - $sql = "SELECT r.module, r.perms, r.subperms"; + $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,"; $sql.= " ".MAIN_DB_PREFIX."rights_def as r";