From 2c6e7e2eccbeea0537812372231836d3552182de Mon Sep 17 00:00:00 2001 From: Haitem Date: Tue, 8 Sep 2020 18:00:44 +0200 Subject: [PATCH] Add function on change room --- app/controllers/deviceController.php | 5 ++++- app/views/templates/device.phtml | 23 ++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/controllers/deviceController.php b/app/controllers/deviceController.php index cb47edf..bc367f3 100644 --- a/app/controllers/deviceController.php +++ b/app/controllers/deviceController.php @@ -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(); } diff --git a/app/views/templates/device.phtml b/app/views/templates/device.phtml index 66ea919..b0396ca 100644 --- a/app/views/templates/device.phtml +++ b/app/views/templates/device.phtml @@ -44,17 +44,22 @@ &#x - +
+ "> + +
- - +