dolibarr 21.0.0-alpha
multicompany_page.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This file is a modified version of datepicker.php from phpBSM to fix some
6 * bugs, to add new features and to dramatically increase speed.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
27//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
28//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
29//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
30//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
31if (!defined('NOCSRFCHECK')) {
32 define('NOCSRFCHECK', 1);
33}
34if (!defined('NOTOKENRENEWAL')) {
35 define('NOTOKENRENEWAL', 1);
36}
37//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
38if (!defined('NOREQUIREMENU')) {
39 define('NOREQUIREMENU', 1);
40}
41//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
42
43require_once '../main.inc.php';
44
45$action = GETPOST('action', 'aZ');
46$entityid = GETPOSTINT('entity');
47$backtourl = GETPOST('backtourl');
48if (empty($backtourl)) {
49 $backtourl = DOL_URL_ROOT;
50}
51
52if (GETPOST('lang', 'aZ09')) {
53 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
54}
55
56$langs->load("main");
57
58$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
59$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
60
61
62
63/*
64 * Actions
65 */
66
67if ($action == 'switchentity') {
68 if (is_object($mc)) {
69 $mc->switchEntity($entityid);
70 }
71
72 header("Location: ".$backtourl);
73 exit(0);
74}
75
76
77
78/*
79 * View
80 */
81
82$title = $langs->trans("Multicompanies");
83
84// URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests
85$head = '<!-- Multicompany selection -->'."\n"; // This is used by DoliDroid to know page is a multicompany selection page
86$arrayofjs = array();
87$arrayofcss = array();
88top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
89
90
91print '<body>'."\n";
92print '<div>';
93//print '<br>';
94
95
96$bookmarkList = '';
97if (!isModEnabled('multicompany')) {
98 $langs->load("admin");
99 $bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("MultiCompany")).'</span>';
100 $bookmarkList .= '<br><br>';
101} else {
102 // Instantiate hooks of thirdparty module
103 $hookmanager->initHooks(array('multicompany'));
104
105 // Define $bookmarks
106 $multicompanyList = '';
107 $searchForm = '';
108
109
110 if (is_object($mc)) {
111 $listofentities = $mc->getEntitiesList($user->login, false, true);
112 } else {
113 $listofentities = array();
114 }
115
116 $multicompanyList .= '<ul class="ullistonly left" style="list-style: none;">';
117 foreach ($listofentities as $entityid => $entitycursor) {
118 $url = DOL_URL_ROOT.'/core/multicompany_page.php?action=switchentity&token='.newToken().'&entity='.((int) $entityid).($backtourl ? '&backtourl='.urlencode($backtourl) : '');
119 $multicompanyList .= '<li class="lilistonly" style="height: 2.5em; font-size: 1.15em;">';
120 $multicompanyList .= '<a class="dropdown-item multicompany-item" id="multicompany-item-'.$entityid.'" data-id="'.$entityid.'" href="'.dol_escape_htmltag($url).'">';
121 $multicompanyList .= img_picto('', 'entity', 'class="pictofixedwidth"');
122 $multicompanyList .= dol_escape_htmltag($entitycursor);
123 if ($conf->entity == $entityid) {
124 $multicompanyList .= ' <span class="opacitymedium">('.$langs->trans("Currently").')</span>';
125 }
126 $multicompanyList .= '</a>';
127 $multicompanyList .= '</li>';
128 }
129 $multicompanyList .= '</ul>';
130
131 $searchForm .= '<input name="bookmark" id="top-multicompany-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Entity').'" autocomplete="off" >';
132
133
134 // Execute hook printBookmarks
135 $parameters = array('multicompany' => $multicompanyList);
136 $reshook = $hookmanager->executeHooks('printMultiCompanyEntities', $parameters); // Note that $action and $object may have been modified by some hooks
137 if (empty($reshook)) {
138 $multicompanyList .= $hookmanager->resPrint;
139 } else {
140 $multicompanyList = $hookmanager->resPrint;
141 }
142
143
144 print "\n";
145 print "<!-- Begin Multicompany list -->\n";
146 print '<div class="center"><div class="center" style="padding: 6px;">';
147 print '<style>.menu_titre { padding-top: 7px; }</style>';
148 print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
149 print $multicompanyList;
150 print '</div>'."\n";
151 print '</div></div>';
152 print "\n<!-- End SearchForm -->\n";
153}
154
155print '</div>';
156print '</body></html>'."\n";
157
158$db->close();
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.
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.