function propise_plugin_setting_page() { global $_, $myUser, $conf; if (isset($_['section']) && $_['section'] == 'propise') { require_once 'Data.class.php'; require_once 'Sensor.class.php'; if (!$myUser) { throw new Exception('Vous devez être connecté pour effectuer cette action'); } $sensorManager = new Sensor(); $sensors = $sensorManager->populate(); $roomManager = new Room(); $rooms = $roomManager->populate(); $selected = new Sensor(); //Si on est en mode modification if (isset($_['id'])) { $selected = $sensorManager->getById($_['id']); } ?> <div class="span9 userBloc"> <h1>Propise</h1> <p>Gestion des multi-sondes</p> <fieldset> <legend>Ajouter/Modifier une sonde</legend> <div class="left"> <label for="labelSensor">Nom</label> <input type="hidden" id="id" value="<?php echo $selected->id; ?> "> <input type="text" id="labelSensor" value="<?php echo $selected->label; ?> " placeholder="Sonde du salon"/> <label for="uidSensor">UID</label> <input type="text" value="<?php echo $selected->uid; ?> " id="uidSensor" placeholder="sonde-1,sonde-2..." /> <label for="locationSensor">Pièce de la maison</label> <select id="locationSensor"> <?php foreach ($rooms as $room) { ?> <option <?php if ($selected->location == $room->getId()) { echo "selected"; } ?> value="<?php echo $room->getId(); ?> "><?php echo $room->getName(); ?> </option> <?php } ?> </select> </div> <div class="clear"></div> <br/><button onclick="plugin_propise_save(this)" class="btn">Enregistrer</button> </fieldset> <br/> <fieldset> <legend>Consulter les sondes existants</legend> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Nom</th> <th>UID</th> <th>Pièce</th> <th colspan="2"></th> </tr> </thead> <?php foreach ($sensors as $sensor) { $room = $roomManager->load(array('id' => $sensor->location)); ?> <tr> <td><?php echo $sensor->label; ?> </td> <td><?php echo $sensor->uid; ?> </td> <td><?php echo $room->getName(); ?> </td> <td> <a class="btn" href="setting.php?section=propise&id=<?php echo $sensor->id; ?> "><i class="fa fa-pencil"></i></a> <div class="btn" onclick="plugin_propise_delete(<?php echo $sensor->id; ?> ,this);"><i class="fa fa-times"></i></div> </td> </td> </tr> <?php } ?> </table> </fieldset> </div> <?php } }
function sensor_plugin_setting_page() { global $_, $myUser, $conf; if (isset($_['section']) && $_['section'] == 'sensor') { if ($myUser != false) { $sensorManager = new Sensor(); $sensors = $sensorManager->populate(); $roomManager = new Room(); $rooms = $roomManager->populate(); $typeManager = new SensorType(); $sensorTypes = $typeManager->populate(); //Si on est en mode modification if (isset($_['id'])) { $id_mod = $_['id']; $selected = $sensorManager->getById($id_mod); $description = $selected->GetName(); $button = "Modifier"; } else { $description = "Ajout d'un capteur"; $button = "Ajouter"; } ?> <div class="span9 userBloc"> <h1>Capteurs</h1> <p>Gestion des capteurs radio</p> <form action="action.php?action=sensor_add_sensor" method="POST"> <fieldset> <legend><?php echo $description; ?> </legend> <div class="left"> <label for="typeSensor">Type capteur</label> <select name="typeSensor" id="typeSensor"> <?php foreach ($sensorTypes as $sensorType) { if (isset($selected)) { $selected_type = $selected->getType(); } else { if (isset($_['type'])) { $selected_type = $_['type']; } else { $selected_type = null; } } ?> <option <?php if ($selected_type == $sensorType->getId()) { echo "selected"; } ?> value="<?php echo $sensorType->getId(); ?> "><?php echo $sensorType->getName(); ?> </option> <?php } ?> </select> <label for="nameSensor">Nom</label> <?php if (isset($selected)) { echo '<input type="hidden" name="id" value="' . $id_mod . '">'; } ?> <input type="text" id="nameSensor" value="<?php if (isset($selected)) { echo $selected->getName(); } ?> " onkeyup="$('#vocalCommand').html($(this).val());" name="nameSensor" placeholder="Capteur Température Salon"/> <small>Commande vocale associée : "<?php echo $conf->get('VOCAL_ENTITY_NAME'); ?> , donne <span id="vocalCommand"></span>"</small> <label for="descriptionSensor">Description</label> <input type="text" value="<?php if (isset($selected)) { echo $selected->getDescription(); } ?> " name="descriptionSensor" id="descriptionSensor" placeholder="Capteur dans le salon" /> <label for="radioCodeSensor">Code radio</label> <input type="text" value="<?php if (isset($selected)) { echo $selected->getRadioCode(); } ?> " name="radioCodeSensor" id="radioCodeSensor" placeholder="0,1,2…" /> <label for="roomSensor">Pièce</label> <select name="roomSensor" id="roomSensor"> <?php foreach ($rooms as $room) { if (isset($selected)) { $selected_room = $selected->getRoom(); } else { if (isset($_['room'])) { $selected_room = $_['room']; } else { $selected_room = null; } } ?> <option <?php if ($selected_room == $room->getId()) { echo "selected"; } ?> value="<?php echo $room->getId(); ?> "><?php echo $room->getName(); ?> </option> <?php } ?> </select> </div> <div class="clear"></div> <br/><button type="submit" class="btn"><?php echo $button; ?> </button> </fieldset> <br/> </form> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Type</th> <th>Nom</th> <th>Description</th> <th>Code radio</th> <th>Pièce</th> <th></th> </tr> </thead> <?php foreach ($sensors as $sensor) { $room = $roomManager->load(array('id' => $sensor->getRoom())); $typeSensor = $typeManager->load(array('id' => $sensor->getType())); ?> <tr> <td><?php echo $typeSensor->getName(); ?> </td> <td><?php echo $sensor->getName(); ?> </td> <td><?php echo $sensor->getDescription(); ?> </td> <td><?php echo $sensor->getRadioCode(); ?> </td> <td><?php echo $room->getName(); ?> </td> <td><a class="btn" href="action.php?action=sensor_delete_sensor&id=<?php echo $sensor->getId(); ?> "><i class="icon-remove"></i></a> <a class="btn" href="setting.php?section=sensor&id=<?php echo $sensor->getId(); ?> "><i class="icon-edit"></i></a></td> </tr> <?php } ?> </table> </div> <?php } else { ?> <div id="main" class="wrapper clearfix"> <article> <h3>Vous devez être connecté</h3> </article> </div> <?php } } }