-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
534 lines (498 loc) · 21.5 KB
/
index.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
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
<?php
session_start();
error_reporting(0);
include './includes/dbconfig.php';
if($con){
$result = mysqli_query($con,"SHOW TABLES");
$tableList=array();
while($cRow = mysqli_fetch_array($result))
{
$tableList[] = $cRow[0];
}
if(in_array('users',$tableList) && in_array('list_for_the_day',$tableList)){
}
else{
echo "<script>window.location.href ='install.php';</script>";
die();
}
}
else{
echo "<h1>Please update Database configuration</h1>";
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
<title>KCTT League App</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="js/bootstrapvalidator-master/dist/css/bootstrapValidator.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui.css">
<!-- Custom CSS -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container col-lg-offset-5 col-md-offset-5 col-sm-offset-5 col-xs-offset-4">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand myLogo" href="#"><img src="images/logo.png"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a id="viewListButton" style="cursor: pointer">View List</a>
</li>
<li>
<a id="addNewPlayerLink" style="cursor: pointer">Add New User</a>
</li>
<li>
<a id="refreshMe" style="cursor: pointer">Start Over</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<div class="clearfix" style="margin-top: 60px"></div>
<!-- Page Content -->
<div class="container" id="importDiv">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<?php
if(isset($_SESSION['success'])){
echo '<div class="alert alert-success" role="alert" id="alrt_success"><strong>Install completed successfully! Ready for CSV import</strong></div>';
unset($_SESSION['success']);
}
?>
<h1>Import Players</h1>
<div id="errorFlag"></div>
<form name="importForm" id="importForm" enctype="multipart/form-data">
<div class="box-body">
<div class="form-group">
<label for="exampleInputFile">Select File *</label>
<input type="file" id="importInputFile" name="importInputFile" />
<p class="help-block">.csv</p>
</div>
<div class="progress progress-sm active">
<div style="width:0%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="20" role="progressbar" id="progress-bar" class="progress-bar progress-bar-success progress-bar-striped">
<span class="sr-only"></span>
</div>
</div>
<div class="box-footer">
<button class="btn btn-primary" id="ajaxImportUpload" type="submit">Submit</button>
<button class="btn btn-primary" id="viewListButton" type="button" style="display: none">View List</button>
</div>
</div>
</form>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<div class="clearfix" style="margin-top: 60px"></div>
<div class="container" id="dualListDiv" style="display: none">
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="panel panel-info">
<div class="panel-heading">
<h4><i class="fa fa-fw fa-check"></i>All Players<button type="button" id="leftSortButton" class="btn btn-warning pull-right">Sort</button></h4>
</div>
<div class="panel-body">
<div class="form-group">
<input type="text" class="form-control" name="searchLeft" id="searchLeft" placeholder="Search by USATT Member ID, Name or Email" />
</div>
<ul class="source connected">
</ul>
</div>
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="panel panel-success">
<div class="panel-heading">
<h4><i class="fa fa-fw fa-check"></i>Today's Players<button type="button" id="rightSortButton" class="btn btn-warning pull-right">Sort</button></h4>
</div>
<div class="panel-body">
<div class="right">
<ul class="target connected">
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="row"><div class="col-lg-9"><button type="button" class="btn btn-primary pull-right btn-lg" id="processButton">Create Groups</button></div></div>
<br>
</div>
<div class="container" id="addNewPlayerContainer" style="display: none">
<div class="row">
<div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="panel panel-info">
<div class="panel-heading"><strong>Add New Player</strong></div>
<div class="panel-body">
<form role="form" id="addUserForm" method="post" action="addNewPlayer.php">
<div id="messageAlert"></div>
<div class="col-md-12">
<div class="form-group">
<label>First Name</label>
<input class="form-control" name="firstname" id="firstname" type="text" autocomplete="off"/>
</div>
<div class="form-group">
<label>Last Name</label>
<input class="form-control" name="lastname" id="lastname" type="text" autocomplete="off"/>
</div>
<div class="form-group">
<label>Middle Name</label>
<input class="form-control" name="mname" id="mname" type="text" autocomplete="off"/>
</div>
<div class="form-group">
<label>Birth Date (MM/DD/YYYY)</label>
<input type="text" class="form-control" name="bdate" id="datetimePicker"/>
</div>
<div class="form-group">
<label>Sex</label>
<div class="radio">
<label>
<input type="radio" name="emodel" id="M" value="M">Male
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="emodel" id="F" value="F">Female
</label>
</div>
</div>
<div class="form-group">
<label>Email</label>
<input class="form-control" name="email" id="email" type="text" autocomplete="off"/>
</div>
<div class="form-group">
<label>League Rating</label>
<input class="form-control" name="rating" id="rating" type="text" autocomplete="off"/>
</div>
<div class="form-group">
<label>USATT Member ID</label>
<input class="form-control" name="usatt" id="usatt" type="text" autocomplete="off"/>
</div>
<button type="submit" class="btn btn-primary">Create Player</button>
<button type="reset" class="btn btn-default" id="resetForm"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button>
</div>
</form>
</div>
</div>
</div><!-- /.col-->
</div><!-- /.row -->
</div>
<div class="container" id="finalListDiv" style="display: none">
<div class="row" id="finalListrow">
</div>
</div>
<!-- jQuery Version 1.11.1 -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrapvalidator-master/dist/js/bootstrapValidator.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/daterangepicker.js"></script>
</body>
</html>
<script>
$('#addNewPlayerLink').click(function (){
//$('#finalListrow').hide('slow').fadeOut('3000');
$('#importDiv').hide('slow').fadeOut('3000');
$('#dualListDiv').hide('slow').fadeOut('3000');
$('#addNewPlayerContainer').show('slow').fadeIn('3000');
});
$('#importForm').submit(function(e) {
var formData = new FormData(this);
$.ajax({
type:'POST',
url: "insertPlayers.php",
data:formData,
beforeSend: function(){
$('#ajaxImportUpload').prop("disabled", true);
},
xhr: function() {
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener('progress',progress, false);
}
return myXhr;
},
cache:false,
contentType: false,
processData: false,
dataType : "json",
success:function(response){
if(response.error=='true'){
$('#importForm')[0].reset();
$('#progress-bar').css('width','0%');
$('#ajaxImportUpload').prop("disabled", false);
$('#errorFlag').html('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>Error! '+response.msg+'</strong></div>');
}
else if(response.error=='false'){
$('#errorFlag').html('<div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>Success! '+response.msg+'</strong></div>');
//$('#viewListButton').show().fadeIn("slow");
setTimeout(function(){ $("#viewListButton").trigger("click"); },1000);
}
}
});
e.preventDefault();
});
$('#viewListButton').click(function (){
//$(this).hide();
$.ajax({
type:'POST',
url: "getPlayers.php",
success:function(response){
$("ul.source").html(response);
}
});
$('#importDiv').hide('slow').fadeOut('3000');
//$('#finalListrow').hide('slow').fadeOut('3000');
$('#addNewPlayerContainer').hide('slow').fadeOut('3000');
$('#dualListDiv').show('slow').fadeIn('3000');
});
$('#processButton').click(function (){
//get target list
var items = [];
$("ul.target").children().each(function() {
var item = $(this).attr('data-id');
items.push(item);
});
var jsonData = JSON.stringify(items);
$.ajax({
type:'POST',
url: "selectedPlayers.php",
data: {
user_id : jsonData
},
success:function(response){
$('#dualListDiv').hide('slow').fadeOut('3000');
$('#finalListDiv').show('slow').fadeIn('3000');
$('#finalListrow').html(response);
$( ".sortable_list" ).sortable({
connectWith: ".connectedSortable",
placeholder: "placeholder",
start: function (event, ui) {
ui.item.toggleClass("placeholder");
},
stop: function (event, ui) {
ui.item.toggleClass("placeholder");
}
}).disableSelection();
}
});
});
function progress(e){
if(e.lengthComputable){
var max = e.total;
var current = e.loaded;
var Percentage = (current * 100)/max;
$('#progress-bar').css('width',Percentage+'%');
$('.sr-only').html(Percentage+'%');
if(Percentage >= 100)
{
// process completed
}
}
}
$('#searchLeft').keyup(function(){
var searchText = $(this).val().toLowerCase();
$('.source > li').each(function(){
var currentLiText = $(this).text().toLowerCase(),
showCurrentLi = currentLiText.indexOf(searchText) !== -1;
$(this).toggle(showCurrentLi);
});
});
</script>
<script type="text/javascript">
$(document).on('click','.allSortButton',function (){
$(this).closest('h4').closest('div').next().children("ul").children().sort(sort_li).appendTo($(this).closest('h4').closest('div').next().children("ul"));
});
$('#leftSortButton').click(function (){
$(".source li").sort(sort_li).appendTo('.source');
//$('#leftSortButton').closest('h4').closest('div').next().children("ul").children().sort(sort_li).appendTo($('#leftSortButton').closest('h4').closest('div').next().children("ul"));
});
$('#rightSortButton').click(function (){
$(".target li").sort(sort_li).appendTo('.target');
});
function sort_li(a, b){
return ($(b).data('rating')) > ($(a).data('rating')) ? 1 : -1;
}
$(function () {
$(".source, .target").sortable({
connectWith: ".connected",
placeholder: "placeholder",
start: function (event, ui) {
ui.item.toggleClass("placeholder");
},
stop: function (event, ui) {
ui.item.toggleClass("placeholder");
}
}).disableSelection().on('click', '.click_area', function(){
$(this).appendTo($(".source, .target").not($(this).closest("ul")));
});
});
</script>
<script type="text/javascript">
$(function() {
$( ".sortable_list" ).sortable({
connectWith: ".connectedSortable",
/*stop: function(event, ui) {
var item_sortable_list_id = $(this).attr('id');
console.log(ui);
//alert($(ui.sender).attr('id'))
},*/
receive: function(event, ui) {
alert("dropped on = "+this.id); // Where the item is dropped
alert("sender = "+ui.sender[0].id); // Where it came from
alert("item = "+ui.item[0].innerHTML); //Which item (or ui.item[0].id)
}
}).disableSelection();
});
$(function() {
$('#datetimePicker').daterangepicker({
singleDatePicker: true,
showDropdowns: true
});
$('#expiration').daterangepicker({
singleDatePicker: true
});
$('#last_played').daterangepicker({
singleDatePicker: true
});
});
$('#resetForm').click(function(){
var $form = $('#addUserForm');
$form.bootstrapValidator('resetForm', true);
});
$('#addUserForm').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
firstname: {
message: 'The First Name entered is not valid.',
validators: {
notEmpty: {
message: 'The First Name is required and can\'t be empty.'
},
stringLength: {
min: 2,
max: 30,
message: 'The First Name must be more than 2 and fewer than 30 characters long.'
},
regexp: {
regexp: /^[a-zA-Z]+$/,
message: 'The First Name can only consist of alphabetical characters.'
}
}
},
lastname: {
validators: {
notEmpty: {
message: 'The Last Name is required and can\'t be empty.'
},
stringLength: {
min: 2,
max: 30,
message: 'The Last Name must be more than 2 and less than 30 characters long.'
},
regexp: {
regexp: /^[a-zA-Z]+$/,
message: 'The Last Name can only consist of alphabetical characters.'
}
}
},
bdate: {
validators: {
notEmpty: {
message: 'Birth Date is required and cannot be empty.'
}
}
},
emodel:{
},
usatt:{
validators: {
stringLength: {
min: 1,
max: 30,
message: 'The USATT Member ID must be more than 1 and less than 30 characters long.'
},
regexp: {
regexp: /^[0-9]+$/,
message: 'The USATT Member ID can only consist of numbers.'
}
}
},
email:{
validators:{
emailAddress : {
message: 'Please enter a valid email address.'
}
}
},
rating :{
validators:{
regexp: {
regexp: /^[0-9]+$/,
message: 'The League Rating can only consist of numbers.'
}
}
}
}
})
.on('success.form.bv', function(e) {
// Prevent form submission
e.preventDefault();
// Get the form instance
var $form = $(e.target);
// Get the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Use Ajax to submit form data
$.post($form.attr('action'), $form.serialize(), function(result) {
if(result.error=="false"){
$('#messageAlert').html('<div class="alert alert-success" role="alert"><strong>'+result.msg+'.</strong></div>');
$form.bootstrapValidator('resetForm', true);
}
else{
$('#messageAlert').html('<div class="alert alert-danger" role="alert"> <strong>Something Went Wrong</strong></div>');
$form.bootstrapValidator('resetForm', true);
}
}, 'json');
});
$('#refreshMe').click(function (){
location.reload();
});
setTimeout(function() {
$("#alrt_success").hide('blind', {}, 500)
}, 5000);
</script>