Work on multicompany module with smarty integration
This commit is contained in:
parent
47bc7b1dfe
commit
a3fa165d48
@ -60,6 +60,7 @@ print_titre($langs->trans("MultiCompanyModule"));
|
||||
|
||||
$mc = new Multicompany($db);
|
||||
$mc->getEntities();
|
||||
//var_dump($mc->entities);
|
||||
|
||||
$smarty->template_dir = DOL_DOCUMENT_ROOT.'/multicompany/templates/';
|
||||
|
||||
|
||||
@ -89,6 +89,40 @@ class Multicompany
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Fetch entity
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql.= $this->db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." as name";
|
||||
$sql.= ", ".$this->db->decrypt('value',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." as value";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)." LIKE 'MAIN_%'";
|
||||
$sql.= " AND entity = ".$id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$entityDetails = array();
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$entityDetails[$obj->name] = $obj->value;
|
||||
|
||||
$i++;
|
||||
}
|
||||
return $entityDetails;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Enable/disable entity
|
||||
*/
|
||||
@ -125,7 +159,6 @@ class Multicompany
|
||||
$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 value ASC";
|
||||
@ -143,9 +176,10 @@ class Multicompany
|
||||
$active = 1;
|
||||
if ($obj->entity < 0) $active = 0;
|
||||
|
||||
$this->entities[$i]['label'] = $obj->value;
|
||||
$this->entities[$i]['id'] = $obj->entity;
|
||||
$this->entities[$i]['active'] = $active;
|
||||
$this->entities[$i]['label'] = $obj->value;
|
||||
$this->entities[$i]['id'] = $obj->entity;
|
||||
$this->entities[$i]['details'] = $this->fetch($obj->entity);
|
||||
$this->entities[$i]['active'] = $active;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -23,14 +23,18 @@
|
||||
<tr class="liste_titre">
|
||||
|
||||
<td>{$langs->trans('Name')}</td>
|
||||
<td align="left">{$langs->trans('Description')}</td>
|
||||
<td align="left">{$langs->trans('Town')}</td>
|
||||
<td align="left">{$langs->trans('Country')}</td>
|
||||
<td align="left">{$langs->trans('Currency')}</td>
|
||||
<td align="center">{$langs->trans('Status')}</td>
|
||||
|
||||
{section name=mc loop=$entities}
|
||||
{strip}
|
||||
<tr class="{cycle values="impair,pair"}">
|
||||
<td>{$entities[mc].label}</td>
|
||||
<td align="left"> </td>
|
||||
<td align="left">{$entities[mc].details.MAIN_INFO_SOCIETE_VILLE}</td>
|
||||
<td align="left">{$entities[mc].details.MAIN_INFO_SOCIETE_PAYS}</td>
|
||||
<td align="left">{$entities[mc].details.MAIN_MONNAIE}</td>
|
||||
<td align="center">
|
||||
|
||||
{if $entities[mc].active}
|
||||
@ -46,4 +50,8 @@
|
||||
|
||||
</tr></table>
|
||||
|
||||
<div class="tabsAction">
|
||||
<a class="butAction" href="{$smarty.server.SCRIPT_NAME}?action=create">{$langs->trans('AddEntity')}</a>
|
||||
</div>
|
||||
|
||||
<!-- END SMARTY TEMPLATE -->
|
||||
Loading…
Reference in New Issue
Block a user