dolibarr 18.0.6
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
32{
33 global $db, $langs, $conf;
34
35 $h = 0;
36 $head = array();
37
38 $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id;
39 $head[$h][1] = $langs->trans("ExpenseReport");
40 $head[$h][2] = 'card';
41 $h++;
42
43 // Show more tabs from modules
44 // Entries must be declared in modules descriptor with line
45 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
46 // $this->tabs = array('entity:-tabname); to remove a tab
47 complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'core');
48
49 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
50 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
51 $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref);
52 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
53 $nbLinks = Link::count($db, $object->element, $object->id);
54 $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
55 $head[$h][1] = $langs->trans('Documents');
56 if (($nbFiles + $nbLinks) > 0) {
57 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
58 }
59 $head[$h][2] = 'documents';
60 $h++;
61
62 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
63 $nbNote = 0;
64 if (!empty($object->note_private)) {
65 $nbNote++;
66 }
67 if (!empty($object->note_public)) {
68 $nbNote++;
69 }
70 $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
71 $head[$h][1] = $langs->trans('Notes');
72 if ($nbNote > 0) {
73 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
74 }
75 $head[$h][2] = 'note';
76 $h++;
77 }
78
79 $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id;
80 $head[$h][1] = $langs->trans("Info");
81 $head[$h][2] = 'info';
82 $h++;
83
84 complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'external');
85
86 complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
87
88 return $head;
89}
90
99{
100 global $langs, $conf;
101
102 $h = 0;
103 $head = array();
104
105 $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
106 $head[$h][1] = $langs->trans("ExpenseReportPayment");
107 $head[$h][2] = 'payment';
108 $h++;
109
110 // Show more tabs from modules
111 // Entries must be declared in modules descriptor with line
112 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
113 // $this->tabs = array('entity:-tabname); to remove a tab
114 complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport');
115
116 $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
117 $head[$h][1] = $langs->trans("Info");
118 $head[$h][2] = 'info';
119 $h++;
120
121 complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove');
122
123 return $head;
124}
125
132{
133 global $langs, $conf, $user, $db;
134
135 $h = 0;
136 $head = array();
137
138 $extrafields = new ExtraFields($db);
139 $extrafields->fetch_name_optionals_label('expensereport');
140
141 $h = 0;
142
143 $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
144 $head[$h][1] = $langs->trans("ExpenseReports");
145 $head[$h][2] = 'expensereport';
146 $h++;
147
148 $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
149 $head[$h][1] = $langs->trans("ExpenseReportsRules");
150 $head[$h][2] = 'expenserules';
151 $h++;
152
153 if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
154 $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
155 $head[$h][1] = $langs->trans("ExpenseReportsIk");
156 $head[$h][2] = 'expenseik';
157 $h++;
158 }
159
160 // Show more tabs from modules
161 // Entries must be declared in modules descriptor with line
162 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
163 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
164 complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin');
165
166 $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
167 $head[$h][1] = $langs->trans("ExtraFields");
168 $nbExtrafields = $extrafields->attributes['expensereport']['count'];
169 if ($nbExtrafields > 0) {
170 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
171 }
172 $head[$h][2] = 'attributes';
173 $h++;
174
175 /*
176 $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
177 $head[$h][1] = $langs->trans("ExtraFieldsLines");
178 $head[$h][2] = 'attributesdet';
179 $h++;
180 */
181
182 complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove');
183
184 return $head;
185}
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 informations.
dol_dir_list($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:62
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).