options.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <?php
  2. /* Copyright (C) 2011-2022 Regis Houssin <regis.houssin@inodbox.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. /**
  19. * \file /multicompany/admin/options.php
  20. * \ingroup multicompany
  21. * \brief Configuration of Multicompany module
  22. */
  23. $res=@include("../../main.inc.php"); // For root directory
  24. if (empty($res) && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) {
  25. $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only
  26. }
  27. if (empty($res)) {
  28. $res=@include("../../../main.inc.php"); // For "custom" directory
  29. }
  30. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  31. dol_include_once('/multicompany/class/actions_multicompany.class.php', 'ActionsMulticompany');
  32. $langs->loadLangs(array('admin', 'multicompany@multicompany'));
  33. // Security check
  34. if (empty($user->admin) || !empty($user->entity)) {
  35. accessforbidden();
  36. }
  37. $action = GETPOST('action','alpha');
  38. $object = new ActionsMulticompany($db);
  39. /*
  40. * Action
  41. */
  42. /*
  43. * View
  44. */
  45. $extrajs = array(
  46. '/multicompany/core/js/lib_head.js'
  47. );
  48. $help_url='EN:Module_MultiCompany|FR:Module_MultiSoci&eacute;t&eacute;';
  49. llxHeader('', $langs->trans("MultiCompanySetup"), $help_url,'','','',$extrajs);
  50. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  51. print load_fiche_titre($langs->trans("MultiCompanySetup"),$linkback,'multicompany@multicompany',0,'multicompany_title');
  52. $head = multicompany_prepare_head();
  53. dol_fiche_head($head, 'options', $langs->trans("ModuleSetup"), -1);
  54. $level = checkMultiCompanyVersion();
  55. if ($level === -1) { // shouldn't happen
  56. print '<div class="multicompany_checker">';
  57. dol_htmloutput_mesg($langs->trans("DolibarrIsOlderThanMulticompany"), '', 'warning', 1);
  58. print '</div>';
  59. }
  60. $form=new Form($db);
  61. $hidden=true;
  62. $checkconfig = checkMulticompanyAutentication();
  63. if ($checkconfig !== true) {
  64. if (!empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) {
  65. $hidden=false;
  66. }
  67. print '<div id="mc_hide_login_combobox_error"'.($hidden ? ' style="display:none;"' : '').'>'.get_htmloutput_mesg($langs->trans("ErrorMulticompanyConfAuthentication"),'','error',1).'</div>';
  68. } else {
  69. if (empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) {
  70. $hidden=false;
  71. }
  72. print '<div id="dol_hide_login_combobox_error"'.($hidden ? ' style="display:none;"' : '').'>'.get_htmloutput_mesg($langs->trans("ErrorDolibarrConfAuthentication"),'','error',1).'</div>';
  73. }
  74. print '<table class="noborder" width="100%">';
  75. print '<tr class="liste_titre">';
  76. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  77. print '<td align="center" width="20">&nbsp;</td>';
  78. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  79. print '</tr>';
  80. /*
  81. * System parameters
  82. */
  83. // Login page combobox activation
  84. print '<tr class="oddeven">';
  85. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("HideLoginCombobox").'</span></td>';
  86. print '<td align="center" width="20">&nbsp;</td>';
  87. print '<td align="center" width="100">';
  88. if ($checkconfig !== true) {
  89. $input = array(
  90. 'showhide' => array(
  91. '#mc_hide_login_combobox_error'
  92. )
  93. );
  94. } else {
  95. $input = array(
  96. 'hideshow' => array(
  97. '#dol_hide_login_combobox_error'
  98. )
  99. );
  100. }
  101. $input['hideshow'][] = '#changeloginlogo';
  102. $input['hideshow'][] = '#changeloginbackground';
  103. $input['del'] = array('MULTICOMPANY_LOGIN_LOGO_BY_ENTITY', 'MULTICOMPANY_LOGIN_BACKGROUND_BY_ENTITY');
  104. print ajax_mcconstantonoff('MULTICOMPANY_HIDE_LOGIN_COMBOBOX', $input, 0);
  105. print '</td></tr>';
  106. // Replace entity logo in login page
  107. print '<tr id="changeloginlogo" class="oddeven"'.(!empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX) ? ' style="display:none;"' : '').'>';
  108. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("EntityLogoInLoginPage").'</span></td>';
  109. print '<td align="center" width="20">&nbsp;</td>';
  110. print '<td align="center" width="100">';
  111. $input = array(
  112. 'showhide' => array(
  113. '#changeloginbackground'
  114. ),
  115. 'del' => array(
  116. 'MULTICOMPANY_LOGIN_BACKGROUND_BY_ENTITY'
  117. )
  118. );
  119. print ajax_mcconstantonoff('MULTICOMPANY_LOGIN_LOGO_BY_ENTITY', $input, 0);
  120. print '</td></tr>';
  121. // Replace entity background in login page
  122. print '<tr id="changeloginbackground" class="oddeven"'.(empty($conf->global->MULTICOMPANY_LOGIN_LOGO_BY_ENTITY) ? ' style="display:none;"' : '').'>';
  123. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("EntityBackgroundInLoginPage").'</span></td>';
  124. print '<td align="center" width="20">&nbsp;</td>';
  125. print '<td align="center" width="100">';
  126. print ajax_mcconstantonoff('MULTICOMPANY_LOGIN_BACKGROUND_BY_ENTITY', '', 0);
  127. print '</td></tr>';
  128. // Disable the new dropdown menu
  129. print '<tr id="disabledropdownmenu" class="oddeven">';
  130. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("DisableSwitchEntityDropdownMenu").'</span></td>';
  131. print '<td align="center" width="20">&nbsp;</td>';
  132. print '<td align="center" width="100">';
  133. $input = array(
  134. 'reload' => true
  135. );
  136. print ajax_mcconstantonoff('MULTICOMPANY_DROPDOWN_MENU_DISABLED', $input, 0);
  137. print '</td></tr>';
  138. // Hide/View top menu entity label
  139. print '<tr id="showtopmenuentitylabel" class="oddeven">';
  140. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("ShowTopMenuEntityLabel").'</span></td>';
  141. print '<td align="center" width="20">&nbsp;</td>';
  142. print '<td align="center" width="100">';
  143. $input = array(
  144. 'reload' => true
  145. );
  146. print ajax_mcconstantonoff('MULTICOMPANY_NO_TOP_MENU_ENTITY_LABEL', $input, 0, 1);
  147. print '</td></tr>';
  148. // Active by default during create
  149. print '<tr class="oddeven">';
  150. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("EntityActiveByDefault").'</span></td>';
  151. print '<td align="center" width="20">&nbsp;</td>';
  152. print '<td align="center" width="100">';
  153. $input = array(
  154. 'showhide' => array(
  155. '#visiblebydefault'
  156. ),
  157. 'del' => array(
  158. 'MULTICOMPANY_VISIBLE_BY_DEFAULT'
  159. )
  160. );
  161. print ajax_mcconstantonoff('MULTICOMPANY_ACTIVE_BY_DEFAULT', $input, 0);
  162. print '</td></tr>';
  163. // Visible by default during create
  164. print '<tr id="visiblebydefault" class="oddeven"'.(empty($conf->global->MULTICOMPANY_ACTIVE_BY_DEFAULT) ? ' style="display:none;"' : '').'>';
  165. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("EntityVisibleByDefault").'</span></td>';
  166. print '<td align="center" width="20">&nbsp;</td>';
  167. print '<td align="center" width="100">';
  168. print ajax_mcconstantonoff('MULTICOMPANY_VISIBLE_BY_DEFAULT', '', 0);
  169. print '</td></tr>';
  170. // Template management
  171. $text = img_picto('', 'info','class="linkobject"');
  172. $htmltext = $langs->trans("TemplateOfEntityManagementInfo");
  173. print '<tr id="template" class="oddeven">';
  174. print '<td><span class="fa fa-cogs"></span><span class="multiselect-title">'.$langs->trans("TemplateOfEntityManagement").' '.$form->textwithtooltip('',$htmltext,2,1,$text).'</span></td>';
  175. print '<td align="center" width="20">&nbsp;</td>';
  176. print '<td align="center" width="100">';
  177. print ajax_mcconstantonoff('MULTICOMPANY_TEMPLATE_MANAGEMENT', '', 0);
  178. print '</td></tr>';
  179. /*
  180. * Sharings parameters
  181. */
  182. print '<tr class="liste_titre">';
  183. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  184. print '<td align="center" width="20">&nbsp;</td>';
  185. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  186. print '</tr>';
  187. /* Mode de gestion des droits :
  188. * Mode Off : mode Off : pyramidale. Les droits et les groupes sont gérés dans chaque entité : les utilisateurs appartiennent au groupe de l'entity pour obtenir leurs droits
  189. * Mode On : mode On : transversale : Les groupes ne peuvent appartenir qu'a l'entity = 0 et c'est l'utilisateur qui appartient à tel ou tel entity
  190. */
  191. $text = img_picto('', 'info','class="linkobject"');
  192. $htmltext = $langs->trans("GroupModeTransversalInfoFull");
  193. print '<tr class="oddeven">';
  194. print '<td><span class="fa fa-users"></span><span class="multiselect-title">'.$langs->trans("GroupModeTransversal").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</span></td>';
  195. print '<td align="center" width="20">&nbsp;</td>';
  196. print '<td align="center" width="100">';
  197. $input = array(
  198. 'alert' => array(
  199. 'set' => array(
  200. 'info' => true,
  201. 'height' => 200,
  202. 'yesButton' => $langs->trans('Ok'),
  203. 'title' => $langs->transnoentities('GroupModeTransversalTitle'),
  204. 'content' => img_warning().' '.$langs->trans('GroupModeTransversalInfo')
  205. )
  206. )
  207. );
  208. print ajax_mcconstantonoff('MULTICOMPANY_TRANSVERSE_MODE', $input, 0);
  209. print '</td></tr>';
  210. // Enable global sharings
  211. if (1==1 || !empty($conf->societe->enabled) // Show all options everywhere !
  212. || !empty($conf->product->enabled)
  213. || !empty($conf->service->enabled)
  214. || !empty($conf->categorie->enabled)
  215. || !empty($conf->adherent->enabled)
  216. || !empty($conf->agenda->enabled))
  217. {
  218. print '<tr class="oddeven">';
  219. print '<td><span class="fa fa-project-diagram"></span><span class="multiselect-title">'.$langs->trans("EnableGlobalSharings").'</span></td>';
  220. print '<td align="center" width="20">&nbsp;</td>';
  221. print '<td align="center" width="100">';
  222. $input = array(
  223. 'alert' => array(
  224. 'set' => array(
  225. 'info' => true,
  226. 'yesButton' => $langs->trans('Ok'),
  227. 'title' => $langs->transnoentities('GlobalSharings'),
  228. 'content' => img_warning().' '.$langs->trans('GlobalSharingsInfo')
  229. )
  230. ),
  231. 'showhide' => array(
  232. '#shareelementtitle',
  233. '#sharethirdparty',
  234. '#sharingbyelement'
  235. ),
  236. 'hide' => array(
  237. '#shareelementtitle',
  238. '#shareobjecttitle',
  239. '#sharethirdparty',
  240. '#sharingbyelement'
  241. ),
  242. 'del' => array(
  243. 'MULTICOMPANY_THIRDPARTY_SHARING_ENABLED',
  244. 'MULTICOMPANY_SHARING_BYELEMENT_ENABLED',
  245. 'MULTICOMPANY_THIRDPARTY_SHARING_BYELEMENT_ENABLED',
  246. 'MULTICOMPANY_CONTACT_SHARING_BYELEMENT_ENABLED',
  247. 'MULTICOMPANY_PRODUCT_SHARING_BYELEMENT_ENABLED'
  248. )
  249. );
  250. foreach ($object->sharingelements as $key => $values) {
  251. if (!isset($values['disable'])) {
  252. if (isset($values['input']) && isset($values['input']['global'])) {
  253. if (isset($values['input']['global']['showhide']) && $values['input']['global']['showhide'] === true) {
  254. if (!isset($input['showhide'])) {
  255. $input['showhide'] = array();
  256. }
  257. array_push($input['showhide'], '#share'.$key);
  258. }
  259. if (isset($values['input']['global']['hide']) && $values['input']['global']['hide'] === true) {
  260. if (!isset($input['hide'])) {
  261. $input['hide'] = array();
  262. }
  263. array_push($input['hide'], '#share'.$key);
  264. }
  265. if (isset($values['input']['global']['del']) && $values['input']['global']['del'] === true) {
  266. if (!isset($input['del'])) {
  267. $input['del'] = array();
  268. }
  269. array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_ENABLED');
  270. }
  271. }
  272. }
  273. }
  274. print ajax_mcconstantonoff('MULTICOMPANY_SHARINGS_ENABLED', $input, 0);
  275. print '</td></tr>';
  276. // Sharing by element
  277. $text = img_picto('', 'info', 'class="linkobject"');
  278. $htmltext = $langs->trans("SharingsByElementInfo");
  279. $input = array(
  280. 'reload' => true,
  281. 'del' => array(
  282. 'MULTICOMPANY_THIRDPARTY_SHARING_BYELEMENT_ENABLED',
  283. 'MULTICOMPANY_CONTACT_SHARING_BYELEMENT_ENABLED',
  284. 'MULTICOMPANY_PRODUCT_SHARING_BYELEMENT_ENABLED'
  285. )
  286. );
  287. print '<tr id="sharingbyelement" class="oddeven"'.(empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) ? ' style="display:none;"' : '').'>';
  288. print '<td><span class="fa fa-project-diagram"></span><span class="multiselect-title">'.$langs->trans("EnableSharingsByElement").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</span></td>';
  289. print '<td align="center" width="20">&nbsp;</td>';
  290. print '<td align="center" width="100">';
  291. print ajax_mcconstantonoff('MULTICOMPANY_SHARING_BYELEMENT_ENABLED', $input, 0);
  292. print '</td></tr>';
  293. }
  294. $text = img_picto('', 'info','class="linkobject"');
  295. $htmltext = $langs->trans("GlobalSharingsInfo");
  296. print '<tr class="liste_titre" id="shareelementtitle"'.(empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) ? ' style="display:none;"' : '').'>';
  297. print '<td>'.$langs->trans("ActivatingShares").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</td>'."\n";
  298. print '<td align="center" width="20">&nbsp;</td>';
  299. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  300. print '</tr>';
  301. // Share thirparties and contacts
  302. if (1==1 || !empty($conf->societe->enabled)) // Show all options everywhere !
  303. {
  304. print '<tr id="sharethirdparty" class="oddeven"'.(empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) ? ' style="display:none;"' : '').'>';
  305. print '<td><span class="fa fa-'.$object->sharingelements['thirdparty']['icon'].'"></span><span class="multiselect-title">'.$langs->trans("ShareThirdpartiesAndContacts").'</span></td>';
  306. print '<td align="center" width="20">&nbsp;</td>';
  307. print '<td align="center" width="100">';
  308. $input = array(
  309. 'showhide' => array(
  310. '#shareobjecttitle'
  311. ),
  312. 'del' => array(
  313. 'MULTICOMPANY_THIRDPARTY_SHARING_BYELEMENT_ENABLED',
  314. 'MULTICOMPANY_CONTACT_SHARING_BYELEMENT_ENABLED'
  315. )
  316. );
  317. foreach ($object->sharingelements as $key => $values) {
  318. if (!isset($values['disable']) && ($values['type'] === 'object' || $values['type'] === 'objectnumber')) {
  319. if (isset($values['input']) && isset($values['input']['thirdparty'])) {
  320. if (isset($values['input']['thirdparty']['showhide']) && $values['input']['thirdparty']['showhide'] === true) {
  321. if (!isset($input['showhide'])) {
  322. $input['showhide'] = array();
  323. }
  324. array_push($input['showhide'], '#share'.$key);
  325. }
  326. if (isset($values['input']['thirdparty']['hide']) && $values['input']['thirdparty']['hide'] === true) {
  327. if (!isset($input['hide'])) {
  328. $input['hide'] = array();
  329. }
  330. array_push($input['hide'], '#share'.$key);
  331. }
  332. if (isset($values['input']['thirdparty']['del']) && $values['input']['thirdparty']['del'] === true) {
  333. if (!isset($input['del'])) {
  334. $input['del'] = array();
  335. }
  336. array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_ENABLED');
  337. }
  338. }
  339. }
  340. }
  341. print ajax_mcconstantonoff('MULTICOMPANY_THIRDPARTY_SHARING_ENABLED', $input, 0);
  342. print '</td></tr>';
  343. }
  344. // Elements sharings
  345. $text = img_picto('', 'info','class="linkobject"');
  346. foreach ($object->sharingelements as $element => $params) {
  347. if (!isset($params['disable']) && $params['type'] === 'element') {
  348. $tooltip = null;
  349. $display = !empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED);
  350. $module = ((isset($object->sharingmodulename[$element]) && !empty($object->sharingmodulename[$element])) ? $object->sharingmodulename[$element] : $element);
  351. //$enabled = (!empty($params['enable']) ? dol_eval($params['enable'], 1) : $conf->$module->enabled);
  352. $enabled = 1; // Show all options everywhere !
  353. if (!empty($enabled)) {
  354. $icon = (!empty($params['icon']) ? $params['icon'] : 'cogs');
  355. if (!empty($params['lang'])) {
  356. $langs->load($params['lang']);
  357. }
  358. if (!empty($params['tooltip'])) {
  359. $htmltext = $langs->trans($params['tooltip']);
  360. $tooltip = $form->textwithtooltip('', $htmltext, 2, 1, $text);
  361. }
  362. if (!empty($params['display'])) {
  363. $display = ($display && dol_eval($params['display'], 1));
  364. }
  365. $display = ($display ? '' : ' style="display:none;"');
  366. print '<tr id="share'.$element.'" class="oddeven"'.$display.'>';
  367. print '<td><span class="fa fa-'.$icon.'"></span>';
  368. print '<span class="multiselect-title">'.$langs->trans("Share".ucfirst($element)).(!empty($tooltip) ? ' '.$tooltip : '').'</span></td>';
  369. print '<td align="center" width="20">&nbsp;</td>';
  370. print '<td align="center" width="100">';
  371. $input = array();
  372. if ($element == 'product') {
  373. $input = array(
  374. 'del' => array(
  375. 'MULTICOMPANY_PRODUCT_SHARING_BYELEMENT_ENABLED'
  376. )
  377. );
  378. }
  379. foreach ($object->sharingelements as $key => $values) {
  380. if (!isset($values['disable']) && isset($values['input']) && isset($values['input'][$element])) {
  381. if (isset($values['input'][$element]['showhide']) && $values['input'][$element]['showhide'] === true) {
  382. if (!isset($input['showhide'])) $input['showhide'] = array();
  383. array_push($input['showhide'], '#share'.$key);
  384. }
  385. if (isset($values['input'][$element]['hide']) && $values['input'][$element]['hide'] === true) {
  386. if (!isset($input['hide'])) $input['hide'] = array();
  387. array_push($input['hide'], '#share'.$key);
  388. }
  389. if (isset($values['input'][$element]['del']) && $values['input'][$element]['del'] === true) {
  390. if (!isset($input['del'])) $input['del'] = array();
  391. array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_ENABLED');
  392. }
  393. if (isset($values['input'][$element]['granularity']) && $values['input'][$element]['del'] === true) {
  394. if (!isset($input['del'])) {
  395. $input['del'] = array();
  396. }
  397. array_push($input['del'], 'MULTICOMPANY_'.strtoupper($key).'_SHARING_BYELEMENT_ENABLED');
  398. }
  399. }
  400. }
  401. print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED', $input, 0);
  402. print '</td></tr>';
  403. }
  404. }
  405. }
  406. // Objects sharings
  407. $text = img_picto('', 'info','class="linkobject"');
  408. $htmltext = $langs->trans("ObjectSharingsInfo");
  409. $display=(!empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && !empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_ENABLED) ? '' : ' style="display:none;"');
  410. print '<tr class="liste_titre" id="shareobjecttitle"'.$display.'>';
  411. print '<td>'.$langs->trans("ActivatingObjectShares").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</td>'."\n";
  412. print '<td align="center" width="20">&nbsp;</td>';
  413. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  414. print '</tr>';
  415. foreach ($object->sharingelements as $element => $params) {
  416. if (!isset($params['disable']) && $params['type'] === 'object') {
  417. $tooltip = null;
  418. $display = !empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED);
  419. $module = ((isset($object->sharingmodulename[$element]) && !empty($object->sharingmodulename[$element])) ? $object->sharingmodulename[$element] : $element);
  420. //$enabled = (!empty($params['enable']) ? dol_eval($params['enable'], 1) : $conf->$module->enabled);
  421. $enabled = 1; // Show all options everywhere !
  422. if (!empty($enabled)) {
  423. $icon = (!empty($params['icon'])?$params['icon']:'cogs');
  424. if (!empty($params['lang'])) {
  425. $langs->load($params['lang']);
  426. }
  427. if (!empty($params['tooltip'])) {
  428. $htmltext = $langs->trans($params['tooltip']);
  429. $tooltip = $form->textwithtooltip('', $htmltext, 2, 1, $text);
  430. }
  431. if (!empty($params['display'])) {
  432. $display = ($display && dol_eval($params['display'], 1));
  433. }
  434. $display = ($display ? '' : ' style="display:none;"');
  435. print '<tr id="share'.$element.'" class="oddeven"'.$display.'>';
  436. print '<td><span class="fa fa-'.$icon.'"></span>';
  437. print '<span class="multiselect-title">'.$langs->trans("Share".ucfirst($element)).(!empty($tooltip) ? ' '.$tooltip : '').'</span></td>';
  438. print '<td align="center" width="20">&nbsp;</td>';
  439. print '<td align="center" width="100">';
  440. $input = array();
  441. print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED', $input, 0);
  442. print '</td></tr>';
  443. }
  444. }
  445. }
  446. // Objects number sharings
  447. $text = img_picto('', 'info','class="linkobject"');
  448. $htmltext = $langs->trans("ObjectNumberSharingsInfo");
  449. $display=(!empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) ? '' : ' style="display:none;"');
  450. print '<tr class="liste_titre" id="shareobjecttitle"'.$display.'>';
  451. print '<td>'.$langs->trans("ActivatingObjectNumberShares").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</td>'."\n";
  452. print '<td align="center" width="20">&nbsp;</td>';
  453. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  454. print '</tr>';
  455. foreach ($object->sharingelements as $element => $params) {
  456. if (!isset($params['disable']) && $params['type'] === 'objectnumber') {
  457. $tooltip = null;
  458. $display = !empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED);
  459. $module = ((isset($object->sharingmodulename[$element]) && !empty($object->sharingmodulename[$element])) ? $object->sharingmodulename[$element] : $element);
  460. //$enabled = (!empty($params['enable']) ? dol_eval($params['enable'], 1) : $conf->$module->enabled);
  461. $enabled = 1; // Show all options everywhere !
  462. if (!empty($enabled)) {
  463. $icon = (!empty($params['icon'])?$params['icon']:'cogs');
  464. if (!empty($params['lang'])) {
  465. $langs->load($params['lang']);
  466. }
  467. if (!empty($params['tooltip'])) {
  468. $htmltext = $langs->trans($params['tooltip']);
  469. $tooltip = $form->textwithtooltip('', $htmltext, 2, 1, $text);
  470. }
  471. if (!empty($params['display'])) {
  472. $display = ($display && dol_eval($params['display'], 1));
  473. }
  474. $display = ($display ? '' : ' style="display:none;"');
  475. print '<tr id="share'.$element.'" class="oddeven"'.$display.'>';
  476. print '<td><span class="fa fa-'.$icon.'"></span>';
  477. print '<span class="multiselect-title">'.$langs->trans("Share".ucfirst($element)).(!empty($tooltip) ? ' '.$tooltip : '').'</span></td>';
  478. print '<td align="center" width="20">&nbsp;</td>';
  479. print '<td align="center" width="100">';
  480. $input = array();
  481. print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED', $input, 0);
  482. print '</td></tr>';
  483. }
  484. }
  485. }
  486. // Dictionnaries
  487. if (!empty($object->customdicts)) {
  488. $text = img_picto('', 'info','class="linkobject"');
  489. $htmltext = $langs->trans("DictsSharingsInfo");
  490. print '<tr class="liste_titre" id="dictsharetitle">';
  491. print '<td>'.$langs->trans("ActivatingDictsShares").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</td>'."\n";
  492. print '<td align="center" width="20">&nbsp;</td>';
  493. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  494. print '</tr>';
  495. foreach ($object->customdicts as $dict => $params) {
  496. if (empty($params['disabled'])) {
  497. $icon = (!empty($params['icon']) ? $params['icon'] : 'book');
  498. $transkey = 'Custom'.(!empty($params['transkey']) ? $params['transkey'] : ucfirst($dict));
  499. print '<tr id="share'.$dict.'" class="oddeven">';
  500. print '<td><span class="fa fa-'.$icon.'"></span>';
  501. print '<span class="multiselect-title">'.$langs->trans($transkey).'</span></td>';
  502. print '<td align="center" width="20">&nbsp;</td>';
  503. print '<td align="center" width="100">';
  504. print ajax_mcconstantonoff('MULTICOMPANY_'.strtoupper($dict).'_CUSTOM_ENABLED', '', 0);
  505. print '</td></tr>';
  506. }
  507. }
  508. }
  509. print '</table>';
  510. // Card end
  511. dol_fiche_end();
  512. // Footer
  513. llxFooter();
  514. // Close database handler
  515. $db->close();