1<?php
2/**
3 * Copyright (C) 2015	Charlie BENKE       <charlie@patas-monkey.com>
4 * Copyright (C) 2019	Alexandre Spangaro  <aspangaro@open-dsi.fr>
5 * Copyright (C) 2021		Gauthier VERDOL         <gauthier.verdol@atm-consulting.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
22/**
23 * Returns an array with the tabs for the "salaries" section
24 * It loads tabs from modules looking for the entity salaries
25 *
26 * @param Paiement $object Current salaries object
27 * @return array Tabs for the salaries section
28 */
29function salaries_prepare_head($object)
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("Salary");
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) {
55		$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
56	}
57	$head[$h][2] = 'documents';
58	$h++;
59
60	$head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
61	$head[$h][1] = $langs->trans("Info");
62	$head[$h][2] = 'info';
63	$h++;
64
65	complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
66
67	return $head;
68}
69
70/**
71 *  Return array head with list of tabs to view object informations
72 *
73 *  @return	array		head
74 */
75function salaries_admin_prepare_head()
76{
77	global $langs, $conf, $user;
78
79	$h = 0;
80	$head = array();
81
82	$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
83	$head[$h][1] = $langs->trans("Miscellaneous");
84	$head[$h][2] = 'general';
85	$h++;
86
87	// Show more tabs from modules
88	// Entries must be declared in modules descriptor with line
89	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
90	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
91	complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
92
93	$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
94	$head[$h][1] = $langs->trans("ExtraFieldsSalaries");
95	$head[$h][2] = 'attributes';
96	$h++;
97
98	complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
99
100	return $head;
101}
102