multicompany.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /* Copyright (C) 2009-2021 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/multicompany.php
  20. * \ingroup multicompany
  21. * \brief Page d'administration/configuration du module Multi-societe
  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. dol_include_once('/multicompany/class/actions_multicompany.class.php', 'ActionsMulticompany');
  31. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  32. require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
  33. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
  34. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
  35. $langs->loadLangs(array('admin', 'languages', 'multicompany@multicompany'));
  36. if (empty($user->admin) || !empty($user->entity)) {
  37. accessforbidden();
  38. }
  39. $action = GETPOST('action', 'alpha');
  40. $object = new ActionsMulticompany($db);
  41. $form = new Form($db);
  42. $formadmin = new FormAdmin($db);
  43. $formcompany = new FormCompany($db);
  44. /*
  45. * Actions
  46. */
  47. $object->doAdminActions($action);
  48. //$test = new DaoMulticompany($db);
  49. //$test->deleteEntityRecords(4);
  50. /*
  51. * View
  52. */
  53. $extrajs='';
  54. $extracss='';
  55. if (empty($action) || $action == "update" || $action == "add") {
  56. $extrajs = array(
  57. '/multicompany/inc/datatables/js/jquery.dataTables.min.js',
  58. //'/multicompany/inc/datatables/responsive/js/dataTables.responsive.min.js',
  59. '/multicompany/inc/datatables/buttons/js/dataTables.buttons.min.js',
  60. '/multicompany/inc/datatables/buttons/js/buttons.colVis.min.js',
  61. '/multicompany/inc/datatables/buttons/js/buttons.html5.min.js'
  62. );
  63. $extracss = array(
  64. '/multicompany/inc/datatables/css/jquery.dataTables.min.css',
  65. //'/multicompany/inc/datatables/responsive/css/responsive.dataTables.min.css',
  66. '/multicompany/inc/datatables/buttons/css/buttons.dataTables.min.css'
  67. );
  68. } else if (!empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) {
  69. $extrajs = array(
  70. '/multicompany/inc/multiselect/js/multiselect.min.js',
  71. //'/multicompany/inc/multiselect/js/multiselect.js'
  72. );
  73. $extracss = array(
  74. '/multicompany/inc/multiselect/css/bootstrap-iso.min.css'
  75. );
  76. }
  77. $help_url='EN:Module_MultiCompany|FR:Module_MultiSoci&eacute;t&eacute;';
  78. llxHeader('', $langs->trans("MultiCompanySetup"), $help_url, '', '', '', $extrajs, $extracss);
  79. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  80. print load_fiche_titre($langs->trans("MultiCompanySetup"), $linkback, 'multicompany@multicompany', 0, 'multicompany_title');
  81. $head = multicompany_prepare_head();
  82. dol_fiche_head($head, 'entities', $object->getTitle($action), -1);
  83. $level = checkMultiCompanyVersion();
  84. if ($level === -1) { // shouldn't happen
  85. print '<div class="multicompany_checker">';
  86. dol_htmloutput_mesg($langs->trans("DolibarrIsOlderThanMulticompany"), '', 'warning', 1);
  87. print '</div>';
  88. }
  89. // Assign template values
  90. $object->assign_values($action);
  91. // Isolate Boostrap for avoid conflicts
  92. if (!empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && !empty($action) && $action != "update" && $action != "add") {
  93. print '<div class="bootstrap-iso">';
  94. }
  95. // Show the template
  96. $object->display();
  97. // Isolate Boostrap for avoid conflicts
  98. if (!empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) && !empty($action) && $action != "update" && $action != "add") {
  99. print '</div>';
  100. }
  101. // Card end
  102. dol_fiche_end();
  103. // Footer
  104. llxFooter();
  105. // Close database handler
  106. $db->close();