info.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  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 <https://www.gnu.org/licenses/>.
  17. * or see https://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/holiday/info.php
  21. * \ingroup holiday
  22. * \brief Page to show a leave information
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  29. // Load translation files required by the page
  30. $langs->load("holiday");
  31. $id = GETPOST('id', 'int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $childids = $user->getAllChildIds(1);
  34. $morefilter = '';
  35. if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) {
  36. $morefilter = 'AND employee = 1';
  37. }
  38. $object = new Holiday($db);
  39. $extrafields = new ExtraFields($db);
  40. // fetch optionals attributes and labels
  41. $extrafields->fetch_name_optionals_label($object->table_element);
  42. if (($id > 0) || $ref) {
  43. $object->fetch($id, $ref);
  44. // Check current user can read this leave request
  45. $canread = 0;
  46. if (!empty($user->rights->holiday->readall)) {
  47. $canread = 1;
  48. }
  49. if (!empty($user->rights->holiday->read) && in_array($object->fk_user, $childids)) {
  50. $canread = 1;
  51. }
  52. if (!$canread) {
  53. accessforbidden();
  54. }
  55. }
  56. // Security check
  57. if ($user->socid) {
  58. $socid = $user->socid;
  59. }
  60. $result = restrictedArea($user, 'holiday', $object->id, 'holiday');
  61. /*
  62. * View
  63. */
  64. $form = new Form($db);
  65. $title = $langs->trans("Leave")." - ".$langs->trans("Info");
  66. $helpurl = "";
  67. llxHeader("", $title, $helpurl);
  68. if ($id > 0 || !empty($ref)) {
  69. $object = new Holiday($db);
  70. $object->fetch($id, $ref);
  71. $object->info($object->id);
  72. $head = holiday_prepare_head($object);
  73. print dol_get_fiche_head($head, 'info', $langs->trans("Holiday"), -1, 'holiday');
  74. $linkback = '<a href="'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  75. $morehtmlref = '<div class="refidno">';
  76. $morehtmlref .= '</div>';
  77. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  78. print '<div class="fichecenter">';
  79. print '<div class="underbanner clearboth"></div>';
  80. print '<br>';
  81. print '<table width="100%"><tr><td>';
  82. dol_print_object_info($object);
  83. print '</td></tr></table>';
  84. print '</div>';
  85. print dol_get_fiche_end();
  86. }
  87. // End of page
  88. llxFooter();
  89. $db->close();