dolibarr  7.0.0-beta
document.php
Go to the documentation of this file.
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@capnetworks.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 <http://www.gnu.org/licenses/>.
20  */
21 
27 require('../../main.inc.php');
28 require_once(DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php");
29 require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php");
30 require_once(DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php");
31 require_once(DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php");
32 require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
33 
34 $langs->load("banks");
35 
36 
37 $langs->load('companies');
38 $langs->load('other');
39 
40 $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int'));
41 $ref = GETPOST('ref', 'alpha');
42 $action = GETPOST('action', 'alpha');
43 $confirm = GETPOST('confirm', 'alpha');
44 
45 $mesg = '';
46 if (isset($_SESSION['DolMessage'])) {
47  $mesg = $_SESSION['DolMessage'];
48  unset($_SESSION['DolMessage']);
49 }
50 
51 // Security check
52 if ($user->societe_id) {
53  $action = '';
54  $socid = $user->societe_id;
55 }
56 if ($user->societe_id)
57  $socid = $user->societe_id;
58 $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '',
59  $fieldtype);
60 
61 // Get parameters
62 $sortfield = GETPOST("sortfield", 'alpha');
63 $sortorder = GETPOST("sortorder", 'alpha');
64 $page = GETPOST("page", 'int');
65 if (empty($page) || $page == -1) { $page = 0; }
66 $offset = $conf->liste_limit * $page;
67 $pageprev = $page - 1;
68 $pagenext = $page + 1;
69 if (!$sortorder)
70  $sortorder = "ASC";
71 if (!$sortfield)
72  $sortfield = "name";
73 
74 $object = new Account($db);
75 if ($id)
76  $object->fetch($id);
77 
78 /*
79  * Actions
80  */
81 
82 if ($object->id > 0)
83 {
84  $object->fetch_thirdparty();
85  $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
86 }
87 
88 include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
89 
90 
91 /*
92  * View
93  */
94 
95 $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents");
96 $helpurl = "";
97 llxHeader('',$title,$helpurl);
98 
99 $form = new Form($db);
100 
101 if ($id > 0 || !empty($ref)) {
102  if ($object->fetch($id, $ref)) {
103 
104  $upload_dir = $conf->bank->dir_output . '/' . $object->ref;
105 
106  // Onglets
107  $head = bank_prepare_head($object);
108  dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account');
109 
110 
111  // Construit liste des fichiers
112  $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$',
113  $sortfield,
114  (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
115  $totalsize = 0;
116  foreach ($filearray as $key => $file) {
117  $totalsize+=$file['size'];
118  }
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" width="100%">';
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">' . $totalsize . ' ' . $langs->trans("bytes") . '</td></tr>';
131  print "</table>\n";
132 
133  print '</div>';
134 
135  dol_fiche_end();
136 
137 
138  $modulepart = 'bank';
139  $permission = $user->rights->banque->modifier;
140  $permtoedit = $user->rights->banque->modifier;
141  $param = '&id=' . $object->id;
142  include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
143  }
144  else {
145  dol_print_error($db);
146  }
147 }
148 else {
149  Header('Location: index.php');
150  exit;
151 }
152 
153 
154 llxFooter();
155 
156 $db->close();
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition: bank.lib.php:34
llxHeader()
Header empty.
Definition: document.php:70
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to manage bank accounts.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
print
Draft customers invoices.
Definition: index.php:91
llxFooter()
Footer empty.
Definition: document.php:76
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.