32if (!defined(
'NOCSRFCHECK')) {
33 define(
'NOCSRFCHECK', 1);
35if (!defined(
'NOTOKENRENEWAL')) {
36 define(
'NOTOKENRENEWAL', 1);
39if (!defined(
'NOREQUIREMENU')) {
40 define(
'NOREQUIREMENU', 1);
44require_once
'../main.inc.php';
53$action =
GETPOST(
'action',
'aZ');
55$backtourl =
GETPOST(
'backtourl');
56if (empty($backtourl)) {
57 $backtourl = DOL_URL_ROOT;
61 $langs->setDefaultLang(
GETPOST(
'lang',
'aZ09'));
66$right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
67$left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
69if (!isModEnabled(
'multicompany')) {
78if ($action ==
'switchentity') {
80 $mc->switchEntity($entityid);
83 header(
"Location: ".$backtourl);
93$title = $langs->trans(
"Multicompanies");
96$head =
'<!-- Multicompany selection -->'.
"\n";
99top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
107$multicompanyList =
'';
110if (!isModEnabled(
'multicompany')) {
111 $langs->load(
"admin");
112 $multicompanyList .=
'<br><span class="opacitymedium">'.$langs->trans(
"WarningModuleNotActive", $langs->transnoentitiesnoconv(
"MultiCompany")).
'</span>';
113 $multicompanyList .=
'<br><br>';
114} elseif (!empty($user->entity) && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
115 $langs->load(
"errors");
116 $multicompanyList .=
'<br><span class="opacitymedium">'.$langs->trans(
"ErrorForbidden").
'</span>';
117 $multicompanyList .=
'<br><br>';
120 $hookmanager->initHooks(array(
'multicompany'));
122 if (is_object($mc)) {
123 $listofentities = $mc->getEntitiesList(
true,
false,
true);
125 $listofentities = array();
128 $multicompanyList .=
'<ul class="ullistonly left" style="list-style: none; padding: 10px; padding-top: 20px;">';
132 $imagesofentities = array();
133 $sql =
"SELECT entity, name, value FROM ".MAIN_DB_PREFIX.
"const";
134 $sql .=
" WHERE name in ('MAIN_INFO_SOCIETE_LOGO', 'MAIN_INFO_SOCIETE_LOGO_MINI', 'MAIN_INFO_SOCIETE_LOGO_SQUARRED', 'MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI')";
135 $sql .=
" GROUP BY entity, name, value";
136 $sql .=
" ORDER BY entity, name, value";
137 $resql = $db->query($sql);
139 while ($obj = $db->fetch_object($resql)) {
143 if ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') {
144 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'mini');
145 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_MINI') {
146 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'mini');
147 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO_SQUARRED') {
148 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'normal');
149 } elseif ($obj->name ==
'MAIN_INFO_SOCIETE_LOGO') {
150 $imagesofentities[$obj->entity] = array(
'file' => $obj->value,
'type' =>
'normal');
155 foreach ($listofentities as $entityid => $entitycursor) {
157 if (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && !empty($user->entity) && $mc->checkRight($user->id, $entityid) < 0) {
160 $url = DOL_URL_ROOT.
'/core/multicompany_page.php?action=switchentity&token='.
newToken().
'&entity='.((int) $entityid).($backtourl ?
'&backtourl='.urlencode($backtourl) :
'');
161 $multicompanyList .=
'<li class="lilistonly" style="height: 4em; font-size: 1.5em;">';
162 $multicompanyList .=
'<a class="dropdown-item multicompany-item paddingtopimp paddingbottomimp" id="multicompany-item-'.$entityid.
'" data-id="'.$entityid.
'" href="'.
dol_escape_htmltag($url).
'">';
164 $urlforimage = DOL_URL_ROOT.
'/public/theme/common/company.png';
165 if (!empty($imagesofentities[$entityid])) {
166 if ($imagesofentities[$entityid][
'type'] ==
'mini') {
167 $urlforimage = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$entityid.
'&file='.urlencode(
'logos/thumbs/'.$imagesofentities[$entityid][
'file']);
169 $urlforimage = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$entityid.
'&file='.urlencode(
'logos/'.$imagesofentities[$entityid][
'file']);
172 $multicompanyList .=
'<img class="photocontact photorefnoborder valignmiddle marginrightonly" alt="" src="'.$urlforimage.
'">';
175 if (
$conf->entity == $entityid) {
176 $multicompanyList .=
' <span class="opacitymedium">'.img_picto($langs->trans(
"Currently"),
'tick').
'</span>';
178 $multicompanyList .=
'</a>';
179 $multicompanyList .=
'</li>';
181 $multicompanyList .=
'</ul>';
184 $parameters = array(
'multicompany' => $multicompanyList);
185 $reshook = $hookmanager->executeHooks(
'printMultiCompanyEntities', $parameters);
186 if (empty($reshook)) {
187 $multicompanyList .= $hookmanager->resPrint;
189 $multicompanyList = $hookmanager->resPrint;
194print
"<!-- Begin Multicompany list -->\n";
195print
'<div class="center"><div class="center" style="padding: 6px;">';
196print
'<style>.menu_titre { padding-top: 7px; }</style>';
197print
'<div id="blockvmenusearch" class="tagtable center searchpage">'.
"\n";
198print $multicompanyList;
201print
"\n<!-- End Multicompany list -->\n";
204print
'</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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.