dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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 3 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 <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
23// Following var can be set
24// $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)
25// $modulepart = for download
26// $param = param to add to download links
27// $moreparam = param to add to download link for the form_attach_new_file function
28// $upload_dir
29// $object
30// $filearray
31// $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
38// Protection to avoid direct call of template
39if (empty($langs) || !is_object($langs)) {
40 print "Error, template page can't be called as URL";
41 exit(1);
42}
43
44
45$langs->load("link");
46if (empty($relativepathwithnofile)) {
47 $relativepathwithnofile = '';
48}
49
50// Set $permission from the $permissiontoadd var defined on calling page
51if (!isset($permission)) {
52 $permission = $permissiontoadd;
53}
54if (!isset($permtoedit)) {
55 $permtoedit = $permissiontoadd;
56}
57if (!isset($param)) {
58 $param = '';
59}
60
61// Drag and drop for up and down allowed on product, thirdparty, ...
62// The drag and drop call the page core/ajax/row.php
63// 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'
64// Also the object->fk_element must be defined.
65$disablemove = 1;
66if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) {
67 $disablemove = 0;
68}
69$parameters = array();
70$reshook = $hookmanager->executeHooks('isLinkedDocumentObjectNotMovable', $parameters, $object);
71if ($reshook) {
72 $disablemove = $hookmanager->resArray['disablemove'];
73}
74
75/*
76 * Confirm form to delete a file
77 */
78
79if ($action == 'deletefile' || $action == 'deletelink') {
80 $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
81 print $form->formconfirm(
82 $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOSTINT('linkid').(empty($param) ? '' : $param),
83 $langs->trans('DeleteFile'),
84 $langs->trans('ConfirmDeleteFile'),
85 'confirm_deletefile',
86 '',
87 '',
88 1
89 );
90}
91
92// We define var to enable the feature to add prefix of uploaded files.
93// Caller of this include can make
94// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
95if (!isset($savingdocmask) || getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
96 $savingdocmask = '';
97 if (!getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
98 //var_dump($modulepart);
99 if (in_array($modulepart, array(
100 'facture_fournisseur',
101 'commande_fournisseur',
102 'facture',
103 'commande',
104 'propal',
105 'payment',
106 'supplier_proposal',
107 'ficheinter',
108 'contract',
109 'expedition',
110 'project',
111 'project_task',
112 'expensereport',
113 'tax',
114 'tax-vat',
115 'produit',
116 'product_batch',
117 'bom',
118 'mrp'
119 ))) {
120 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
121 }
122 /*if (in_array($modulepart,array('member')))
123 {
124 $savingdocmask=$object->login.'___file__';
125 }*/
126 }
127}
128
129if (empty($formfile) || !is_object($formfile)) {
130 $formfile = new FormFile($db);
131}
132
133// Get the form to add files (upload and links)
134$tmparray = $formfile->form_attach_new_file(
135 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
136 '',
137 0,
138 0,
139 $permission,
140 $conf->browser->layout == 'phone' ? 40 : 60,
141 $object,
142 '',
143 1,
144 $savingdocmask,
145 1,
146 'formuserfile',
147 '',
148 '',
149 0,
150 0,
151 0,
152 2
153);
154
155$formToUploadAFile = $tmparray['formToUploadAFile'];
156$formToAddALink = $tmparray['formToAddALink'];
157
158
159// List of document
160$formfile->list_of_documents(
161 $filearray,
162 $object,
163 $modulepart,
164 $param,
165 0,
166 $relativepathwithnofile, // relative path with no file. For example "0/1"
167 $permission,
168 0,
169 '',
170 0,
171 '',
172 '',
173 0,
174 $permtoedit,
175 $upload_dir,
176 $sortfield,
177 $sortorder,
178 $disablemove,
179 0,
180 -1,
181 '',
182 array('afteruploadtitle' => $formToUploadAFile, 'showhideaddbutton' => 1)
183);
184
185
186print "<br><br>";
187
188
189//List of links
190$formfile->listOfLinks(
191 $object,
192 $permission,
193 $action,
194 GETPOSTINT('linkid'),
195 $param,
196 'formaddlink',
197 array('afterlinktitle' => $formToAddALink, 'showhideaddbutton' => 1)
198);
199
200print "<br>";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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)
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