dolibarr  7.0.0-beta
expensereport.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.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  global $langs, $conf;
91 
92  $h = 0;
93  $head = array();
94 
95  $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
96  $head[$h][1] = $langs->trans("Card");
97  $head[$h][2] = 'payment';
98  $h++;
99 
100  // Show more tabs from modules
101  // Entries must be declared in modules descriptor with line
102  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
103  // $this->tabs = array('entity:-tabname); to remove a tab
104  complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
105 
106  $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
107  $head[$h][1] = $langs->trans("Info");
108  $head[$h][2] = 'info';
109  $h++;
110 
111  complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
112 
113  return $head;
114 }
115 
122 {
123  global $langs, $conf, $user;
124 
125  $h = 0;
126  $head = array();
127 
128  $h = 0;
129 
130  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
131  $head[$h][1] = $langs->trans("ExpenseReports");
132  $head[$h][2] = 'expensereport';
133  $h++;
134 
135  if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
136  {
137  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
138  $head[$h][1] = $langs->trans("ExpenseReportsIk");
139  $head[$h][2] = 'expenseik';
140  $h++;
141  }
142 
143  if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
144  {
145  $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
146  $head[$h][1] = $langs->trans("ExpenseReportsRules");
147  $head[$h][2] = 'expenserules';
148  $h++;
149  }
150 
151  // Show more tabs from modules
152  // Entries must be declared in modules descriptor with line
153  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
154  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
155  complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
156 
157  $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
158  $head[$h][1] = $langs->trans("ExtraFields");
159  $head[$h][2] = 'attributes';
160  $h++;
161 
162  /*
163  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
164  $head[$h][1] = $langs->trans("ExtraFieldsLines");
165  $head[$h][2] = 'attributesdet';
166  $h++;
167  */
168 
169  complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
170 
171  return $head;
172 }
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.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
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.
Class to manage payments of expense report.