categorie.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  4. * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/categories/admin/categorie.php
  21. * \ingroup categories
  22. * \brief Categorie admin pages
  23. */
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
  26. if (!$user->admin) {
  27. accessforbidden();
  28. }
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("categories", "admin"));
  31. $action = GETPOST('action', 'aZ09');
  32. /*
  33. * Actions
  34. */
  35. $reg = array();
  36. if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
  37. $code = $reg[1];
  38. if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
  39. header("Location: ".$_SERVER["PHP_SELF"]);
  40. exit;
  41. } else {
  42. setEventMessages($db->lasterror(), null, 'errors');
  43. }
  44. }
  45. if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
  46. $code = $reg[1];
  47. if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
  48. header("Location: ".$_SERVER["PHP_SELF"]);
  49. exit;
  50. } else {
  51. setEventMessages($db->lasterror(), null, 'errors');
  52. }
  53. }
  54. /*
  55. * View
  56. */
  57. $help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías';
  58. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  59. llxHeader('', $langs->trans("Categories"), $help_url);
  60. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  61. print load_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'title_setup');
  62. $head = categoriesadmin_prepare_head();
  63. print dol_get_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category');
  64. print '<table class="noborder centpercent">';
  65. print '<tr class="liste_titre">';
  66. print '<td>'.$langs->trans("Description").'</td>';
  67. print '<td align="center" width="20">&nbsp;</td>';
  68. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  69. print '</tr>';
  70. $form = new Form($db);
  71. // Mail required for members
  72. print '<tr class="oddeven">';
  73. print '<td>'.$langs->trans("CategorieRecursiv").'</td>';
  74. print '<td align="center" width="20">'.$form->textwithpicto('', $langs->trans("CategorieRecursivHelp"), 1, 'help').'</td>';
  75. print '<td align="center" width="100">';
  76. if ($conf->use_javascript_ajax) {
  77. print ajax_constantonoff('CATEGORIE_RECURSIV_ADD');
  78. } else {
  79. if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
  80. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  81. } else {
  82. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  83. }
  84. }
  85. print '</td></tr>';
  86. print '</table>';
  87. // End of page
  88. llxFooter();
  89. $db->close();