info.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/expensereport/info.php
  21. * \ingroup expensereport
  22. * \brief Page to show a trip information
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  29. // Load translation files required by the page
  30. $langs->load("trips");
  31. $id = GETPOST('id', 'int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $childids = $user->getAllChildIds(1);
  34. // Security check
  35. if ($user->socid) {
  36. $socid = $user->socid;
  37. }
  38. $result = restrictedArea($user, 'expensereport', $id, 'expensereport');
  39. $object = new ExpenseReport($db);
  40. if (!$object->fetch($id, $ref) > 0) {
  41. dol_print_error($db);
  42. }
  43. if ($object->id > 0) {
  44. // Check current user can read this expense report
  45. $canread = 0;
  46. if (!empty($user->rights->expensereport->readall)) {
  47. $canread = 1;
  48. }
  49. if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) {
  50. $canread = 1;
  51. }
  52. if (!$canread) {
  53. accessforbidden();
  54. }
  55. }
  56. /*
  57. * View
  58. */
  59. $form = new Form($db);
  60. $title = $langs->trans("ExpenseReport")." - ".$langs->trans("Info");
  61. $helpurl = "EN:Module_Expense_Reports";
  62. llxHeader("", $title, $helpurl);
  63. if ($id > 0 || !empty($ref)) {
  64. $object = new ExpenseReport($db);
  65. $object->fetch($id, $ref);
  66. $object->info($object->id);
  67. $head = expensereport_prepare_head($object);
  68. print dol_get_fiche_head($head, 'info', $langs->trans("ExpenseReport"), -1, 'trip');
  69. $linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  70. $morehtmlref = '<div class="refidno">';
  71. $morehtmlref .= '</div>';
  72. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  73. print '<div class="fichecenter">';
  74. print '<div class="underbanner clearboth"></div>';
  75. print '<br>';
  76. print '<table width="100%"><tr><td>';
  77. dol_print_object_info($object);
  78. print '</td></tr></table>';
  79. print '</div>';
  80. print dol_get_fiche_end();
  81. }
  82. // End of page
  83. llxFooter();
  84. $db->close();