Automation Creation modal Fix
This commit is contained in:
parent
11eae4932c
commit
d6e09a20e9
@ -6,9 +6,9 @@ if (isset($_POST) && !empty($_POST)){
|
|||||||
$onDays = $_POST['atDays'];
|
$onDays = $_POST['atDays'];
|
||||||
|
|
||||||
AutomationManager::create('name', $onDays, $doCode, $ifCode);
|
AutomationManager::create('name', $onDays, $doCode, $ifCode);
|
||||||
}
|
|
||||||
|
|
||||||
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -30,154 +30,40 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9 main-body">
|
<div class="col-md-9 main-body">
|
||||||
<a href="#modal" class="button is-primary m-1">Create Automation</a>
|
<a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php echo $LANG['t_createAutomation'];?></a>
|
||||||
<a id="remove" class="button m-1"><i class="fa fa-trash" aria-hidden="true"></i></a>
|
|
||||||
<div class="row no-gutters">
|
<div class="row no-gutters">
|
||||||
<?php foreach ($AUTOMATIONS as $automationId => $automationData) { ?>
|
<?php foreach ($AUTOMATIONS as $automationId => $automationData) {
|
||||||
<div class="col-12 col-md-6 col-xl-4 square-wrap">
|
//BUTTON
|
||||||
<div class="rectangle-2">
|
$partial = new Partial('automationButton');
|
||||||
<div class="square-content double <?php echo ($automationData['active'] == 0 ? 'paused' : ''); ?>" onClick="ajaxPost('./ajax.php',{automation_id:'<?php echo $automationId; ?>'}, this, true);">
|
$partial->prepare('lang',$LANG);
|
||||||
<div class="delete">delete</div>
|
$partial->prepare('automationId',$automationId);
|
||||||
<div class="row">
|
$partial->prepare('automationData',$automationData);
|
||||||
<div class="col-1">
|
$partial->render();
|
||||||
<h5 class="fa">
|
|
||||||
|
//EDIT
|
||||||
|
$partial = new Partial('automationEdit');
|
||||||
|
$partial->prepare('lang',$LANG);
|
||||||
|
$partial->prepare('automationId',$automationId);
|
||||||
|
$partial->prepare('automation',$automationData);
|
||||||
|
$partial->prepare('subDevices',$SUBDEVICES);
|
||||||
|
$partial->render();
|
||||||
|
} ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php
|
<?php
|
||||||
switch ($automationData['ifSomething']) {
|
ECHO $_POST['modalNext'];
|
||||||
case 'sunSet':
|
if (isset($_POST['modalNext'])) {
|
||||||
echo'';
|
$partial = new Partial('automationCreateFinal');
|
||||||
break;
|
$partial->prepare('lang',$LANG);
|
||||||
|
$partial->prepare('subDevices',$SUBDEVICES);
|
||||||
case 'sunRise':
|
$partial->render();
|
||||||
echo' ';
|
} else {
|
||||||
break;
|
$partial = new Partial('automationCreate');
|
||||||
|
$partial->prepare('lang',$LANG);
|
||||||
default:
|
$partial->prepare('subDevices',$SUBDEVICES);
|
||||||
echo'';
|
$partial->render();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<h5 class="text-right break-all">
|
|
||||||
<?php
|
|
||||||
if (!in_array($automationData['ifSomething'], ["sunRise", "sunSet"])) {
|
|
||||||
echo $automationData['ifSomething'];
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<?php echo $automationData['onDays'];?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-container modal-container-hiden" id="modal">
|
|
||||||
<div class="modal">
|
|
||||||
<a href=""><i class="fa fa-times close"></i></a>
|
|
||||||
<h4 class="mb-4">Modal bitch</h4>
|
|
||||||
<?php if (!isset($_POST['modalNext'])) { ?>
|
|
||||||
<form method="post">
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">Run at:</div>
|
|
||||||
<div class="field">
|
|
||||||
<select class="input" name="atSelector" id="valueSelector" required>
|
|
||||||
<option value="sunSet">Západu Slunce</option>
|
|
||||||
<option value="sunRise">Východu Slunce</option>
|
|
||||||
<option value="time">Čase</option>
|
|
||||||
<option value="atDeviceValue">Hodnbotě Zařízení</option>
|
|
||||||
</select>
|
|
||||||
<input class="input" type="time" name="atTime" id="atTime" disabled/>
|
|
||||||
<select class="input" name="atDeviceValue" id="atDeviceValue" disabled>
|
|
||||||
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
|
|
||||||
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
=
|
|
||||||
<input class="input" type="num" name="atDeviceValueInt" id="atDeviceValueInt" required disabled/>
|
|
||||||
</div>
|
|
||||||
<div class="label">Select Affected Devices:</div>
|
|
||||||
<div class="field">
|
|
||||||
<select class="input" name="devices[]" multiple>
|
|
||||||
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){
|
|
||||||
if ($subDeviceValue['type'] != 'on/off') continue;?>
|
|
||||||
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?></option>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="label">ve dny:</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="mon"/> Pondělí
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="tue"/> Úterý
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="wed"/> Středa
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="thu"/> Čtvrtek
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="fri"/> Pátek
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="sat"/> Sobota
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<input type="checkbox" name="day[]" value="sun"/> Neděle
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<input type="submit" class="button" name="modalNext" value="Next"/>
|
|
||||||
</form>
|
|
||||||
<?php } else if (isset($_POST['modalNext'])) { ?>
|
|
||||||
<form method="post" action="controls/automation.php">
|
|
||||||
<div class="field">
|
|
||||||
<input type="hidden" name="atSelector" value="<?php if (isset($_POST['atTime'])) {
|
|
||||||
echo $_POST['atTime'];
|
|
||||||
} else if (isset($_POST['atDeviceValue'])) {
|
|
||||||
$subDeviceId = $_POST['atDeviceValue'];
|
|
||||||
$subDeviceValue = $_POST['atDeviceValueInt'];
|
|
||||||
$subDevice = SubDeviceManager::getSubDevice($subDeviceId);
|
|
||||||
$subDeviceMaster = SubDeviceManager::getSubDeviceMaster($subDeviceId,$subDevice['type']);
|
|
||||||
|
|
||||||
$json = json_encode([
|
|
||||||
'deviceID' => $subDeviceMaster['device_id'],
|
|
||||||
'type'=> htmlspecialchars($subDevice['type']),
|
|
||||||
'value'=> $subDeviceValue,
|
|
||||||
]);
|
|
||||||
echo htmlspecialchars($json);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo $_POST['atSelector'];
|
|
||||||
} ?>" required/>
|
|
||||||
<input type="hidden" name="atDays" value="<?php echo htmlspecialchars(($_POST['day'] != '' ? json_encode($_POST['day']) : '')); ?>" required/>
|
|
||||||
<?php foreach ($_POST['devices'] as $value) { ?>
|
|
||||||
<?php $deviceData = DeviceManager::getDeviceById($value); ?>
|
|
||||||
<div class="label"><?php echo $deviceData['name'];?></div>
|
|
||||||
<select class="input" name="device[<?php echo $deviceData['device_id'];?>]">
|
|
||||||
<option value="1">ON</option>
|
|
||||||
<option value="0">OFF</option>
|
|
||||||
</select>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<input type="submit" class="button" name="modalFinal" value="Next"/>
|
|
||||||
</form>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$partial = new Partial('footer');
|
$partial = new Partial('footer');
|
||||||
$partial->render();
|
$partial->render();
|
||||||
?>
|
?>
|
||||||
|
@ -24,28 +24,6 @@
|
|||||||
<input class="input" type="num" name="atDeviceValueInt" id="atDeviceValueInt" required disabled/>
|
<input class="input" type="num" name="atDeviceValueInt" id="atDeviceValueInt" required disabled/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="label"><?php echo $LANG['l_resetAt']?></div>
|
|
||||||
<div class="field">
|
|
||||||
<select class="input" name="restartAtSelector" id="valueSelector" required>
|
|
||||||
<option value="sunSet"><?php echo $LANG['l_sunSet']?></option>
|
|
||||||
<option value="sunRise"><?php echo $LANG['l_sunRice']?></option>
|
|
||||||
<option value="inHome"><?php echo $LANG['l_inHome']?></option>
|
|
||||||
<option value="outHome"><?php echo $LANG['l_outHome']?></option>
|
|
||||||
<option value="time"><?php echo $LANG['l_time']?></option>
|
|
||||||
<option value="atDeviceValue"><?php echo $LANG['l_deviceValue']?></option>
|
|
||||||
</select>
|
|
||||||
<input class="input" type="time" name="restartAtTime" id="atTime" disabled/>
|
|
||||||
<select class="input" name="restartAtDeviceValue" id="atDeviceValue" disabled>
|
|
||||||
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
|
|
||||||
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
=
|
|
||||||
<input class="input" type="num" name="restartAtDeviceValueInt" id="atDeviceValueInt" required disabled/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="label"><?php echo $LANG['l_affectedDevices']?></div>
|
<div class="label"><?php echo $LANG['l_affectedDevices']?></div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<select class="input" name="devices[]" multiple>
|
<select class="input" name="devices[]" multiple>
|
||||||
|
Loading…
Reference in New Issue
Block a user