2015-02-15 21:49:23 +00:00
|
|
|
<?php
|
2025-01-06 17:20:18 +00:00
|
|
|
/* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
|
2026-06-13 23:09:51 +00:00
|
|
|
* Copyright (C) 2022-2026 Frédéric France <frederic.france@free.fr>
|
2025-01-06 17:20:18 +00:00
|
|
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
2015-02-15 21:49:23 +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
|
|
|
|
|
* (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/
|
2015-02-15 21:49:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file htdocs/core/lib/expensereport.lib.php
|
|
|
|
|
* \brief Functions for module expensereport
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare array with list of tabs
|
|
|
|
|
*
|
|
|
|
|
* @param Object $object Object related to tabs
|
2024-09-22 22:37:30 +00:00
|
|
|
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
|
2015-02-15 21:49:23 +00:00
|
|
|
*/
|
|
|
|
|
function expensereport_prepare_head($object)
|
|
|
|
|
{
|
2016-01-23 16:19:34 +00:00
|
|
|
global $db, $langs, $conf;
|
2015-02-15 21:49:23 +00:00
|
|
|
|
|
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
|
|
|
|
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/expensereport/card.php', ['id' => $object->id]);
|
2020-05-17 11:34:16 +00:00
|
|
|
$head[$h][1] = $langs->trans("ExpenseReport");
|
2015-02-15 21:49:23 +00:00
|
|
|
$head[$h][2] = 'card';
|
|
|
|
|
$h++;
|
|
|
|
|
|
|
|
|
|
// Show more tabs from modules
|
|
|
|
|
// Entries must be declared in modules descriptor with line
|
2020-10-31 13:32:18 +00:00
|
|
|
// $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-09-22 12:06:50 +00:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'core');
|
2015-02-15 21:49:23 +00:00
|
|
|
|
2015-05-01 06:46:37 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
2020-10-31 13:32:18 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
2020-04-10 08:59:32 +00:00
|
|
|
$upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref);
|
2019-01-27 10:55:16 +00:00
|
|
|
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
2020-10-31 13:32:18 +00:00
|
|
|
$nbLinks = Link::count($db, $object->element, $object->id);
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/expensereport/document.php', ['id' => $object->id]);
|
2015-05-01 06:46:37 +00:00
|
|
|
$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>';
|
|
|
|
|
}
|
2015-02-15 21:49:23 +00:00
|
|
|
$head[$h][2] = 'documents';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2023-11-27 10:39:32 +00:00
|
|
|
if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
|
2020-10-31 13:32:18 +00:00
|
|
|
$nbNote = 0;
|
2021-02-23 21:03:23 +00:00
|
|
|
if (!empty($object->note_private)) {
|
|
|
|
|
$nbNote++;
|
|
|
|
|
}
|
|
|
|
|
if (!empty($object->note_public)) {
|
|
|
|
|
$nbNote++;
|
|
|
|
|
}
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/expensereport/note.php', ['id' => $object->id]);
|
2020-10-31 13:32:18 +00:00
|
|
|
$head[$h][1] = $langs->trans('Notes');
|
2021-02-23 21:03:23 +00:00
|
|
|
if ($nbNote > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
|
|
|
|
}
|
2020-10-31 13:32:18 +00:00
|
|
|
$head[$h][2] = 'note';
|
|
|
|
|
$h++;
|
2016-11-30 19:24:36 +00:00
|
|
|
}
|
2018-08-15 16:14:02 +00:00
|
|
|
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/expensereport/info.php', ['id' => $object->id]);
|
2015-02-15 21:49:23 +00:00
|
|
|
$head[$h][1] = $langs->trans("Info");
|
|
|
|
|
$head[$h][2] = 'info';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2024-03-01 17:49:37 +00:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'external');
|
2022-09-22 12:06:50 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
|
2015-02-15 21:49:23 +00:00
|
|
|
|
|
|
|
|
return $head;
|
|
|
|
|
}
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2017-05-27 06:18:53 +00:00
|
|
|
/**
|
|
|
|
|
* Returns an array with the tabs for the "Expense report payment" section
|
|
|
|
|
* It loads tabs from modules looking for the entity payment
|
2018-08-15 16:14:02 +00:00
|
|
|
*
|
2023-05-02 02:11:05 +00:00
|
|
|
* @param PaymentExpenseReport $object Current payment object
|
2024-10-13 23:59:44 +00:00
|
|
|
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
|
2017-05-27 06:18:53 +00:00
|
|
|
*/
|
2018-08-15 16:14:02 +00:00
|
|
|
function payment_expensereport_prepare_head(PaymentExpenseReport $object)
|
|
|
|
|
{
|
2017-05-27 06:18:53 +00:00
|
|
|
global $langs, $conf;
|
|
|
|
|
|
|
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/expensereport/payment/card.php', ['id' => $object->id]);
|
2020-10-02 10:54:56 +00:00
|
|
|
$head[$h][1] = $langs->trans("ExpenseReportPayment");
|
2017-05-27 06:18:53 +00:00
|
|
|
$head[$h][2] = 'payment';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
// 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, $object, $head, $h, 'payment_expensereport');
|
2017-05-27 06:18:53 +00:00
|
|
|
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/expensereport/payment/info.php', ['id' => $object->id]);
|
2017-05-27 06:18:53 +00:00
|
|
|
$head[$h][1] = $langs->trans("Info");
|
|
|
|
|
$head[$h][2] = 'info';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove');
|
2017-05-27 06:18:53 +00:00
|
|
|
|
|
|
|
|
return $head;
|
|
|
|
|
}
|
2015-02-22 12:16:49 +00:00
|
|
|
|
|
|
|
|
/**
|
2024-01-13 18:48:20 +00:00
|
|
|
* Return array head with list of tabs to view object information.
|
2015-02-22 12:16:49 +00:00
|
|
|
*
|
2024-10-13 23:59:44 +00:00
|
|
|
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
|
2015-02-22 12:16:49 +00:00
|
|
|
*/
|
|
|
|
|
function expensereport_admin_prepare_head()
|
|
|
|
|
{
|
2026-06-13 23:09:51 +00:00
|
|
|
global $langs, $conf, $user, $extrafields;
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2022-11-30 17:26:26 +00:00
|
|
|
$extrafields->fetch_name_optionals_label('expensereport');
|
|
|
|
|
|
2015-02-22 12:16:49 +00:00
|
|
|
$h = 0;
|
2024-03-12 23:29:46 +00:00
|
|
|
$head = array();
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/expensereport.php");
|
2015-02-22 12:16:49 +00:00
|
|
|
$head[$h][1] = $langs->trans("ExpenseReports");
|
|
|
|
|
$head[$h][2] = 'expensereport';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/expensereport_rules.php");
|
2021-10-21 20:57:50 +00:00
|
|
|
$head[$h][1] = $langs->trans("ExpenseReportsRules");
|
|
|
|
|
$head[$h][2] = 'expenserules';
|
|
|
|
|
$h++;
|
2018-08-15 16:14:02 +00:00
|
|
|
|
2023-11-27 10:39:32 +00:00
|
|
|
if (getDolGlobalString('MAIN_USE_EXPENSE_IK')) {
|
2025-10-17 00:31:07 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/expensereport_ik.php");
|
2020-09-08 09:51:36 +00:00
|
|
|
$head[$h][1] = $langs->trans("ExpenseReportsIk");
|
|
|
|
|
$head[$h][2] = 'expenseik';
|
|
|
|
|
$h++;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:16:49 +00:00
|
|
|
// 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:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
2019-01-27 10:55:16 +00:00
|
|
|
complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin');
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2026-08-11 16:51:17 +00:00
|
|
|
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'expensereport'));
|
2015-02-22 12:16:49 +00:00
|
|
|
$head[$h][1] = $langs->trans("ExtraFields");
|
2022-11-30 17:26:26 +00:00
|
|
|
$nbExtrafields = $extrafields->attributes['expensereport']['count'];
|
|
|
|
|
if ($nbExtrafields > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
|
|
|
|
|
}
|
2020-10-31 13:32:18 +00:00
|
|
|
$head[$h][2] = 'attributes';
|
|
|
|
|
$h++;
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove');
|
2015-02-22 12:16:49 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
return $head;
|
2015-02-22 12:16:49 +00:00
|
|
|
}
|