diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 97186b84d8d..23d340d2daa 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -38,7 +38,7 @@ $typeconst=array('yesno','texte','chaine'); if ($_POST["action"] == 'update' || $_POST["action"] == 'add') { - if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'')); + if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'',$_POST["entity"])); { print $db->error(); } @@ -93,10 +93,17 @@ print ''; # Affiche lignes des constantes if ($all==1){ - $sql = "SELECT rowid, name, value, note FROM llx_const ORDER BY name ASC"; + $sql = "SELECT rowid, name, value, note, entity "; + $sql.= "FROM llx_const "; + $sql.= "WHERE entity = 0 OR entity = ".$conf->entity." "; + $sql.= "ORDER BY name ASC"; }else{ - $sql = "SELECT rowid, name, value, note FROM llx_const WHERE visible = 1 ORDER BY name ASC"; + $sql = "SELECT rowid, name, value, note, entity "; + $sql.= "FROM llx_const "; + $sql.= "WHERE visible = 1 AND (entity = 0 OR entity = ".$conf->entity.") "; + $sql.= "ORDER BY name ASC"; } +dol_syslog("Const::listConstant sql=".$sql,LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -113,6 +120,7 @@ if ($result) print ''; print ''; print ''; + print ''; print "$obj->name\n"; diff --git a/htdocs/core/conf.class.php b/htdocs/core/conf.class.php index 223df365100..4930536c950 100644 --- a/htdocs/core/conf.class.php +++ b/htdocs/core/conf.class.php @@ -84,7 +84,7 @@ class Conf * - En $this->global->key=value */ $sql = "SELECT name, value, entity FROM ".MAIN_DB_PREFIX."const "; - $sql.= " WHERE entity = ".$this->entity; + $sql.= " WHERE entity = 0 OR entity = ".$this->entity; $result = $db->query($sql); if ($result) { diff --git a/mysql/tables/llx_const.sql b/mysql/tables/llx_const.sql index 5cae9a285da..9dead9c3dbc 100644 --- a/mysql/tables/llx_const.sql +++ b/mysql/tables/llx_const.sql @@ -36,4 +36,13 @@ create table llx_const tms timestamp, entity integer DEFAULT 1 NOT NULL, -- multi company id UNIQUE INDEX(name) -)type=innodb; \ No newline at end of file +)type=innodb; + +-- +-- List of codes for the field entity +-- +-- 0 : common constant +-- 1 : first company constant +-- 2 : second company constant +-- 3 : etc... +-- \ No newline at end of file