Add function on change room
This commit is contained in:
parent
32521d0ed3
commit
2c6e7e2ecc
@ -15,12 +15,15 @@ if (!empty ($_POST)){
|
||||
}
|
||||
if (isset ($_POST['deviceCommand']) && !empty ($_POST['deviceId'])) {
|
||||
$deviceManager->edit ($_POST['deviceId'], array ('command' => $_POST['deviceCommand']));
|
||||
}else if (!empty ($_POST['deviceCommand'])) {
|
||||
} else if (!empty ($_POST['deviceCommand'])) {
|
||||
$devices = $deviceManager->getAllDevices();
|
||||
foreach ($devices as $key => $device) {
|
||||
$deviceManager->edit ($device['device_id'], array ('command' => $_POST['deviceCommand']));
|
||||
}
|
||||
}
|
||||
if (!empty ($_POST['deviceRoomId']) && !empty ($_POST['deviceId'])) {
|
||||
$deviceManager->edit ($_POST['deviceId'], array ('room_id' => $_POST['deviceRoomId']));
|
||||
}
|
||||
header('Location: ./device');
|
||||
die();
|
||||
}
|
||||
|
@ -44,13 +44,18 @@
|
||||
<td><i class="fa">&#x<?php echo (!empty($device['icon']) ? $device['icon'] : ""); ?></i></td>
|
||||
<td><?php echo (!empty($device['name']) ? $device['name'] : ""); ?></td>
|
||||
<td>
|
||||
<select class="input" id="device-<?php echo $device['device_id']?>-roomId">
|
||||
<form method="post" action="" enctype="multipart/form-data">
|
||||
<input type="hidden" name="deviceId" value="<?php echo (!empty($device['device_id']) ? $device['device_id'] : ""); ?>">
|
||||
<select class="input" name="deviceRoomId" onchange="this.form.submit();">
|
||||
<?php
|
||||
if (!empty ($ROOMS)) {
|
||||
foreach ($ROOMS as $key => $room) {
|
||||
echo '<option value="'.$room['room_id'].'" '.($device['room_id'] == $room['room_id'] ? 'selected' : '').'>'.$room['name'].'</option>';
|
||||
echo '<option value="' . $room['room_id'] . '" ' . ($device['room_id'] == $room['room_id'] ? 'selected' : '') . '>' . $room['name'] . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (!empty($device['mac'])) : ?>
|
||||
|
Loading…
Reference in New Issue
Block a user