diff --git a/htdocs/admin/multicompany.php b/htdocs/admin/multicompany.php
index 54bdc925387..8e991934380 100644
--- a/htdocs/admin/multicompany.php
+++ b/htdocs/admin/multicompany.php
@@ -38,6 +38,12 @@ accessforbidden();
* Actions
*/
+if ($_GET["action"] == 'enable' || $_GET["action"] == 'disable')
+{
+ $mc = new Multicompany($db);
+ $mc->setEntity($_GET['id'],$_GET["action"]);
+}
+
llxHeader('',$langs->trans("MultiCompanySetup"));
@@ -46,7 +52,7 @@ print_fiche_titre($langs->trans("MultiCompanySetup"),$linkback,'setup');
/*
- *
+ * View
*/
print '
';
diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php
index 346be15ce58..62f5dd835dd 100644
--- a/htdocs/admin/propale.php
+++ b/htdocs/admin/propale.php
@@ -344,7 +344,7 @@ while (($file = readdir($handle))!==false)
print $module->description;
print '';
- // Activ�
+ // Activate
if (in_array($name, $def))
{
print "
\n";
@@ -367,7 +367,7 @@ while (($file = readdir($handle))!==false)
print " | ";
}
- // Defaut
+ // Default
print "";
if ($conf->global->PROPALE_ADDON_PDF == "$name")
{
@@ -411,7 +411,7 @@ print ' ';
/*
- * Autres options
+ * Other options
*
*/
print_titre($langs->trans("OtherOptions"));
@@ -495,7 +495,7 @@ print '';
/*
- * Repertoire
+ * Directory
*/
print ' ';
print_titre($langs->trans("PathToDocuments"));
diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php
index d9938a1735c..4423609e305 100644
--- a/htdocs/includes/modules/DolibarrModules.class.php
+++ b/htdocs/includes/modules/DolibarrModules.class.php
@@ -759,11 +759,14 @@ class DolibarrModules
$val = $this->const[$key][2];
$note = $this->const[$key][3];
$visible= $this->const[$key][4];
+ $entity = $this->const[$key][5];
+
+ $entity = ((!empty($entity) || $entity == 0)?$entity:$conf->entity);
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." = '".$name."'";
- $sql.= " AND entity = ".$conf->entity;
+ $sql.= " AND entity = ".$entity;
$result=$this->db->query($sql);
if ($result)
@@ -782,7 +785,7 @@ class DolibarrModules
$sql.= ",".$this->db->encrypt($val,$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1);
$sql.= ",'".$note."'";
$sql.= ",'".$visible."'";
- $sql.= ",".$conf->entity;
+ $sql.= ",".$entity;
$sql.= ")";
}
elseif (strlen($val))
@@ -793,7 +796,7 @@ class DolibarrModules
$sql.= ",'".$type."'";
$sql.= ",".$this->db->encrypt($val,$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1);
$sql.= ",'".$visible."'";
- $sql.= ",".$conf->entity;
+ $sql.= ",".$entity;
$sql.= ")";
}
else
@@ -803,7 +806,7 @@ class DolibarrModules
$sql.= $this->db->encrypt($name,$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1);
$sql.= ",'".$type."'";
$sql.= ",'".$visible."'";
- $sql.= ",".$conf->entity;
+ $sql.= ",".$entity;
$sql.= ")";
}
@@ -816,7 +819,7 @@ class DolibarrModules
}
else
{
- dol_syslog("DolibarrModules::insert_const constant '".$name."' alreday exists");
+ dol_syslog("DolibarrModules::insert_const constant '".$name."' already exists");
}
}
else
diff --git a/htdocs/includes/modules/modMultiCompany.class.php b/htdocs/includes/modules/modMultiCompany.class.php
index 104c017a92b..b62869dc25b 100644
--- a/htdocs/includes/modules/modMultiCompany.class.php
+++ b/htdocs/includes/modules/modMultiCompany.class.php
@@ -70,7 +70,7 @@ class modMultiCompany extends DolibarrModules
$this->picto='globe';
// Data directories to create when module is enabled.
- $this->dirs = array();
+ $this->dirs = array('/smarty/cache/temp','/smarty/templates/temp');
// Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'.
$this->style_sheet = '';
@@ -86,10 +86,12 @@ class modMultiCompany extends DolibarrModules
$this->langfiles = array("multicompany");
// Constants
- $this->const = array(); // List of particular constants to add when module is enabled
+ // List of particular constants to add when module is enabled
//Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),
// 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );
+ $this->const=array(1=>array('MAIN_MODULE_MULTICOMPANY_NEEDSMARTY',"chaine",1,'Need smarty',0,0));
+
// Array to add new pages in new tabs
//$this->tabs = array('entity:Title:@mymodule:/mymodule/mynewtab.php?id=__ID__');
// where entity can be
diff --git a/htdocs/multicompany/multicompany.class.php b/htdocs/multicompany/multicompany.class.php
index d8aebd1a672..547498ca2b2 100644
--- a/htdocs/multicompany/multicompany.class.php
+++ b/htdocs/multicompany/multicompany.class.php
@@ -89,6 +89,32 @@ class Multicompany
}
+ /**
+ * \brief Enable/disable entity
+ */
+ function setEntity($id,$action)
+ {
+ 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',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." = 'MAIN_INFO_SOCIETE_NOM'";
+ $sql.= " AND entity = ".$id;
+
+ dol_syslog("Multicompany::setEntity sql=".$sql, LOG_DEBUG);
+
+ $result = $this->db->query($sql);
+ }
+
/**
* \brief List of entities
*/
@@ -96,12 +122,13 @@ class Multicompany
{
global $conf;
- $sql = "SELECT ".$this->db->decrypt('value',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." as value";
+ $sql = "SELECT ";
+ $sql.= $this->db->decrypt('value',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." as value";
$sql.= ", entity";
$sql.= ", visible";
$sql.= " FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." = 'MAIN_INFO_SOCIETE_NOM'";
- $sql.= " ORDER BY entity ASC";
+ $sql.= " ORDER BY value ASC";
$result = $this->db->query($sql);
if ($result)
@@ -139,12 +166,14 @@ class Multicompany
{
foreach ($entities as $entity)
{
- print '';
+ if ($entity['active'] == 1)
+ {
+ print '';
+ }
}
}
print '';
@@ -166,7 +195,7 @@ class Multicompany
$smarty->assign('entities',$this->entities);
$smarty->assign('img_on',img_picto($langs->trans("Activated"),'on'));
- $smarty->assign('img_off',img_picto($langs->trans("Disabled"),'on'));
+ $smarty->assign('img_off',img_picto($langs->trans("Disabled"),'off'));
}
diff --git a/htdocs/multicompany/templates/admin-entity.tpl b/htdocs/multicompany/templates/admin-entity.tpl
index 347d2680475..9805f85fb5c 100644
--- a/htdocs/multicompany/templates/admin-entity.tpl
+++ b/htdocs/multicompany/templates/admin-entity.tpl
@@ -34,9 +34,9 @@
|
{if $entities[mc].active}
- {$img_on}
+ {$img_on}
{else}
- {$img_off}
+ {$img_off}
{/if}
|