hotelnaplo_extrafields.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
  7. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file admin/hotelnaplo_extrafields.php
  24. * \ingroup settlements
  25. * \brief Page to setup extra fields of hotelnaplo
  26. */
  27. // Load Dolibarr environment
  28. $res = 0;
  29. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  30. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  31. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
  32. }
  33. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  34. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
  35. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  36. $i--; $j--;
  37. }
  38. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
  39. $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
  40. }
  41. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
  42. $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
  43. }
  44. // Try main.inc.php using relative path
  45. if (!$res && file_exists("../../main.inc.php")) {
  46. $res = @include "../../main.inc.php";
  47. }
  48. if (!$res && file_exists("../../../main.inc.php")) {
  49. $res = @include "../../../main.inc.php";
  50. }
  51. if (!$res) {
  52. die("Include of main fails");
  53. }
  54. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  55. require_once '../lib/settlements.lib.php';
  56. // Load translation files required by the page
  57. $langs->loadLangs(array('settlements@settlements', 'admin'));
  58. $extrafields = new ExtraFields($db);
  59. $form = new Form($db);
  60. // List of supported format
  61. $tmptype2label = ExtraFields::$type2label;
  62. $type2label = array('');
  63. foreach ($tmptype2label as $key => $val) {
  64. $type2label[$key] = $langs->transnoentitiesnoconv($val);
  65. }
  66. $action = GETPOST('action', 'aZ09');
  67. $attrname = GETPOST('attrname', 'alpha');
  68. $elementtype = 'settlements_hotelnaplo'; //Must be the $table_element of the class that manage extrafield
  69. if (!$user->admin) {
  70. accessforbidden();
  71. }
  72. /*
  73. * Actions
  74. */
  75. require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  76. /*
  77. * View
  78. */
  79. $textobject = $langs->transnoentitiesnoconv("HotelNaplo");
  80. $help_url = '';
  81. $page_name = "SettlementsSetup";
  82. llxHeader('', $langs->trans("SettlementsSetup"), $help_url);
  83. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  84. print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
  85. $head = settlementsAdminPrepareHead();
  86. print dol_get_fiche_head($head, 'hotelnaplo_extrafields', $langs->trans($page_name), -1, 'settlements@settlements');
  87. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
  88. print dol_get_fiche_end();
  89. // Buttons
  90. if ($action != 'create' && $action != 'edit') {
  91. print '<div class="tabsAction">';
  92. print '<a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a>';
  93. print "</div>";
  94. }
  95. /*
  96. * Creation of an optional field
  97. */
  98. if ($action == 'create') {
  99. print '<br><div id="newattrib"></div>';
  100. print load_fiche_titre($langs->trans('NewAttribute'));
  101. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
  102. }
  103. /*
  104. * Edition of an optional field
  105. */
  106. if ($action == 'edit' && !empty($attrname)) {
  107. print "<br>";
  108. print load_fiche_titre($langs->trans("FieldEdition", $attrname));
  109. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
  110. }
  111. // End of page
  112. llxFooter();
  113. $db->close();