PHP_SMART_HOME_V3/app/templates/part/deviceEdit.phtml
2020-03-11 14:45:42 +01:00

186 lines
12 KiB
PHTML

<div class="modal-container modal-container-hiden" id="modal-setting-<?php echo $DEVICEID ?>">
<div class="modal">
<div class="close">
<i class="fa fa-times"></i>
</div>
<h4 class="mb-4"><?php $LANGMNG->echo('t_editDevice'); ?></h4>
<form method="post" action="" enctype="multipart/form-data">
<input class="input" type="hidden" name="deviceId" value="<?php echo $DEVICEID; ?>">
<?php if ($DEVICE['approved'] != 0) { ?>
<?php if ($DEVICE['userIsAdmin']) { ?>
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_owner'); ?></div>
<select class="input" name="deviceOwnerUserId">
<option value=""><?php $LANGMNG->echo('w_noOne'); ?></option>
<?php foreach ($USERS as $user) {
$userId = $user['user_id'];
$userName = $user['username'];
?>
<option value="<?php echo $userId; ?>" <?php ECHO ((int) $userId === (int) $DEVICE['owner'] ? 'selected="selected"' : ''); ?>><?php echo $userName; ?></option>
<?php } ?>
</select>
</div>
<div class="label"><?php $LANGMNG->echo('l_permission'); ?></div>
<div class="row">
<div class="col-6">
<div class="label"> - <?php $LANGMNG->echo('l_owner'); ?></div>
</div>
<div class="col-6">
<?php
$permissions = $DEVICE['permission'];
//Debug
if (DEBUGMOD == 1) {
echo '<pre>';
VAR_DUMP($permissions);
echo '</pre>';
}
?>
<input type="radio" name="permissionOwner" value=1 <?php ECHO ($permissions[0] == 1 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_read'); ?>
<input type="radio" name="permissionOwner" value=2 <?php ECHO ($permissions[0] == 2 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_use'); ?>
<input type="radio" name="permissionOwner" value=3 <?php ECHO ($permissions[0] == 3 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_edit'); ?>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="label"> - <?php $LANGMNG->echo('l_member'); ?></div>
</div>
<div class="col-6">
<input type="radio" name="permissionOther" value=1 <?php ECHO ($permissions[1] == 1 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_read'); ?>
<input type="radio" name="permissionOther" value=2 <?php ECHO ($permissions[1] == 2 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_use'); ?>
<input type="radio" name="permissionOther" value=3 <?php ECHO ($permissions[1] == 3 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_edit'); ?>
</div>
</div>
<div class="field">
<div class="label"><?php $LANGMNG->echo('w_title'); ?></div>
<input class="input" type="text" name="deviceName" value="<?php echo $DEVICE['name']; ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
</div>
<?php } ?>
<div class="field">
<div class="label">Token:</div>
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['token']; ?>" disabled>
</div>
<h4 class="mb-4"><?php $LANGMNG->echo('t_networkSetting'); ?></h4>
<div class="field">
<div class="label">Type:</div>
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['type']; ?>" disabled>
</div>
<div class="field">
<div class="label">Mac Address:</div>
<input class="input" type="text" name="deviceMac" value="<?php echo $DEVICE['mac']; ?>" disabled>
</div>
<div class="field">
<div class="label">IP:</div>
<input class="input" type="text" name="deviceIp" value="<?php echo $DEVICE['ip']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div>
<div class="field">
<div class="label">Subnet:</div>
<input class="input" type="text" name="deviceSubnet" value="<?php echo $DEVICE['subnet']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div>
<div class="field">
<div class="label">Gateway:</div>
<input class="input" type="text" name="deviceGateway" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div>
<?php //TODO: ADD DNS TO DB MAKE ALL NETWORK SETTING EDITABLE ?>
<div class="field">
<div class="label">DNS:</div>
<input class="input" type="text" name="deviceDns" value="<?php echo $DEVICE['dns']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
</div>
<h4 class="mb-4"><?php $LANGMNG->echo('t_deviceVersion'); ?></h4>
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_uploadFirmware'); ?></div>
<input class="input" type="file" name="deviceFirmware" value="">
</div>
<?php if ($DEVICE['userIsAdmin']) { ?>
<?php if (!in_array($SUBDEVICE['type'], ['on/off', 'door', 'water'])) { ?>
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_sleepTime'); ?></div>
<input class="input" type="int" name="sleepTime" value="<?php echo $DEVICE['sleepTime']; ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
<p>* - <?php $LANGMNG->echo('l_inMinutes'); ?></p>
</div>
<?php }?>
<div class="field">
<div class="label"><?php $LANGMNG->echo('w_room'); ?></div>
<select class="input" name="deviceOwnerId">
<?php foreach ($ROOMS as $room) {
$roomId = $room['room_id'];
$roomName = $room['name'];
?>
<option value="<?php echo $roomId; ?>" <?php ECHO ((int) $roomId === (int) $DEVICE['room'] ? 'selected="selected"' : ''); ?>><?php echo $roomName; ?></option>
<?php } ?>
</select>
</div>
<div class="field">
<div class="label"><?php $LANGMNG->echo('w_icon'); ?></div>
<select class="input fa" name="deviceIcon" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
<option value=""><?php $LANGMNG->echo('w_no'); ?><?php echo ' '; ?><?php $LANGMNG->echo('w_icon'); ?></option>
<option value="f0eb" <?php ECHO ($DEVICE['icon'] == "f0eb" ? 'selected="selected"' : ''); ?>>&#xf0eb; - fa-lightbulb-o</option>
<option value="f2dc" <?php ECHO ($DEVICE['icon'] == "f2dc" ? 'selected="selected"' : ''); ?>>&#xf2dc; - fa-snowflake-o</option>
<option value="f0e7" <?php ECHO ($DEVICE['icon'] == "f0e7" ? 'selected="selected"' : ''); ?>>&#xf0e7; - fa-bolt</option>
<option value="f2c7" <?php ECHO ($DEVICE['icon'] == "f2c7" ? 'selected="selected"' : ''); ?>>&#xf2c7; - fa-thermometer-full</option>
<option value="f236" <?php ECHO ($DEVICE['icon'] == "f236" ? 'selected="selected"' : ''); ?>>&#xf236; - fa-bed</option>
<option value="f185" <?php ECHO ($DEVICE['icon'] == "f185" ? 'selected="selected"' : ''); ?>>&#xf185; - fa-sun-o</option>
<option value="f2db" <?php ECHO ($DEVICE['icon'] == "f2db" ? 'selected="selected"' : ''); ?>>&#xf2db; - fa-microchip</option>
<option value="f011" <?php ECHO ($DEVICE['icon'] == "f011" ? 'selected="selected"' : ''); ?>>&#xf011; - fa-power-off</option>
<option value="f011" <?php ECHO ($DEVICE['icon'] == "f011" ? 'selected="selected"' : ''); ?>>&#xf108; - fa-desktop</option>
</select>
</div>
<?php } ?>
<div class="field">
<div class="label"><?php $LANGMNG->echo('w_moduls'); ?></div>
<div class="row no-gutters">
<?php foreach ($DEVICE['subDevices'] as $subDeviceKey => $subDevice) { ?>
<div class="device-button col-4 col-sm-3 col-xl-2 square-wrap">
<div class="square">
<div class="square-content">
<div class="row no-gutters">
<div class="col">
<h5 unselectable="on" class="fa">&#x<?php echo $DEVICE['icon'] ?></h5>
</div>
<div class="col">
<h5 unselectable="on" class="device-button-value text-right" title="<?php echo $subDevice['lastRecort']['time']; ?>"><?php echo $subDevice['lastRecort']['value'] . $subDevice['unit']?></h5>
</div>
</div>
<div class="row">
<div class="col button-text" unselectable="on" >
<?php echo $DEVICE['name']; ?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<input type="submit" class="button" name="saveDevice" value="<?php $LANGMNG->echo('b_save'); ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>/>
<input type="submit" class="button is-danger" name="disableDevice" value="<?php $LANGMNG->echo('b_disable'); ?>"/>
<?php } else { ?>
<div class="field">
<div class="label"><?php $LANGMNG->echo('w_moduls'); ?></div>
<div class="row no-gutters">
<?php foreach ($DEVICE['subDevices'] as $subDeviceKey => $subDevice) { ?>
<div class="device-button col-4 col-sm-3 col-xl-2 square-wrap">
<div class="square">
<div class="square-content">
<?php echo $DEVICE['name']; ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<input type="submit" class="button is-primary" name="approveDevice" value="<?php $LANGMNG->echo('b_approve'); ?>"/>
<input type="submit" class="button is-danger" name="disableDevice" value="<?php $LANGMNG->echo('b_disable'); ?>"/>
<?php } ?>
</form>
</div>
</div>