31if (!defined(
'NOCSRFCHECK')) {
32 define(
'NOCSRFCHECK', 1);
34if (!defined(
'NOTOKENRENEWAL')) {
35 define(
'NOTOKENRENEWAL', 1);
38if (!defined(
'NOREQUIREMENU')) {
39 define(
'NOREQUIREMENU', 1);
43require_once
'../main.inc.php';
45$action =
GETPOST(
'action',
'aZ');
47$backtourl =
GETPOST(
'backtourl');
48if (empty($backtourl)) {
49 $backtourl = DOL_URL_ROOT;
53 $langs->setDefaultLang(
GETPOST(
'lang',
'aZ09'));
58$right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
59$left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
61if (!isModEnabled(
'multicompany')) {
70if ($action ==
'switchentity') {
72 $mc->switchEntity($entityid);
75 header(
"Location: ".$backtourl);
85$title = $langs->trans(
"Multicompanies");
88$head =
'<!-- Multicompany selection -->'.
"\n";
91top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
99$multicompanyList =
'';
102if (!isModEnabled(
'multicompany')) {
103 $langs->load(
"admin");
104 $multicompanyList .=
'<br><span class="opacitymedium">'.$langs->trans(
"WarningModuleNotActive", $langs->transnoentitiesnoconv(
"MultiCompany")).
'</span>';
105 $multicompanyList .=
'<br><br>';
106} elseif (!empty($user->entity) && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
107 $langs->load(
"errors");
108 $multicompanyList .=
'<br><span class="opacitymedium">'.$langs->trans(
"ErrorForbidden").
'</span>';
109 $multicompanyList .=
'<br><br>';
112 $hookmanager->initHooks(array(
'multicompany'));
114 if (is_object($mc)) {
115 $listofentities = $mc->getEntitiesList(
true,
false,
true);
117 $listofentities = array();
120 $multicompanyList .=
'<ul class="ullistonly left" style="list-style: none; padding: 0">';
121 foreach ($listofentities as $entityid => $entitycursor) {
123 if (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && !empty($user->entity) && $mc->checkRight($user->id, $entityid) < 0) {
126 $url = DOL_URL_ROOT.
'/core/multicompany_page.php?action=switchentity&token='.
newToken().
'&entity='.((int) $entityid).($backtourl ?
'&backtourl='.urlencode($backtourl) :
'');
127 $multicompanyList .=
'<li class="lilistonly" style="height: 2.5em; font-size: 1.15em;">';
128 $multicompanyList .=
'<a class="dropdown-item multicompany-item paddingtopimp paddingbottomimp" id="multicompany-item-'.$entityid.
'" data-id="'.$entityid.
'" href="'.
dol_escape_htmltag($url).
'">';
129 $multicompanyList .=
img_picto(
'',
'entity',
'class="pictofixedwidth"');
131 if ($conf->entity == $entityid) {
132 $multicompanyList .=
' <span class="opacitymedium">'.img_picto($langs->trans(
"Currently"),
'tick').
'</span>';
134 $multicompanyList .=
'</a>';
135 $multicompanyList .=
'</li>';
137 $multicompanyList .=
'</ul>';
140 $parameters = array(
'multicompany' => $multicompanyList);
141 $reshook = $hookmanager->executeHooks(
'printMultiCompanyEntities', $parameters);
142 if (empty($reshook)) {
143 $multicompanyList .= $hookmanager->resPrint;
145 $multicompanyList = $hookmanager->resPrint;
150print
"<!-- Begin Multicompany list -->\n";
151print
'<div class="center"><div class="center" style="padding: 6px;">';
152print
'<style>.menu_titre { padding-top: 7px; }</style>';
153print
'<div id="blockvmenusearch" class="tagtable center searchpage">'.
"\n";
154print $multicompanyList;
157print
"\n<!-- End Multicompany list -->\n";
160print
'</body></html>'.
"\n";
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.