|
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
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
class absences_RightList extends absences_Paginate |
|
29
|
|
|
{ |
|
30
|
|
|
public $typetxt; |
|
31
|
|
|
public $desctxt; |
|
32
|
|
|
public $quantitytxt; |
|
33
|
|
|
public $creditortxt; |
|
34
|
|
|
public $datetxt; |
|
35
|
|
|
public $date2txt; |
|
36
|
|
|
public $vrurl; |
|
37
|
|
|
public $vrviewurl; |
|
38
|
|
|
public $description; |
|
39
|
|
|
|
|
40
|
|
|
public $typename; |
|
41
|
|
|
public $quantity; |
|
42
|
|
|
public $creditor; |
|
43
|
|
|
public $date; |
|
44
|
|
|
public $addtxt; |
|
45
|
|
|
public $addurl; |
|
46
|
|
|
public $filteron; |
|
47
|
|
|
public $statustxt; |
|
48
|
|
|
public $activeyes; |
|
49
|
|
|
public $activeno; |
|
50
|
|
|
public $yselected; |
|
51
|
|
|
public $nselected; |
|
52
|
|
|
|
|
53
|
|
|
public $urllistp; |
|
54
|
|
|
public $altlistp; |
|
55
|
|
|
public $selected; |
|
56
|
|
|
|
|
57
|
|
|
public $begintxt; |
|
58
|
|
|
public $endtxt; |
|
59
|
|
|
|
|
60
|
|
|
public $arr = array(); |
|
61
|
|
|
public $count; |
|
62
|
|
|
public $res; |
|
63
|
|
|
public $topurl; |
|
64
|
|
|
public $bottomurl; |
|
65
|
|
|
public $nexturl; |
|
66
|
|
|
public $prevurl; |
|
67
|
|
|
public $topname; |
|
68
|
|
|
public $bottomname; |
|
69
|
|
|
public $nextname; |
|
70
|
|
|
public $prevname; |
|
71
|
|
|
public $pos; |
|
72
|
|
|
public $bclose; |
|
73
|
|
|
public $closedtxt; |
|
74
|
|
|
public $openedtxt; |
|
75
|
|
|
public $statusval; |
|
76
|
|
|
public $alttxt; |
|
77
|
|
|
public $altbg = true; |
|
78
|
|
|
|
|
79
|
|
|
public function __construct($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery, $name) |
|
80
|
|
|
{ |
|
81
|
|
|
|
|
82
|
|
|
$this->desctxt = absences_translate("Description"); |
|
83
|
|
|
$this->typetxt = absences_translate("Type"); |
|
84
|
|
|
$this->nametxt = absences_translate("Name"); |
|
|
|
|
|
|
85
|
|
|
$this->kindtxt = absences_translate("Right kind"); |
|
|
|
|
|
|
86
|
|
|
$this->quantitytxt = absences_translate("Quantity"); |
|
87
|
|
|
$this->creditortxt = absences_translate("Author"); |
|
88
|
|
|
$this->datetxt = absences_translate("Entry date"); |
|
89
|
|
|
$this->date2txt = absences_translate("Entry date ( dd-mm-yyyy )"); |
|
90
|
|
|
$this->addtxt = absences_translate("Allocate vacation rights"); |
|
91
|
|
|
$this->filteron = absences_translate("Filter on"); |
|
92
|
|
|
$this->begintxt = absences_translate("Begin"); |
|
93
|
|
|
$this->endtxt = absences_translate("End"); |
|
94
|
|
|
$this->altlistp = absences_translate("Beneficiaries"); |
|
95
|
|
|
$this->statustxt = absences_translate("Active"); |
|
96
|
|
|
$this->activeyes = absences_translate("Opened rights"); |
|
97
|
|
|
$this->activeno = absences_translate("Closed rights"); |
|
98
|
|
|
$this->closedtxt = absences_translate("Vac. closed"); |
|
99
|
|
|
$this->openedtxt = absences_translate("Vac. opened"); |
|
100
|
|
|
$this->alttxt = absences_translate("Modify"); |
|
101
|
|
|
$this->t_edit = absences_translate("Modification"); |
|
|
|
|
|
|
102
|
|
|
$this->t_first_page = absences_translate("First page"); |
|
|
|
|
|
|
103
|
|
|
$this->t_previous_page = absences_translate("Previous page"); |
|
|
|
|
|
|
104
|
|
|
$this->t_next_page = absences_translate("Next page"); |
|
|
|
|
|
|
105
|
|
|
$this->t_last_page = absences_translate("Last page"); |
|
|
|
|
|
|
106
|
|
|
$this->t_available = absences_translate("Availability"); |
|
|
|
|
|
|
107
|
|
|
$this->topurl = ""; |
|
108
|
|
|
$this->bottomurl = ""; |
|
109
|
|
|
$this->nexturl = ""; |
|
110
|
|
|
$this->prevurl = ""; |
|
111
|
|
|
$this->yselected = ""; |
|
112
|
|
|
$this->nselected = ""; |
|
113
|
|
|
$this->t_position = ''; |
|
114
|
|
|
global $babDB; |
|
115
|
|
|
|
|
116
|
|
|
$this->pos = $pos; |
|
117
|
|
|
|
|
118
|
|
|
$aaareq = array(); |
|
119
|
|
|
$req = "".ABSENCES_RIGHTS_TBL." r LEFT JOIN ".ABSENCES_TYPES_TBL." t ON t.id=r.id_type where "; |
|
120
|
|
|
|
|
121
|
|
|
if( $name != "") { |
|
122
|
|
|
$aaareq[] = "r.description LIKE '%".$babDB->db_escape_like($name)."%'"; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
if( $active != "") |
|
126
|
|
|
$aaareq[] = "r.active='".$babDB->db_escape_string($active)."'"; |
|
127
|
|
|
|
|
128
|
|
|
if( $idcoll != "") |
|
129
|
|
|
{ |
|
130
|
|
|
$aaareq[] = "r.id IN(SELECT id_right FROM absences_coll_rights WHERE id_coll=".$babDB->quote($idcoll).")"; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
if( $idtype != "") |
|
134
|
|
|
{ |
|
135
|
|
|
$aaareq[] = "r.id_type=".$babDB->quote($idtype); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
if( $rgroup != "") |
|
139
|
|
|
{ |
|
140
|
|
|
$aaareq[] = "r.id_rgroup=".$babDB->quote($rgroup); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
if( $dateb != "" ) |
|
144
|
|
|
{ |
|
145
|
|
|
$ar = explode("-", $dateb); |
|
146
|
|
|
$dateb = $ar[2]."-".$ar[1]."-".$ar[0]; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
View Code Duplication |
if( $datee != "" ) |
|
|
|
|
|
|
150
|
|
|
{ |
|
151
|
|
|
$ar = explode("-", $datee); |
|
152
|
|
|
$datee = $ar[2]."-".$ar[1]."-".$ar[0]; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
if( $dateb != "" && $datee != "") |
|
156
|
|
|
{ |
|
157
|
|
|
$aaareq[] = "( r.date_entry between '".$babDB->db_escape_string($dateb)."' and '".$babDB->db_escape_string($datee)."')"; |
|
158
|
|
|
} |
|
159
|
|
|
else if( $dateb == "" && $datee != "" ) |
|
160
|
|
|
{ |
|
161
|
|
|
$aaareq[] = "r.date_entry <= '".$babDB->db_escape_string($datee)."'"; |
|
162
|
|
|
} |
|
163
|
|
|
else if ($dateb != "" ) |
|
164
|
|
|
{ |
|
165
|
|
|
$aaareq[] = "r.date_entry >= '".$babDB->db_escape_string($dateb)."'"; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
if ($archived) |
|
169
|
|
|
{ |
|
170
|
|
|
$aaareq[] = "r.archived = ".$babDB->quote(1); |
|
171
|
|
|
} else { |
|
172
|
|
|
$aaareq[] = "r.archived = ".$babDB->quote(0); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
if ($recovery) |
|
176
|
|
|
{ |
|
177
|
|
|
$aaareq[] = "r.kind = ".$babDB->quote(absences_Right::RECOVERY); |
|
178
|
|
|
} else { |
|
179
|
|
|
$aaareq[] = "r.kind <> ".$babDB->quote(absences_Right::RECOVERY); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
|
|
183
|
|
View Code Duplication |
if( isset($aaareq) && sizeof($aaareq) > 0 ) |
|
|
|
|
|
|
184
|
|
|
{ |
|
185
|
|
|
if( sizeof($aaareq) > 1 ) |
|
186
|
|
|
$req .= implode(' and ', $aaareq); |
|
187
|
|
|
else |
|
188
|
|
|
$req .= $aaareq[0]; |
|
189
|
|
|
} |
|
190
|
|
|
$req .= " order by r.date_entry desc, r.id"; |
|
191
|
|
|
|
|
192
|
|
|
list($total) = $babDB->db_fetch_row($babDB->db_query("select count(*) as total from ".$req)); |
|
193
|
|
|
|
|
194
|
|
|
$this->paginate($total, ABSENCES_MAX_RIGHTS_LIST); |
|
195
|
|
|
|
|
196
|
|
|
if( $total > ABSENCES_MAX_RIGHTS_LIST) |
|
197
|
|
|
{ |
|
198
|
|
|
$req .= " limit ".$pos.",".ABSENCES_MAX_RIGHTS_LIST; |
|
199
|
|
|
} |
|
200
|
|
|
bab_debug("select r.*, t.name type, t.color typecolor from ".$req); |
|
201
|
|
|
$this->res = $babDB->db_query("select r.*, t.name type, t.color typecolor from ".$req); |
|
202
|
|
|
$this->count = $babDB->db_num_rows($this->res); |
|
203
|
|
|
$this->addurl = absences_addon()->getUrl()."vacadma&idx=addvr"; |
|
204
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
$this->dateburl = $GLOBALS['babUrlScript']."?tg=month&callback=dateBegin&ymin=0&ymax=3"; |
|
|
|
|
|
|
207
|
|
|
$this->dateeurl = $GLOBALS['babUrlScript']."?tg=month&callback=dateEnd&ymin=0&ymax=3"; |
|
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
$this->searchform = $this->getSearchForm(); |
|
|
|
|
|
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
private function getSearchForm() |
|
214
|
|
|
{ |
|
215
|
|
|
global $babDB; |
|
216
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
|
|
217
|
|
|
$W = bab_Widgets(); |
|
218
|
|
|
$form = $W->Form(null, $W->FlowLayout()->setSpacing(1,'em', 3,'em')); |
|
219
|
|
|
$form->setSelfPageHiddenFields()->setReadOnly(); |
|
220
|
|
|
|
|
221
|
|
|
$form->addClass('widget-bordered'); |
|
222
|
|
|
$form->addClass('BabLoginMenuBackground'); |
|
223
|
|
|
$form->addClass('widget-centered'); |
|
224
|
|
|
$form->addClass(Func_Icons::ICON_LEFT_16); |
|
225
|
|
|
$form->colon(); |
|
226
|
|
|
|
|
227
|
|
|
$form->setCanvasOptions($form->Options()->width(97,'%')); |
|
|
|
|
|
|
228
|
|
|
|
|
229
|
|
|
|
|
230
|
|
|
|
|
231
|
|
|
$form->addItem( |
|
232
|
|
|
$W->LabelledWidget( |
|
233
|
|
|
absences_translate('Name'), |
|
234
|
|
|
$W->LineEdit(), |
|
235
|
|
|
'name' |
|
236
|
|
|
) |
|
237
|
|
|
); |
|
238
|
|
|
|
|
239
|
|
|
|
|
240
|
|
|
|
|
241
|
|
|
$types = $W->Select()->addOption('', ''); |
|
242
|
|
|
$restype = $babDB->db_query("select * from ".ABSENCES_TYPES_TBL." order by name asc"); |
|
243
|
|
|
while ($arr = $babDB->db_fetch_assoc($restype)) |
|
244
|
|
|
{ |
|
245
|
|
|
$types->addOption($arr['id'], $arr['name']); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
$form->addItem( |
|
249
|
|
|
$W->LabelledWidget( |
|
250
|
|
|
absences_translate('Type'), |
|
251
|
|
|
$types, |
|
252
|
|
|
'idtype' |
|
253
|
|
|
) |
|
254
|
|
|
); |
|
255
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
$collections = $W->Select()->addOption('', ''); |
|
258
|
|
|
$rescoll = $babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc"); |
|
259
|
|
|
while ($arr = $babDB->db_fetch_assoc($rescoll)) |
|
260
|
|
|
{ |
|
261
|
|
|
$collections->addOption($arr['id'], $arr['name']); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
$form->addItem( |
|
265
|
|
|
$W->LabelledWidget( |
|
266
|
|
|
absences_translate('Collection'), |
|
267
|
|
|
$collections, |
|
268
|
|
|
'idcoll' |
|
269
|
|
|
) |
|
270
|
|
|
); |
|
271
|
|
|
|
|
272
|
|
|
|
|
273
|
|
|
$rgroups = $W->Select()->addOption('', ''); |
|
274
|
|
|
$resrg = $babDB->db_query("select * from absences_rgroup order by name asc"); |
|
275
|
|
|
while ($arr = $babDB->db_fetch_assoc($resrg)) |
|
276
|
|
|
{ |
|
277
|
|
|
$rgroups->addOption($arr['id'], $arr['name']); |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
|
|
281
|
|
|
$form->addItem( |
|
282
|
|
|
$W->LabelledWidget( |
|
283
|
|
|
absences_translate('Right group'), |
|
284
|
|
|
$rgroups, |
|
285
|
|
|
'rgroup' |
|
286
|
|
|
) |
|
287
|
|
|
); |
|
288
|
|
|
|
|
289
|
|
|
|
|
290
|
|
|
$form->addItem( |
|
291
|
|
|
$W->LabelledWidget( |
|
292
|
|
|
absences_translate('Status'), |
|
293
|
|
|
$W->Select() |
|
294
|
|
|
->addOption('', '') |
|
295
|
|
|
->addOption('Y', absences_translate('Active')) |
|
296
|
|
|
->addOption('N', absences_translate('Inactive')), |
|
297
|
|
|
'active' |
|
298
|
|
|
) |
|
299
|
|
|
); |
|
300
|
|
|
|
|
301
|
|
|
|
|
302
|
|
|
$form->addItem( |
|
303
|
|
|
$W->LabelledWidget( |
|
304
|
|
|
absences_translate('Write date'), |
|
305
|
|
|
$W->PeriodPicker()->setNames('dateb', 'datee') |
|
306
|
|
|
) |
|
307
|
|
|
); |
|
308
|
|
|
|
|
309
|
|
|
|
|
310
|
|
|
$form->setValues($_REQUEST); |
|
311
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
|
|
314
|
|
|
$form->addItem($W->SubmitButton()->setLabel(absences_translate('Search'))); |
|
315
|
|
|
|
|
316
|
|
|
return $form->display($W->HtmlCanvas()); |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
public function getnext() |
|
320
|
|
|
{ |
|
321
|
|
|
static $i = 0; |
|
322
|
|
|
if( $i < $this->count) |
|
323
|
|
|
{ |
|
324
|
|
|
global $babDB; |
|
325
|
|
|
$this->altbg = !$this->altbg; |
|
326
|
|
|
$arr = $babDB->db_fetch_array($this->res); |
|
327
|
|
|
|
|
328
|
|
|
|
|
329
|
|
|
$this->typecolor = bab_toHtml($arr['typecolor']); |
|
|
|
|
|
|
330
|
|
|
$this->typename = bab_toHtml($arr['type']); |
|
331
|
|
|
|
|
332
|
|
|
unset($arr['typecolor']); |
|
333
|
|
|
unset($arr['type']); |
|
334
|
|
|
|
|
335
|
|
|
|
|
336
|
|
|
$right = new absences_Right($arr['id']); |
|
337
|
|
|
$right->setRow($arr); |
|
338
|
|
|
|
|
339
|
|
|
|
|
340
|
|
|
$this->vrurl = bab_toHtml(absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".$arr['id']); |
|
341
|
|
|
$this->vrviewurl = bab_toHtml(absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".$arr['id']); |
|
342
|
|
|
|
|
343
|
|
|
$this->kind = bab_toHtml($right->getKindLabel()); |
|
|
|
|
|
|
344
|
|
|
$this->description = bab_toHtml($right->description); |
|
345
|
|
|
if (0 === (int) round(100*$arr['quantity'])) |
|
346
|
|
|
{ |
|
347
|
|
|
$this->quantity = ''; |
|
348
|
|
|
} else { |
|
349
|
|
|
$this->quantity = bab_toHtml(absences_quantity($arr['quantity'], $arr['quantity_unit'])); |
|
350
|
|
|
} |
|
351
|
|
|
$this->creditor = bab_toHtml(bab_getUserName($arr['id_creditor'])); |
|
352
|
|
|
$this->date = bab_toHtml(bab_shortDate(bab_mktime($arr['date_entry']), false)); |
|
353
|
|
|
$this->bclose = $arr['active'] == "N"; |
|
354
|
|
|
|
|
355
|
|
|
|
|
356
|
|
|
$this->available = $right->isAvailable() ? absences_translate('Available') : ''; |
|
|
|
|
|
|
357
|
|
|
|
|
358
|
|
|
if( $this->bclose ) |
|
359
|
|
|
$this->statusval = $this->closedtxt; |
|
360
|
|
|
else |
|
361
|
|
|
$this->statusval = $this->openedtxt; |
|
362
|
|
|
|
|
363
|
|
|
if (absences_Right::RECOVERY === $right->getKind()) |
|
364
|
|
|
{ |
|
365
|
|
|
$this->urllistp = false; |
|
366
|
|
|
} else { |
|
367
|
|
|
$this->urllistp = absences_addon()->getUrl()."vacadma&idx=lvrc&idvr=".$arr['id']; |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
|
$i++; |
|
371
|
|
|
return true; |
|
372
|
|
|
} |
|
373
|
|
|
else |
|
374
|
|
|
return false; |
|
375
|
|
|
|
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
|
|
381
|
|
|
|
|
382
|
|
|
|
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* Display a menu to add items to the agent list |
|
386
|
|
|
* @return string |
|
387
|
|
|
*/ |
|
388
|
|
|
function absences_rightListMenu() |
|
389
|
|
|
{ |
|
390
|
|
|
$toolbar = absences_getToolbar(); |
|
391
|
|
|
|
|
392
|
|
|
$sImgPath = $GLOBALS['babInstallPath'] . 'skins/ovidentia/images/Puces/'; |
|
393
|
|
|
|
|
394
|
|
|
$url = bab_url::get_request('tg', 'filter'); |
|
395
|
|
|
$url->idx = 'addvr'; |
|
396
|
|
|
|
|
397
|
|
|
$toolbar->addToolbarItem( |
|
398
|
|
|
new BAB_ToolbarItem(absences_translate('Add'), $url->toString(), |
|
399
|
|
|
$sImgPath . 'edit_add.png', '', '', '') |
|
400
|
|
|
); |
|
401
|
|
|
|
|
402
|
|
|
|
|
403
|
|
|
return $toolbar->printTemplate(); |
|
404
|
|
|
} |
|
405
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: