-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.php
80 lines (68 loc) · 2.66 KB
/
device.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
<?php
session_start();
include("_func_info.php");
if ($_SESSION["userid"]==null) {
gotoThePage($homepage);
exit;
}
?>
<?php include 'header.php'; ?>
<a href="#CreateDevice" role="button" class="btn span1 offset0 btn-success" data-toggle="modal">Create</a>
<div id="CreateDevice" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
<h3 id="myModalLabel">Configure your Device</h3>
</div>
<div class="modal-body">
<form action="_manage_device.php" method="post">
<input type="text" placeholder="name" style="height:40px;" name='deviceName'>
<input type="text" placeholder="Description" style="height:80px; width:500px;" name='description'>
type:<select name='deviceType'>
<option value=0>Default</option>
<option value=1>Humidity</option>
<option value=2>Luminance</option>
<option value=3>Temperature</option>
</select>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary" value='Create Device'>
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</form>
</div>
</div>
<?php
$userid = $_SESSION['userid'];
$result = mysqli_query($dbcon, "select * from $tb_device where userid='$userid';") or die("database Fail selection!");
if (mysqli_num_rows($result)== 0)
echo "<div class = 'span15 offset1' align='center'><h1> </h1><h2>Oops, You haven't add any devices yet</h2></div>";
else {
echo "
<div name='device table' class = 'span15'>
<table class = 'span14' style='text-align: center;'>
<tr>
<td class='span1'></td>
<td class='span3'><h2>Device ID</h2></td>
<td class='span4'><h2>Device Name</h2></td>
<td class='span5'><h2>Manage</h2></td>
</tr>
";
while ( ($device = mysqli_fetch_array($result)) ) if ($device['active'] == 1) {
$deviceid = $device['id'];
$deviceName = $device['deviceName'];
$deviceTypePicPath = devicePicPath($device['type']);
echo "<tr>";
echo "<td class='span1'><img src='$deviceTypePicPath' style='width:30px; height:30px;'/></td>";
echo "<td class='span3'><h4>$deviceid</h4></td>";
echo "<td class='span4'><h4>$deviceName</h4></td>";
echo "<td class='span5'>";
echo "<a class='btn btn-medium btn-primary span1' href='$editdevicepage?id=$deviceid'>Edit</a>";
echo "<a class='btn btn-medium btn-danger span1' href='$_mdevicepage?delete=1&id=$deviceid'>Delete</a>";
echo "<a class='btn btn-medium btn-info span1' href='$device_detail?id=$deviceid'>Info</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
</div>
<?php include 'footer.php'; ?>