document.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. // Load Dolibarr environment
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  36. if (isModEnabled('project')) {
  37. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  39. }
  40. // Load translation files required by the page
  41. $langs->loadLangs(array('other', 'companies', 'compta', 'bills'));
  42. $id = GETPOST('id', 'int');
  43. $action = GETPOST('action', 'aZ09');
  44. $confirm = GETPOST('confirm', 'alpha');
  45. // Get parameters
  46. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  47. $sortfield = GETPOST('sortfield', 'aZ09comma');
  48. $sortorder = GETPOST('sortorder', 'aZ09comma');
  49. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  50. if (empty($page) || $page == -1) {
  51. $page = 0;
  52. }
  53. $offset = $limit * $page;
  54. $pageprev = $page - 1;
  55. $pagenext = $page + 1;
  56. if (!$sortorder) {
  57. $sortorder = "ASC";
  58. }
  59. if (!$sortfield) {
  60. $sortfield = "name";
  61. }
  62. $object = new Tva($db);
  63. if ($id > 0) {
  64. $object->fetch($id);
  65. }
  66. $upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref);
  67. $modulepart = 'tax-vat';
  68. // Security check
  69. if ($user->socid) {
  70. $socid = $user->socid;
  71. }
  72. $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
  73. $permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php
  74. /*
  75. * Actions
  76. */
  77. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  78. if ($action == 'setlib' && $permissiontoadd) {
  79. $object->fetch($id);
  80. $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY');
  81. if ($result < 0) {
  82. setEventMessages($object->error, $object->errors, 'errors');
  83. }
  84. }
  85. /*
  86. * View
  87. */
  88. $form = new Form($db);
  89. if (isModEnabled('project')) {
  90. $formproject = new FormProjets($db);
  91. }
  92. $title = $langs->trans("VATPayment").' - '.$langs->trans("Documents");
  93. $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
  94. llxHeader("", $title, $help_url);
  95. if ($object->id) {
  96. $alreadypayed = $object->getSommePaiement();
  97. $head = vat_prepare_head($object);
  98. print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment');
  99. $morehtmlref = '<div class="refidno">';
  100. // Label of social contribution
  101. $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
  102. $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
  103. $morehtmlref .= '</div>';
  104. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  105. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  106. $morehtmlright = '';
  107. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
  108. print '<div class="fichecenter">';
  109. print '<div class="underbanner clearboth"></div>';
  110. // Build file list
  111. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  112. $totalsize = 0;
  113. foreach ($filearray as $key => $file) {
  114. $totalsize += $file['size'];
  115. }
  116. print '<table class="border tableforfield centpercent">';
  117. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  118. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  119. print '</table>';
  120. print '</div>';
  121. print '<div class="clearboth"></div>';
  122. print dol_get_fiche_end();
  123. $permissiontoadd = $user->rights->tax->charges->creer;
  124. $permtoedit = $user->rights->tax->charges->creer;
  125. $param = '&id='.$object->id;
  126. include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  127. } else {
  128. print $langs->trans("ErrorUnknown");
  129. }
  130. llxFooter();
  131. $db->close();