vat.lib.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. * Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
  4. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/core/lib/vat.lib.php
  21. * \ingroup tax
  22. * \brief Library for tax module (VAT)
  23. */
  24. /**
  25. * Prepare array with list of tabs
  26. *
  27. * @param Object $object Object related to tabs
  28. * @return array Array of tabs to show
  29. */
  30. function vat_prepare_head($object)
  31. {
  32. global $db, $langs, $conf;
  33. $tab = 0;
  34. $head = array();
  35. $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
  36. $head[$tab][1] = $langs->trans('VATDeclaration');
  37. $head[$tab][2] = 'card';
  38. $tab++;
  39. // Show more tabs from modules
  40. // Entries must be declared in modules descriptor with line
  41. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  42. // $this->tabs = array('entity:-tabname); to remove a tab
  43. complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat');
  44. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  45. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  46. $upload_dir = $conf->tax->dir_output."/vat/".dol_sanitizeFileName($object->ref);
  47. $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
  48. $nbLinks = Link::count($db, $object->element, $object->id);
  49. $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id;
  50. $head[$tab][1] = $langs->trans("Documents");
  51. if (($nbFiles + $nbLinks) > 0) {
  52. $head[$tab][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
  53. }
  54. $head[$tab][2] = 'documents';
  55. $tab++;
  56. $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/info.php?id='.$object->id;
  57. $head[$tab][1] = $langs->trans("Info");
  58. $head[$tab][2] = 'info';
  59. $tab++;
  60. complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat', 'remove');
  61. return $head;
  62. }