-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirmArrivalDeparture.php
More file actions
469 lines (371 loc) · 12.9 KB
/
Copy pathconfirmArrivalDeparture.php
File metadata and controls
469 lines (371 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<?php
include "home.php";
?>
<script>
$(document).ready(function(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$("#myInputr").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTabler tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<script>
$(function() {
$( ".startDate" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-0:c+1",
dateFormat:"yy-mm-dd"
});
$( "#endDate" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-0:c+1",
dateFormat:"yy-mm-dd"
});
$( ".dateElement" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-35:c+0",
dateFormat:"yy-mm-dd",
onSelect: function(dateText) {
var currentTime = new Date();
var hours = currentTime.getHours().toString().padStart(2, '0');
var minutes = currentTime.getMinutes().toString().padStart(2, '0');
var seconds = currentTime.getSeconds().toString().padStart(2, '0');
var timeString = hours + ':' + minutes+':00';
$(this).val(dateText + ' ' + timeString);
}
});
});
$("#indiv").click(function(){
$("#impo").toggle();
});
</script>
<script>
$(document).ready(function(){
//$("#impo").hide();
$("#indiv").click(function(){
$("#impo").show();
$("#all"). prop("checked", false);
});
$("#all").click(function(){
$("#indiv"). prop("checked", false);
$('#impo option:first').prop('selected',true);
$("#impo").hide();
});
$("#days").click(function(){
for(var c=0,e=0,d=new Date($("#startDate").val()),a=(new Date($("#endDate").val())-d)/864E5;0<=a;a--)
{
var b=new Date(d);
b.setDate(b.getDate()+a);
1==Math.ceil(b.getDay()%6/6)?c++:e++
}
$("#days").val(c);
});
});
</script>
<style>
.tableFixHead { overflow-y: auto; height: 100px; }
.tableFixHead thead th { position: sticky; top: 0; }
</style>
<script type="text/javascript">
$(function() {
$(".tablelist tr:nth-child(even)").addClass("striped");
$(".tablelist tr:nth-child(odd)").addClass("nostriped");
});
$(document).ready(function () {
$('#dtBasicExample').DataTable();
$('.dataTables_length').addClass('bs-select');
});
</script>
<style type="text/css">
body,td {
font-size: 10pt;
}
table.tablelist {
/*background-color: black;*/
border: 1px black solid;
border-collapse: collapse;
}
th {
border: 1px outset silver;
background-color: grey;
color: white;
}
tr.nostriped {
background-color: white;
margin: 1px;
}
tr.striped {
/*background-color: #f09320;*/
background-color: whitesmoke;;
}
td {
padding: 1px 8px;
}
tr:hover {
background-color: #ddd;
}
.normal {
font-weight: normal;
}
</style>
<style>
</style>
<br /><br /><br />
<h1>Arrival and Departure confirmation<h2>
<br/>
<!-- Save outstanding leave -->
<br /><br />
<form action="confirmArrivalDeparture.php" method="post">
<fieldset>
<legend>Get Travel Information</legend>
<table>
<tr>
<td>Travel ID:</td>
<td> <input name="travelID" pattern="^-?\d+(\.\d+)?$" title="Enter a valid number" required="true" /></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='Find Travels' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('findtripsid').click();" class='hrbutton'>
<input type='submit' name='findtrips' value='Find Travels' id='findtripsid' style='display:none;' class='hrbutton'>
</div>
</form>
<hr>
<?php
include "connect.php";
if(isset($_POST['findtrips'])){
include 'createEmail.php';
$creator=$_SESSION['hruseridsession'];
$site=$_SESSION['sitesession'];
$role=$_SESSION['hrrolesession'];
$travelID=$_POST['travelID'];
//Departure
$staffWithtraveldate=mysqli_query($conn,"SELECT requestid,departure_date, departure_location,return_location,logistics_approved,means,assigned_car,purpose,num_trav_with_you,
(SELECT concat(u.lastname,' ',u.firstname) FROM users u where u.userid=assigned_driver) as driver,arrival_datetime,departure_datetime,
(SELECT concat(u.lastname,' ',u.firstname) FROM users u where u.userid=employee) as names, (SELECT program FROM users where userid=employee) as program
FROM travel_request where requestid='$travelID' and return_location like '%".$site."%' and approved=1");
if(mysqli_num_rows($staffWithtraveldate)) {
print("<br />
<fieldset>
<legend>Travel No: $travelID </legend>
<table width='100%' class='tablelist' id='dynamic_field'><thead>
<tr>
<th>No</th>
<th>Date and time</th>
<th>Names</th>
<th>Program</th>
<th>From</th>
<th>To</th>
<th>Purpose</th>
<th>Trans. Mean</th>
<th>Travelling with</th>
<th>Confirmed</th>
<th>Car</th>
<th>Driver</th>
<th>Arrival</th>
<th>Departure</th>
<th>Download</th>
</tr></thead><tbody id='myTable'>");
$i=1;
while($row=mysqli_fetch_array($staffWithtraveldate)){
$requestid=$row['requestid'];
$depdatetime=$row['departure_date'];
$from=$row['departure_location'];
$to=$row['return_location'];
$logistics_approved=$row['logistics_approved'];
$names=$row['names'];
$program=$row['program'];
$means=$row['means'];
$purpose=$row['purpose'];
$assigned_car=$row['assigned_car'];
$driver=$row['driver'];
$num_trav_with_you=$row['num_trav_with_you'];
$arrival_datetime=$row['arrival_datetime'];
$departure_datetime=$row['departure_datetime'];
$link="travel.php?code=".$requestid;
print("<tr>
<td>$requestid</td>
<td>$depdatetime</td>
<td>$names</td>
<td>$program</td>
<td>$from</td>
<td>$to</td>
<td>$purpose</td>
<td>$means</td>
<td>$num_trav_with_you</td>
<td>$logistics_approved</td>
<td>$assigned_car</td>
<td>$driver</td>
<td>$arrival_datetime</td>
<td>$departure_datetime</td>
<td><a href='$link'>Download</a></td>");
print("</tr>");
$i++;
}
if($arrival_datetime==null || $arrival_datetime=="") {
print("<tr><td colspan='15'><br ><form action='confirmArrivalDeparture.php' method='post'><input type='hidden' name='requestid' value='$requestid'>");
print(" Arrival Date and Time: <input type='text' name='arrTime' class='dateElement' required='true'>");
print(" <input type='submit' name='confirmArr' value='Confirm Arrival'> </form>");
print("</td></tr>");
}elseif($departure_datetime==null || $departure_datetime=="") {
print("<tr><td colspan='15'><br ><form action='confirmArrivalDeparture.php' method='post'><input type='hidden' name='requestid' value='$requestid'>");
print(" Departure Date and Time: <input type='text' name='depTime' class='dateElement'>");
print(" <input type='submit' name='confirmDep' value='Confirm Departure'> </form>");
print("</td></tr>");
}else {
print("<tr><td colspan='14'><br > <font color=orange>Arrival and Departure have been completed successfully.</font></td></tr>");
}
print("</tbody></table></fieldset>");
}else {
print("<script>
alert('⚠️ Warning: The Employee is not authorized to go to your Site. Please check well the travel authorization!')
</script>");
}
}
?>
<!-- Update Car, Driver, Departure time and Notification -->
<?php
include "connect.php";
if(isset($_POST['confirmArr'])){
include 'createEmail.php';
$creator=$_SESSION['hruseridsession'];
$site=$_SESSION['sitesession'];
$creatorName=$_SESSION['firstnamesession'];
$arrTime=$_POST['arrTime'];
$requestid=$_POST['requestid'];
$now=date("Y-m-d H:i:s");
$confirmTrips=mysqli_query($conn,"update travel_request set arrival_datetime='$arrTime',arrival_confirmed_by='$creator',arrival_confirmed_datetime='$now',site_confirmed_dep='$site' where requestid ='$requestid'");
$staffQuery=mysqli_query($conn,"select email,concat(lastname,' ',firstname) as staffname from users where userid in ( select employee from travel_request where requestid ='$requestid') ");
$staffnames="";
$rowrec=mysqli_fetch_array($staffQuery);
$staffnames=$rowrec['staffname'];
$email=$rowrec['email'];
$subject="Arrival confirmation (".$requestid.") ";
$messageforStaff="Dear <b>".$staffnames."</b> <br/> You are informed that your arrival has been confirmed by <br>".$creatorName."";
sendEmail($email,$subject,$messageforStaff);
findtrips($requestid);
}
?>
<!-- Update Departure -->
<?php
include "connect.php";
if(isset($_POST['confirmDep'])){
include 'createEmail.php';
$creator=$_SESSION['hruseridsession'];
$site=$_SESSION['sitesession'];
$creatorName=$_SESSION['firstnamesession'];
$depTime=$_POST['depTime'];
$requestid=$_POST['requestid'];
$now=date("Y-m-d H:i:s");
$confirmTrips=mysqli_query($conn,"update travel_request set departure_datetime='$depTime',departure_confirmed_by='$creator',departure_confirmed_datetime='$now',site_confirmed_arr='$site' where requestid ='$requestid'");
$staffQuery=mysqli_query($conn,"select email,concat(lastname,' ',firstname) as staffname from users where userid in ( select employee from travel_request where requestid ='$requestid') ");
$staffnames="";
$rowrec=mysqli_fetch_array($staffQuery);
$staffnames=$rowrec['staffname'];
$email=$rowrec['email'];
$subject="Departure confirmation (".$requestid.") ";
$messageforStaff="Dear <b>".$staffnames."</b> <br/> You are informed that your Departure has been confirmed by <br>".$creatorName."";
sendEmail($email,$subject,$messageforStaff);
findtrips($requestid);
}
?>
<!-- Function to help continue working on selected data -->
<?php
function findtrips($requestid) {
include "connect.php";
$travelID=$requestid;
$site=$_SESSION['sitesession'];
//Departure
//print("Test function");
$staffWithtraveldate=mysqli_query($conn,"SELECT requestid,departure_date, departure_location,return_location,logistics_approved,means,assigned_car,purpose,num_trav_with_you,
(SELECT concat(u.lastname,' ',u.firstname) FROM users u where u.userid=assigned_driver) as driver,arrival_datetime,departure_datetime,
(SELECT concat(u.lastname,' ',u.firstname) FROM users u where u.userid=employee) as names, (SELECT program FROM users where userid=employee) as program
FROM travel_request where requestid='$travelID' and return_location like '%".$site."%' and approved=1");
if(mysqli_num_rows($staffWithtraveldate)) {
print("<br />
<fieldset>
<legend>Travel No: $travelID </legend>
<table width='100%' class='tablelist' id='dynamic_field'><thead>
<tr>
<th>No</th>
<th>Date and time</th>
<th>Names</th>
<th>Program</th>
<th>From</th>
<th>To</th>
<th>Purpose</th>
<th>Trans. Mean</th>
<th>Travelling with</th>
<th>Confirmed</th>
<th>Car</th>
<th>Driver</th>
<th>Arrival</th>
<th>Departure</th>
</tr></thead><tbody id='myTable'>");
$i=1;
while($row=mysqli_fetch_array($staffWithtraveldate)){
$requestid=$row['requestid'];
$depdatetime=$row['departure_date'];
$from=$row['departure_location'];
$to=$row['return_location'];
$logistics_approved=$row['logistics_approved'];
$names=$row['names'];
$program=$row['program'];
$means=$row['means'];
$purpose=$row['purpose'];
$assigned_car=$row['assigned_car'];
$driver=$row['driver'];
$num_trav_with_you=$row['num_trav_with_you'];
$arrival_datetime=$row['arrival_datetime'];
$departure_datetime=$row['departure_datetime'];
print("<tr>
<td>$i</td>
<td>$depdatetime</td>
<td>$names</td>
<td>$program</td>
<td>$from</td>
<td>$to</td>
<td>$purpose</td>
<td>$means</td>
<td>$num_trav_with_you</td>
<td>$logistics_approved</td>
<td>$assigned_car</td>
<td>$driver</td>
<td>$arrival_datetime</td>
<td>$departure_datetime</td>
");
print("</tr>");
$i++;
}
if($arrival_datetime==null || $arrival_datetime=="") {
print("<tr><td colspan='14'><br ><form action='confirmArrivalDeparture.php' method='post'><input type='hidden' name='requestid' value='$requestid'>");
print(" Arrival Date and Time: <input type='text' name='arrTime' class='dateElement'>");
print(" <input type='submit' name='confirmArr' value='Confirm Arrival'> </form>");
print("</td></tr>");
}elseif($departure_datetime==null || $departure_datetime=="") {
print("<tr><td colspan='14'><br ><form action='confirmArrivalDeparture.php' method='post'><input type='hidden' name='requestid' value='$requestid'>");
print(" Departure Date and Time: <input type='text' name='depTime' class='dateElement'>");
print(" <input type='submit' name='confirmDep' value='Confirm Departure'> </form>");
print("</td></tr>");
}else {
print("<tr><td colspan='14'><br > <font color=orange>Arrival and Departure have been completed successfully.</font></td></tr>");
}
print("</tbody></table></fieldset>");
}
}
?>