-
Notifications
You must be signed in to change notification settings - Fork 2
/
history.php
184 lines (165 loc) · 7.3 KB
/
history.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
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] != true) {
header("location: login.php");
}
$connect = mysqli_connect('localhost', 'root', '', 'login')
or die('error connect to server');
date_default_timezone_set('Asia/Kolkata');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="keywords" content="footer, address, phone, icons" />
<link rel="icon" href="../public/assets/24-hours.png" sizes="40x40" type="image/svg">
<title>Anavadya</title>
<link rel="stylesheet" type="text/css" href="public/css/main.css">
<!-- Link to Bootstrap-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<!--Link to morris-->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<!-- Link to font awesome-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script>
$(function() {
// $("#navid").load("partials/header.php");
$("#footid").load("partials/footer.php");
});
</script>
</head>
<body>
<!-- <div id="navid"></div> -->
<nav id="mainNavbar" class=" stroke navbar navbar-expand-md fixed-top navbar-dark">
<a class="navbar-brand">
<img class="navlogo" src="public/assets/24-hours.png"> Anavadya
</a>
<button class="navbar-toggler nav-toggle-btn" type="button" data-toggle="collapse" data-target="#navLinks" aria-label="Toggle navigation">
<span class="navbar-toggler-icon">
</span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navLinks">
<ul class="navbar-nav">
<li class="nav-item active">
<a href="home.php" class="nav-link">Home</a>
</li>
<li class="nav-item">
<a href="buildingDetails.php" class="nav-link">Building Details</a>
</li>
<li class="nav-item">
<a href="occupancy.php" class="nav-link">Occupancy</a>
</li>
<li class="nav-item">
<a href="contacts.php" class="nav-link">Contact Us</a>
</li>
<?php
if($_SESSION["room"]==0)
{ ?>
<li class="nav-item">
<a href="register.php" class="nav-link" id="signin">Register</a>
</li>
<?php }
if (isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == true) {
?>
<li class="nav-item">
<a href="logout.php" class="nav-link">Logout</a>
</li>
<?php
} else {
?>
<li class="nav-item">
<a href="login.php" class="nav-link">Login</a>
</li>
<?php
}
?>
</ul>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#"><img src="https://img.icons8.com/metro/26/ffffff/user-male.png" /><?php echo "Welcome " . $_SESSION['username'] ?></a>
</li>
</ul>
</div>
</nav>
<style rel="stylesheet" type="text/css">
body {
background-image: linear-gradient(-225deg, #DFFFCD 0%, #90F9C4 48%, #39F3BB 100%);
}
</style>
<div class="container">
<h1 style="padding-top: 5rem;">Room no
<?php
$room = $_GET['room'];
echo $room ?></h1>
<form method="POST">
<label for="getdate">Select Date </label>
<input type="date" id="getdate" name="getdate" required>
<input type="submit" name="Submit">
</form>
<?php
$hd="";
if(isset( $_POST['Submit']))
{$hd=$_POST['getdate'];}
$td = date("Y-m-d", time());
$th = date("H", time());
if($hd !="" && $hd<=$td)
{
echo "Selected Date: ". $hd;
$hh=23;
if($td==$hd)
$hh=$th;
$query = "SELECT * FROM roomoccupncy where DATE(timeVal)='" . $hd . "'AND roomno=" . $room . " AND HOUR(timeVal) <='" . $hh . "'";
$result = mysqli_query($connect, $query);
$chart_data = '';
while ($row = mysqli_fetch_array($result)) {
$chart_data .= "{ time: '" . $row["timeVal"] . "', occupancy: " . $row["strength"] . "}, ";
}
if ($chart_data == '') {
$temp = "INSERT into roomoccupncy (timeVal, roomno, strength) VALUES";
$sql = "";
for ($i = 0; $i <= 8; $i++) {
$temp = $temp . "('" . $hd . " 0" . $i . ":00:00', " . $room . ", 0), ";
}
$temp = $temp . "('" . $hd . " 0" . $i . ":00:00', " . $room . ", 5), ";
for ($i = 10; $i <= 20; $i++) {
$temp = $temp . "('" . $hd . " " . $i . ":00:00', " . $room . ", " . rand(20, 45) . "), ";
}
for ($i = 21; $i <= 23; $i++) {
$temp = $temp . "('" . $hd . " " . $i . ":00:00', " . $room . ", 0), ";
}
$temp = substr($temp, 0, -2);
if (mysqli_query($connect, $temp)) {
$result = mysqli_query($connect, $query);
while ($row = mysqli_fetch_array($result)) {
$chart_data .= "{ time: '" . $row["timeVal"] . "', occupancy: " . $row["strength"] . "}, ";
}
} else {
echo "fail";
}
}
$chart_data = substr($chart_data, 0, -2); }
?>
<br> <br> <br>
<div id="chart"> </div>
</div>
<div id="footid"></div>
</body>
</html>
<script>
Morris.Area({
element: 'chart',
data: [<?php echo $chart_data; ?>],
xkey: 'time',
ykeys: ['occupancy'],
labels: ['Occupancy'],
hideHover: 'auto',
stacked: true
});
</script>