/
terminal.php
376 lines (324 loc) · 15.1 KB
/
terminal.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
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
<?php
require_once 'connection.php';
$session = new Session();
if (!$session->getLoggedin()||$session->getUsertype()!=Session::USER_ADMIN) {
header("Location: login.php");
}
$olddb = new Database(DB_SERVER, DB_USER, DB_PASS, "nitcfest_tathva14");
$oldevents = Event::selectAllShort($olddb);
$oldoptions = "";
foreach ($oldevents as $event) {
$oldoptions .= "<option value='{$event['code']}'>{$event['name']}</option>";
}
$events = Event::selectAllShort($db);
$options = "";
foreach ($events as $event) {
$options .= "<option value='{$event['code']}'>{$event['name']}</option>";
}
require './includes/metadetails.php';
?>
<body>
<?php require './includes/header.php'; ?>
<div class="container-fluid">
<?php echo $session->getUsertype(); ?>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#reglist" aria-controls="reglist" role="tab" data-toggle="tab">T14 Reglist</a></li>
<li role="presentation"><a href="#reglist15" aria-controls="reglist15" role="tab" data-toggle="tab">T15 Reglist</a></li>
<li role="presentation"><a href="#users" aria-controls="users" role="tab" data-toggle="tab">Users</a></li>
<li role="presentation"><a href="#events" aria-controls="events" role="tab" data-toggle="tab">Event List</a></li>
<li role="presentation"><a href="#pre-events" aria-controls="eventm" role="tab" data-toggle="tab">T14 Events</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="reglist">
<h2>TATHVA '14 REGISTERATION LIST</h2>
<form action="get.php" id="regform" method="post">
<select name="eventcode" id="event-select">
<option value="">--events--</option>
<?= $oldoptions ?>
</select>
<input type="hidden" name="type" value="reglistold" />
<input name="ersubmit" type="submit" value="Get Event Reg List">
</form>
<div>
<h1 id="noregdetails">No Registerations found for this event</h1>
<table id="regDetails" class="table table-condensed">
<thead>
<th>TEAM ID</th>
<th>TATHVA ID</th>
<th>NAME</th>
<th>CONTACT</th>
<th>EMAIL</th>
<th>COLLEGE</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="reglist15">
<h2>TATHVA '15 REGISTERATION LIST</h2>
<form action="get.php" id="regform15" method="post">
<select name="eventcode" id="event-select15">
<option value="">--events--</option>
<?= $options ?>
</select>
<input type="hidden" name="type" value="reglist" />
<input name="ersubmit" type="submit" value="Get Event Reg List">
</form>
<div>
<h1 id="noregdetails15">No Registerations found for this event</h1>
<table id="regDetails15" class="table table-condensed">
<thead>
<th>TEAM ID</th>
<th>TATHVA ID</th>
<th>NAME</th>
<th>CONTACT</th>
<th>EMAIL</th>
<th>COLLEGE</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="users">
<div id="users">
<h1>Users</h1>
<table class="table table-condensed">
<thead>
<tr><th>ROLLNUMBER</th><th>Username</th>
<th>Password</th><th>Eventcode</th>
<th>Validation</th><th>Delete</th>
</tr>
</thead>
<tbody>
<?php
$users = User::selectAll($db);
foreach ($users as $user) {
$val = ($user->getValidate() == 0) ? "validate" : "invalidate";
$det = "<tr><td>".$user->getRoll()."</td>".
"<td>".$user->getName()."</td>".
"<td>".$user->getPassword()."</td>".
"<td>".$user->getEventcode()."</td>".
'<td><a class="u-validate-btn btn btn-default btn-xs" data-name="'.$user->getName().'">'
.$val.'</a></td>'
.'<td><a class="u-delete-btn btn btn-danger btn-xs" data-name="'.$user->getName().'">delete</a></td></tr>';
echo $det;
}
?>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="events">
<div id="events">
<h1>Events</h1>
<table class="table table-condensed">
<thead><tr>
<th>Code</th>
<th>Event Name</th>
<th>Category</th>
<th>Validation</th>
<th>Delete</th>
<th>Edit Event</th>
<th>Show Details</th>
</tr></thead>
<tbody>
<?php
$query = "SELECT code, name, (SELECT name FROM event_cats WHERE event_cats.cat_id=events.cat_id) AS cat, validate FROM events";
$result = $db->query($query);
$eventDetails = $db->getJSONArray($result);
$eventList = "";
foreach ($eventDetails as $row) {
$val = ($row['validate'] == 0) ? "validate" : "invalidate";
$det = "<tr><td>".$row['code']."</td>".
"<td>".$row['name']."</td>".
"<td>".$row['cat']."</td>".
'<td><a class="e-validate-btn btn btn-default btn-xs" data-name="'.$row['code'].'">'
.$val.'</a></td>'
.'<td><a class="e-delete-btn btn btn-danger btn-xs" data-name="'.$row['code'].'">delete</a></td>'
. '<td><a class="btn btn-default btn-xs" href="event.php?eventcode='.$row['code'].'" target="_blank">Edit Event</a></td>'
. '<td><a class="btn btn-default btn-xs" href="showevent.php?eventcode='.$row['code'].'" target="_blank">show details</a></td>'
. '</tr>';
echo $det;
}
?>
</tbody>
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="pre-events">
<?php
$db = new Database(DB_SERVER, DB_USER, DB_PASS, "nitcfest_tathva14");
$query = "SELECT * FROM events";
$result = $db->query($query);
$events = $db->getJSONArray($result);
foreach ($events as $event) {
echo '<a href="showpreevent.php?eventcode='.$event['code'].'" target="_blank" class="btn btn-default stacked"'.
'>'.$event['name'].'</a>';
}
?>
</div>
</div>
</div>
<div class="progress-dialog hide">
<img src="img/loader.gif" />
<p>Processing...</p>
</div>
<div class="fade-div hide" id="fade-div"></div>
<script>
var $progressDialog = $(".progress-dialog");
var $fadeDiv = $("#fade-div");
function showProgress(){
$progressDialog.removeClass("hide");
$fadeDiv.removeClass("hide");
}
function hideProgress(){
$progressDialog.addClass("hide");
$fadeDiv.addClass("hide");
}
var $noregtext = $("#noregdetails");
var $regDetails = $("#regDetails");
$noregtext.hide();
$regDetails.hide();
$("#regform").submit(function(){
if($("#event-select").val()=="") return false;
showProgress();
var data = $("#regform").serialize();
$.getJSON("./get.php",data,function(data){
hideProgress();
if(data.status=='success'){
if(data.data.length==0){
$noregtext.slideDown(500);
$regDetails.hide();
}else{
$noregtext.hide();
var arr = data.data;
var det = "";
for(var i=0;i<arr.length;i++){
det += '<tr><td>'+arr[i].team_id+"</td>"+
'<td>'+arr[i].tat_id+"</td>"+
'<td>'+arr[i].name+"</td>"+
'<td>'+arr[i].phone+"</td>"+
'<td>'+arr[i].email+"</td>"+
'<td>'+arr[i].clg+"</td></tr>";
}
$regDetails.find("tbody").html(det);
$regDetails.hide().slideDown(500);
}
}else{
alert("this shouldnt be happening!! some kind of error occured");
}
});
return false;
});
var $noregtext15 = $("#noregdetails15");
var $regDetails15 = $("#regDetails15");
$noregtext15.hide();
$regDetails15.hide();
$("#regform15").submit(function(){
if($("#event-select15").val()=="") return false;
showProgress();
var data = $("#regform15").serialize();
$.getJSON("./get.php",data,function(data){
hideProgress();
if(data.status=='success'){
if(data.data.length==0){
$noregtext15.slideDown(500);
$regDetails15.hide();
}else{
$noregtext15.hide();
var arr = data.data;
var det = "";
for(var i=0;i<arr.length;i++){
det += '<tr><td>'+arr[i].team_id+"</td>"+
'<td>'+arr[i].tat_id+"</td>"+
'<td>'+arr[i].name+"</td>"+
'<td>'+arr[i].phone+"</td>"+
'<td>'+arr[i].email+"</td>"+
'<td>'+arr[i].clg+"</td></tr>";
}
$regDetails15.find("tbody").html(det);
$regDetails15.hide().slideDown(500);
}
}else{
alert("this shouldnt be happening!! some kind of error occured");
}
});
return false;
});
$(".u-validate-btn").click(function(){
showProgress();
var ele = $(this);
var uname = $(this).attr("data-name");
var val = $(this).text();
$.getJSON('./get.php',{type:'usermanipulation',username:uname,userop:val},function(data){
hideProgress();
//console.log(JSON.stringify(data));
if(data.status=='success'){
if(val=='validate') ele.text("invalidate");
else ele.text('validate');
}else{
alert("this shouldnt be happening!! some kind of error occured");
}
});
return false;
});
$(".u-delete-btn").click(function(){
showProgress();
var ele = $(this);
var uname = $(this).attr("data-name");
$.getJSON('./get.php',{type:'usermanipulation',username:uname,userop:'delete'},function(data){
hideProgress();
console.log(JSON.stringify(data));
if(data.status=='success'){
ele.parent("tr").remove();
ele.parent().parent().remove();
}else{
alert("this shouldnt be happening!! some kind of error occured");
}
});
return false;
});
$(".e-validate-btn").click(function(){
showProgress();
var ele = $(this);
var uname = $(this).attr("data-name");
var val = $(this).text();
$.getJSON('./get.php',{type:'eventmanipulation',eventcode:uname,eventop:val},function(data){
hideProgress();
console.log(JSON.stringify(data));
if(data.status=='success'){
if(val=='validate') ele.text("invalidate");
else ele.text('validate');
}else{
alert("this shouldnt be happening!! some kind of error occured");
}
});
return false;
});
$(".e-delete-btn").click(function(){
showProgress();
var ele = $(this);
var uname = $(this).attr("data-name");
$.getJSON('./get.php',{type:'eventmanipulation',eventcode:uname,eventop:'delete'},function(data){
hideProgress();
console.log(JSON.stringify(data));
if(data.status=='success'){
ele.parent("tr").remove();
ele.parent().parent().remove();
}else{
alert("this shouldnt be happening!! some kind of error occured");
}
});
return false;
});
/*var $regDetails = $("#regDetails");
var $regSelect = $("#event-select");
$regSelect.change(function(val){
var val = $(this).val();
$.get
});*/
</script>
</body>
</html>