document.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
  7. * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/compta/deplacement/document.php
  25. * \ingroup deplacement
  26. * \brief Page of linked files onto trip and expenses
  27. */
  28. // Load Dolibarr environment
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('other', 'trips', 'companies', 'interventions'));
  37. $id = GETPOST('id', 'int');
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action', 'aZ09');
  40. $confirm = GETPOST('confirm', 'alpha');
  41. // Get parameters
  42. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  43. $sortfield = GETPOST('sortfield', 'aZ09comma');
  44. $sortorder = GETPOST('sortorder', 'aZ09comma');
  45. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  46. if (empty($page) || $page == -1) {
  47. $page = 0;
  48. } // If $page is not defined, or '' or -1
  49. $offset = $limit * $page;
  50. $pageprev = $page - 1;
  51. $pagenext = $page + 1;
  52. if (!$sortorder) {
  53. $sortorder = "ASC";
  54. }
  55. if (!$sortfield) {
  56. $sortfield = "name";
  57. }
  58. $object = new Deplacement($db);
  59. $object->fetch($id, $ref);
  60. $upload_dir = $conf->deplacement->dir_output.'/'.dol_sanitizeFileName($object->ref);
  61. $modulepart = 'trip';
  62. // Security check
  63. if ($user->socid) {
  64. $socid = $user->socid;
  65. }
  66. $result = restrictedArea($user, 'deplacement', $id, '');
  67. $permissiontoadd = $user->rights->deplacement->creer; // Used by the include of actions_dellink.inc.php
  68. /*
  69. * Actions
  70. */
  71. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  72. /*
  73. * View
  74. */
  75. $form = new Form($db);
  76. llxHeader("", "", $langs->trans("TripCard"));
  77. if ($object->id) {
  78. $object->fetch_thirdparty();
  79. $head = trip_prepare_head($object);
  80. print dol_get_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
  81. // Build file list
  82. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  83. $totalsize = 0;
  84. foreach ($filearray as $key => $file) {
  85. $totalsize += $file['size'];
  86. }
  87. print '<table class="border tableforfield centpercent">';
  88. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  89. // Ref
  90. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  91. print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
  92. print '</td></tr>';
  93. // Societe
  94. //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
  95. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  96. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  97. print '</table>';
  98. print '</div>';
  99. $modulepart = 'deplacement';
  100. $permissiontoadd = $user->rights->deplacement->creer;
  101. $param = '&id='.$object->id;
  102. include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  103. } else {
  104. print $langs->trans("ErrorUnknown");
  105. }
  106. // End of page
  107. llxFooter();
  108. $db->close();