Store in GIT
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
require("../inc/connect.php");
|
||||
require("../inc/session.php");
|
||||
|
||||
$sql = "SELECT `dev_id`, `name`, `description`, `location` FROM `device` WHERE `user`=$userid";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
$_GET['info'] = "No devices found";
|
||||
}
|
||||
|
||||
$page = 4;
|
||||
require("inc/header.php");
|
||||
|
||||
?>
|
||||
<!-- MENU SECTION END-->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4 class="page-head-line">Devices</h4>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Your devices
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Device ID</th>
|
||||
<th>Name</th>
|
||||
<th>Location</th>
|
||||
<th>Description</th>
|
||||
<th>Manage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php while($result = $query->fetch_assoc()) { ?>
|
||||
<tr <?php if($result['dev_id'] == $device){echo 'class="success"'; } ?>>
|
||||
<td class="device-id"><?php echo $result['dev_id']; ?></td>
|
||||
<td class="device-name"><?php echo $result['name']; ?></td>
|
||||
<td class="device-location"><?php echo $result['location']; ?></td>
|
||||
<td class="device-description"><?php echo $result['description']; ?></td>
|
||||
<td>
|
||||
<a class="btn btn-primary" href="php/device/device_select.php?id=<?php echo $result['dev_id']; ?>" <?php if($result['dev_id'] == $device){echo 'disabled'; } ?>>Select</a>
|
||||
<a class="btn btn-default edit-button" data-toggle="modal" data-target="#edit-device">Edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<p><a class="btn btn-primary" data-toggle="modal" data-target="#add-device">Add a device</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- EDIT DEVICE -->
|
||||
<div class="modal fade" id="edit-device" tabindex="-1" role="dialog" aria-labelledby="edit-device-label" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="edit-device-label">Edit </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="edit-device-form" method="POST" action="php/device/device_edit.php">
|
||||
<label>Device ID: </label>
|
||||
<input type="text" class="form-control" name="device" id="device-id" readonly/>
|
||||
<label>Name: </label>
|
||||
<input type="text" class="form-control" name="name" id="device-name" maxlength="32" />
|
||||
<label>Location: </label>
|
||||
<input type="text" class="form-control" name="location" id="device-location" maxlength="32" />
|
||||
<label>Description: </label>
|
||||
<input type="text" class="form-control" name="description" id="device-description"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" form="edit-device-form" class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ADD DEVICE -->
|
||||
<div class="modal fade" id="add-device" tabindex="-1" role="dialog" aria-labelledby="add-device-label" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="add-device-label">Add a new device </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="add-device-form" method="POST" action="php/device/device_add.php">
|
||||
<label>Device ID: </label>
|
||||
<input type="text" class="form-control" name="device" minlength="6" maxlength="6" required/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" form="add-device-form" class="btn btn-primary">Add device</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(".edit-button").click(function(){
|
||||
var id = $( this ).parent().parent().find(".device-id").html();
|
||||
var name = $( this ).parent().parent().find(".device-name").html();
|
||||
var location = $( this ).parent().parent().find(".device-location").html();
|
||||
var description = $( this ).parent().parent().find(".device-description").html();
|
||||
|
||||
$("#edit-device-label").html("Edit " + id);
|
||||
$("#device-id").attr("value", id);
|
||||
$("#device-name").attr("value", name);
|
||||
$("#device-location").attr("value", location);
|
||||
$("#device-description").attr("value", description);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- CONTENT-WRAPPER SECTION END-->
|
||||
<?php
|
||||
require("inc/footer.php");
|
||||
?>
|
||||
Reference in New Issue
Block a user