2
0
forked from Wavyzz/dolibarr

New: add dictionnary sharing (multicompany)

This commit is contained in:
Regis Houssin
2017-06-08 10:24:16 +02:00
parent 1820649175
commit 44dba391c1
7 changed files with 89 additions and 47 deletions

View File

@@ -102,18 +102,21 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
/**
* Get list of entity id to use.
*
* @param string $element Current element
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
* 'product', 'productprice', 'stock',
* 'propal', 'supplier_proposal', 'facture', 'facture_fourn',
* 'categorie', 'bank_account', 'bank_account', 'adherent', 'user',
* 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey',
* 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project',
* 'email_template', 'event',
* @param int $shared 1=Return id of current entity + shared entities (default), 0=Return id of current entity only
* @param string $element Current element
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
* 'product', 'productprice', 'stock',
* 'propal', 'supplier_proposal', 'facture', 'facture_fourn',
* 'categorie', 'bank_account', 'bank_account', 'adherent', 'user',
* 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey',
* 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project',
* 'email_template', 'event',
* @param int $shared 0=Return id of current entity only,
* 1=Return id of current entity + shared entities (default),
* 2=Return id of current entity OR $forceentity value (eg. dictionnary share)
* @param int $forceentity Entity id
* @return mixed Entity id(s) to use
*/
function getEntity($element=false, $shared=1)
function getEntity($element=false, $shared=1, $forceentity=null)
{
global $conf, $mc;
@@ -124,14 +127,23 @@ function getEntity($element=false, $shared=1)
if (is_object($mc))
{
return $mc->getEntity($element, $shared);
return $mc->getEntity($element, $shared, $forceentity);
}
else
{
$out='';
$addzero = array('user', 'usergroup', 'email_template', 'default_values');
if (in_array($element, $addzero)) $out.= '0,';
$out.= $conf->entity;
if ($shared == 2)
{
$out.= $forceentity;
}
else
{
$addzero = array('user', 'usergroup', 'email_template', 'default_values');
if (in_array($element, $addzero)) $out.= '0,';
$out.= $conf->entity;
}
return $out;
}
}