diff --git a/htdocs/admin/multicompany.php b/htdocs/admin/multicompany.php index f724dbc6853..4a9d895216d 100644 --- a/htdocs/admin/multicompany.php +++ b/htdocs/admin/multicompany.php @@ -39,9 +39,9 @@ $mc = new Multicompany($db); * Actions */ -if ($_GET["action"] == 'enable' || $_GET["action"] == 'disable') +if ($_GET["action"] == 'set') { - $mc->setEntity($_GET['id'],$_GET["action"]); + $mc->setEntity($_GET['id'],$_GET["active"]); } diff --git a/htdocs/multicompany/multicompany.class.php b/htdocs/multicompany/multicompany.class.php index af4f89b9e2c..c5b78be49b1 100644 --- a/htdocs/multicompany/multicompany.class.php +++ b/htdocs/multicompany/multicompany.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2009-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,28 +49,6 @@ class Multicompany $this->canvas = "default"; $this->name = "admin"; $this->description = ""; - - /* - $this->active = MAIN_MULTICOMPANY; - - $this->menu_new = 'Admin'; - $this->menu_add = 1; - $this->menu_clear = 1; - - $this->no_button_copy = 1; - - $this->menus[0][0] = ''; - $this->menus[0][1] = ''; - $this->menus[1][0] = ''; - $this->menus[1][1] = ''; - - $this->next_prev_filter = "canvas='default'"; - - $this->onglets[0][0] = 'URL'; - $this->onglets[0][1] = 'name1'; - $this->onglets[1][0] = 'URL'; - $this->onglets[1][1] = 'name2'; - */ } /** @@ -137,23 +115,13 @@ class Multicompany /** * \brief Enable/disable entity */ - function setEntity($id,$action) + function setEntity($id,$active) { global $conf; - if ($action == 'enable') - { - $newid = str_replace('-','',$id); - } - else if ($action == 'disable') - { - $newid = '-'.$id; - } - - $sql = "UPDATE ".MAIN_DB_PREFIX."const"; - $sql.= " SET entity = ".$newid; - $sql.= " WHERE ".$this->db->decrypt('name')." = 'MAIN_INFO_SOCIETE_NOM'"; - $sql.= " AND entity = ".$id; + $sql = "UPDATE ".MAIN_DB_PREFIX."entity"; + $sql.= " SET active = ".$active; + $sql.= " WHERE rowid = ".$id; dol_syslog("Multicompany::setEntity sql=".$sql, LOG_DEBUG); @@ -167,12 +135,8 @@ class Multicompany { global $conf; - $sql = "SELECT "; - $sql.= $this->db->decrypt('value')." as value"; - $sql.= ", entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE ".$this->db->decrypt('name')." = 'MAIN_INFO_SOCIETE_NOM'"; - $sql.= " ORDER BY value ASC"; + $sql = "SELECT rowid, label, description, visible, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."entity"; $result = $this->db->query($sql); if ($result) @@ -184,19 +148,12 @@ class Multicompany { $obj = $this->db->fetch_object($result); - $active = 1; - $entity = $obj->entity; - - if ($obj->entity < 0) - { - $entity = str_replace('-','',$obj->entity); - $active = 0; - } - - $this->entities[$i]['label'] = $obj->value; - $this->entities[$i]['id'] = $obj->entity; - if ($details) $this->entities[$i]['details'] = $this->fetch($entity); - $this->entities[$i]['active'] = $active; + $this->entities[$i]['id'] = $obj->rowid; + $this->entities[$i]['label'] = $obj->label; + $this->entities[$i]['description'] = $obj->description; + $this->entities[$i]['visible'] = $obj->visible; + $this->entities[$i]['active'] = $obj->active; + if ($details) $this->entities[$i]['details'] = $this->fetch($obj->rowid); $i++; } diff --git a/htdocs/multicompany/templates/admin-entity.tpl b/htdocs/multicompany/templates/admin-entity.tpl index 6f1d9654365..e8c0fd78b9c 100644 --- a/htdocs/multicompany/templates/admin-entity.tpl +++ b/htdocs/multicompany/templates/admin-entity.tpl @@ -38,9 +38,9 @@ {if $entities[mc].active} - {$img_on} + {$img_on} {else} - {$img_off} + {$img_off} {/if}