FIX compatibility between proposal sharing and proposalnumber sharing

This commit is contained in:
Regis Houssin
2018-11-13 20:20:46 +01:00
parent 77582b2a41
commit 04edcaa89c
6 changed files with 11 additions and 12 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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."')";

View File

@@ -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)

View File

@@ -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;

View File

@@ -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";