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