32if (!defined(
'NOCSRFCHECK')) {
33 define(
'NOCSRFCHECK', 1);
35if (!defined(
'NOTOKENRENEWAL')) {
36 define(
'NOTOKENRENEWAL', 1);
38if (!defined(
'NOREQUIREMENU')) {
39 define(
'NOREQUIREMENU', 1);
43require_once
'../main.inc.php';
52$action =
GETPOST(
'action',
'aZ');
54$backtourl =
GETPOST(
'backtourl');
55if (empty($backtourl)) {
56 $backtourl = DOL_URL_ROOT;
60 $langs->setDefaultLang(
GETPOST(
'lang',
'aZ09'));
65$right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
66$left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
77if ($action ==
'switchentity') {
78 if (isset($mc) && is_object($mc)) {
79 $mc->switchEntity($entityid);
82 header(
"Location: ".$backtourl);
92$title = $langs->trans(
"Multicompanies");
95$head =
'<!-- Multicompany selection -->'.
"\n";
98top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
106$multicompanyList =
'';
110 $langs->load(
"admin");
111 $multicompanyList .=
'<br><span class="opacitymedium">'.$langs->trans(
"WarningModuleNotActive", $langs->transnoentitiesnoconv(
"MultiCompany")).
'</span>';
112 $multicompanyList .=
'<br><br>';
113} elseif (!empty($user->entity) && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
114 $langs->load(
"errors");
115 $multicompanyList .=
'<br><span class="opacitymedium">'.$langs->trans(
"ErrorForbidden").
'</span>';
116 $multicompanyList .=
'<br><br>';
119 $hookmanager->initHooks(array(
'multicompany'));
121 if (isset($mc) && is_object($mc)) {
122 $listofentities = $mc->getEntitiesList(
true,
false,
true);
124 $listofentities = array();
127 $multicompanyList .=
'<ul class="ullistonly left" style="list-style: none; padding: 10px; padding-top: 20px;">';
131 $imagesofentities = array();
132 $sql =
"SELECT entity, name, value FROM ".MAIN_DB_PREFIX.
"const";
133 $sql .=
" WHERE name in ('MAIN_INFO_SOCIETE_LOGO', 'MAIN_INFO_SOCIETE_LOGO_MINI', 'MAIN_INFO_SOCIETE_LOGO_SQUARRED', 'MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI')";
134 $sql .=
" GROUP BY entity, name, value";
135 $sql .=
" ORDER BY entity, name, value";
136 $resql = $db->query($sql);
138 while ($obj = $db->fetch_object($resql)) {
142 if ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') {
143 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'mini');
144 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_MINI') {
145 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'mini');
146 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_SQUARRED') {
147 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'normal');
148 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO') {
149 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'normal');
154 foreach ($listofentities as $entityid => $entitycursor) {
156 if (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && !empty($user->entity) && $mc->checkRight($user->id, (
string) $entityid) < 0) {
159 $url = DOL_URL_ROOT.
'/core/multicompany_page.php?action=switchentity&token='.
newToken().
'&entity='.((int) $entityid).($backtourl ?
'&backtourl='.urlencode($backtourl) :
'');
160 $multicompanyList .=
'<li class="lilistonly" style="height: 4em; font-size: 1.5em;">';
161 $multicompanyList .=
'<a class="dropdown-item multicompany-item paddingtopimp paddingbottomimp" id="multicompany-item-'.$entityid.
'" data-id="'.$entityid.
'" href="'.
dol_escape_htmltag($url).
'">';
163 $urlforimage = DOL_URL_ROOT.
'/public/theme/common/company.png';
164 if (!empty($imagesofentities[$entityid])) {
165 if ($imagesofentities[$entityid][
'type'] ==
'mini') {
166 $urlforimage = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$entityid.
'&file='.urlencode(
'logos/thumbs/'.$imagesofentities[$entityid][
'file']);
168 $urlforimage = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$entityid.
'&file='.urlencode(
'logos/'.$imagesofentities[$entityid][
'file']);
171 $multicompanyList .=
'<img class="photocontact photorefnoborder valignmiddle marginrightonly" alt="" src="'.$urlforimage.
'">';
174 if (
$conf->entity == $entityid) {
175 $multicompanyList .=
' <span class="opacitymedium">'.img_picto($langs->trans(
"Currently"),
'tick').
'</span>';
177 $multicompanyList .=
'</a>';
178 $multicompanyList .=
'</li>';
180 $multicompanyList .=
'</ul>';
183 $parameters = array(
'multicompany' => $multicompanyList);
184 $reshook = $hookmanager->executeHooks(
'printMultiCompanyEntities', $parameters);
185 if (empty($reshook)) {
186 $multicompanyList .= $hookmanager->resPrint;
188 $multicompanyList = $hookmanager->resPrint;
193print
"<!-- Begin Multicompany list -->\n";
194print
'<div class="center"><div class="center" style="padding: 6px;">';
195print
'<style>.menu_titre { padding-top: 7px; }</style>';
196print
'<div id="blockvmenusearch" class="tagtable center searchpage">'.
"\n";
197print $multicompanyList;
200print
"\n<!-- End Multicompany list -->\n";
203print
'</body></html>'.
"\n";
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
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.