-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathleaderboard.php
183 lines (151 loc) · 8.66 KB
/
leaderboard.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
<?php
session_start();
if(isset($_SESSION['username'])){
$username = $_SESSION['username'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Net Worth</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Poppins:400,700,900&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/36afc40636.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/dashboard.css">
<link rel="stylesheet" href="css/navbar.css">
<link rel="icon" type="image/x-icon" href="./img/Purple logo Group.png">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light container-fluid" id="header__nav">
<?php include('logo.php'); ?>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto navbar__menu">
<?php if(!isset($username)): ?>
<?php else: ?>
<?php include('nav.php'); ?>
<?php endif; ?>
</ul>
</div>
</nav>
</header>
<section>
<main class="container">
<div class="row" style="margin-top:20px;">
<div class="main_pad col-xs-12 col-sm-12 col-md-5 col-lg-7 offset-md-3 offset-lg-3">
<h1 class="main__caption mt-1 mb-3">Leaderboard </h1>
<span class="badge badge-primary">Check Leaders on specific dates</span>
<div class="line-through" style="width:100%;"></div>
<div class="description__advantages">
<form action="processleaderboard.php" method="POST">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="">Start Date</label>
<input type="date" name="startdate" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="">End Date</label>
<input type="date" name="enddate" class="form-control">
</div>
</div>
</div>
<button type="submit" class="btn btn-primary" name="leaderboard">Fetch</button>
</form>
</div>
</div>
</div>
<div class="row" style="margin-top:50px;">
<div class="main_pad col-xs-12 col-sm-12 col-md-5 col-lg-7 offset-md-3 offset-lg-3">
<h1 class="main__caption mt-1 mb-3">Richest People in Deimos </h1>
<div class="table-responsive">
<table class="table table-hover table-bordered">
<thead>
<th>Initial</th>
<th>Networth (₦)</th>
<th>Date</th>
</thead>
<tbody>
<?php if(isset($_SESSION['data']) ):
$data = $_SESSION['data'];
?>
<?php foreach($data as $leader) : ?>
<tr>
<?php
$string = $leader['username'];
$expr = '/(?<=\s|^)[a-z]/i';
preg_match_all($expr, $string, $matches);
$result = implode('', $matches[0]);
$result = strtoupper($result);
?>
<td>
<span class="badge badge-info" style="border-radius:50%;"><?php echo $result; ?>
</span>
</td>
<?php $netw = (int)$leader['networth'];?>
<?php if ($netw < 0): ?>
<td><?php echo number_format($leader['networth']); ?> (debtor)</td>
<?php else: ?>
<td><?php echo number_format($leader['networth']); ?></td>
<?php endif; ?>
<td><?php echo date('M j', strtotime($leader['created_at']) ); ?></td>
</tr>
<?php endforeach; ?>
<?php unset($_SESSION['data']); ?>
<?php elseif(isset($_SESSION['data_default']) ):
$data = $_SESSION['data_default'];
?>
<?php foreach($data as $leader) : ?>
<tr>
<?php
$string = $leader['username'];
$expr = '/(?<=\s|^)[a-z]/i';
preg_match_all($expr, $string, $matches);
$result = implode('', $matches[0]);
$result = strtoupper($result);
?>
<td><span class="badge badge-info" style="border-radius:50%;">
<?php echo $result; ?></span>
</td>
<?php $netw = (int)$leader['networth'];?>
<?php if ($netw < 0): ?>
<td><?php echo number_format($leader['networth']); ?> (debtor)</td>
<?php else: ?>
<td><?php echo number_format($leader['networth']); ?></td>
<?php endif; ?>
<td><?php echo date('M j', strtotime($leader['created_at']) ); ?></td>
</tr>
<?php endforeach; ?>
<?php unset($_SESSION['data_default']); ?>
<?php elseif(isset($_SESSION['lb']) ): ?>
<div class="alert alert-danger">
<span style="font-size:13px; font-weight:bold;">
<span><?php echo "No record found for that date.Please try a different date"; ?> </span>
<?php unset($_SESSION['lb']); ?>
</span>
</div>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</main>
</section>
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="js/dashboard.js"></script>
</body>
</html>