document_actions_post_headers.tpl.php 4.4 KB

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