multicompany_extrafields.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /* Copyright (C) 2014 Florian HENRY <florian.henry@open-concept.pro>
  3. * Copyright (C) 2016-2021 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file /multicompany/admin/multicompany.php
  20. * \ingroup multicompany
  21. * \brief Page to setup extra fields of entities
  22. */
  23. // Dolibarr environment
  24. $res=@include("../../main.inc.php"); // For root directory
  25. if (empty($res) && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php"))
  26. $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only
  27. if (empty($res)) $res=@include("../../../main.inc.php"); // For "custom" directory
  28. require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
  29. dol_include_once('/multicompany/lib/multicompany.lib.php');
  30. // Security check
  31. if (empty($user->admin) || !empty($user->entity)) {
  32. accessforbidden();
  33. }
  34. $langs->loadLangs(array('admin', 'other'));
  35. $extrafields = new ExtraFields($db);
  36. $form = new Form($db);
  37. // List of supported format
  38. $tmptype2label = ExtraFields::$type2label;
  39. $type2label = array('');
  40. foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
  41. $action = GETPOST('action', 'alpha');
  42. $attrname = GETPOST('attrname', 'alpha');
  43. $elementtype = 'entity'; // Must be the $table_element of the class that manage extrafield
  44. /*
  45. * Actions
  46. */
  47. require DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php';
  48. /*
  49. * View
  50. */
  51. $textobject = $langs->transnoentitiesnoconv("Entities");
  52. $help_url='EN:Module_MultiCompany|FR:Module_MultiSoci&eacute;t&eacute;';
  53. llxHeader('', $langs->trans("MultiCompanySetup"), $help_url);
  54. $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
  55. print load_fiche_titre($langs->trans("MultiCompanySetup"), $linkback, 'multicompany@multicompany',0,'multicompany_title');
  56. // Configuration header
  57. $head = multicompany_prepare_head();
  58. dol_fiche_head($head, 'attributes', $langs->trans("ModuleSetup"), -1);
  59. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
  60. dol_fiche_end();
  61. // Buttons
  62. if ($action != 'create' && $action != 'edit') {
  63. print '<div class="tabsAction">';
  64. print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=create">' . $langs->trans("NewAttribute") . '</a>';
  65. print '</div>';
  66. }
  67. /* ************************************************************************* */
  68. /* */
  69. /* Creation d'un champ optionnel */
  70. /* */
  71. /* ************************************************************************** */
  72. if ($action == 'create') {
  73. print "<br>";
  74. print load_fiche_titre($langs->trans('NewAttribute'));
  75. require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php';
  76. }
  77. /* ************************************************************************* */
  78. /* */
  79. /* Edition d'un champ optionnel */
  80. /* */
  81. /* ************************************************************************** */
  82. if ($action == 'edit' && !empty($attrname)) {
  83. print "<br>";
  84. print load_fiche_titre($langs->trans("FieldEdition", $attrname));
  85. require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php';
  86. }
  87. // End of page
  88. llxFooter();
  89. $db->close();