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$parameters = array();
64$reshook = $hookmanager->executeHooks('isLinkedDocumentObjectNotMovable', $parameters, $object);
65if ($reshook) {
66 $disablemove = $hookmanager->resArray['disablemove'];
67}
68
69/*
70 * Confirm form to delete a file
71 */
72
73if ($action == 'deletefile' || $action == 'deletelink') {
74 $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
75 print $form->formconfirm(
76 $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOSTINT('linkid').(empty($param) ? '' : $param),
77 $langs->trans('DeleteFile'),
78 $langs->trans('ConfirmDeleteFile'),
79 'confirm_deletefile',
80 '',
81 '',
82 1
83 );
84}
85
86// We define var to enable the feature to add prefix of uploaded files.
87// Caller of this include can make
88// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
89if (!isset($savingdocmask) || getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
90 $savingdocmask = '';
91 if (!getDolGlobalString('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) {
92 //var_dump($modulepart);
93 if (in_array($modulepart, array(
94 'facture_fournisseur',
95 'commande_fournisseur',
96 'facture',
97 'commande',
98 'propal',
99 'payment',
100 'supplier_proposal',
101 'ficheinter',
102 'contract',
103 'expedition',
104 'project',
105 'project_task',
106 'expensereport',
107 'tax',
108 'tax-vat',
109 'produit',
110 'product_batch',
111 'bom',
112 'mrp'
113 ))) {
114 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
115 }
116 /*if (in_array($modulepart,array('member')))
117 {
118 $savingdocmask=$object->login.'___file__';
119 }*/
120 }
121}
122
123if (empty($formfile) || !is_object($formfile)) {
124 $formfile = new FormFile($db);
125}
126
127// Show upload form (document and links)
128$formfile->form_attach_new_file(
129 $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
130 '',
131 0,
132 0,
133 $permission,
134 $conf->browser->layout == 'phone' ? 40 : 60,
135 $object,
136 '',
137 1,
138 $savingdocmask
139);
140
141//var_dump($modulepart);var_dump($upload_dir);
142
143// List of document
144$formfile->list_of_documents(
145 $filearray,
146 $object,
147 $modulepart,
148 $param,
149 0,
150 $relativepathwithnofile, // relative path with no file. For example "0/1"
151 $permission,
152 0,
153 '',
154 0,
155 '',
156 '',
157 0,
158 $permtoedit,
159 $upload_dir,
160 $sortfield,
161 $sortorder,
162 $disablemove
163);
164
165print "<br>";
166
167//List of links
168$formfile->listOfLinks($object, $permission, $action, GETPOSTINT('linkid'), $param);
169print "<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.