-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
793 lines (704 loc) · 28.6 KB
/
index.php
File metadata and controls
793 lines (704 loc) · 28.6 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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<?php require_once('login.php'); ?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="HandheldFriendly" content="true" />
<?php require_once('header.php');
$TimeQuery = $db_server->query("SELECT starttime,endtime FROM globals");
$TimeQuery = $TimeQuery->fetch_array();
$globalstarttime = new DateTime($TimeQuery['starttime']);
$globalendtime = new DateTime($TimeQuery['endtime']);
$globalstarttime = $globalstarttime->format("H:iA");
$globalendtime = $globalendtime->format("H:iA");
?>
<script type="text/javascript">
$(document).ready(function(){
$('#offtime').timepicker({ 'scrollDefaultNow': true, 'minTime': <?php echo(json_encode($globalstarttime)); ?>, 'maxTime': <?php echo(json_encode($globalendtime)); ?>, 'timeFormat': 'g:i', 'step': 5 });
$('#fttime').timepicker({ 'scrollDefaultNow': true, 'minTime': <?php echo(json_encode($globalstarttime)); ?>, 'maxTime': <?php echo(json_encode($globalendtime)); ?>, 'timeFormat': 'g:i', 'step': 15 });
$('.late_time').timepicker({ 'scrollDefaultNow': true, 'minTime': <?php echo(json_encode($globalstarttime)); ?>, 'maxTime': <?php echo(json_encode($globalendtime)); ?>, 'timeFormat': 'g:i', 'step': 5 });
});
</script>
<script type="text/javascript">
function setIdle(cb, seconds) {
var timer;
var interval = seconds * 1000;
function refresh() {
clearInterval(timer);
timer = setTimeout(cb, interval);
};
$(document).on('keypress, click, mousemove', refresh);
refresh();
}
setIdle(function() {location.href = location.href;}, 300);
</script>
</head>
<body class="mainpage">
<!-- setup -->
<?php
$null_value = null;
$status_result = $db_server->query("SELECT DISTINCT statusname FROM statusdata");
$result_array = array();
while ($blah = $status_result->fetch_assoc()) {
$status_array[] = $blah['statusname'];
}
//time for fetching groups!!
$groupsQuery = $db_server->query("SELECT * FROM groups ORDER BY name DESC");
$groupsResult = array();
while ($group = $groupsQuery->fetch_array()) {
array_push($groupsResult, $group);
//$groupsCount += 1;
}
$group = ltrim($group, ",");
//this function sorts multidimensional arrays by one of their subkeys
//$a = the array to be sorted -- $subkey = the subkey to be sorted by
function subval_sort($a, $subkey, $result) {
//dynamic variable naming to ensure the result array is named 'subkey'_array
$temp_varname = $result . "_array";
$$temp_varname = array();
//goes through the array, $k = the key, $v = value in the array
foreach($a as $k=>$v) {
$b[$k] = $v[$subkey];
}
if (!empty($b)) {
if ($subkey == 'statusname') {
asort($b);
}
foreach($b as $key=>$val) {
if ($val == $result) {
array_push($$temp_varname, $a[$key]);
}
}
if ($subkey == 'statusname') {
asort($$temp_varname);
}
return $$temp_varname;
}
}
//facilitator array, $facilitators is array of all from sql
$facget = $db_server->query("SELECT * FROM facilitators ORDER BY facilitatorname ASC");
$facilitators = array();
while ($fac_row = $facget->fetch_row()) {
array_push ($facilitators, $fac_row[0]);
}
//current students array
$studentquery = "SELECT studentid FROM studentdata WHERE current=1 ORDER BY firstname";
if (!empty($_GET['sortBy'])) {
if ($_GET['sortBy'] == 'student' && $_GET['r'] == 1) {
$studentquery = "SELECT studentid FROM studentdata WHERE current=1 ORDER BY firstname DESC";
}
}
$current_users_result = $db_server->query($studentquery);
// get dates
$globals_query = "SELECT * FROM globals";
$globals_result = $db_server->query($globals_query);
$globals_data = $globals_result->fetch_array();
$getendDate = new DateTime($globals_data['enddate']);
$getstartDate = new DateTime($globals_data['startdate']);
date_add($getstartDate, date_interval_create_from_date_string('1 day'));
date_add($getendDate, date_interval_create_from_date_string('-1 day'));
$startDate = $getstartDate->format('Y-m-d H:i:s');
$endDate = $getendDate->format('Y-m-d H:i:s');
// changestatus functions to create new entries in the database
//each only triggers if each field is correctly filled out, and the corresponding submit button has been pressed
//checks value of either checkboxes - $name = all checked students
if (!empty($_POST['person']) && isPost()){
$name = $_POST['person'];
//present
if (!empty($_POST['present']) or in_array("P", $_POST)) {
foreach ($name as $student)
{
changestatus($student, '1', '', '');
}
}
//offsite
if (!empty($_POST['offsite'])) {
if (!empty($_POST['customtext'])) {
$info = $_POST['customtext'];
if (validTime($_POST['offtime'])){
foreach ($name as $student){
changestatus($student, '2', $info, $_POST['offtime']);
}
} else {
echo "<div class='error'>Please enter a valid return time.</div>";
}
} else {
if (!empty($_POST['offlocDropdown']) && $_POST['offlocDropdown'] != ''){
$info = $_POST['offlocDropdown'];
if (validTime($_POST['offtime'])){
foreach ($name as $student){
changestatus($student, '2', $info, convertHours('offtime'));
}
} else {
echo "<div class='error'>Please enter a valid return time.</div>";
}
} else {
echo "<div class='error'>You must choose an offsite location.</div>";
}
}
}
//fieldtrip
if (!empty($_POST['fieldtrip'])) {
if (!empty($_POST['facilitator'])){
$info = $_POST['facilitator'];
if (validTime($_POST['fttime'])){
foreach ($name as $student){
changestatus($student, '3', $info, convertHours('fttime'));
}
} else {
echo "<div class='error'>Please enter a valid return time.</div>";
}
} else {
echo "<div class='error'>Please chose a valid facilitator.</div>";
}
}
//Sign out querying -- "4" refers to "Checked Out" in statusdata table
if (!empty($_POST['checkout'])) {
foreach ($name as $student) {
changestatus($student, '4', '', '');
}
}
//error message when no boxes are checked
} else if(isPost() && empty($_POST['person'])) {
echo "<div class='error'>Please choose a student.</div>";
}
//individual present button querying -- "1" refers to "Present" in statusdata table
if (!empty($_POST['present_bstudent'])) {
$name = $_POST['present_bstudent'];
changestatus($name, '1', '', $null_value);
}
//individual Checked Out button querying -- "4" refers to "Checked Out" in statusdata table
if (!empty($_POST['co_bstudent'])) {
$name = $_POST['co_bstudent'];
changestatus($name, '4', '', $null_value);
}
//late status querying -- "5" refers to "Late" in statusdata table
if (!empty($_POST['Late'])) {
if (validTime($_POST['late_time'])) {
$name = $_POST['late_student'];
$status = convertHours('late_time');
changestatus($name, '5', '', $status);
}
else {
echo "<div class='error'>Please enter a valid expected arrival time.</div>";
}
}
//absent buttons
if (!empty($_POST['Absent'])) {
$name = $_POST['absent_student'];
changestatus($name, '7', '', $null_value);
}
//basic checks to set a variable equal to the correct string to be passed into the get variable
//sortBy == the value that the table should be sorted by $r == whether to reverse sort
//default values, when get is empty
if (empty($_GET['sortBy'])) {
$getvar_sort_status = 'sortBy=status&r=0';
$getvar_sort_student = 'sortBy=student&r=0';
}
//triggers when get[sortby] is populated with values
else {
//correctly makes the table reverse sortable when a header is clicked twice
//also assigns the default value for the opposite sortby value when the get variable is populated
if ($_GET['sortBy'] == 'status' && $_GET['r'] == 0) {
$getvar_sort_status = 'sortBy=status&r=1';
$getvar_sort_student = 'sortBy=student&r=0';
}
if ($_GET['sortBy'] == 'student' && $_GET['r'] == 0) {
$getvar_sort_student = 'sortBy=student&r=1';
$getvar_sort_status = 'sortBy=status&r=0';
}
if ($_GET['sortBy'] == 'status' && $_GET['r'] == 1) {
$getvar_sort_status = 'sortBy=status&r=0';
$getvar_sort_student = 'sortBy=student&r=0';
}
if ($_GET['sortBy'] == 'student' && $_GET['r'] == 1) {
$getvar_sort_student = 'sortBy=student&r=0';
$getvar_sort_status = 'sortBy=status&r=0';
}
}
if(ispost()){
header('Location: '.$_SERVER['PHP_SELF']);
die;
}
// THIS IS FOR THE "Check Out" Buttons at the end of the day
//Sets current time
$phpdatetime = new dateTime();
$current_time = $phpdatetime->format('h:i a');
//Query for globals
$globalsresult = $db_server->query("SELECT * FROM globals");
while ($list = mysqli_fetch_assoc($globalsresult))
{
// Making time look nice
$pretty_end_time = new DateTime($list['endtime']);
// Code for checking if 10 min before globals.endtime
$co_start_time = date($list['endtime']);
$co_start = strtotime ( '-10 minute' , strtotime ( $co_start_time ) ) ;
$co_start = date ( 'h:i a' , $co_start );
// Code for checking if 10 min after globals.endtime
$co_end_time = date($list['endtime']);
$co_end = strtotime ( '+10 minute' , strtotime ( $co_end_time ) ) ;
$co_end = date ( 'h:i a' , $co_end );
}
//Making Varibles possible
$date1 = DateTime::createFromFormat('h:i a', $current_time);
$date2 = DateTime::createFromFormat('h:i a', $co_start);
$date3 = DateTime::createFromFormat('h:i a', $co_end);
// Checking if between globals.endtime time
if ($date1 > $date2 && $date1 < $date3) {
if ($pretty_end_time->format('hi a') < date('hi a')) { ?>
<div class='COTimer COTgood'>Current Time: <?php echo date('g:i a'); ?></div>
<?php } elseif ($pretty_end_time->format('hi a') > date('hi a')) { ?>
<div class='COTimer COTbad'>Current Time: <?php echo date('g:i a'); ?></div>
<?php } else { ?>
<div class='COTimer COTgood'>Current Time: <?php echo date('g:i a'); ?></div>
<?php } }?>
<?php
$studentcount = 0;
$student_data_array = array();
//loops through current students
while ($current_student_id = $current_users_result->fetch_assoc()) {
//fetches most recent data from the events table
//joins with the tables that key student names/status names to the ids in the events table
$result = $db_server->query("SELECT firstname,lastname,statusname,studentdata.studentid,info,timestamp,returntime
FROM events
JOIN statusdata ON events.statusid = statusdata.statusid
RIGHT JOIN studentdata ON events.studentid = studentdata.studentid
WHERE studentdata.studentid = $current_student_id[studentid]
ORDER BY timestamp DESC
LIMIT 1")
or die(mysqli_error($db_server));
$result_array = $result->fetch_assoc();
//pushed each individual student's data into an array
array_push($student_data_array, $result_array);
$studentcount ++;
}
/*echo "<pre>";
print_r($student_data_array);
echo "</pre>";*/
$fieldTripArray = array();
$uniqueFacil = array();
for ($i = 0; $i < count($student_data_array); $i++) {
if ($student_data_array[$i]['statusname'] == "Field Trip") {
if (!in_array($student_data_array[$i]['info'], $uniqueFacil)) {
array_push($uniqueFacil, $student_data_array[$i]['info']);
}
array_push($fieldTripArray, $student_data_array[$i]['studentid'] . "---" . $student_data_array[$i]['info']);
}
}
//echo "<pre>";
//print_r($fieldTripArray); //works
//echo "</pre>";
//echo "<br /><pre>";
//print_r($uniqueFacil); //works
//echo "</pre>";
?>
<form method='post' action='<?php echo basename($_SERVER['PHP_SELF']); ?>' id='lmain' >
<?php
if (!empty($groupsResult)) {
echo "<div class='groupsGUI'>";
echo "<h1 class='groupHeader tab'>Groups</h1>";
for ($j = 0; $j < count($groupsResult); $j++) {
echo "<input class='groupButton' type='submit' name='" . $groupsResult[$j]["name"] . "' value='" . str_replace("_"," ", $groupsResult[$j]["name"]) . "'><br />";
}
if (!empty($uniqueFacil)) {
echo "<p class='groupHeader'>Field Trip Groups</p>";
foreach ($uniqueFacil as $sub) {
echo "<input class='groupButton' type='submit' name='" . $sub . "' value = '" . $sub . "'><br />";
}
}
echo "</div> ";
}
?>
</form>
<!-- top form for change status -->
<div id="top_header">
<form method='post' action='<?php echo basename($_SERVER['PHP_SELF']); ?>' id='main' >
<div>
<!-- top interface present button -->
<input class="PSCSbtn button" id="present_button" type="submit" value="Present" name="present">
</div>
<div>
<!-- top interface sign out button -->
<input class="PSCSbtn" type="submit" value="Check Out" name="checkout" onclick="return confirm('Confirmation: \nAre you sure you want to check out?');">
</div>
<div>
<!-- top interface offsite -->
<span id="cdropdown"><select id="offlocDropdown" name="offlocDropdown" class="offlocDropdown">
<option value=''>Offsite Location</option>
<?php
$placeget = $db_server->query("SELECT * FROM offsiteloc ORDER BY place ASC");
while ($place_option = $placeget->fetch_assoc()) {
?> <option value= "<?php echo $place_option['place']; ?> "><?php echo $place_option['place']; ?></option> <?php } ?>
<option name="Custom" value="Custom" style="background-color:lightgrey;">Custom</option>
</select></span>
<span id="cdiv">
</span>
<input type="text" class="aTextField" name="offtime" placeholder="Return time" id="offtime">
<input class="button" type="submit" name="offsite" value="Offsite">
</div>
<div>
<!-- top interface fieldtrip -->
<!-- Creates the dropdown of facilitators -->
<select name='facilitator'><option value=''>Select Facilitator</option>
<?php
//checks the database of facilitators to ensure the dropdown menu is correctly populated by all current staff/facilitators
foreach ($facilitators as $facilitator_option) {
?>
<option value= '<?php echo $facilitator_option; ?>'> <?php echo $facilitator_option; ?></option>
<?php
}
?>
</select>
<input type="text" name="fttime" placeholder="Return time" id="fttime">
<input class="button" type="submit" name="fieldtrip" value="Field Trip">
</div>
<div class="statusview_button">
<a href="statusview.php">Status View</a>
</div>
<!-- Link To Admin Page -->
<?php
if (isset($_COOKIE['login'])) {
if ($_COOKIE['login'] == $SecureAdminPW || $_COOKIE['login'] == $crypt) {
echo '<div class="admin_button"><a href="a/p/index.php">Admin</a></div>';
}
}
?>
<div class="viewreports_button">
<a href="viewreports.php">View Reports</a>
</div>
<div>
<a href="secondary_login.php?logout=1">Logout</a>
</div>
</form>
</div>
<script>
$(document).ready(function() {
$(window).resize(function() {
if($(window).width() < 1020) {
$('.viewreports_button a').text('Reports');
$('.statusview_button a').text('Status');
$('.admin_button a').text('A');
$("#present_button").prop('value', 'P');
$("#present_button").css('width', '25px');
}
else {
$('.viewreports_button a').text('View Reports');
$('.statusview_button a').text('Status View');
$('.admin_button a').text('Admin');
$("#present_button").prop('value', 'Present');
$("#present_button").css('width', '60px');
}
if ($(window).width() < 830) {
$(".l_button").prop('value', 'L');
}
else {
$('.l_button').prop('value', 'Late');
}
});
if($(window).width() < 1020) {
$('.viewreports_button a').text('Reports');
$('.statusview_button a').text('Status');
$('.admin_button a').text('A');
$("#present_button").prop('value', 'P');
$("#present_button").css('width', '25px');
}
else {
$('.viewreports_button a').text('View Reports');
$('.statusview_button a').text('Status View');
$('.admin_button a').text('Admin');
$("#present_button").prop('value', 'Present');
$("#present_button").css('width', '60px');
}
if ($(window).width() < 830) {
$(".l_button").prop('value', 'L');
}
else {
$('.l_button').prop('value', 'Late');
}
});
</script>
<!-- student information table rendering -->
<div id="main_table">
<table class='data_table' id='big_table'>
<tr>
<th class='select_col'><input type="checkbox" id="checkAll"/></th>
<!-- clickable headers for the table, allows them to be sorted -->
<th class='student_col'><a href="index.php?<?php echo $getvar_sort_student; ?>">Student</a></th>
<th class='blank_col'></th>
<th class='status_col' id='status_header'><a href="index.php?<?php echo $getvar_sort_status; ?>">Status</a></th>
</tr>
<?php
//echo "<br /><br />";
//print_r($currFieldTrips);
//checks how the table should be sorted. Default is alphabetically by student
if (isset($_GET['sortBy'])) {
if ($_GET['sortBy'] == 'status') {
$result_total_array = array();
foreach ($status_array as $status) {
$result_array = subval_sort($student_data_array, 'statusname', $status);
array_push($result_total_array, $result_array);
}
$student_data_array = $result_total_array;
}
}
if (isset($_GET['sortBy'])) {
if ($_GET['sortBy'] != 'status') {
$result_total_array = array();
array_push($result_total_array, $student_data_array);
$student_data_array = $result_total_array;
}
}
elseif (empty($_GET['sortBy'])) {
$result_total_array = array();
array_push($result_total_array, $student_data_array);
$student_data_array = $result_total_array;
}
if (!empty($_GET['sortBy'])) {
if ($_GET['sortBy'] == 'status' && $_GET['r'] == 0) {
$student_data_array = array_reverse($student_data_array);
}
}
//loops through student data array
//does it twice because when the table is sorted by status, the array containing the data has an extra dimension
if (empty($_POST['admin_view'])) {
foreach ($student_data_array as $mini_array) {
foreach ($mini_array as $latestdata) {
//sets up relevant time and date data to automatically start a new day the first time the page is loaded
$day_data = new DateTime($latestdata['timestamp']);
$yesterday = new DateTime('yesterday 23:59:59');
$today = new DateTime();
$todaydate = $today->format('Y-m-d');
if ($day_data < $yesterday) {
$student = $latestdata['studentid'];
$future_event_query = $db_server->query("SELECT * FROM `preplannedevents` WHERE `eventdate` = '".$todaydate."' and `studentid` = '".$student."'") or die (mysqli_error($db_server));
$future_events = mysqli_fetch_assoc($future_event_query);
if($future_events!=False){
changestatus($student, $future_events['statusid'],$future_events['info'],$future_events['returntime']);
} else {
//if the last entry for a student was yesterday and there are no preplanned events, this makes an entry for 'not checked in'
changestatus($latestdata['studentid'], '8', '', '');
}
}
// SETTING VERIBLES FOR CONTEXTUAL COLORING //
// Get Current Time
$cTime = new DateTime();
// Get ENTERED return time
$mReturn= new DateTime($latestdata['returntime']);
// Get globals.starttime
$globals_query = "SELECT starttime FROM globals";
// Setting query info as varible
$globals_result = $db_server->query($globals_query);
// Put query data into an array
$globals_data = $globals_result->fetch_array();
// Set globals.starttime as varible
$ttStart = new DateTime($globals_data['starttime']);
// These is for making the IF statment shorter
$currStatus = $latestdata['statusname'];
if ($cTime > $ttStart && $currStatus == 'Not Checked In' || $cTime > $mReturn && $currStatus == "Offsite" || $cTime > $mReturn && $currStatus == "Late" || $cTime > $mReturn && $currStatus == "Independent Study" || $cTime > $mReturn && $currStatus == "Field Trip") {
?>
<tr class="Status_Red">
<?php } else { ?>
<tr>
<?php } ?>
<td class='select_col'>
<!-- checkbox that gives student data to the form at the top -->
<input type='checkbox' name='person[]' id='<?php echo $latestdata['studentid']; ?>' value='<?php echo $latestdata['studentid']; ?>' form='main' class='c_box'>
</td>
<?php
//variable equal to a students last name initial
$lastinitial = substr($latestdata['lastname'], 0, 1); ?>
<!-- displays current rows student name, that students status and any comment associated with that status -->
<td class='student_col'>
<a href="user.php?id=<?php echo $latestdata['studentid']; ?>&name=<?php echo $latestdata['firstname'];?>"><?php print $latestdata['firstname'] . " " . $lastinitial; ?></a>
</td>
<td class="student_col_buttons">
<!-- IF CHECK OUT IS NEAR -->
<?php
// Checking if checkout times are within range
if ($date1 > $date2 && $date1 < $date3) {
//checking if before checkout time
if ($pretty_end_time->format('hi a') > date('hi a')) {
if ($latestdata['statusname'] != 'Checked Out' && $latestdata['statusname'] != 'Absent' && $latestdata['statusname'] != 'Independent Study')
{
?>
<form action='<?php echo basename($_SERVER['PHP_SELF']); ?>' method='post'>
<input type='submit' value='Check Out' class='p_button' name='co_button'>
<input type='hidden' name='co_bstudent' value='<?php echo $latestdata['studentid']; ?>'>
</form>
<?php } } }
// if the student is not present or hasn't updated since midnight, show a present button
if (($latestdata['statusname'] != 'Present' && $latestdata['statusname'] != 'Absent' && $latestdata['statusname'] != 'Checked Out') || ($day_data < $yesterday)) {
?>
<form action='<?php echo basename($_SERVER['PHP_SELF']); ?>' method='post'>
<input type='submit' value='P' class='p_button tablebutton' name='present_button'>
<input type='hidden' name='present_bstudent' value='<?php echo $latestdata['studentid']; ?>'>
</form>
<?php
}
// if the student is not checked in, display an absent button
if ($latestdata['statusname'] == 'Not Checked In') {
?>
<form action='<?php echo basename($_SERVER['PHP_SELF']); ?>' method='post'>
<input class="tablebutton" type='submit' value='A' name='Absent' class='absent_button' >
<input type='hidden' name='absent_student' value='<?php echo $latestdata['studentid']; ?>'>
</form>
<?php }
// if the student is not checked in or is already late, display a late button
if ($latestdata['statusname'] == 'Not Checked In' || $latestdata['statusname'] == 'Late') {
?>
<!-- Late button with time input next to it -->
<form action='<?php echo basename($_SERVER['PHP_SELF']); ?>' method='post'>
<input class="tablebutton l_button" id="latebutton" type='submit' value='Late' name='Late'>
<input type='input' name='late_time' placeholder='Expected' class='late_time'>
<input type='hidden' name='late_student' value='<?php echo $latestdata['studentid']; ?>'>
</form>
</form>
<?php } ?>
</td>
<td class='status_col'><?php
$returntimeobject = new DateTime($latestdata['returntime']);
echo $latestdata['statusname'] . " ";
if ($latestdata['statusname'] == "Offsite") {
echo "at " . $latestdata['info'] . " returning at " . $returntimeobject->format('g:i a');
}
if ($latestdata['statusname'] == "Field Trip") {
echo "with " . $latestdata['info'] . " returning at " . $returntimeobject->format('g:i a');
}
if ($latestdata['statusname'] == "Late") {
echo $latestdata['info'] . " arriving at " . $returntimeobject->format('g:i a');
}
if ($latestdata['statusname'] == "Independent Study") {
echo $latestdata['info'] . " returning at " . $returntimeobject->format('g:i a');
}
?>
</td>
</tr>
<?php
}
}
}
// SELECTION FOR GROUPS
for ($k = 0; $k < count($groupsResult); $k++) {
$fixedName = str_replace(" ","_",$groupsResult[$k]["name"]);
if (!empty($_POST[$fixedName])) {
$ids = explode(",", $groupsResult[$k]['studentid']);;
for ($l = 1; $l < count($ids); $l++) {
$currentId = $ids[$l];
$recentEventQuery = $db_server->query("SELECT statusid FROM events WHERE studentid = " . $currentId . " ORDER BY timestamp DESC LIMIT 1");
$getRecentEvent = $recentEventQuery->fetch_assoc();
$recentEvent = $getRecentEvent['statusid'];
if ($recentEvent == 1) {
echo "<script>document.getElementById(" . $ids[$l] . ").checked = true;</script>";
}
}
}
}
// SELECTION FOR FIELD TRIP GROUPS
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
$tempExploded = array();
foreach ($uniqueFacil as $sub) {
if (!empty($_POST[$sub])) {
foreach ($fieldTripArray as $child) {
$tempExploded = explode("---", $child);
if ($tempExploded[1] == $sub) {
echo "<script>document.getElementById(" . $tempExploded[0] . ").checked = true;</script>";
}
}
}
}
?>
</table>
</table>
</div>
<!-- CODE FOR GROUPS BOX -->
<script>
$(document).ready(function() {
$('.groupsGUI').mouseenter(function() {
$('.groupsGUI').stop().animate({ right: "0px"} , "fast");
$('.groupHeader').addClass('active');
$('.groupButton').addClass('active');
});
$('.groupsGUI').mouseleave(function() {
$('.groupsGUI').stop().animate({ right: "-140px"} , "fast");
$('.groupHeader').removeClass('active');
$('.groupButton').removeClass('active');
});
});
</script>
<!-- CODE FOR MULTI-CHECKBOX SELECT-->
<script>
$.fn.shiftSelectable = function() {
var lastChecked,
$boxes = this;
$boxes.click(function(evt) {
if(!lastChecked) {
lastChecked = this;
return;
}
if(evt.shiftKey) {
var start = $boxes.index(this),
end = $boxes.index(lastChecked);
$boxes.slice(Math.min(start, end), Math.max(start, end) + 1)
.prop('checked', lastChecked.checked)
.trigger('change');
}
lastChecked = this;
});
};
</script>
<script>
$(document).ready(function() {
$('.c_box').shiftSelectable();
});
</script>
<script>
$(document).ready(function(){
$("#checkAll").change(function () {
if (document.getElementById("checkAll").checked == true) {
var ok = confirm("Select All Students?");
if (ok == true) {
$("input:checkbox").prop('checked', $(this).prop("checked"));
} else {
document.getElementById("checkAll").checked = false;
}
} else if (document.getElementById("checkAll").checked == false) {
var ok = confirm("Deselect All Students?");
if (ok == true) {
$("input:checkbox").prop('checked', $(this).prop("checked"));
} else {
document.getElementById("checkAll").checked = true;
}
}
});
});
/*$("#offlocDropdown").change(function () {
alert($(this).val());
});
if you click on an option it gives an alert with that option*/
$("#offlocDropdown").change(function () {
if ($(this).val() == "Custom") {
//alert("hola");
//document.write("<style>#customtext { opacity:9.0; }</style>");
document.getElementById("cdropdown").innerHTML = '';
document.getElementById("cdiv").innerHTML = '<input type="text" name="customtext" id="customtext" placeholder="Custom Location" list="offlocDropdown" maxlength="25" class="offloc" style="width:100px;opacity:9.0;">';
}
});
</script>
<script type="text/javascript">
// Original JavaScript code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.
function getCookie(name)
{
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
}
function del_cookie(name) {
document.cookie = name +
'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
</script>
</body>
</html>