-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
472 lines (392 loc) · 16.2 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
<?php ob_start();
$GLOBALS['labelDates'] = array();
?>
<!DOCTYPE html>
<html lang="en">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<body>
<style type="text/css">
.container-flex {
display: flex;
width: 100%;
justify-content: space-between;
}
.card-description{
padding: 10px;
}
</style>
<div class="container-scroller">
<?php
// Function to get all the dates in given range
function getDatesFromRange($start, $end, $format = 'Y-m-d') {
$GLOBALS['labelDates'] = array();
// Declare an empty array
$dates = array();
// Variable that store the date interval
// of period 1 day
$interval = new DateInterval('P1D');
$realEnd = new DateTime($end);
$realEnd->add($interval);
$period = new DatePeriod(new DateTime($start), $interval, $realEnd);
// Use loop to store date into array
foreach($period as $date) {
$dates[] = $date->format($format);
if($date->format($format) == date('Y-m-d'))
$GLOBALS['labelDates'][] = "Today";
else
$GLOBALS['labelDates'][] = $date->format('M-d');
}
$dates = array_reverse($dates) ;
$GLOBALS['labelDates'] = array_reverse( $GLOBALS['labelDates']) ;
// Return the array elements
return $dates;
}
include("includes/header.php");
if (strtolower($_SESSION["role"]) == "entry maker"){
header("Location: addattendanceentry.php");
}
?>
<div class="container-fluid page-body-wrapper">
<?php include("includes/sidebar.php"); ?>
<div class="main-panel">
<div class="content-wrapper">
<div class="row">
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-6 grid-margin stretch-card">
<div class="card card-statistics">
<div class="card-body">
<div class="clearfix">
<div class="float-left">
<i class="mdi mdi-cube text-success icon-lg"></i>
</div>
<div class="float-right">
<p class="mb-0 text-right">Locations</p>
<div class="fluid-container">
<h3 class="font-weight-medium text-right mb-0">4
</h3>
</div>
</div>
</div>
<p class="text-muted mt-3 mb-0">
<i class="mdi mdi-alert-octagon mr-1" aria-hidden="true"></i> More to come soon!
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-6 grid-margin stretch-card">
<div class="card card-statistics">
<div class="card-body">
<div class="clearfix">
<div class="float-left">
<i class="mdi mdi-receipt text-success icon-lg"></i>
</div>
<div class="float-right">
<p class="mb-0 text-right">Entry Makers</p>
<div class="fluid-container">
<h3 class="font-weight-medium text-right mb-0">20</h3>
</div>
</div>
</div>
<p class="text-muted mt-3 mb-0">
<i class="mdi mdi-bookmark-outline mr-1" aria-hidden="true"></i> Total Entry Makers
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-6 grid-margin stretch-card">
<div class="card card-statistics">
<div class="card-body">
<div class="clearfix">
<div class="float-left">
<i class="mdi mdi-poll-box text-success icon-lg"></i>
</div>
<div class="float-right">
<p class="mb-0 text-right">Super Admins</p>
<div class="fluid-container">
<h3 class="font-weight-medium text-right mb-0">2</h3>
</div>
</div>
</div>
<p class="text-muted mt-3 mb-0">
<i class="mdi mdi-calendar mr-1" aria-hidden="true"></i> Total Super Admins
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-6 grid-margin stretch-card">
<div class="card card-statistics">
<div class="card-body">
<div class="clearfix">
<div class="float-left">
<i class="mdi mdi-account-location text-success icon-lg"></i>
</div>
<div class="float-right">
<p class="mb-0 text-right">Employees</p>
<div class="fluid-container">
<h3 class="font-weight-medium text-right mb-0">246</h3>
</div>
</div>
</div>
<p class="text-muted mt-3 mb-0">
<i class="mdi mdi-reload mr-1" aria-hidden="true"></i> Total employees
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-7 grid-margin stretch-card">
<!--weather card-->
<div class="card card-weather">
<div class="card-body">
<div style="float:right;">
<div id="icon"></div>
<h3 id="weather"></h3>
</div>
<div class="weather-date-location">
<h3>Monday</h3>
<p class="text-gray">
<span class="weather-date">25 October, 2016</span>
<span class="weather-location">
<form id="search" class="" role="form" action="javascript:void(0);">
<input type="text" id="city" class="btn btn-success" placeholder="City, country" autocomplete disabled/>
</form>
</span>
</p>
</div>
<div class="weather-data d-flex">
<div class="mr-auto">
<h4 class="display-3"><span id="temp"></span> <span id="unit">°C</span></h4>
<p>
Humidity: <span id="hum"></span> %
</p>
</div>
</div>
</div>
</div>
<!--weather card ends-->
</div>
<div class="col-lg-5 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h2 class="card-title mb-5" style="color:#006a4a;"><b>Employee Stats</b></h2>
<div class="wrapper d-flex justify-content-between">
<div class="side-left">
<p class="mb-2">Admins</p>
<p class="display-3 mb-4 font-weight-light">20%</p>
</div>
<div class="side-right">
<small class="text-muted">2018</small>
</div>
</div>
<div class="wrapper d-flex justify-content-between">
<div class="side-left">
<p class="mb-2">Entry Makers</p>
<p class="display-3 mb-5 font-weight-light">60%</p>
</div>
<div class="side-right">
<small class="text-muted">2018</small>
</div>
</div>
<div class="wrapper">
<div class="d-flex justify-content-between">
<p class="mb-2">Entry Makers</p>
<p class="mb-2" >60%</p>
</div>
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 60%" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" ></div>
</div>
</div>
<div class="wrapper mt-4">
<div class="d-flex justify-content-between">
<p class="mb-2">Visits</p>
<p class="mb-2" >20%</p>
</div>
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 20%" aria-valuenow="20"
aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<?php
$locationList = getlocations();
while($row = mysqli_fetch_assoc($locationList )){
$markedEntries = [];
$dates = [];
$startDate = date('Y-m-d', strtotime('today - 29 days'));
$endDate = date("Y-m-d");
if(strtolower($_SESSION["role"])=="admin" || strtolower($_SESSION["role"])=="entry maker")
$locationName = $_SESSION['location'];
else
$locationName = $row['location_name'];
// Function call with passing the start date and end date
$dates = getDatesFromRange($startDate, $endDate);
for($i=0; $i<sizeof($dates); $i++ ){
if(check_Admin_Entry_Made($locationName, $dates[$i]))
$markedEntries[] = true;
else
$markedEntries[] = false;
}
?>
<div class="row my-2">
<div class="col-md-12">
<div class="card">
<!-- <div class="container-flex">
<div class="flex-start">
<h4 class="card-description"><?php echo $locationName ; ?></h4>
<p > Attendance record log </p>
</div>
<div class="flex-end">
<img src="1.png">
</div>
</div> -->
<div class="card-body">
<h3><?php echo $locationName ; ?></h3>
<p class="card-description">
Attendance record log
</p>
</div>
<div class="card-body">
<canvas id="<?php echo $row['location_name']; ?>" height="30"></canvas>
</div>
</div>
</div>
</div>
<script type="text/javascript">
/* chart.js chart examples */
// chart colors
var colors = ['#007bff','#28a745','#444444','#c3e6cb','#dc3545','#6c757d'];
var chBar = document.getElementById("<?php echo $row['location_name']; ?>");
var lebelsList = <?php echo json_encode( $GLOBALS['labelDates']); ?>;
var markedEntriesList = <?php echo json_encode($markedEntries); ?>;
var chartData = {
labels: lebelsList,
datasets: [{
data: markedEntriesList,
backgroundColor: colors[1]
}]
};
if (chBar) {
new Chart(chBar, {
type: 'bar',
data: chartData,
options: {
scales: {
xAxes: [{
barPercentage: 0.8,
categoryPercentage: 0.7,
scaleLabel: {
display: true,
labelString: 'Last 30 Days'
},
gridLines: {
color: "rgba(0, 0, 0, 0)",
}
}],
yAxes: [{
ticks: {
beginAtZero: false,
display: false
},gridLines: {
color: "rgba(0, 0, 0, 0)",
}
}]
},
legend: {
display: false
}
}
});
}
</script>
<?php
if(strtolower($_SESSION["role"])=="admin" || strtolower($_SESSION["role"])=="entry maker")
break;
}
?>
</div>
<div class="row">
<div class="col-md-12 grid-margin">
<div class="card">
<div class="card-body">
<h4 class="card-title">Overview Bar Chart</h4>
<canvas id="barChart" ></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<?php include("includes/footer.php");?>
</div>
<!-- main-panel ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<script>
var lat = 0,
lon = 0;
$(document).ready(function() {
//Weather through geolocation
if (navigator && navigator.geolocation) {
navigator.geolocation.getCurrentPosition(succesGetPos, errorGetPos);
}
//Weather through city search
$("#search").submit(getCityWeather);
//Unit conversion
$("#unit").click(unitConversion);
});
function succesGetPos(pos) {
var openWeatherURL = "",
corsAwURL = "https://cors-anywhere.herokuapp.com/";
lat = pos.coords.latitude;
lon = pos.coords.longitude;
// The "https://cors-anywhere.herokuapp.com/" url is used to fix the "same-origin policy" (crossorigin) problem with the ajax call.
//If you want to work with navigator.geolocation, JSONP can't solve the issue for every browser due to the different connection type: https on codepen (for making navigator.geolocation works on chrome), http on api.openweathermap (it doesn't seem to work on firefox anyway).
// The "https://cors-anywhere.herokuapp.com/" url actually behaves like a proxy.
openWeatherURL = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&appid=3d3b5a9ac6383aca1ebce6fe9865189d";
$.getJSON(corsAwURL + openWeatherURL, openWeatherCall);
return 0;
}
function errorGetPos() {
alert("Failed to get current position.");
return -1
}
function openWeatherCall(json) {
$("#city").val(json.name + ", " + json.sys.country);
$("#temp").html(json.main.temp.toFixed(1));
$("#hum").html(json.main.humidity);
$("#icon").html("<img src='http://openweathermap.org/img/w/" + json.weather[0]["icon"] + ".png'>");
$("#weather").html(json.weather[0]["description"]);
return 0;
}
function getCityWeather() {
var openWeatherQuery = "http://api.openweathermap.org/data/2.5/weather?q=",
cityName = $("#city").val(),
appid = "&units=metric&appid=3d3b5a9ac6383aca1ebce6fe9865189d",
corsAwURL = "https://cors-anywhere.herokuapp.com/";
$.getJSON(corsAwURL + openWeatherQuery + cityName + appid, openWeatherCall);
return 0;
}
function unitConversion() {
var T = $("#temp").html(),
unit = $("#unit").html();
if (unit == "°C") {
T = (T * 1.8) + 32;
$("#temp").html(T.toFixed(1));
$("#unit").html("°F");
} else {
T = (T - 32) / 1.8;
$("#temp").html(T.toFixed(1));
$("#unit").html("°C");
}
return 0;
}
</script>
</body>
</html>