info.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2017 Ferran Marcet <fmarcet@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/info.php
  21. * \ingroup categories
  22. * \brief Category info page
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
  29. if (!$user->hasRight('categorie', 'lire')) {
  30. accessforbidden();
  31. }
  32. // Load translation files required by the page
  33. $langs->loadLangs(array('categories', 'sendings'));
  34. $socid = 0;
  35. $id = GETPOST('id', 'int');
  36. $label = GETPOST('label', 'alpha');
  37. // Security check
  38. if ($user->socid) {
  39. $socid = $user->socid;
  40. }
  41. $result = restrictedArea($user, 'categorie', $id, '&category');
  42. $object = new Categorie($db);
  43. $result = $object->fetch($id, $label);
  44. if ($result <= 0) {
  45. dol_print_error($db, $object->error);
  46. exit;
  47. }
  48. $type = $object->type;
  49. if (is_numeric($type)) {
  50. $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
  51. }
  52. /*
  53. * View
  54. */
  55. $form = new Form($db);
  56. llxHeader('', $langs->trans('Categories'), '');
  57. //$object->info($object->id);
  58. $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
  59. $head = categories_prepare_head($object, $type);
  60. print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category');
  61. $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
  62. $linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
  63. $object->next_prev_filter = 'type = '.((int) $object->type);
  64. $object->ref = $object->label;
  65. $morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a> >> ';
  66. $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
  67. foreach ($ways as $way) {
  68. $morehtmlref .= $way."<br>\n";
  69. }
  70. $morehtmlref .= '</div>';
  71. dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.$type, 0, '', '', 1);
  72. print '<br>';
  73. print '<div class="fichecenter">';
  74. print '<div class="underbanner clearboth"></div>';
  75. print '<br>';
  76. print '<table "border centpercent tableforfield">';
  77. print '<tr><td>';
  78. dol_print_object_info($object);
  79. print '</td></tr>';
  80. print '</table>';
  81. print '</div>';
  82. print dol_get_fiche_end();
  83. // End of page
  84. llxFooter();
  85. $db->close();