Remake approved view and add rename input in setting for room name
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
if (isset($_POST) && !empty($_POST)){
 | 
					if (isset($_POST) && !empty($_POST)){
 | 
				
			||||||
	$userManager = new UserManager();
 | 
						$userManager = new UserManager();
 | 
				
			||||||
 | 
						$roomManager = new RoomManager();
 | 
				
			||||||
	if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
 | 
						if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
 | 
				
			||||||
		$oldPassword = $_POST['oldPassword'];
 | 
							$oldPassword = $_POST['oldPassword'];
 | 
				
			||||||
		$newPassword = $_POST['newPassword1'];
 | 
							$newPassword = $_POST['newPassword1'];
 | 
				
			||||||
@@ -30,6 +31,10 @@ if (isset($_POST) && !empty($_POST)){
 | 
				
			|||||||
		$userManager->setUserDataAdmin("permission", $_POST['userPermission'], $_POST['userID']);
 | 
							$userManager->setUserDataAdmin("permission", $_POST['userPermission'], $_POST['userID']);
 | 
				
			||||||
		header('Location: ' . BASEURL . 'setting');
 | 
							header('Location: ' . BASEURL . 'setting');
 | 
				
			||||||
		die();
 | 
							die();
 | 
				
			||||||
 | 
						} if (isset ($_POST['roomName']) && !empty ($_POST['roomId'])) {
 | 
				
			||||||
 | 
							$roomManager->edit($_POST['roomId'], array("name" => $_POST['roomName']));
 | 
				
			||||||
 | 
							header('Location: ' . BASEURL . 'setting');
 | 
				
			||||||
 | 
							die();
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		foreach ($_POST as $key => $value) {
 | 
							foreach ($_POST as $key => $value) {
 | 
				
			||||||
			if ($key == 'submit') continue;
 | 
								if ($key == 'submit') continue;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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) {
 | 
						public static function delete ($roomId) {
 | 
				
			||||||
		Db::command ('DELETE FROM rooms WHERE room_id=?', array ($roomId));
 | 
							Db::command ('DELETE FROM rooms WHERE room_id=?', array ($roomId));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,8 +115,12 @@
 | 
				
			|||||||
										<input type="hidden" name="deviceId" value="<?php echo (!empty($device['device_id']) ? $device['device_id'] : ""); ?>">
 | 
															<input type="hidden" name="deviceId" value="<?php echo (!empty($device['device_id']) ? $device['device_id'] : ""); ?>">
 | 
				
			||||||
										<button class="fa custom-file-input" <?php echo (!empty($device['command']) && $device['command'] == "reset" ? "style=\"color:red;\"" : ""); ?> type="submit" name="deviceCommand" value="reset" title="Reset"></button>
 | 
															<button class="fa custom-file-input" <?php echo (!empty($device['command']) && $device['command'] == "reset" ? "style=\"color:red;\"" : ""); ?> type="submit" name="deviceCommand" value="reset" title="Reset"></button>
 | 
				
			||||||
										<button class="fa custom-file-input" <?php echo (!empty($device['command']) && $device['command'] == "config" ? "style=\"color:red;\"" : ""); ?> type="submit" name="deviceCommand" value="config" title="Config"></button>
 | 
															<button class="fa custom-file-input" <?php echo (!empty($device['command']) && $device['command'] == "config" ? "style=\"color:red;\"" : ""); ?> type="submit" name="deviceCommand" value="config" title="Config"></button>
 | 
				
			||||||
										<button class="fas fa custom-file-input" <?php echo (!empty($device['approved']) && $device['approved'] == 1 ? "style=\"color:Green;\"" : ""); ?> type="submit" name="deviceApproved" value="1" title="Approved"></button>
 | 
															<?php if (isset($device['approved']) && $device['approved'] == 0) : ?>
 | 
				
			||||||
										<button class="fas fa custom-file-input" <?php echo (!empty($device['approved']) && $device['approved'] == 2 ? "style=\"color:red;\"" : ""); ?> type="submit" name="deviceApproved" value="2" title="Blocked"></button>
 | 
																<button class="fas fa custom-file-input" type="submit" name="deviceApproved" value="1" title="Approved"></button>
 | 
				
			||||||
 | 
															<?php endif; ?>
 | 
				
			||||||
 | 
															<?php if (isset($device['approved']) && $device['approved']  < 2) : ?>
 | 
				
			||||||
 | 
																<button class="fas fa custom-file-input" type="submit" name="deviceApproved" value="2" title="Blocked"></button>
 | 
				
			||||||
 | 
															<?php endif; ?>
 | 
				
			||||||
										<div style="float: clear;"></div>
 | 
															<div style="float: clear;"></div>
 | 
				
			||||||
									</form>
 | 
														</form>
 | 
				
			||||||
								<?php endif; ?>
 | 
													<?php endif; ?>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,7 +177,12 @@ $partial = new Partial('head');
 | 
				
			|||||||
					<tbody>
 | 
										<tbody>
 | 
				
			||||||
						<?php foreach ($ROOMS as $key => $room) { ?>
 | 
											<?php foreach ($ROOMS as $key => $room) { ?>
 | 
				
			||||||
							<tr>
 | 
												<tr>
 | 
				
			||||||
								<td><?php echo $room['name']; ?></td>
 | 
													<td>
 | 
				
			||||||
 | 
														<form method="post" action="">
 | 
				
			||||||
 | 
															<input type="hidden" name="roomId" value="<?php echo (!empty($room['room_id']) ? $room['room_id'] : ""); ?>">
 | 
				
			||||||
 | 
															<input class="input" type="text" onchange="this.form.submit();" name="roomName" value="<?php echo (!empty($room['name']) ? $room['name'] : ""); ?>">
 | 
				
			||||||
 | 
														</form>
 | 
				
			||||||
 | 
													</td>
 | 
				
			||||||
								<td>
 | 
													<td>
 | 
				
			||||||
									<button name="deleteRoom" type="button" class="button is-danger fa"></button>
 | 
														<button name="deleteRoom" type="button" class="button is-danger fa"></button>
 | 
				
			||||||
									<button name="defaultRoom" type="button" class="button fa" <?php echo ($room['default'] ? 'disabled' : ''); ?>></button>
 | 
														<button name="defaultRoom" type="button" class="button fa" <?php echo ($room['default'] ? 'disabled' : ''); ?>></button>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user