Fix: use object entity ID instead current entity
This commit is contained in:
parent
df55bee8ae
commit
80adac12c0
@ -708,9 +708,10 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
|
|||||||
* @param string $mode 'next' for next value or 'last' for last value
|
* @param string $mode 'next' for next value or 'last' for last value
|
||||||
* @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany)
|
* @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany)
|
||||||
* @param User $objuser Object user we need data from.
|
* @param User $objuser Object user we need data from.
|
||||||
|
* @param int $forceentity Entity id to force
|
||||||
* @return string New value (numeric) or error message
|
* @return string New value (numeric) or error message
|
||||||
*/
|
*/
|
||||||
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null)
|
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null, $forceentity=null)
|
||||||
{
|
{
|
||||||
global $conf,$user;
|
global $conf,$user;
|
||||||
|
|
||||||
@ -987,7 +988,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
|||||||
$sql.= " AND ".$field." NOT LIKE '(PROV%)'";
|
$sql.= " AND ".$field." NOT LIKE '(PROV%)'";
|
||||||
if ($bentityon) // only if entity enable
|
if ($bentityon) // only if entity enable
|
||||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||||
|
else if (! empty($forceentity))
|
||||||
|
$sql.= " AND entity = ".(int) $forceentity;
|
||||||
if ($where) $sql.=$where;
|
if ($where) $sql.=$where;
|
||||||
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||||
|
|
||||||
@ -1035,6 +1037,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
|||||||
$sql.= " AND ".$field." NOT LIKE '%PROV%'";
|
$sql.= " AND ".$field." NOT LIKE '%PROV%'";
|
||||||
if ($bentityon) // only if entity enable
|
if ($bentityon) // only if entity enable
|
||||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||||
|
else if (! empty($forceentity))
|
||||||
|
$sql.= " AND entity = ".(int) $forceentity;
|
||||||
if ($where) $sql.=$where;
|
if ($where) $sql.=$where;
|
||||||
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||||
|
|
||||||
@ -1089,6 +1093,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
|||||||
$maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
|
$maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
|
||||||
if ($bentityon) // only if entity enable
|
if ($bentityon) // only if entity enable
|
||||||
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
|
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||||
|
else if (! empty($forceentity))
|
||||||
|
$sql.= " AND entity = ".(int) $forceentity;
|
||||||
if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
|
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
|
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."')";
|
$maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')";
|
||||||
|
|||||||
@ -108,12 +108,15 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
|||||||
{
|
{
|
||||||
global $db,$conf;
|
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
|
// D'abord on recupere la valeur max
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||||
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$entity;
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -124,9 +124,12 @@ class mod_propale_saphir extends ModeleNumRefPropales
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use object entity ID
|
||||||
|
$entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity);
|
||||||
|
|
||||||
$date = $propal->date;
|
$date = $propal->date;
|
||||||
|
|
||||||
$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date);
|
$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date,'next',false,null,$entity);
|
||||||
|
|
||||||
return $numFinal;
|
return $numFinal;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user