-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall_games.php
185 lines (163 loc) · 5.91 KB
/
all_games.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
<?php include "access_check.php"; ?>
<?php
include "connect.php";
$pid=$_SESSION['pid'];
?>
<!doctype html>
<html class="sidebar-light fixed sidebar-left-collapsed">
<head>
<?php include "head.php"; ?>
<style>
td{
color:#000000;
}
.ui-pnotify.red .ui-pnotify-container {
background-color: #0088cc !important;
color:#ffffff;
border:0px;
}
</style>
</head>
<body>
<section class="body">
<?php include "header.php"; ?>
<div class="inner-wrapper">
<!-- start: sidebar -->
<?php include "sidebar.php"; ?>
<!-- end: sidebar -->
<section role="main" class="content-body">
<header class="page-header">
<h2>BO HOUSIE</h2>
</header>
<!-- start: page -->
<div class='row'>
<div class="col-xl-12">
<h5 class="font-weight-semibold text-dark text-uppercase mb-3 mt-3">All Games</h5>
<section class="card mt-4">
<div class="card-body">
<table class="table table-responsive-md table-striped mb-0">
<thead>
<tr>
<th>Game</th>
<th>Date</th>
<th>Time</th>
<th>Game Status</th>
<th>Join Game</th>
</tr>
</thead>
<tbody>
<?php
$game_res=mysqli_query($conn, "SELECT g.gid, DATE_FORMAT(schedule, '%W %e %M') as dt, DATE_FORMAT(schedule, '%h:%i %p') as tm, status, cost FROM games g, player_games p where p.gid=g.gid and pid=$pid order by schedule desc;");
while($row=mysqli_fetch_array($game_res))
{
$gid=$row['gid'];
echo "<tr>";
echo "<td><a href='game.php?gid=$gid'><b>Game #$gid</b></a></td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
if($row['status'] == 0) {$status="<span class='badge badge-danger'>Game Over</span>";}
else if($row['status'] == 1) {$status="<span class='badge badge-success'>In Progress</span>";}
else if($row['status'] == 2) {$status="<span class='badge badge-warning'>Game Paused</span>";}
else if($row['status'] == 3) {$status="<span class='badge badge-primary'>Game Scheduled</span>";}
echo "<td>$status</td>";
if($row['status'] == 0)
{
echo "<td id='gerr$gid'><a href='game.php?gid=$gid'><button type='button' class='mb-1 mt-1 mr-1 btn btn-xs btn-danger' DISABLED>GAME OVER - YOU CANT JOIN</button></a></td>";
}
else
{
$sub_res=mysqli_query($conn, "SELECT * FROM player_games where gid=$gid and pid='$pid';");
if(mysqli_num_rows($sub_res) > 0)
{
echo "<td id='gerr$gid'><a href='game.php?gid=$gid'><button type='button' class='mb-1 mt-1 mr-1 btn btn-xs btn-success'>JOINED (VIEW GAME)</button></a></td>";
}
else
{
$cost = $row[4]>0? $row[4]." points" : "<span style='color:yellow;'>FREE GAME</span>";
echo "<td id='gerr$gid'><button type='button' class='mb-1 mt-1 mr-1 btn btn-xs btn-primary' onclick='buy_ticket($pid,$gid);'>JOIN GAME ($cost)</button></td>";
}
}
echo "</tr>";
}
?>
</tbody>
</table>
<!-- <div align='right'><a href=''>More...</a></div> -->
</div>
</section>
</div>
</div>
</section>
</div>
</section>
<!-- Vendor -->
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
<script src="vendor/popper/umd/popper.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.js"></script>
<script src="vendor/common/common.js"></script>
<script src="vendor/nanoscroller/nanoscroller.js"></script>
<script src="vendor/magnific-popup/jquery.magnific-popup.js"></script>
<script src="vendor/jquery-placeholder/jquery-placeholder.js"></script>
<!-- Specific Page Vendor -->
<script src="vendor/jquery-ui/jquery-ui.js"></script>
<script src="vendor/jqueryui-touch-punch/jqueryui-touch-punch.js"></script>
<script src="vendor/jquery-appear/jquery-appear.js"></script>
<script src="vendor/owl.carousel/owl.carousel.js"></script>
<!-- Theme Base, Components and Settings -->
<script src="js/theme.js"></script>
<script src="js/examples/examples.modals.js"></script>
<script src="vendor/pnotify/pnotify.custom.js"></script>
<!-- Theme Custom -->
<!--<script src="js/custom.js"></script>-->
<!--<script src="js/housie.js"></script> -->
<!-- Theme Initialization Files -->
<script src="js/theme.init.js"></script>
<script>
//BUY_TICKET......
function buy_ticket(pid, gid)
{
var er = "gerr" + gid;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==1)
{
document.getElementById(er).innerHTML="Joining Game...!";
}
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(er).innerHTML=xmlhttp.responseText;
get_points();
}
}
xmlhttp.open("GET","buy_ticket.php" + "?pid=" + pid + "&gid=" + gid, true);
xmlhttp.send();
}
</script>
<script>
var source = new EventSource("login_alert.php");
source.onmessage = function(event) {
if(event.data != "0")
{
new PNotify({
title: 'New Login!',
text: event.data,
addclass: 'red notification-primary',
icon: 'fab fa-twitter',
delay:1000
});
}
}
</script>
<br><br>
<?php include "footer.php"; ?>
</body>
</html>