mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Work on multicompany module with smarty integration
This commit is contained in:
parent
739b230b86
commit
03ff1d83c7
|
|
@ -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 '<br>';
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ while (($file = readdir($handle))!==false)
|
|||
print $module->description;
|
||||
print '</td>';
|
||||
|
||||
// Activ<EFBFBD>
|
||||
// Activate
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
print "<td align=\"center\">\n";
|
||||
|
|
@ -367,7 +367,7 @@ while (($file = readdir($handle))!==false)
|
|||
print "</td>";
|
||||
}
|
||||
|
||||
// Defaut
|
||||
// Default
|
||||
print "<td align=\"center\">";
|
||||
if ($conf->global->PROPALE_ADDON_PDF == "$name")
|
||||
{
|
||||
|
|
@ -411,7 +411,7 @@ print '<br>';
|
|||
|
||||
|
||||
/*
|
||||
* Autres options
|
||||
* Other options
|
||||
*
|
||||
*/
|
||||
print_titre($langs->trans("OtherOptions"));
|
||||
|
|
@ -495,7 +495,7 @@ print '</table>';
|
|||
|
||||
|
||||
/*
|
||||
* Repertoire
|
||||
* Directory
|
||||
*/
|
||||
print '<br>';
|
||||
print_titre($langs->trans("PathToDocuments"));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 '<option value="'.$entity['id'].'" ';
|
||||
if ($selected == $entity['id']) print 'selected="true"';
|
||||
if ($entity['active'] == 0) print 'disabled="disabled"';
|
||||
print '>';
|
||||
print $entity['label'];
|
||||
print '</option>';
|
||||
if ($entity['active'] == 1)
|
||||
{
|
||||
print '<option value="'.$entity['id'].'" ';
|
||||
if ($selected == $entity['id']) print 'selected="true"';
|
||||
print '>';
|
||||
print $entity['label'];
|
||||
print '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
|
|
@ -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'));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@
|
|||
<td align="center">
|
||||
|
||||
{if $entities[mc].active}
|
||||
{$img_on}
|
||||
<a href="{$smarty.server.SCRIPT_NAME}?action=disable&id={$entities[mc].id}">{$img_on}</a>
|
||||
{else}
|
||||
{$img_off}
|
||||
<a href="{$smarty.server.SCRIPT_NAME}?action=enable&id={$entities[mc].id}">{$img_off}</a>
|
||||
{/if}
|
||||
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user