dolibarr 24.0.0-beta
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-2026 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
52// Protection to avoid direct call of template
53if (empty($langs) || !is_object($langs)) {
54 print "Error, template page can't be called as URL";
55 exit(1);
56}
67'
68@phan-var-force string $action
69@phan-var-force string $modulepart
70@phan-var-force string $upload_dir
71@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
72@phan-var-force ?int<0,1> $permtoedit
73@phan-var-force ?int<0,1> $permission
74@phan-var-force int<0,1> $permissiontoadd
75@phan-var-force ?string $savingdocmask
76@phan-var-force ?string $param
77@phan-var-force CommonObject $object
78@phan-var-force string $sortfield
79@phan-var-force string $sortorder
80';
81
82
83$langs->load("link");
84if (empty($relativepathwithnofile)) {
85 $relativepathwithnofile = '';
86}
87
88// Set $permission from the $permissiontoadd var defined on calling page
89if (!isset($permission)) {
90 $permission = $permissiontoadd;
91}
92if (!isset($permtoedit)) {
93 $permtoedit = $permissiontoadd;
94}
95if (!isset($param)) {
96 $param = '';
97}
98
99// Drag and drop for up and down allowed on product, thirdparty, ...
100// The drag and drop call the page core/ajax/row.php
101// 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'
102// Also the object->fk_element must be defined.
103$disablemove = 1;
104if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) {
105 $disablemove = 0;
106}
107$parameters = array();
108$reshook = $hookmanager->executeHooks('isLinkedDocumentObjectNotMovable', $parameters, $object); // @phan-suppress-current-line PhanTypeMismatchArgumentNullable
109if ($reshook) {
110 $disablemove = $hookmanager->resArray['disablemove'];
111}
112
113/*
114 * Confirm form to delete a file
115 */
116
117if ($action == 'deletefile' || $action == 'deletelink') {
118 $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
119 print $form->formconfirm(
120 $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOSTINT('linkid').(empty($param) ? '' : $param),
121 $langs->trans('DeleteFile'),
122 $langs->trans('ConfirmDeleteFile'),
123 'confirm_deletefile',
124 '',
125 '',
126 1
127 );
128}
129
130// We define var to enable the feature to add prefix of uploaded files.
131// Caller of this include can make
132// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
133if (!isset($savingdocmask) || getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
134 $savingdocmask = '';
135 if (!getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
136 //var_dump($modulepart);
137 if (in_array($modulepart, array(
138 'facture_fournisseur',
139 'commande_fournisseur',
140 'facture',
141 'commande',
142 'propal',
143 'payment',
144 'supplier_proposal',
145 'ficheinter',
146 'contract',
147 'expedition',
148 'project',
149 'project_task',
150 'expensereport',
151 'tax',
152 'tax-vat',
153 'produit',
154 'product_batch',
155 'bom',
156 'mrp'
157 ))) {
158 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
159 }
160 /*if (in_array($modulepart,array('member')))
161 {
162 $savingdocmask=$object->login.'___file__';
163 }*/
164 }
165}
166
167if (empty($formfile) || !is_object($formfile)) {
168 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
169 $formfile = new FormFile($db);
170}
171
172// Get the form to add files (upload and links)
173$tmparray = $formfile->form_attach_new_file(
174 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
175 '',
176 0,
177 0,
178 $permission,
179 $conf->browser->layout == 'phone' ? 40 : 60,
180 $object,
181 '',
182 1,
183 $savingdocmask,
184 1,
185 'formuserfile',
186 '',
187 '',
188 0,
189 0,
190 0,
191 2
192);
193
194$formToUploadAFile = '';
195$formToAddALink = '';
196
197if (is_array($tmparray) && !empty($tmparray)) {
198 $formToUploadAFile = $tmparray['formToUploadAFile'];
199 $formToAddALink = $tmparray['formToAddALink'];
200}
201
202
203if (getDolGlobalString('MAIN_DOCUMENTS_LIST_IN_TWOCOLUMNS')) {
204 // We use a table with 2 columns
205 print '<div class="fichecenter">';
206 print '<div class="fichehalfleft">';
207}
208
209// Force displaying form to attach files and documents
210$showHideAddButtonValue = 1;
211if (getDolGlobalInt('MAIN_DOCUMENTS_SHOW_FILE_ATTACHMENT_FORM')) {
212 $showHideAddButtonValue = 0;
213}
214
215// List of document
216$formfile->list_of_documents(
217 $filearray,
218 $object,
219 $modulepart,
220 $param,
221 0,
222 $relativepathwithnofile, // relative path with no file. For example "0/1"
223 $permission,
224 0,
225 '',
226 0,
227 '',
228 '',
229 0,
230 $permtoedit,
231 $upload_dir,
232 $sortfield,
233 $sortorder,
234 $disablemove,
235 0,
236 -1,
237 '',
238 array('afteruploadtitle' => $formToUploadAFile, 'showhideaddbutton' => $showHideAddButtonValue)
239);
240
241if (getDolGlobalString('MAIN_DOCUMENTS_LIST_IN_TWOCOLUMNS')) {
242 print '</div>';
243 print '<div class="fichehalfright">';
244} else {
245 print "<br>";
246}
247
248// Force displaying form to link files and documents
249$showHideAddButtonValue = 1;
250if (getDolGlobalInt('MAIN_DOCUMENTS_SHOW_FILE_LINKING_FORM')) {
251 $showHideAddButtonValue = 0;
252}
253
254//List of links
255$formfile->listOfLinks(
256 $object,
257 $permission,
258 $action,
259 (string) GETPOSTINT('linkid'),
260 $param,
261 'formaddlink',
262 array('afterlinktitle' => $formToAddALink, 'showhideaddbutton' => $showHideAddButtonValue)
263);
264
265if (getDolGlobalString('MAIN_DOCUMENTS_LIST_IN_TWOCOLUMNS')) {
266 print '</div>';
267 print '</div>';
268}
269
270print "<br>";
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to offer components to list and upload files.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.