dolibarr 19.0.3
document_actions_post_headers.tpl.php
1<?php
2/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
3 * Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
5 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.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 * or see https://www.gnu.org/
20 */
21
22// Following var can be set
23// $permissiontoadd = permission or not to add a file (can use also $permission) and permission or not to edit file name or crop file (can use also $permtoedit)
24// $modulepart = for download
25// $param = param to add to download links
26// $moreparam = param to add to download link for the form_attach_new_file function
27// $upload_dir
28// $object
29// $filearray
30// $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
31
32// Protection to avoid direct call of template
33if (empty($langs) || !is_object($langs)) {
34 print "Error, template page can't be called as URL";
35 exit;
36}
37
38
39$langs->load("link");
40if (empty($relativepathwithnofile)) {
41 $relativepathwithnofile = '';
42}
43
44// Set $permission from the $permissiontoadd var defined on calling page
45if (!isset($permission)) {
46 $permission = $permissiontoadd;
47}
48if (!isset($permtoedit)) {
49 $permtoedit = $permissiontoadd;
50}
51if (!isset($param)) {
52 $param = '';
53}
54
55// Drag and drop for up and down allowed on product, thirdparty, ...
56// The drag and drop call the page core/ajax/row.php
57// If you enable the move up/down of files here, check that page that include template set its sortorder on 'position_name' instead of 'name'
58// Also the object->fk_element must be defined.
59$disablemove = 1;
60if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) {
61 $disablemove = 0;
62}
63
64
65
66/*
67 * Confirm form to delete a file
68 */
69
70if ($action == 'deletefile' || $action == 'deletelink') {
71 $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
72 print $form->formconfirm(
73 $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param),
74 $langs->trans('DeleteFile'),
75 $langs->trans('ConfirmDeleteFile'),
76 'confirm_deletefile',
77 '',
78 '',
79 1
80 );
81}
82
83// We define var to enable the feature to add prefix of uploaded files.
84// Caller of this include can make
85// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
86if (!isset($savingdocmask) || getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
87 $savingdocmask = '';
88 if (!getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
89 //var_dump($modulepart);
90 if (in_array($modulepart, array(
91 'facture_fournisseur',
92 'commande_fournisseur',
93 'facture',
94 'commande',
95 'propal',
96 'supplier_proposal',
97 'ficheinter',
98 'contract',
99 'expedition',
100 'project',
101 'project_task',
102 'expensereport',
103 'tax',
104 'tax-vat',
105 'produit',
106 'product_batch',
107 'bom',
108 'mrp'
109 ))) {
110 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
111 }
112 /*if (in_array($modulepart,array('member')))
113 {
114 $savingdocmask=$object->login.'___file__';
115 }*/
116 }
117}
118
119if (empty($formfile) || !is_object($formfile)) {
120 $formfile = new FormFile($db);
121}
122
123// Show upload form (document and links)
124$formfile->form_attach_new_file(
125 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
126 '',
127 0,
128 0,
129 $permission,
130 $conf->browser->layout == 'phone' ? 40 : 60,
131 $object,
132 '',
133 1,
134 $savingdocmask
135);
136
137// List of document
138$formfile->list_of_documents(
139 $filearray,
140 $object,
141 $modulepart,
142 $param,
143 0,
144 $relativepathwithnofile, // relative path with no file. For example "0/1"
145 $permission,
146 0,
147 '',
148 0,
149 '',
150 '',
151 0,
152 $permtoedit,
153 $upload_dir,
154 $sortfield,
155 $sortorder,
156 $disablemove
157);
158
159print "<br>";
160
161//List of links
162$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param);
163print "<br>";
Class to offer components to list and upload files.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.