categorie.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. // Load Dolibarr environment
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
  27. if (!$user->admin) {
  28. accessforbidden();
  29. }
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("categories", "admin"));
  32. $action = GETPOST('action', 'aZ09');
  33. /*
  34. * Actions
  35. */
  36. $reg = array();
  37. if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
  38. $code = $reg[1];
  39. if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
  40. header("Location: ".$_SERVER["PHP_SELF"]);
  41. exit;
  42. } else {
  43. setEventMessages($db->lasterror(), null, 'errors');
  44. }
  45. }
  46. if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
  47. $code = $reg[1];
  48. if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
  49. header("Location: ".$_SERVER["PHP_SELF"]);
  50. exit;
  51. } else {
  52. setEventMessages($db->lasterror(), null, 'errors');
  53. }
  54. }
  55. /*
  56. * View
  57. */
  58. $help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías|DE:Modul_Kategorien';
  59. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  60. llxHeader('', $langs->trans("Categories"), $help_url);
  61. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  62. print load_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'title_setup');
  63. $head = categoriesadmin_prepare_head();
  64. print dol_get_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category');
  65. print '<table class="noborder centpercent">';
  66. print '<tr class="liste_titre">';
  67. print '<td>'.$langs->trans("Description").'</td>';
  68. print '<td align="center" width="20">&nbsp;</td>';
  69. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  70. print '</tr>';
  71. $form = new Form($db);
  72. // Mail required for members
  73. print '<tr class="oddeven">';
  74. print '<td>'.$langs->trans("CategorieRecursiv").'</td>';
  75. print '<td align="center" width="20">'.$form->textwithpicto('', $langs->trans("CategorieRecursivHelp"), 1, 'help').'</td>';
  76. print '<td align="center" width="100">';
  77. if ($conf->use_javascript_ajax) {
  78. print ajax_constantonoff('CATEGORIE_RECURSIV_ADD');
  79. } else {
  80. if (!getDolGlobalString('CATEGORIE_RECURSIV_ADD')) {
  81. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_CATEGORIE_RECURSIV_ADD&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  82. } else {
  83. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_CATEGORIE_RECURSIV_ADD&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  84. }
  85. }
  86. print '</td></tr>';
  87. print '</table>';
  88. // End of page
  89. llxFooter();
  90. $db->close();