document.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 3 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', 'aZ09comma');
  48. $sortorder = GETPOST('sortorder', 'aZ09comma');
  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. $permissiontoadd = $user->rights->banque->modifier; // Used by the include of actions_dellink.inc.php
  68. /*
  69. * Actions
  70. */
  71. if ($object->id > 0) {
  72. $object->fetch_thirdparty();
  73. $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref);
  74. }
  75. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  76. /*
  77. * View
  78. */
  79. $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents");
  80. $help_url = "EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses";
  81. llxHeader("", $title, $help_url);
  82. $form = new Form($db);
  83. if ($id > 0 || !empty($ref)) {
  84. if ($object->fetch($id, $ref)) {
  85. $upload_dir = $conf->bank->dir_output.'/'.$object->ref;
  86. // Onglets
  87. $head = bank_prepare_head($object);
  88. print dol_get_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account');
  89. // Build file list
  90. $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
  91. $totalsize = 0;
  92. foreach ($filearray as $key => $file) {
  93. $totalsize += $file['size'];
  94. }
  95. $morehtmlref = '';
  96. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  97. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  98. print '<div class="fichecenter">';
  99. print '<div class="underbanner clearboth"></div>';
  100. print '<table class="border tableforfield centpercent">';
  101. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  102. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  103. print "</table>\n";
  104. print '</div>';
  105. print dol_get_fiche_end();
  106. $modulepart = 'bank';
  107. $permissiontoadd = $user->rights->banque->modifier;
  108. $permtoedit = $user->rights->banque->modifier;
  109. $param = '&id='.$object->id;
  110. include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  111. } else {
  112. dol_print_error($db);
  113. }
  114. } else {
  115. Header('Location: index.php');
  116. exit;
  117. }
  118. // End of page
  119. llxFooter();
  120. $db->close();