dolibarr 21.0.0-alpha
expensereport.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2022 Frédéric France <frederic.france@netlogic.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;
35
36 $h = 0;
37 $head = array();
38
39 $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id;
40 $head[$h][1] = $langs->trans("ExpenseReport");
41 $head[$h][2] = 'card';
42 $h++;
43
44 // Show more tabs from modules
45 // Entries must be declared in modules descriptor with line
46 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47 // $this->tabs = array('entity:-tabname); to remove a tab
48 complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'core');
49
50 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
52 $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref);
53 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
54 $nbLinks = Link::count($db, $object->element, $object->id);
55 $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
56 $head[$h][1] = $langs->trans('Documents');
57 if (($nbFiles + $nbLinks) > 0) {
58 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
59 }
60 $head[$h][2] = 'documents';
61 $h++;
62
63 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
64 $nbNote = 0;
65 if (!empty($object->note_private)) {
66 $nbNote++;
67 }
68 if (!empty($object->note_public)) {
69 $nbNote++;
70 }
71 $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
72 $head[$h][1] = $langs->trans('Notes');
73 if ($nbNote > 0) {
74 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
75 }
76 $head[$h][2] = 'note';
77 $h++;
78 }
79
80 $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id;
81 $head[$h][1] = $langs->trans("Info");
82 $head[$h][2] = 'info';
83 $h++;
84
85 complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'external');
86
87 complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
88
89 return $head;
90}
91
100{
101 global $langs, $conf;
102
103 $h = 0;
104 $head = array();
105
106 $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
107 $head[$h][1] = $langs->trans("ExpenseReportPayment");
108 $head[$h][2] = 'payment';
109 $h++;
110
111 // Show more tabs from modules
112 // Entries must be declared in modules descriptor with line
113 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
114 // $this->tabs = array('entity:-tabname); to remove a tab
115 complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport');
116
117 $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
118 $head[$h][1] = $langs->trans("Info");
119 $head[$h][2] = 'info';
120 $h++;
121
122 complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove');
123
124 return $head;
125}
126
133{
134 global $langs, $conf, $user, $db;
135
136 $extrafields = new ExtraFields($db);
137 $extrafields->fetch_name_optionals_label('expensereport');
138
139 $h = 0;
140 $head = array();
141
142 $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
143 $head[$h][1] = $langs->trans("ExpenseReports");
144 $head[$h][2] = 'expensereport';
145 $h++;
146
147 $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
148 $head[$h][1] = $langs->trans("ExpenseReportsRules");
149 $head[$h][2] = 'expenserules';
150 $h++;
151
152 if (getDolGlobalString('MAIN_USE_EXPENSE_IK')) {
153 $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
154 $head[$h][1] = $langs->trans("ExpenseReportsIk");
155 $head[$h][2] = 'expenseik';
156 $h++;
157 }
158
159 // Show more tabs from modules
160 // Entries must be declared in modules descriptor with line
161 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
162 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
163 complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin');
164
165 $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
166 $head[$h][1] = $langs->trans("ExtraFields");
167 $nbExtrafields = $extrafields->attributes['expensereport']['count'];
168 if ($nbExtrafields > 0) {
169 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
170 }
171 $head[$h][2] = 'attributes';
172 $h++;
173
174 /*
175 $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
176 $head[$h][1] = $langs->trans("ExtraFieldsLines");
177 $head[$h][2] = 'attributesdet';
178 $h++;
179 */
180
181 complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove');
182
183 return $head;
184}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage standard extra fields.
Class to manage payments of expense report.
expensereport_prepare_head($object)
Prepare array with list of tabs.
payment_expensereport_prepare_head(PaymentExpenseReport $object)
Returns an array with the tabs for the "Expense report payment" section It loads tabs from modules lo...
expensereport_admin_prepare_head()
Return array head with list of tabs to view object information.
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:63
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.