document.php 4.6 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@capnetworks.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 <http://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', 'alpha');
  36. $confirm = GETPOST('confirm', 'alpha');
  37. $mesg = '';
  38. if (isset($_SESSION['DolMessage'])) {
  39. $mesg = $_SESSION['DolMessage'];
  40. unset($_SESSION['DolMessage']);
  41. }
  42. // Security check
  43. if ($user->societe_id) {
  44. $action = '';
  45. $socid = $user->societe_id;
  46. }
  47. if ($user->societe_id)
  48. $socid = $user->societe_id;
  49. $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '',
  50. $fieldtype);
  51. // Get parameters
  52. $sortfield = GETPOST("sortfield", 'alpha');
  53. $sortorder = GETPOST("sortorder", 'alpha');
  54. $page = GETPOST("page", 'int');
  55. if (empty($page) || $page == -1) { $page = 0; }
  56. $offset = $conf->liste_limit * $page;
  57. $pageprev = $page - 1;
  58. $pagenext = $page + 1;
  59. if (!$sortorder)
  60. $sortorder = "ASC";
  61. if (!$sortfield)
  62. $sortfield = "name";
  63. $object = new Account($db);
  64. if ($id)
  65. $object->fetch($id);
  66. /*
  67. * Actions
  68. */
  69. if ($object->id > 0)
  70. {
  71. $object->fetch_thirdparty();
  72. $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
  73. }
  74. include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
  75. /*
  76. * View
  77. */
  78. $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents");
  79. $helpurl = "";
  80. llxHeader('',$title,$helpurl);
  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. dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account');
  88. // Construit liste des fichiers
  89. $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$',
  90. $sortfield,
  91. (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
  92. $totalsize = 0;
  93. foreach ($filearray as $key => $file) {
  94. $totalsize+=$file['size'];
  95. }
  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" width="100%">';
  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. dol_fiche_end();
  106. $modulepart = 'bank';
  107. $permission = $user->rights->banque->modifier;
  108. $permtoedit = $user->rights->banque->modifier;
  109. $param = '&id=' . $object->id;
  110. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  111. }
  112. else {
  113. dol_print_error($db);
  114. }
  115. }
  116. else {
  117. Header('Location: index.php');
  118. exit;
  119. }
  120. llxFooter();
  121. $db->close();