dolibarr 19.0.3
vat.lib.php
Go to the documentation of this file.
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
33function vat_prepare_head($object)
34{
35 global $db, $langs, $conf;
36
37 $tab = 0;
38 $head = array();
39
40 $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
41 $head[$tab][1] = $langs->trans('VATDeclaration');
42 $head[$tab][2] = 'card';
43 $tab++;
44
45 // Show more tabs from modules
46 // Entries must be declared in modules descriptor with line
47 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
48 // $this->tabs = array('entity:-tabname); to remove a tab
49 complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat');
50
51 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
52 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
53 $upload_dir = $conf->tax->dir_output."/vat/".dol_sanitizeFileName($object->ref);
54 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
55 $nbLinks = Link::count($db, $object->element, $object->id);
56 $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id;
57 $head[$tab][1] = $langs->trans("Documents");
58 if (($nbFiles + $nbLinks) > 0) {
59 $head[$tab][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
60 }
61 $head[$tab][2] = 'documents';
62 $tab++;
63
64 $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/info.php?id='.$object->id;
65 $head[$tab][1] = $langs->trans("Info");
66 $head[$tab][2] = 'info';
67 $tab++;
68
69 complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat', 'remove');
70
71 return $head;
72}
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
vat_prepare_head($object)
Prepare array with list of tabs.
Definition vat.lib.php:33