dolibarr 22.0.5
document_actions_post_headers.tpl.php
1<?php
2
3/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
4 * Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 * or see https://www.gnu.org/
23 */
24
25// Following var can be set
26// $modulepart = for download
27// $param = param to add to download links
28// $moreparam = param to add to download link for the form_attach_new_file function
29// $upload_dir
30// $object
31// $filearray
32// $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
33
44// Protection to avoid direct call of template
45if (empty($langs) || !is_object($langs)) {
46 print "Error, template page can't be called as URL";
47 exit(1);
48}
49'
50@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $filearray
51@phan-var-force ?int<0,1> $permtoedit
52@phan-var-force ?int<0,1> $permission
53@phan-var-force int<0,1> $permissiontoadd
54@phan-var-force ?string $savingdocmask
55@phan-var-force ?string $param
56@phan-var-force CommonObject $object
57';
58
59
60$langs->load("link");
61if (empty($relativepathwithnofile)) {
62 $relativepathwithnofile = '';
63}
64
65// Set $permission from the $permissiontoadd var defined on calling page
66if (!isset($permission)) {
67 $permission = $permissiontoadd;
68}
69if (!isset($permtoedit)) {
70 $permtoedit = $permissiontoadd;
71}
72if (!isset($param)) {
73 $param = '';
74}
75
76// Drag and drop for up and down allowed on product, thirdparty, ...
77// The drag and drop call the page core/ajax/row.php
78// 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'
79// Also the object->fk_element must be defined.
80$disablemove = 1;
81if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) {
82 $disablemove = 0;
83}
84$parameters = array();
85$reshook = $hookmanager->executeHooks('isLinkedDocumentObjectNotMovable', $parameters, $object); // @phan-suppress-current-line PhanTypeMismatchArgumentNullable
86if ($reshook) {
87 $disablemove = $hookmanager->resArray['disablemove'];
88}
89
90/*
91 * Confirm form to delete a file
92 */
93
94if ($action == 'deletefile' || $action == 'deletelink') {
95 $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
96 print $form->formconfirm(
97 $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOSTINT('linkid').(empty($param) ? '' : $param),
98 $langs->trans('DeleteFile'),
99 $langs->trans('ConfirmDeleteFile'),
100 'confirm_deletefile',
101 '',
102 '',
103 1
104 );
105}
106
107// We define var to enable the feature to add prefix of uploaded files.
108// Caller of this include can make
109// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
110if (!isset($savingdocmask) || getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
111 $savingdocmask = '';
112 if (!getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
113 //var_dump($modulepart);
114 if (in_array($modulepart, array(
115 'facture_fournisseur',
116 'commande_fournisseur',
117 'facture',
118 'commande',
119 'propal',
120 'payment',
121 'supplier_proposal',
122 'ficheinter',
123 'contract',
124 'expedition',
125 'project',
126 'project_task',
127 'expensereport',
128 'tax',
129 'tax-vat',
130 'produit',
131 'product_batch',
132 'bom',
133 'mrp'
134 ))) {
135 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
136 }
137 /*if (in_array($modulepart,array('member')))
138 {
139 $savingdocmask=$object->login.'___file__';
140 }*/
141 }
142}
143
144if (empty($formfile) || !is_object($formfile)) {
145 $formfile = new FormFile($db);
146}
147
148// Get the form to add files (upload and links)
149$tmparray = $formfile->form_attach_new_file(
150 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
151 '',
152 0,
153 0,
154 $permission,
155 $conf->browser->layout == 'phone' ? 40 : 60,
156 $object,
157 '',
158 1,
159 $savingdocmask,
160 1,
161 'formuserfile',
162 '',
163 '',
164 0,
165 0,
166 0,
167 2
168);
169
170$formToUploadAFile = '';
171$formToAddALink = '';
172
173if (is_array($tmparray) && !empty($tmparray)) {
174 $formToUploadAFile = $tmparray['formToUploadAFile'];
175 $formToAddALink = $tmparray['formToAddALink'];
176}
177
178
179// List of document
180$formfile->list_of_documents(
181 $filearray,
182 $object,
183 $modulepart,
184 $param,
185 0,
186 $relativepathwithnofile, // relative path with no file. For example "0/1"
187 $permission,
188 0,
189 '',
190 0,
191 '',
192 '',
193 0,
194 $permtoedit,
195 $upload_dir,
196 $sortfield,
197 $sortorder,
198 $disablemove,
199 0,
200 -1,
201 '',
202 array('afteruploadtitle' => $formToUploadAFile, 'showhideaddbutton' => 1)
203);
204
205
206print "<br>";
207
208
209//List of links
210$formfile->listOfLinks(
211 $object,
212 $permission,
213 $action,
214 (string) GETPOSTINT('linkid'),
215 $param,
216 'formaddlink',
217 array('afterlinktitle' => $formToAddALink, 'showhideaddbutton' => 1)
218);
219
220print "<br>";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
Class to offer components to list and upload files.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79