dolibarr  17.0.4
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
33 if (empty($langs) || !is_object($langs)) {
34  print "Error, template page can't be called as URL";
35  exit;
36 }
37 
38 
39 $langs->load("link");
40 if (empty($relativepathwithnofile)) {
41  $relativepathwithnofile = '';
42 }
43 
44 if (!isset($permission)) {
45  $permission = $permissiontoadd;
46 }
47 if (!isset($permtoedit)) {
48  $permtoedit = $permissiontoadd;
49 }
50 if (!isset($param)) {
51  $param = '';
52 }
53 
54 // Drag and drop for up and down allowed on product, thirdparty, ...
55 // The drag and drop call the page core/ajax/row.php
56 // 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'
57 // Also the object->fk_element must be defined.
58 $disablemove = 1;
59 if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) {
60  $disablemove = 0;
61 }
62 
63 
64 
65 /*
66  * Confirm form to delete a file
67  */
68 
69 if ($action == 'deletefile' || $action == 'deletelink') {
70  $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
71  print $form->formconfirm(
72  $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param),
73  $langs->trans('DeleteFile'),
74  $langs->trans('ConfirmDeleteFile'),
75  'confirm_deletefile',
76  '',
77  '',
78  1
79  );
80 }
81 
82 // We define var to enable the feature to add prefix of uploaded files.
83 // Caller of this include can make
84 // $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
85 if (!isset($savingdocmask) || !empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) {
86  $savingdocmask = '';
87  if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) {
88  //var_dump($modulepart);
89  if (in_array($modulepart, array(
90  'facture_fournisseur',
91  'commande_fournisseur',
92  'facture',
93  'commande',
94  'propal',
95  'supplier_proposal',
96  'ficheinter',
97  'contract',
98  'expedition',
99  'project',
100  'project_task',
101  'expensereport',
102  'tax',
103  'tax-vat',
104  'produit',
105  'product_batch',
106  'bom',
107  'mrp'
108  ))) {
109  $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
110  }
111  /*if (in_array($modulepart,array('member')))
112  {
113  $savingdocmask=$object->login.'___file__';
114  }*/
115  }
116 }
117 
118 if (empty($formfile) || !is_object($formfile)) {
119  $formfile = new FormFile($db);
120 }
121 
122 // Show upload form (document and links)
123 $formfile->form_attach_new_file(
124  $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject) ? '' : '&withproject=1').(empty($moreparam) ? '' : $moreparam),
125  '',
126  0,
127  0,
128  $permission,
129  $conf->browser->layout == 'phone' ? 40 : 60,
130  $object,
131  '',
132  1,
133  $savingdocmask
134 );
135 
136 // List of document
137 $formfile->list_of_documents(
138  $filearray,
139  $object,
140  $modulepart,
141  $param,
142  0,
143  $relativepathwithnofile, // relative path with no file. For example "0/1"
144  $permission,
145  0,
146  '',
147  0,
148  '',
149  '',
150  0,
151  $permtoedit,
152  $upload_dir,
153  $sortfield,
154  $sortorder,
155  $disablemove
156 );
157 
158 print "<br>";
159 
160 //List of links
161 $formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param);
162 print "<br>";
Class to offer components to list and upload files.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.