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