|
1
|
|
|
<?php |
|
2
|
|
|
/************************************************************************ |
|
3
|
|
|
* OVIDENTIA http://www.ovidentia.org * |
|
4
|
|
|
************************************************************************ |
|
5
|
|
|
* Copyright (c) 2003 by CANTICO ( http://www.cantico.fr ) * |
|
6
|
|
|
* * |
|
7
|
|
|
* This file is part of Ovidentia. * |
|
8
|
|
|
* * |
|
9
|
|
|
* Ovidentia is free software; you can redistribute it and/or modify * |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by * |
|
11
|
|
|
* the Free Software Foundation; either version 2, or (at your option) * |
|
12
|
|
|
* any later version. * |
|
13
|
|
|
* * |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, but * |
|
15
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
|
17
|
|
|
* See the GNU General Public License for more details. * |
|
18
|
|
|
* * |
|
19
|
|
|
* You should have received a copy of the GNU General Public License * |
|
20
|
|
|
* along with this program; if not, write to the Free Software * |
|
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,* |
|
22
|
|
|
* USA. * |
|
23
|
|
|
************************************************************************/ |
|
24
|
|
|
|
|
25
|
|
|
include_once $babInstallPath."utilit/afincl.php"; |
|
26
|
|
|
include_once dirname(__FILE__).'/utilit/vacincl.php'; |
|
27
|
|
|
include_once dirname(__FILE__).'/functions.php'; |
|
28
|
|
|
include_once dirname(__FILE__).'/utilit/agent.class.php'; |
|
29
|
|
|
include_once dirname(__FILE__).'/utilit/request.class.php'; |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
function absences_waitingEmails() |
|
35
|
|
|
{ |
|
36
|
|
|
$W = bab_Widgets(); |
|
37
|
|
|
$page = $W->babPage(); |
|
38
|
|
|
|
|
39
|
|
|
$page->setTitle(absences_translate('Waiting requests by approvers')); |
|
40
|
|
|
|
|
41
|
|
|
$arr = absences_getRequestsApprovers(null); |
|
42
|
|
|
|
|
43
|
|
|
$tree = $W->SimpleTreeView(); |
|
44
|
|
|
$root = $tree->createRootNode('Emails', 'Root'); |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
$mailId = 0; |
|
47
|
|
|
foreach($arr as $email) { |
|
48
|
|
|
$mailId++; |
|
49
|
|
|
$element = $tree->createElement('email'.$mailId, 'email', 'Mail '.$mailId); |
|
50
|
|
|
$tree->appendElement($element, 'Root'); |
|
51
|
|
|
|
|
52
|
|
|
$approvers = $tree->createElement('approvers'.$mailId, 'approvers', absences_translate('Approvers')); |
|
53
|
|
|
$approvers->setIcon($GLOBALS['babInstallPath'] . 'skins/ovidentia/images/Puces/folder.gif'); |
|
54
|
|
|
$tree->appendElement($approvers, 'email'.$mailId); |
|
55
|
|
|
|
|
56
|
|
|
$requests = $tree->createElement('requests'.$mailId, 'requests', absences_translate('Requests')); |
|
57
|
|
|
$requests->setIcon($GLOBALS['babInstallPath'] . 'skins/ovidentia/images/Puces/folder.gif'); |
|
58
|
|
|
$tree->appendElement($requests, 'email'.$mailId); |
|
59
|
|
|
|
|
60
|
|
|
foreach($email['approvers'] as $id_user) { |
|
61
|
|
|
$user = $tree->createElement('user'.$id_user, 'user', bab_getUserName($id_user)); |
|
62
|
|
|
$tree->appendElement($user, 'approvers'.$mailId); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
foreach($email['requests'] as $request) { |
|
66
|
|
|
|
|
67
|
|
|
/*@var $request absences_Request */ |
|
68
|
|
|
|
|
69
|
|
|
$reqnode = $tree->createElement('request'.$request->id, 'request', $request->getUserName().' : '.$request->getTitle()); |
|
70
|
|
|
|
|
71
|
|
|
try { |
|
72
|
|
|
$tree->appendElement($reqnode, 'requests'.$mailId); |
|
73
|
|
|
} catch (ErrorException $e) { |
|
|
|
|
|
|
74
|
|
|
bab_debug($e->getMessage()); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$page->addItem($tree); |
|
80
|
|
|
$page->displayHtml(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
function absences_waitingRequestList() |
|
87
|
|
|
{ |
|
88
|
|
|
$W = bab_Widgets(); |
|
89
|
|
|
$page = $W->babPage(); |
|
90
|
|
|
|
|
91
|
|
|
$page->addStyleSheet(absences_Addon()->getStylePath().'vacation.css'); |
|
92
|
|
|
$page->setTitle(absences_translate('Waiting requests')); |
|
93
|
|
|
|
|
94
|
|
|
$f = new absences_getRequestSearchForm(); |
|
95
|
|
|
|
|
96
|
|
|
$I = new absences_RequestIterator(); |
|
97
|
|
|
$I->status = ''; |
|
98
|
|
|
|
|
99
|
|
|
|
|
100
|
|
|
if ($userid = $f->param('userid')) |
|
101
|
|
|
{ |
|
102
|
|
|
$I->users = array($userid); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
if ($organization = $f->param('organization')) |
|
106
|
|
|
{ |
|
107
|
|
|
$I->organization = array($organization); |
|
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
$datePicker = $W->DatePicker(); |
|
111
|
|
|
|
|
112
|
|
|
if ('0000-00-00' !== $begin = $datePicker->getISODate($f->param('dateb', null))) |
|
113
|
|
|
{ |
|
114
|
|
|
$I->startFrom = $begin; |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
if ('0000-00-00' !== $end = $datePicker->getISODate($f->param('datee', null))) |
|
118
|
|
|
{ |
|
119
|
|
|
$I->startTo = $end; |
|
|
|
|
|
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
|
|
123
|
|
|
|
|
124
|
|
|
$table = $W->BabTableView(); |
|
125
|
|
|
$table->addClass(Func_Icons::ICON_LEFT_16); |
|
126
|
|
|
|
|
127
|
|
|
$table->addItem($W->Label(absences_translate('Request type')) , 0, 0); |
|
128
|
|
|
$table->addItem($W->Label(absences_translate('Appliquant')) , 0, 1); |
|
129
|
|
|
$table->addItem($W->Label(absences_translate('Approver(s)')) , 0, 2); |
|
130
|
|
|
$table->addItem($W->Label(absences_translate('Approbation sheme')) , 0, 3); |
|
131
|
|
|
$table->addItem($W->Label(absences_translate('Last action date')) , 0, 4); |
|
132
|
|
|
$table->addItem($W->Label(absences_translate('Last action')) , 0, 5); |
|
133
|
|
|
$table->addItem($W->Label(absences_translate('Edit')) , 0, 6); |
|
134
|
|
|
$table->addItem($W->Label(absences_translate('Delete')) , 0, 7); |
|
135
|
|
|
|
|
136
|
|
|
$table->addHeadRow(0); |
|
137
|
|
|
|
|
138
|
|
|
$row = 1; |
|
139
|
|
|
foreach($I as $request) |
|
140
|
|
|
{ |
|
141
|
|
|
/* @var $request absences_Request */ |
|
142
|
|
|
|
|
143
|
|
|
$appliquant = absences_Agent::getFromIdUser($request->id_user); |
|
144
|
|
|
$approbation = $appliquant->getApprobation(); |
|
145
|
|
|
|
|
146
|
|
|
if ($movement = $request->getLastMovement()) |
|
147
|
|
|
{ |
|
148
|
|
|
$last_createdOn = $movement->createdOn; |
|
149
|
|
|
$last_message = $movement->message; |
|
150
|
|
|
} else { |
|
151
|
|
|
$last_createdOn = ''; |
|
152
|
|
|
$last_message = ''; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
|
|
156
|
|
|
$table->addItem($W->Label($request->getRequestType()) , $row, 0 ); |
|
157
|
|
|
$table->addItem($W->Label($appliquant->getName()) , $row, 1 ); |
|
158
|
|
|
$table->addItem($W->Label($request->getNextApprovers()) , $row, 2 ); |
|
159
|
|
|
$table->addItem($W->Label($approbation['name'].sprintf(' (%s)', $approbation['type'])) , $row, 3 ); |
|
160
|
|
|
$table->addItem($W->Label(bab_shortDate(bab_mktime($last_createdOn))) , $row, 4 ); |
|
161
|
|
|
$table->addItem($W->Label($last_message) , $row, 5 ); |
|
162
|
|
|
$table->addItem($W->Link($W->Icon('', Func_Icons::ACTIONS_DOCUMENT_EDIT), $request->getManagerEditUrl()) , $row, 6 ); |
|
163
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
$deleteLink = $W->Link($W->Icon('', Func_Icons::ACTIONS_EDIT_DELETE), $request->getManagerDeleteUrl()); |
|
166
|
|
|
|
|
167
|
|
|
if (!($request instanceof absences_Entry)) |
|
168
|
|
|
{ |
|
169
|
|
|
$deleteLink->setConfirmationMessage(absences_translate('Do you really want to delete?')); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
|
|
173
|
|
|
$table->addItem($deleteLink , $row, 7 ); |
|
174
|
|
|
|
|
175
|
|
|
if ($request->approbAlert()) |
|
176
|
|
|
{ |
|
177
|
|
|
$table->addRowClass($row, 'widget-strong'); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
$row++; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
|
|
186
|
|
|
$page->addItem($f->getForm()); |
|
187
|
|
|
$page->addItem($table); |
|
188
|
|
|
|
|
189
|
|
|
$page->displayHtml(); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
|
|
193
|
|
|
|
|
194
|
|
|
|
|
195
|
|
|
|
|
196
|
|
|
|
|
197
|
|
|
// main |
|
198
|
|
|
bab_requireCredential(); |
|
199
|
|
|
$agent = absences_Agent::getCurrentUser(); |
|
200
|
|
|
if( !$agent->isManager()) |
|
201
|
|
|
{ |
|
202
|
|
|
$babBody->msgerror = absences_translate("Access denied"); |
|
203
|
|
|
return; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
|
|
207
|
|
|
if ($agent->isInPersonnel()) |
|
208
|
|
|
{ |
|
209
|
|
|
$babBody->addItemMenu("vacuser", absences_translate("Vacations"), absences_addon()->getUrl()."vacuser"); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
$babBody->addItemMenu("menu", absences_translate("Management"), absences_addon()->getUrl()."vacadm&idx=menu"); |
|
213
|
|
|
|
|
214
|
|
|
|
|
215
|
|
|
$idx = bab_rp('idx', "list"); |
|
216
|
|
|
|
|
217
|
|
|
|
|
218
|
|
View Code Duplication |
switch($idx) |
|
|
|
|
|
|
219
|
|
|
{ |
|
220
|
|
|
case 'emails': |
|
221
|
|
|
$babBody->addItemMenu("emails", absences_translate("By approvers"), absences_addon()->getUrl()."waiting&idx=emails"); |
|
222
|
|
|
absences_waitingEmails(); |
|
223
|
|
|
break; |
|
224
|
|
|
|
|
225
|
|
|
|
|
226
|
|
|
default: |
|
227
|
|
|
case 'list': |
|
228
|
|
|
$babBody->addItemMenu("list", absences_translate("Waiting requests"), absences_addon()->getUrl()."waiting&idx=list"); |
|
229
|
|
|
absences_waitingRequestList(); |
|
230
|
|
|
break; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
$babBody->setCurrentItemMenu($idx); |
|
234
|
|
|
bab_siteMap::setPosition('absences','User'); |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.