Scenes/Automation function Fixs

This commit is contained in:
JonatanRek 2019-10-13 10:07:03 +02:00
parent 875fbccd6e
commit 986bcff3c8
7 changed files with 28 additions and 16 deletions

View File

@ -1,6 +1,6 @@
<?php
if (isset($_POST) && !empty($_POST)){
if (isset($_POST['modalFinal']) && $_POST['modalFinal'] == "Next") {
if (isset($_POST['modalFinal']) && $_POST['action'] == "add") {
$doCode = json_encode($_POST['device'], JSON_PRETTY_PRINT);
$ifCode = json_encode([
"type" => $_POST['atSelector'],
@ -8,11 +8,22 @@ if (isset($_POST) && !empty($_POST)){
], JSON_PRETTY_PRINT);
$onDays = $_POST['atDays'];
//Debug
if (DEBUGMOD == 1) {
echo '<pre>';
echo $permissionsInJson;
echo $deviceId;
var_dump(json_decode ($permissionsInJson));
echo '</pre>';
echo '<a href="' . BASEDIR .'">CONTINUE</a>';
die();
}
AutomationManager::create($_POST['name'], $onDays, $doCode, $ifCode);
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')), TRUE);
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
die();
} else if (isset($_POST['modalFinal']) && $_POST['modalFinal'] == "Upravit") {
} else if (isset($_POST['modalFinal']) && $_POST['action'] == "edit") {
$doCode = json_encode($_POST['device'], JSON_PRETTY_PRINT);
if (isset ($_POST['atDeviceValue'])) {
@ -22,9 +33,9 @@ if (isset($_POST) && !empty($_POST)){
$subDeviceMaster = SubDeviceManager::getSubDeviceMaster($subDeviceId,$subDevice['type']);
$json = json_encode([
'deviceID' => $subDeviceMaster['device_id'],
'type'=> $subDevice['type'],
'value'=> $subDeviceValue,
'deviceID' => $subDeviceMaster['device_id'],
'type'=> $subDevice['type'],
'value'=> $subDeviceValue,
]);
}

View File

@ -1,8 +1,10 @@
<?php
if (isset($_POST) && !empty($_POST)){
if (sset($_POST['devices']) && $_POST['devices'] != '') {
if (isset($_POST['submitFinal']) && $_POST['submitFinal'] != "") {
SceneManager::create($_POST['sceneIcon'], $_POST['sceneName'], json_encode($_POST['devices']));
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
die();
}
//Debug
@ -13,7 +15,4 @@ if (isset($_POST) && !empty($_POST)){
echo '<a href="/' . BASEDIR . strtolower(basename(__FILE__, '.php')).'">CONTINUE</a>';
die();
}
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
die();
}

View File

@ -1,9 +1,10 @@
<div class="modal-container" id="modal">
<div class="modal">
<div class="modal" action="" >
<a href=""><i class="fa fa-times close"></i></a>
<h4 class="mb-4"><?php $LANGMNG->echo('t_createAutomation'); ?></h4>
<form method="post">
<div class="field">
<input type="hidden" name="action" value="add" required/>
<input type="hidden" name="atSelector" value="<?php echo $_POST['atSelector']; ?>" required/>
<input type="hidden" name="name" value="<?php echo $_POST['name']; ?>" required/>
<input type="hidden" name="atSelectorValue" value="<?php if (isset($_POST['atTime'])) {

View File

@ -5,6 +5,7 @@
</div>
<h4 class="mb-4"><?php $LANGMNG->echo('t_createAutomation');?></h4>
<form method="post">
<input type="hidden" name="action" value="edit" required/>
<input name="automation_id" type="hidden" value="<?php echo $AUTOMATIONID; ?>">
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_nameAt');?></div>

View File

@ -4,7 +4,7 @@
<i class="fa fa-times"></i>
</div>
<h4 class="mb-4"><?php $LANGMNG->echo('t_createScene');?></h4>
<form method="post" action="" >
<form method="post">
<div class="field">
<div class="label"><?php $LANGMNG->echo('w_title');?>:</div>
<input type="text" class="input" name="sceneName" value=""/>

View File

@ -3,7 +3,7 @@
<div class="close">
<i class="fa fa-times"></i>
</div>
<h4 class="mb-4"><?php echo $LANG['t_createScene'];?></h4>
<h4 class="mb-4"><?php $LANGMNG->echo('t_createScene');?></h4>
<form method="post">
<input type="hidden" name="sceneName" value="<?php echo $SCENENAME; ?>">
<input type="hidden" name="sceneIcon" value="<?php echo $SCENEICON; ?>">
@ -20,7 +20,7 @@
<?php
$i++;
} ?>
<input type="submit" class="button" name="submit" value="<?php echo $LANG['b_create'];?>"/>
<input type="submit" class="button" name="submitFinal" value="<?php echo $LANGMNG->echo('b_create');?>"/>
</form>
</div>
</div>

View File

@ -44,8 +44,8 @@
</div>
</div>
<?php if (isset($_POST['devices'])) {
$partial = new Partial('sceneCreateOptions');
<?php if (isset($_POST['submit'])) {
$partial = new Partial('sceneCreateFinal');
$partial->prepare('langMng',$LANGMNG);
$partial->prepare('setStateFormDevices',$SETSTATEFORMDEVICES );
$partial->prepare('sceneIcon',$SCENEICON );