dolibarr 23.0.3
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-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 * or see https://www.gnu.org/
24 */
25
26// Following var can be set
27// $object
28// $filearray
29
50// Protection to avoid direct call of template
51if (empty($langs) || !is_object($langs)) {
52 print "Error, template page can't be called as URL";
53 exit(1);
54}
55'
56@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
57@phan-var-force ?int<0,1> $permtoedit
58@phan-var-force ?int<0,1> $permission
59@phan-var-force int<0,1> $permissiontoadd
60@phan-var-force ?string $savingdocmask
61@phan-var-force ?string $param
62@phan-var-force CommonObject $object
63';
64
65
66$langs->load("link");
67if (empty($relativepathwithnofile)) {
68 $relativepathwithnofile = '';
69}
70
71// Set $permission from the $permissiontoadd var defined on calling page
72if (!isset($permission)) {
73 $permission = $permissiontoadd;
74}
75if (!isset($permtoedit)) {
76 $permtoedit = $permissiontoadd;
77}
78if (!isset($param)) {
79 $param = '';
80}
81
82// Drag and drop for up and down allowed on product, thirdparty, ...
83// The drag and drop call the page core/ajax/row.php
84// 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'
85// Also the object->fk_element must be defined.
86$disablemove = 1;
87if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) {
88 $disablemove = 0;
89}
90$parameters = array();
91$reshook = $hookmanager->executeHooks('isLinkedDocumentObjectNotMovable', $parameters, $object); // @phan-suppress-current-line PhanTypeMismatchArgumentNullable
92if ($reshook) {
93 $disablemove = $hookmanager->resArray['disablemove'];
94}
95
96/*
97 * Confirm form to delete a file
98 */
99
100if ($action == 'deletefile' || $action == 'deletelink') {
101 $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
102 print $form->formconfirm(
103 $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOSTINT('linkid').(empty($param) ? '' : $param),
104 $langs->trans('DeleteFile'),
105 $langs->trans('ConfirmDeleteFile'),
106 'confirm_deletefile',
107 '',
108 '',
109 1
110 );
111}
112
113// We define var to enable the feature to add prefix of uploaded files.
114// Caller of this include can make
115// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
116if (!isset($savingdocmask) || getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
117 $savingdocmask = '';
118 if (!getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
119 //var_dump($modulepart);
120 if (in_array($modulepart, array(
121 'facture_fournisseur',
122 'commande_fournisseur',
123 'facture',
124 'commande',
125 'propal',
126 'payment',
127 'supplier_proposal',
128 'ficheinter',
129 'contract',
130 'expedition',
131 'project',
132 'project_task',
133 'expensereport',
134 'tax',
135 'tax-vat',
136 'produit',
137 'product_batch',
138 'bom',
139 'mrp'
140 ))) {
141 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
142 }
143 /*if (in_array($modulepart,array('member')))
144 {
145 $savingdocmask=$object->login.'___file__';
146 }*/
147 }
148}
149
150if (empty($formfile) || !is_object($formfile)) {
151 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
152 $formfile = new FormFile($db);
153}
154
155// Get the form to add files (upload and links)
156$tmparray = $formfile->form_attach_new_file(
157 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
158 '',
159 0,
160 0,
161 $permission,
162 $conf->browser->layout == 'phone' ? 40 : 60,
163 $object,
164 '',
165 1,
166 $savingdocmask,
167 1,
168 'formuserfile',
169 '',
170 '',
171 0,
172 0,
173 0,
174 2
175);
176
177$formToUploadAFile = '';
178$formToAddALink = '';
179
180if (is_array($tmparray) && !empty($tmparray)) {
181 $formToUploadAFile = $tmparray['formToUploadAFile'];
182 $formToAddALink = $tmparray['formToAddALink'];
183}
184
185
186if (getDolGlobalString('MAIN_DOCUMENTS_LIST_IN_TWOCOLUMNS')) {
187 // We use a table with 2 columns
188 print '<div class="fichecenter">';
189 print '<div class="fichehalfleft">';
190}
191// List of document
192$formfile->list_of_documents(
193 $filearray,
194 $object,
195 $modulepart,
196 $param,
197 0,
198 $relativepathwithnofile, // relative path with no file. For example "0/1"
199 $permission,
200 0,
201 '',
202 0,
203 '',
204 '',
205 0,
206 $permtoedit,
207 $upload_dir,
208 $sortfield,
209 $sortorder,
210 $disablemove,
211 0,
212 -1,
213 '',
214 array('afteruploadtitle' => $formToUploadAFile, 'showhideaddbutton' => 1)
215);
216
217if (getDolGlobalString('MAIN_DOCUMENTS_LIST_IN_TWOCOLUMNS')) {
218 print '</div>';
219 print '<div class="fichehalfright">';
220} else {
221 print "<br>";
222}
223
224//List of links
225$formfile->listOfLinks(
226 $object,
227 $permission,
228 $action,
229 (string) GETPOSTINT('linkid'),
230 $param,
231 'formaddlink',
232 array('afterlinktitle' => $formToAddALink, 'showhideaddbutton' => 1)
233);
234
235if (getDolGlobalString('MAIN_DOCUMENTS_LIST_IN_TWOCOLUMNS')) {
236 print '</div>';
237 print '</div>';
238}
239
240print "<br>";
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.