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: 10px; padding-top: 20px;">';
124 $imagesofentities = array();
125 $sql =
"SELECT entity, name, value FROM ".MAIN_DB_PREFIX.
"const";
126 $sql .=
" WHERE name in ('MAIN_INFO_SOCIETE_LOGO', 'MAIN_INFO_SOCIETE_LOGO_MINI', 'MAIN_INFO_SOCIETE_LOGO_SQUARRED', 'MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI')";
127 $sql .=
" GROUP BY entity, name, value";
128 $sql .=
" ORDER BY entity, name, value";
129 $resql = $db->query($sql);
131 while ($obj = $db->fetch_object($resql)) {
135 if ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') {
136 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'mini');
137 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_MINI') {
138 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'mini');
139 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_SQUARRED') {
140 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'normal');
141 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO') {
142 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'normal');
147 foreach ($listofentities as $entityid => $entitycursor) {
149 if (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && !empty($user->entity) && $mc->checkRight($user->id, $entityid) < 0) {
152 $url = DOL_URL_ROOT.
'/core/multicompany_page.php?action=switchentity&token='.
newToken().
'&entity='.((int) $entityid).($backtourl ?
'&backtourl='.urlencode($backtourl) :
'');
153 $multicompanyList .=
'<li class="lilistonly" style="height: 4em; font-size: 1.5em;">';
154 $multicompanyList .=
'<a class="dropdown-item multicompany-item paddingtopimp paddingbottomimp" id="multicompany-item-'.$entityid.
'" data-id="'.$entityid.
'" href="'.
dol_escape_htmltag($url).
'">';
156 $urlforimage = DOL_URL_ROOT.
'/public/theme/common/company.png';
157 if (!empty($imagesofentities[$entityid])) {
158 if ($imagesofentities[$entityid][
'type'] ==
'mini') {
159 $urlforimage = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$entityid.
'&file='.urlencode(
'logos/thumbs/'.$imagesofentities[$entityid][
'file']);
161 $urlforimage = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$entityid.
'&file='.urlencode(
'logos/'.$imagesofentities[$entityid][
'file']);
164 $multicompanyList .=
'<img class="photocontact photorefnoborder valignmiddle marginrightonly" alt="" src="'.$urlforimage.
'">';
167 if ($conf->entity == $entityid) {
168 $multicompanyList .=
' <span class="opacitymedium">'.img_picto($langs->trans(
"Currently"),
'tick').
'</span>';
170 $multicompanyList .=
'</a>';
171 $multicompanyList .=
'</li>';
173 $multicompanyList .=
'</ul>';
176 $parameters = array(
'multicompany' => $multicompanyList);
177 $reshook = $hookmanager->executeHooks(
'printMultiCompanyEntities', $parameters);
178 if (empty($reshook)) {
179 $multicompanyList .= $hookmanager->resPrint;
181 $multicompanyList = $hookmanager->resPrint;
186print
"<!-- Begin Multicompany list -->\n";
187print
'<div class="center"><div class="center" style="padding: 6px;">';
188print
'<style>.menu_titre { padding-top: 7px; }</style>';
189print
'<div id="blockvmenusearch" class="tagtable center searchpage">'.
"\n";
190print $multicompanyList;
193print
"\n<!-- End Multicompany list -->\n";
196print
'</body></html>'.
"\n";
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.