From d944c3bf1753a0a2807017eb245228881d3a044b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2015 11:40:24 +0200 Subject: [PATCH] Code cleaner when we are using multicompany --- htdocs/user/hierarchy.php | 22 +++++++++++++++++++++- htdocs/user/home.php | 15 ++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 0d6c2f9a7b8..b2090501789 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -78,7 +78,27 @@ foreach($fulltree as $key => $val) $userstatic->firstname=$val['firstname']; $userstatic->lastname=$val['lastname']; $userstatic->statut=$val['statut']; - $li=$userstatic->getNomUrl(1,'').' ('.$val['login'].(empty($conf->multicompany->enabled)?'':' - '.$langs->trans("Instance").' '.$val['entity']).')'; + + $entity=$val['entity']; + $entitystring=''; + // TODO Set of entitystring should be done with a hook + if (is_object($mc)) + { + if (! empty($conf->multicompany->enabled)) + { + if (empty($entity)) + { + $entitystring=$langs->trans("AllEntities"); + } + else + { + $mc->getInfo($entity); + $entitystring=$mc->label; + } + } + } + + $li=$userstatic->getNomUrl(1,'').' ('.$val['login'].($entitystring?' - '.$entitystring:'').')'; $data[] = array( 'rowid'=>$val['rowid'], diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 61d09e0e4c2..6288448349a 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -176,22 +176,27 @@ if ($resql) { print ' ('.$langs->trans("DomainUser").')'; } - // TODO This should be done with a hook + + $entity=$obj->entity; + $entitystring=''; + // TODO Set of entitystring should be done with a hook if (is_object($mc)) { if (! empty($conf->multicompany->enabled)) { - if (empty($obj->entity)) + if (empty($entity)) { - print ' ('.$langs->trans("AllEntities").')'; + $entitystring=$langs->trans("AllEntities"); } else { - $mc->getInfo($obj->entity); - print ' ('.$mc->label.')'; + $mc->getInfo($entity); + $entitystring=$mc->label; } } } + print ($entitystring?' ('.$entitystring.')':''); + print ''; print ''.dol_print_date($db->jdate($obj->datec),'dayhour').''; print '';