dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
16  * or see http://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("Card");
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) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
56  $head[$h][2] = 'documents';
57  $h++;
58 
59  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60  {
61  $nbNote = 0;
62  if(!empty($object->note_private)) $nbNote++;
63  if(!empty($object->note_public)) $nbNote++;
64  $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65  $head[$h][1] = $langs->trans('Notes');
66  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67  $head[$h][2] = 'note';
68  $h++;
69  }
70 
71  $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
72  $head[$h][1] = $langs->trans("Info");
73  $head[$h][2] = 'info';
74  $h++;
75 
76  complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
77 
78  return $head;
79 }
80 
89 {
90 
91  global $langs, $conf;
92 
93  $h = 0;
94  $head = array();
95 
96  $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
97  $head[$h][1] = $langs->trans("Card");
98  $head[$h][2] = 'payment';
99  $h++;
100 
101  // Show more tabs from modules
102  // Entries must be declared in modules descriptor with line
103  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
104  // $this->tabs = array('entity:-tabname); to remove a tab
105  complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
106 
107  $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
108  $head[$h][1] = $langs->trans("Info");
109  $head[$h][2] = 'info';
110  $h++;
111 
112  complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
113 
114  return $head;
115 }
116 
123 {
124  global $langs, $conf, $user;
125 
126  $h = 0;
127  $head = array();
128 
129  $h = 0;
130 
131  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
132  $head[$h][1] = $langs->trans("ExpenseReports");
133  $head[$h][2] = 'expensereport';
134  $h++;
135 
136  if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
137  {
138  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
139  $head[$h][1] = $langs->trans("ExpenseReportsIk");
140  $head[$h][2] = 'expenseik';
141  $h++;
142  }
143 
144  if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
145  {
146  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
147  $head[$h][1] = $langs->trans("ExpenseReportsRules");
148  $head[$h][2] = 'expenserules';
149  $h++;
150  }
151 
152  // Show more tabs from modules
153  // Entries must be declared in modules descriptor with line
154  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
155  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
156  complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
157 
158  $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
159  $head[$h][1] = $langs->trans("ExtraFields");
160  $head[$h][2] = 'attributes';
161  $h++;
162 
163  /*
164  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
165  $head[$h][1] = $langs->trans("ExtraFieldsLines");
166  $head[$h][2] = 'attributesdet';
167  $h++;
168  */
169 
170  complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
171 
172  return $head;
173 }
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
expensereport_admin_prepare_head()
Return array head with list of tabs to view object informations.
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_prepare_head($object)
Prepare array with list of tabs.
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:59
Class to manage payments of expense report.