dolibarr  9.0.0
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  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  * or see http://www.gnu.org/
19  */
20 
21 // Following var can be set
22 // $permission = permission or not to add a file
23 // $permtoedit = permission or not to edit file name, crop file
24 // $modulepart = for download
25 // $param = param to add to download links
26 
27 // Protection to avoid direct call of template
28 if (empty($langs) || ! is_object($langs))
29 {
30  print "Error, template page can't be called as URL";
31  exit;
32 }
33 
34 
35 $langs->load("link");
36 if (empty($relativepathwithnofile)) $relativepathwithnofile='';
37 if (empty($permtoedit)) $permtoedit=-1;
38 
39 // Drag and drop for up and down allowed on product, thirdparty, ...
40 // The drag and drop call the page core/ajax/row.php
41 // 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'
42 // Also the object->fk_element must be defined.
43 $disablemove=1;
44 if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket', 'holiday', 'expensereport'))) $disablemove=0;
45 
46 
47 
48 /*
49  * Confirm form to delete
50  */
51 
52 if ($action == 'delete')
53 {
54  $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
55  print $form->formconfirm(
56  $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int') . (empty($param)?'':$param),
57  $langs->trans('DeleteFile'),
58  $langs->trans('ConfirmDeleteFile'),
59  'confirm_deletefile',
60  '',
61  0,
62  1
63  );
64 }
65 
66 $formfile=new FormFile($db);
67 
68 // We define var to enable the feature to add prefix of uploaded files
69 $savingdocmask='';
70 if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
71 {
72  //var_dump($modulepart);
73  if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax', 'produit', 'product_batch')))
74  {
75  $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
76  }
77  /*if (in_array($modulepart,array('member')))
78  {
79  $savingdocmask=$object->login.'___file__';
80  }*/
81 }
82 
83 // Show upload form (document and links)
84 $formfile->form_attach_new_file(
85  $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject)?'':'&withproject=1'),
86  '',
87  0,
88  0,
89  $permission,
90  $conf->browser->layout == 'phone' ? 40 : 60,
91  $object,
92  '',
93  1,
94  $savingdocmask
95 );
96 
97 // List of document
98 $formfile->list_of_documents(
99  $filearray,
100  $object,
101  $modulepart,
102  $param,
103  0,
104  $relativepathwithnofile, // relative path with no file. For example "0/1"
105  $permission,
106  0,
107  '',
108  0,
109  '',
110  '',
111  0,
112  $permtoedit,
113  $upload_dir,
114  $sortfield,
115  $sortorder,
116  $disablemove
117 );
118 
119 print "<br>";
120 //List of links
121 $formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param);
122 print "<br>";
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
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.