From 4ab70a1c2dcdf19933270ca4e0f2893f03fed9bd Mon Sep 17 00:00:00 2001 From: haitem Date: Mon, 1 Mar 2021 17:38:44 +0100 Subject: [PATCH] Remake approved view and add rename input in setting for room name --- app/controllers/settingController.php | 5 +++++ app/models/managers/RoomManager.php | 9 +++++++++ app/views/templates/device.phtml | 8 ++++++-- app/views/templates/setting.phtml | 7 ++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/controllers/settingController.php b/app/controllers/settingController.php index 4ac7544..d594437 100644 --- a/app/controllers/settingController.php +++ b/app/controllers/settingController.php @@ -1,6 +1,7 @@ setUserDataAdmin("permission", $_POST['userPermission'], $_POST['userID']); header('Location: ' . BASEURL . 'setting'); die(); + } if (isset ($_POST['roomName']) && !empty ($_POST['roomId'])) { + $roomManager->edit($_POST['roomId'], array("name" => $_POST['roomName'])); + header('Location: ' . BASEURL . 'setting'); + die(); } else { foreach ($_POST as $key => $value) { if ($key == 'submit') continue; diff --git a/app/models/managers/RoomManager.php b/app/models/managers/RoomManager.php index 722b923..4935473 100644 --- a/app/models/managers/RoomManager.php +++ b/app/models/managers/RoomManager.php @@ -37,6 +37,15 @@ class RoomManager{ } } + public static function edit ($roomId, $values = []) { + try { + Db::edit ('rooms', $values, 'WHERE room_id = ?', array($roomId)); + } catch(PDOException $error) { + echo $error->getMessage(); + die(); + } + } + public static function delete ($roomId) { Db::command ('DELETE FROM rooms WHERE room_id=?', array ($roomId)); } diff --git a/app/views/templates/device.phtml b/app/views/templates/device.phtml index 619f158..6fecddf 100644 --- a/app/views/templates/device.phtml +++ b/app/views/templates/device.phtml @@ -115,8 +115,12 @@ "> - - + + + + + +
diff --git a/app/views/templates/setting.phtml b/app/views/templates/setting.phtml index 12b224c..9c8806f 100644 --- a/app/views/templates/setting.phtml +++ b/app/views/templates/setting.phtml @@ -177,7 +177,12 @@ $partial = new Partial('head'); $room) { ?> - + +
+ "> + "> +
+