dolibarr/htdocs/core/lib/holiday.lib.php

115 lines
4.1 KiB
PHP
Raw Permalink Normal View History

2012-12-01 14:50:39 +00:00
<?php
2022-11-30 17:20:29 +00:00
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
2012-12-01 14:50:39 +00:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2012-12-01 14:50:39 +00:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
2012-12-01 14:50:39 +00:00
*/
/**
* \file htdocs/core/lib/holiday.lib.php
2022-11-30 17:20:29 +00:00
* \brief base functions for holiday
2012-12-01 14:50:39 +00:00
*/
/**
* Return array head with list of tabs to view object information
2012-12-01 14:50:39 +00:00
*
2025-11-04 17:45:58 +00:00
* @param Holiday $object Holiday
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
2012-12-01 14:50:39 +00:00
*/
function holiday_prepare_head($object)
{
global $db, $langs, $conf, $user;
2012-12-01 14:50:39 +00:00
$h = 0;
$head = array();
add dolBuildUrl with examples of use (#35549) * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * wip * wip * add more example * add more example * add more example * add more example * add more example * add more example * add more example * add example * add example * add example * add example * add example * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * clean code * clean code * clean code * clean code * clean code * clean code * clean code * add example * add example * add example * add example * add example * add example add example add example add example add example * add example * add example add example add example add example * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * fix * wip * wip * clean code
2025-10-06 16:17:02 +00:00
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/card.php', ['id' => $object->id]);
$head[$h][1] = $langs->trans("Leave");
$head[$h][2] = 'card';
$h++;
// Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->holiday->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'holiday');
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
add dolBuildUrl with examples of use (#35549) * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * wip * wip * add more example * add more example * add more example * add more example * add more example * add more example * add more example * add example * add example * add example * add example * add example * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * clean code * clean code * clean code * clean code * clean code * clean code * clean code * add example * add example * add example * add example * add example * add example add example add example add example add example * add example * add example add example add example add example * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * fix * wip * wip * clean code
2025-10-06 16:17:02 +00:00
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/document.php', ['id' => $object->id]);
$head[$h][1] = $langs->trans('Documents');
2021-02-23 21:03:23 +00:00
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
}
$head[$h][2] = 'documents';
$h++;
2022-11-30 17:20:29 +00:00
complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'add', 'core');
add dolBuildUrl with examples of use (#35549) * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * wip * wip * add more example * add more example * add more example * add more example * add more example * add more example * add more example * add example * add example * add example * add example * add example * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * clean code * clean code * clean code * clean code * clean code * clean code * clean code * add example * add example * add example * add example * add example * add example add example add example add example add example * add example * add example add example add example add example * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * fix * wip * wip * clean code
2025-10-06 16:17:02 +00:00
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/info.php', ['id' => $object->id]);
2021-02-04 11:15:31 +00:00
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
2022-11-30 17:20:29 +00:00
complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'add', 'external');
2012-12-01 14:50:39 +00:00
complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'remove');
2012-12-01 14:50:39 +00:00
return $head;
}
/**
* Return array head with list of tabs to view object information
*
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
*/
function holiday_admin_prepare_head()
{
global $db, $langs, $conf, $extrafields;
2022-11-30 17:20:29 +00:00
$extrafields->fetch_name_optionals_label('holiday');
$h = 0;
$head = array();
add dolBuildUrl with examples of use (#35549) * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * wip * wip * add more example * add more example * add more example * add more example * add more example * add more example * add more example * add example * add example * add example * add example * add example * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * clean code * clean code * clean code * clean code * clean code * clean code * clean code * add example * add example * add example * add example * add example * add example add example add example add example add example * add example * add example add example add example add example * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * fix * wip * wip * clean code
2025-10-06 16:17:02 +00:00
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/holiday.php');
$head[$h][1] = $langs->trans("Setup");
$head[$h][2] = 'holiday';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'holiday'));
$head[$h][1] = $langs->trans("ExtraFields");
2022-11-30 17:20:29 +00:00
$nbExtrafields = $extrafields->attributes['holiday']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes';
$h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin', 'remove');
return $head;
}