PHP_SMART_HOME_V3/app/templates/home.phtml

108 lines
3.0 KiB
PHTML

<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$partial->prepare('baseDir', $BASEDIR);
$partial->render();
?>
<title><?php echo $TITLE ?></title>
</head>
<body class="no-transitions">
<div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container">
<?php
$partial = new Partial('menu');
$partial->prepare('item', 'home');
$partial->prepare('langMng',$LANGMNG);
$partial->prepare('debugMod',$DEBUGMOD);
$partial->render();
?>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script>
<div class="col-md-9 main-body">
<div class="label m-1">
<?php
if ($USERSATHOME != "") {
$LANGMNG->echo('l_atHome');
echo ': ' . $USERSATHOME;
}
?>
</div>
<div class="m-1">
<select class="select" name="room">
<option value="all">All</option>
<?php foreach ($ROOMS as $key => $room) {
if ($room['device_count'] > 0) { ?>
<option value="<?php echo $room['room_id']?>"><?php echo $room['name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="row no-gutters">
<?php foreach ($DATA as $roomId => $room) { ?>
<?php foreach ($room['devices'] as $deviceId => $device) { ?>
<?php foreach ($device['subDevices'] as $subDeviceKey => $subDevice) {
//BUTTON
$partialDeviceButton = new Partial('deviceButton');
$partialDeviceButton->prepare('roomid',$roomId);
$partialDeviceButton->prepare('subdeviceid',$subDeviceKey);
$partialDeviceButton->prepare('subdevice',$subDevice);
$partialDeviceButton->prepare('deviceid',$deviceId);
$partialDeviceButton->prepare('device',$device);
$partialDeviceButton->render();
//DETAIL
$partialDetail = new Partial('deviceDetail');
$partialDetail->prepare('subdeviceid',$subDeviceKey);
$partialDetail->prepare('subdevice',$subDevice);
$partialDetail->prepare('device',$device);
$partialDetail->prepare('langMng',$LANGMNG);
$partialDetail->render();
//SETTING
$partialEdit = new Partial('deviceEdit');
$partialEdit->prepare('deviceid',$deviceId);
$partialEdit->prepare('subdevice',$subDevice);
$partialEdit->prepare('device',$device);
$partialEdit->prepare('users',$USERS);
$partialEdit->prepare('rooms',$ROOMS);
$partialEdit->prepare('langMng',$LANGMNG);
$partialEdit->render();
}
}
} ?>
</div>
</div>
</div>
<?php
$partial = new Partial('footer');
$partial->render();
?>
<script>
$(document).on('keyup mouseup', '#value_control', function(event) {
$.ajax({
url: 'ajax',
type: 'POST',
//TODO: GET Attribute from ID
data: { subDevice_id : '46', action : 'set', value: this.value},
success: function(msg){
console.log("message");
console.log(msg);
},
error: function (request, status, error) {
console.log('0');
}
});
console.log(this.value);
});
</script>
</body>
</html>