document.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/compta/bank/document.php
  22. * \ingroup banque
  23. * \brief Page de gestion des documents attaches a un compte bancaire
  24. */
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT."/core/lib/bank.lib.php";
  27. require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
  28. require_once DOL_DOCUMENT_ROOT."/core/lib/images.lib.php";
  29. require_once DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php";
  30. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  31. // Load translation files required by the page
  32. $langs->loadLangs(array('banks', 'companies', 'other'));
  33. $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int'));
  34. $ref = GETPOST('ref', 'alpha');
  35. $action = GETPOST('action', 'aZ09');
  36. $confirm = GETPOST('confirm', 'alpha');
  37. // Security check
  38. if ($user->socid) {
  39. $action = '';
  40. $socid = $user->socid;
  41. }
  42. if ($user->socid) {
  43. $socid = $user->socid;
  44. }
  45. // Get parameters
  46. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  47. $sortfield = GETPOST("sortfield", 'alpha');
  48. $sortorder = GETPOST("sortorder", 'alpha');
  49. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  50. if (empty($page) || $page == -1) {
  51. $page = 0;
  52. }
  53. $offset = $limit * $page;
  54. $pageprev = $page - 1;
  55. $pagenext = $page + 1;
  56. if (!$sortorder) {
  57. $sortorder = "ASC";
  58. }
  59. if (!$sortfield) {
  60. $sortfield = "name";
  61. }
  62. $object = new Account($db);
  63. if ($id > 0 || !empty($ref)) {
  64. $object->fetch($id, $ref);
  65. }
  66. $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', '');
  67. /*
  68. * Actions
  69. */
  70. if ($object->id > 0) {
  71. $object->fetch_thirdparty();
  72. $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref);
  73. }
  74. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  75. /*
  76. * View
  77. */
  78. $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents");
  79. $help_url = "EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses";
  80. llxHeader("", $title, $help_url);
  81. $form = new Form($db);
  82. if ($id > 0 || !empty($ref)) {
  83. if ($object->fetch($id, $ref)) {
  84. $upload_dir = $conf->bank->dir_output.'/'.$object->ref;
  85. // Onglets
  86. $head = bank_prepare_head($object);
  87. print dol_get_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account');
  88. // Build file list
  89. $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
  90. $totalsize = 0;
  91. foreach ($filearray as $key => $file) {
  92. $totalsize += $file['size'];
  93. }
  94. $morehtmlref = '';
  95. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  96. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  97. print '<div class="fichecenter">';
  98. print '<div class="underbanner clearboth"></div>';
  99. print '<table class="border tableforfield centpercent">';
  100. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  101. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  102. print "</table>\n";
  103. print '</div>';
  104. print dol_get_fiche_end();
  105. $modulepart = 'bank';
  106. $permission = $user->rights->banque->modifier;
  107. $permtoedit = $user->rights->banque->modifier;
  108. $param = '&id='.$object->id;
  109. include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  110. } else {
  111. dol_print_error($db);
  112. }
  113. } else {
  114. Header('Location: index.php');
  115. exit;
  116. }
  117. // End of page
  118. llxFooter();
  119. $db->close();