document.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. * or see http://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/compta/bank/various_payment/document.php
  20. * \ingroup banque
  21. * \brief Page of linked files onto various_payment
  22. */
  23. require '../../../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
  28. $langs->load("other");
  29. $langs->load("bank");
  30. $langs->load("companies");
  31. $id = GETPOST('id','int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $action = GETPOST('action','alpha');
  34. $confirm = GETPOST('confirm','alpha');
  35. // Security check
  36. if ($user->societe_id) $socid=$user->societe_id;
  37. $result = restrictedArea($user, 'salaries', $id, '');
  38. // Get parameters
  39. $sortfield = GETPOST('sortfield','alpha');
  40. $sortorder = GETPOST('sortorder','alpha');
  41. $page = GETPOST('page','int');
  42. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  43. $offset = $conf->liste_limit * $page;
  44. $pageprev = $page - 1;
  45. $pagenext = $page + 1;
  46. if (! $sortorder) $sortorder="ASC";
  47. if (! $sortfield) $sortfield="name";
  48. $object = new PaymentVarious($db);
  49. $object->fetch($id, $ref);
  50. $upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id);
  51. $modulepart='banque';
  52. /*
  53. * Actions
  54. */
  55. include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
  56. /*
  57. * View
  58. */
  59. $form = new Form($db);
  60. llxHeader("",$langs->trans("VariousPayment"));
  61. if ($object->id)
  62. {
  63. $head=various_payment_prepare_head($object);
  64. dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), 0, 'payment');
  65. // Construit liste des fichiers
  66. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  67. $totalsize=0;
  68. foreach($filearray as $key => $file)
  69. {
  70. $totalsize+=$file['size'];
  71. }
  72. print '<table class="border" width="100%">';
  73. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  74. // Ref
  75. print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
  76. print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
  77. print '</td></tr>';
  78. // Societe
  79. //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
  80. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  81. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  82. print '</table>';
  83. print '</div>';
  84. $modulepart = 'banque';
  85. $permission = $user->rights->banque->modifier;
  86. $param = '&id=' . $object->id;
  87. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  88. }
  89. else
  90. {
  91. print $langs->trans("ErrorUnknown");
  92. }
  93. llxFooter();
  94. $db->close();