Completed
Branch develop (4833c2)
by
unknown
24:33
created

salaries.lib.php ➔ salaries_admin_prepare_head()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 27
rs 9.488
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (C) 2015	Charlie BENKE       <[email protected]>
4
 * Copyright (C) 2019	Alexandre Spangaro  <[email protected]>
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 <http://www.gnu.org/licenses/>.
18
 * or see http://www.gnu.org/
19
 */
20
21
/**
22
 * Returns an array with the tabs for the "salaries" section
23
 * It loads tabs from modules looking for the entity salaries
24
 *
25
 * @param Paiement $object Current salaries object
26
 * @return array Tabs for the salaries section
27
 */
28
function salaries_prepare_head($object)
29
{
30
31
    global $db, $langs, $conf;
32
33
    $h = 0;
34
    $head = array();
35
36
    $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
37
    $head[$h][1] = $langs->trans("Card");
38
    $head[$h][2] = 'card';
39
    $h++;
40
41
    // Show more tabs from modules
42
    // Entries must be declared in modules descriptor with line
43
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
44
    // $this->tabs = array('entity:-tabname);   												to remove a tab
45
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
46
47
    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48
    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
49
    $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
50
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
51
    $nbLinks=Link::count($db, $object->element, $object->id);
52
    $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
53
    $head[$h][1] = $langs->trans('Documents');
54
    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
55
    $head[$h][2] = 'documents';
56
    $h++;
57
58
    $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
59
    $head[$h][1] = $langs->trans("Info");
60
    $head[$h][2] = 'info';
61
    $h++;
62
63
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
64
65
    return $head;
66
}
67
68
/**
69
 *  Return array head with list of tabs to view object informations
70
 *
71
 *  @return	array		head
72
 */
73
function salaries_admin_prepare_head()
74
{
75
    global $langs, $conf, $user;
76
77
    $h = 0;
78
    $head = array();
79
80
    $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
81
    $head[$h][1] = $langs->trans("Miscellaneous");
82
    $head[$h][2] = 'general';
83
    $h++;
84
85
    // Show more tabs from modules
86
    // Entries must be declared in modules descriptor with line
87
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
88
    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
89
    complete_head_from_modules($conf, $langs, '', $head, $h, 'salaries_admin');
90
91
    $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
92
    $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
93
    $head[$h][2] = 'attributes';
94
    $h++;
95
96
    complete_head_from_modules($conf, $langs, '', $head, $h, 'salaries_admin', 'remove');
97
98
    return $head;
99
}
100