dolibarr 23.0.3
holiday.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2022-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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 * or see https://www.gnu.org/
19 */
20
33{
34 global $db, $langs, $conf, $user;
35
36 $h = 0;
37 $head = array();
38
39 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/card.php', ['id' => $object->id]);
40 $head[$h][1] = $langs->trans("Leave");
41 $head[$h][2] = 'card';
42 $h++;
43
44 // Attachments
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
47 $upload_dir = $conf->holiday->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'holiday');
48 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
49 $nbLinks = Link::count($db, $object->element, $object->id);
50 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/document.php', ['id' => $object->id]);
51 $head[$h][1] = $langs->trans('Documents');
52 if (($nbFiles + $nbLinks) > 0) {
53 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
54 }
55 $head[$h][2] = 'documents';
56 $h++;
57
58 complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'add', 'core');
59
60 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/info.php', ['id' => $object->id]);
61 $head[$h][1] = $langs->trans("Info");
62 $head[$h][2] = 'info';
63 $h++;
64
65 // Show more tabs from modules
66 // Entries must be declared in modules descriptor with line
67 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
68 // $this->tabs = array('entity:-tabname); to remove a tab
69 complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'add', 'external');
70
71 complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'remove');
72
73 return $head;
74}
75
76
83{
84 global $db, $langs, $conf, $user;
85
86 $extrafields = new ExtraFields($db);
87 $extrafields->fetch_name_optionals_label('holiday');
88
89 $h = 0;
90 $head = array();
91
92 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/holiday.php');
93 $head[$h][1] = $langs->trans("Setup");
94 $head[$h][2] = 'holiday';
95 $h++;
96
97 // Show more tabs from modules
98 // Entries must be declared in modules descriptor with line
99 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
100 // $this->tabs = array('entity:-tabname); to remove a tab
101 complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin');
102
103 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/holiday_extrafields.php');
104 $head[$h][1] = $langs->trans("ExtraFields");
105 $nbExtrafields = $extrafields->attributes['holiday']['count'];
106 if ($nbExtrafields > 0) {
107 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
108 }
109 $head[$h][2] = 'attributes';
110 $h++;
111
112 complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin', 'remove');
113
114 return $head;
115}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage standard extra fields.
dol_dir_list($utf8_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:64
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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).
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
holiday_prepare_head($object)
Return array head with list of tabs to view object information.
holiday_admin_prepare_head()
Return array head with list of tabs to view object information.