-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.php
196 lines (170 loc) · 8.42 KB
/
scheduler.php
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
<?php
/**
* Copyright (c) 2017 John Malandrakis
* This software is provided to St. John's University to be
* used, modified, and distributed at their discretion.
* All other rights reserved.
*/
require_once './php/initialize.php';
$page_style = "scheduler.css";
$page_title = "Scheduler";
/*
* Handles self submit form data and redirects to appropriate search page
*/
$time_start = $time_end = "";
$camp_code = $bldg_code = $room_code = "";
if (isset($_GET['submit'])) {
$search = filter_input(INPUT_GET, 'search');
if ($search === "rooms") {
$camp_code = filter_input(INPUT_GET, 'camp');
$bldg_code = filter_input(INPUT_GET, 'bldg');
$room_code = filter_input(INPUT_GET, 'room');
header('Location: ' . BASE_URL . 'search_rooms.php?camp=' . $camp_code . '&bldg=' . $bldg_code . '&room=' . $room_code . '&submit=Submit');
exit();
} else if ($search === "times") {
$time_start = filter_input(INPUT_GET, 'time-start');
$time_end = filter_input(INPUT_GET, 'time-end');
header('Location: ' . BASE_URL . 'search_times.php?time-start=' . $time_start . '&time-end=' . $time_end . '&submit=Submit');
exit();
} else if ($search === "terms") {
$term_code = filter_input(INPUT_GET, 'term');
$crn_key = filter_input(INPUT_GET, 'crn');
header('Location: ' . BASE_URL . 'search_courses.php?term=' . $term_code . '&crn=' . $crn_key . '&submit=Submit');
exit();
}
}
?>
<html>
<?php include ROOT_DIR . 'php/template/head_template.php'; ?>
<body>
<?php include ROOT_DIR . 'php/template/navigation_template.php'; ?>
<main>
<div class="container">
<div class="row">
<ul class="nav nav-tabs">
<li class="col-xs-4 active" id="search-rooms-tab">
<a class="" href="JavaScript:void(0);">Rooms</a>
</li>
<li class="col-xs-4" id="search-times-tab">
<a class="" href="JavaScript:void(0);">Times</a>
</li>
<li class="col-xs-4" id="search-crn-tab">
<a class="" href="JavaScript:void(0);">Courses</a>
</li>
</ul>
</div>
<div class="row">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="get">
<input type="hidden" name="search" value="rooms">
<div class="row" id="search-rooms">
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="camp">Select Campus</label>
<div>
<select class="form-control" name="camp">
</select>
</div>
</div>
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="bldg">Select Building</label>
<div>
<select class="form-control" name="bldg">
</select>
</div>
</div>
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="room">Select Room</label>
<div>
<select class="form-control" name="room">
</select>
</div>
</div>
</div>
<div class="row" id="search-times">
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="time-start">Select Start Time</label>
<div>
<input class="form-control" type="datetime-local" name="time-start" value="">
</div>
</div>
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="time-end">Select End Time</label>
<div>
<input class="form-control" type="datetime-local" name="time-end" value="">
</div>
</div>
</div>
<div class="row" id="search-crn">
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="term">Select Term</label>
<div>
<select class="form-control" name="term">
</select>
</div>
</div>
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="crn">Enter CRN</label>
<div>
<input type="text" class="form-control" name="crn">
</div>
</div>
</div>
<input type="text" name="search" value="rooms" hidden>
<input class="btn btn-primary col-xs-4 col-xs-offset-4 col-sm-4 col-sm-offset-4" type="submit" name="submit">
</form>
</div>
</div>
</main>
<?php include ROOT_DIR . 'php/template/footer_template.php'; ?>
<script type="text/javascript">
$(function() {
/* Handles switching between search tabs and search page redirect */
$('#search-times').hide();
$('#search-crn').hide();
$('#search-rooms-tab').on('click', function(e) {
e.preventDefault();
$('#search-rooms-tab').addClass('active');
$('#search-times-tab').removeClass('active');
$('#search-crn-tab').removeClass('active');
$('#search-rooms').show();
$('#search-times').hide();
$('#search-crn').hide();
$('input[name=search]').val("rooms");
});
$('#search-times-tab').on('click', function(e) {
e.preventDefault();
$('#search-times-tab').addClass('active');
$('#search-rooms-tab').removeClass('active');
$('#search-crn-tab').removeClass('active');
$('#search-times').show();
$('#search-rooms').hide();
$('#search-crn').hide();
$('input[name=search]').val("times");
});
$('#search-crn-tab').on('click', function(e) {
e.preventDefault();
$('#search-crn-tab').addClass('active');
$('#search-times-tab').removeClass('active');
$('#search-rooms-tab').removeClass('active');
$('#search-crn').show();
$('#search-times').hide();
$('#search-rooms').hide();
$('input[name=search]').val("terms");
});
/* Handles select tag option loading through AJAX calls to functions.php */
let campInput = $("select[name=camp]");
let bldgInput = $("select[name=bldg]");
let roomInput = $("select[name=room]");
let termInput = $("select[name=term]");
campInput.load("php/functions.php?ftype=camp");
termInput.load("php/functions.php?ftype=term");
campInput.on('change', function () {
bldgInput.load("php/functions.php?ftype=bldg&camp=" + campInput.val());
roomInput.load("php/functions.php?ftype=room&bldg=" + bldgInput.val());
}).trigger("change");
bldgInput.on('change', function () {
roomInput.load("php/functions.php?ftype=room&bldg=" + bldgInput.val());
}).trigger("change");
});
</script>
</body>
</html>