dolibarr 21.0.0-alpha
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(1);
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='.GETPOSTINT('linkid').(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 'payment',
97 'supplier_proposal',
98 'ficheinter',
99 'contract',
100 'expedition',
101 'project',
102 'project_task',
103 'expensereport',
104 'tax',
105 'tax-vat',
106 'produit',
107 'product_batch',
108 'bom',
109 'mrp'
110 ))) {
111 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
112 }
113 /*if (in_array($modulepart,array('member')))
114 {
115 $savingdocmask=$object->login.'___file__';
116 }*/
117 }
118}
119
120if (empty($formfile) || !is_object($formfile)) {
121 $formfile = new FormFile($db);
122}
123
124// Show upload form (document and links)
125$formfile->form_attach_new_file(
126 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
127 '',
128 0,
129 0,
130 $permission,
131 $conf->browser->layout == 'phone' ? 40 : 60,
132 $object,
133 '',
134 1,
135 $savingdocmask
136);
137
138//var_dump($modulepart);var_dump($upload_dir);
139
140// List of document
141$formfile->list_of_documents(
142 $filearray,
143 $object,
144 $modulepart,
145 $param,
146 0,
147 $relativepathwithnofile, // relative path with no file. For example "0/1"
148 $permission,
149 0,
150 '',
151 0,
152 '',
153 '',
154 0,
155 $permtoedit,
156 $upload_dir,
157 $sortfield,
158 $sortorder,
159 $disablemove
160);
161
162print "<br>";
163
164//List of links
165$formfile->listOfLinks($object, $permission, $action, GETPOSTINT('linkid'), $param);
166print "<br>";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.