diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c839d4fe462..cdf2bab0d78 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -508,10 +508,9 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $counter=0; $sql = "SELECT MAX(".$sqlstring.") as val"; $sql.= " FROM ".MAIN_DB_PREFIX.$table; - // $sql.= " WHERE ".$field." not like '(%'"; $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; $sql.= " AND ".$field." NOT LIKE '%PROV%'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".getEntity($table); if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere;