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