dolibarr  16.0.5
expensereport.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  * or see https://www.gnu.org/
17  */
18 
30 function expensereport_prepare_head($object)
31 {
32  global $db, $langs, $conf;
33 
34  $h = 0;
35  $head = array();
36 
37  $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id;
38  $head[$h][1] = $langs->trans("ExpenseReport");
39  $head[$h][2] = 'card';
40  $h++;
41 
42  // Show more tabs from modules
43  // Entries must be declared in modules descriptor with line
44  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
45  // $this->tabs = array('entity:-tabname); to remove a tab
46  complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport');
47 
48  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
49  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
50  $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref);
51  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
52  $nbLinks = Link::count($db, $object->element, $object->id);
53  $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54  $head[$h][1] = $langs->trans('Documents');
55  if (($nbFiles + $nbLinks) > 0) {
56  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
57  }
58  $head[$h][2] = 'documents';
59  $h++;
60 
61  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
62  $nbNote = 0;
63  if (!empty($object->note_private)) {
64  $nbNote++;
65  }
66  if (!empty($object->note_public)) {
67  $nbNote++;
68  }
69  $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
70  $head[$h][1] = $langs->trans('Notes');
71  if ($nbNote > 0) {
72  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
73  }
74  $head[$h][2] = 'note';
75  $h++;
76  }
77 
78  $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id;
79  $head[$h][1] = $langs->trans("Info");
80  $head[$h][2] = 'info';
81  $h++;
82 
83  complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
84 
85  return $head;
86 }
87 
96 {
97 
98  global $langs, $conf;
99 
100  $h = 0;
101  $head = array();
102 
103  $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
104  $head[$h][1] = $langs->trans("ExpenseReportPayment");
105  $head[$h][2] = 'payment';
106  $h++;
107 
108  // Show more tabs from modules
109  // Entries must be declared in modules descriptor with line
110  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
111  // $this->tabs = array('entity:-tabname); to remove a tab
112  complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport');
113 
114  $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
115  $head[$h][1] = $langs->trans("Info");
116  $head[$h][2] = 'info';
117  $h++;
118 
119  complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove');
120 
121  return $head;
122 }
123 
130 {
131  global $langs, $conf, $user;
132 
133  $h = 0;
134  $head = array();
135 
136  $h = 0;
137 
138  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
139  $head[$h][1] = $langs->trans("ExpenseReports");
140  $head[$h][2] = 'expensereport';
141  $h++;
142 
143  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
144  $head[$h][1] = $langs->trans("ExpenseReportsRules");
145  $head[$h][2] = 'expenserules';
146  $h++;
147 
148  if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
149  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
150  $head[$h][1] = $langs->trans("ExpenseReportsIk");
151  $head[$h][2] = 'expenseik';
152  $h++;
153  }
154 
155  // Show more tabs from modules
156  // Entries must be declared in modules descriptor with line
157  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
158  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
159  complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin');
160 
161  $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
162  $head[$h][1] = $langs->trans("ExtraFields");
163  $head[$h][2] = 'attributes';
164  $h++;
165 
166  /*
167  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
168  $head[$h][1] = $langs->trans("ExtraFieldsLines");
169  $head[$h][2] = 'attributesdet';
170  $h++;
171  */
172 
173  complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove');
174 
175  return $head;
176 }
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
expensereport_prepare_head
expensereport_prepare_head($object)
Prepare array with list of tabs.
Definition: expensereport.lib.php:30
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9038
payment_expensereport_prepare_head
payment_expensereport_prepare_head(PaymentExpenseReport $object)
Returns an array with the tabs for the "Expense report payment" section It loads tabs from modules lo...
Definition: expensereport.lib.php:95
expensereport_admin_prepare_head
expensereport_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: expensereport.lib.php:129
PaymentExpenseReport
Class to manage payments of expense report.
Definition: paymentexpensereport.class.php:31