dolibarr  9.0.0
vat.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
3  * Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
32 function vat_prepare_head($object)
33 {
34  global $db, $langs, $conf;
35 
36  $tab = 0;
37  $head = array();
38 
39  $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
40  $head[$tab][1] = $langs->trans('Card');
41  $head[$tab][2] = 'card';
42  $tab++;
43 
44  // Show more tabs from modules
45  // Entries must be declared in modules descriptor with line
46  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47  // $this->tabs = array('entity:-tabname); to remove a tab
48  complete_head_from_modules($conf, $langs, $object, $head, $tab,'vat');
49 
50  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
51  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
52  $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
53  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
54  $nbLinks=Link::count($db, $object->element, $object->id);
55  $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id;
56  $head[$tab][1] = $langs->trans("Documents");
57  if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
58  $head[$tab][2] = 'documents';
59  $tab++;
60 
61  $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/info.php?id='.$object->id;
62  $head[$tab][1] = $langs->trans("Info");
63  $head[$tab][2] = 'info';
64  $tab++;
65 
66  complete_head_from_modules($conf,$langs,$object,$head,$tab,'vat','remove');
67 
68  return $head;
69 }
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:59
vat_prepare_head($object)
Prepare array with list of tabs.
Definition: vat.lib.php:32