From 5bd665f10d062640760174bc42f8e026fc040601 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Fri, 17 Oct 2014 09:53:17 +0200 Subject: [PATCH 1/3] Update functions2.lib.php disable entity filter fields for module who not use multicompany fields --- htdocs/core/lib/functions2.lib.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index e6f6228eec9..2272fb49988 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -573,17 +573,18 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti /** * Return last or next value for a mask (according to area we should not reset) * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler * @param string $mask Mask to use * @param string $table Table containing field with counter * @param string $field Field containing already used values of counter * @param string $where To add a filter on selection (for exemple to filter on invoice types) * @param Societe $objsoc The company that own the object we need a counter for * @param string $date Date to use for the {y},{m},{d} tags. - * @param string $mode 'next' for next value or 'last' for last value - * @return string New value (numeric) or error message + * @param string $mod 'next' for next value or 'last' for last value + * @param integer $bentityon enable or disable the entity filter (for modules not compatible with multicompany) + * @return string New value (numeric) or error message */ -function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next') +function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=1) { global $conf; @@ -784,7 +785,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sql.= " FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; $sql.= " AND ".$field." NOT LIKE '%PROV%'"; - $sql.= " AND entity IN (".getEntity($table, 1).")"; + if ($bEntityOn) // only if entity enable + $sql.= " AND entity IN (".getEntity($table, 1).")"; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; From 589a3fdf952fe4a075cb581d1158d0e14785429c Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Fri, 17 Oct 2014 10:26:34 +0200 Subject: [PATCH 2/3] Update functions2.lib.php --- htdocs/core/lib/functions2.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2272fb49988..4b206f852fc 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -580,11 +580,11 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti * @param string $where To add a filter on selection (for exemple to filter on invoice types) * @param Societe $objsoc The company that own the object we need a counter for * @param string $date Date to use for the {y},{m},{d} tags. - * @param string $mod 'next' for next value or 'last' for last value - * @param integer $bentityon enable or disable the entity filter (for modules not compatible with multicompany) + * @param string $mode 'next' for next value or 'last' for last value + * @param bool $bentityon activate the entity filterdefault is true (for modules not compatible with multicompany) * @return string New value (numeric) or error message */ -function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=1) +function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true) { global $conf; From 8095bbf809e0635d4819b8e47c6d8b3ae8410b93 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Fri, 17 Oct 2014 17:10:12 +0200 Subject: [PATCH 3/3] Update functions2.lib.php --- htdocs/core/lib/functions2.lib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 4b206f852fc..a2420624695 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -785,7 +785,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sql.= " FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; $sql.= " AND ".$field." NOT LIKE '%PROV%'"; - if ($bEntityOn) // only if entity enable + if ($bentityon) // only if entity enable $sql.= " AND entity IN (".getEntity($table, 1).")"; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; @@ -826,7 +826,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sql.= " FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; $sql.= " AND ".$field." NOT LIKE '%PROV%'"; - $sql.= " AND entity IN (".getEntity($table, 1).")"; + if ($bentityon) // only if entity enable + $sql.= " AND entity IN (".getEntity($table, 1).")"; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; @@ -879,7 +880,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; //$sql.= " WHERE ".$field." not like '(%'"; $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; - $maskrefclient_sql.= " AND entity IN (".getEntity($table, 1).")"; + if ($bentityon) // only if entity enable + $maskrefclient_sql.= " AND entity IN (".getEntity($table, 1).")"; 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."')";