document.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
  7. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  9. * Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/compta/tva/document.php
  26. * \ingroup tax
  27. * \brief Page with attached files on social contributions
  28. */
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  35. if (!empty($conf->projet->enabled)) {
  36. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  38. }
  39. // Load translation files required by the page
  40. $langs->loadLangs(array('other', 'companies', 'compta', 'bills'));
  41. $id = GETPOST('id', 'int');
  42. $action = GETPOST('action', 'aZ09');
  43. $confirm = GETPOST('confirm', 'alpha');
  44. // Get parameters
  45. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  46. $sortfield = GETPOST('sortfield', 'aZ09comma');
  47. $sortorder = GETPOST('sortorder', 'aZ09comma');
  48. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  49. if (empty($page) || $page == -1) {
  50. $page = 0;
  51. }
  52. $offset = $limit * $page;
  53. $pageprev = $page - 1;
  54. $pagenext = $page + 1;
  55. if (!$sortorder) {
  56. $sortorder = "ASC";
  57. }
  58. if (!$sortfield) {
  59. $sortfield = "name";
  60. }
  61. $object = new Tva($db);
  62. if ($id > 0) {
  63. $object->fetch($id);
  64. }
  65. $upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref);
  66. $modulepart = 'tax-vat';
  67. // Security check
  68. if ($user->socid) {
  69. $socid = $user->socid;
  70. }
  71. $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
  72. $permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php
  73. /*
  74. * Actions
  75. */
  76. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  77. if ($action == 'setlib' && $permissiontoadd) {
  78. $object->fetch($id);
  79. $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY');
  80. if ($result < 0) {
  81. setEventMessages($object->error, $object->errors, 'errors');
  82. }
  83. }
  84. /*
  85. * View
  86. */
  87. $form = new Form($db);
  88. if (!empty($conf->projet->enabled)) {
  89. $formproject = new FormProjets($db);
  90. }
  91. $title = $langs->trans("VATPayment").' - '.$langs->trans("Documents");
  92. $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
  93. llxHeader("", $title, $help_url);
  94. if ($object->id) {
  95. $alreadypayed = $object->getSommePaiement();
  96. $head = vat_prepare_head($object);
  97. print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment');
  98. $morehtmlref = '<div class="refidno">';
  99. // Label of social contribution
  100. $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
  101. $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
  102. $morehtmlref .= '</div>';
  103. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  104. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  105. $morehtmlright = '';
  106. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
  107. print '<div class="fichecenter">';
  108. print '<div class="underbanner clearboth"></div>';
  109. // Build file list
  110. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  111. $totalsize = 0;
  112. foreach ($filearray as $key => $file) {
  113. $totalsize += $file['size'];
  114. }
  115. print '<table class="border tableforfield centpercent">';
  116. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  117. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  118. print '</table>';
  119. print '</div>';
  120. print '<div class="clearboth"></div>';
  121. print dol_get_fiche_end();
  122. $permissiontoadd = $user->rights->tax->charges->creer;
  123. $permtoedit = $user->rights->tax->charges->creer;
  124. $param = '&id='.$object->id;
  125. include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  126. } else {
  127. print $langs->trans("ErrorUnknown");
  128. }
  129. llxFooter();
  130. $db->close();