assets_extrafields.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
  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 htdocs/asset/admin/asset_extrafields.php
  20. * \ingroup asset
  21. * \brief Page to setup extra fields of assets
  22. */
  23. require '../../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  26. // Load translation files required by the page
  27. $langs->loadLangs(array("assets","admin","companies"));
  28. $extrafields = new ExtraFields($db);
  29. $form = new Form($db);
  30. // List of supported format
  31. $tmptype2label=ExtraFields::$type2label;
  32. $type2label=array('');
  33. foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
  34. $action=GETPOST('action', 'alpha');
  35. $attrname=GETPOST('attrname', 'alpha');
  36. $elementtype='don'; //Must be the $table_element of the class that manage extrafield
  37. if (!$user->admin) accessforbidden();
  38. /*
  39. * Actions
  40. */
  41. require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
  42. /*
  43. * View
  44. */
  45. $textobject=$langs->transnoentitiesnoconv("Assets");
  46. llxHeader('',$langs->trans("AssetsSetup"));
  47. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  48. print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup');
  49. $head = asset_admin_prepare_head();
  50. dol_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic');
  51. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
  52. dol_fiche_end();
  53. // Buttons
  54. if ($action != 'create' && $action != 'edit')
  55. {
  56. print '<div class="tabsAction">';
  57. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
  58. print "</div>";
  59. }
  60. /* ************************************************************************** */
  61. /* */
  62. /* Create optional field */
  63. /* */
  64. /* ************************************************************************** */
  65. if ($action == 'create')
  66. {
  67. print "<br>";
  68. print load_fiche_titre($langs->trans('NewAttribute'));
  69. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
  70. }
  71. /* ************************************************************************** */
  72. /* */
  73. /* Edit optional field */
  74. /* */
  75. /* ************************************************************************** */
  76. if ($action == 'edit' && ! empty($attrname))
  77. {
  78. print "<br>";
  79. print load_fiche_titre($langs->trans("FieldEdition", $attrname));
  80. require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
  81. }
  82. // End of page
  83. llxFooter();
  84. $db->close();