document.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  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 bank
  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. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
  31. $id = GETPOST('id','int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $action = GETPOST('action','alpha');
  34. $confirm = GETPOST('confirm','alpha');
  35. // Security check
  36. $socid = GETPOST("socid","int");
  37. if ($user->societe_id) $socid=$user->societe_id;
  38. $result = restrictedArea($user, 'banque', '', '', '');
  39. // Get parameters
  40. $sortfield = GETPOST('sortfield','alpha');
  41. $sortorder = GETPOST('sortorder','alpha');
  42. $page = GETPOST('page','int');
  43. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  44. $offset = $conf->liste_limit * $page;
  45. $pageprev = $page - 1;
  46. $pagenext = $page + 1;
  47. if (! $sortorder) $sortorder="ASC";
  48. if (! $sortfield) $sortfield="name";
  49. $object = new PaymentVarious($db);
  50. $object->fetch($id, $ref);
  51. $upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id);
  52. $modulepart='banque';
  53. /*
  54. * Actions
  55. */
  56. include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
  57. /*
  58. * View
  59. */
  60. $form = new Form($db);
  61. $title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents");
  62. $help_url = '';
  63. llxHeader("",$title,$help_url);
  64. if ($object->id)
  65. {
  66. $head=various_payment_prepare_head($object);
  67. dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, 'payment');
  68. $morehtmlref='<div class="refidno">';
  69. // Project
  70. if (! empty($conf->projet->enabled))
  71. {
  72. $langs->load("projects");
  73. $morehtmlref.=$langs->trans('Project') . ' : ';
  74. if ($user->rights->banque->modifier && 0)
  75. {
  76. if ($action != 'classify')
  77. $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  78. if ($action == 'classify') {
  79. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  80. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  81. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  82. $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  83. $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  84. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  85. $morehtmlref.='</form>';
  86. } else {
  87. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  88. }
  89. } else {
  90. if (! empty($object->fk_project)) {
  91. $proj = new Project($db);
  92. $proj->fetch($object->fk_project);
  93. $morehtmlref.=$proj->getNomUrl(1);
  94. } else {
  95. $morehtmlref.='';
  96. }
  97. }
  98. }
  99. $morehtmlref.='</div>';
  100. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  101. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
  102. print '<div class="fichecenter">';
  103. print '<div class="underbanner clearboth"></div>';
  104. // Build file list
  105. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  106. $totalsize=0;
  107. foreach($filearray as $key => $file)
  108. {
  109. $totalsize+=$file['size'];
  110. }
  111. print '<table class="border" width="100%">';
  112. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  113. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  114. print '</table>';
  115. print '</div>';
  116. print '<div class="clearboth"></div>';
  117. dol_fiche_end();
  118. $modulepart = 'banque';
  119. $permission = $user->rights->banque->modifier;
  120. $param = '&id=' . $object->id;
  121. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  122. }
  123. else
  124. {
  125. print $langs->trans("ErrorUnknown");
  126. }
  127. // End of page
  128. llxFooter();
  129. $db->close();