function radioRelay_plugin_setting_page()
{
    global $_, $myUser, $conf;
    if (isset($_['section']) && $_['section'] == 'radioRelay') {
        if (!$myUser) {
            throw new Exception('Vous devez être connecté pour effectuer cette action');
        }
        $radioRelayManager = new RadioRelay();
        $radioRelays = $radioRelayManager->populate();
        $roomManager = new Room();
        $rooms = $roomManager->populate();
        $selected = new RadioRelay();
        $selected->pulse = 0;
        $selected->icon = 'fa fa-flash';
        //Si on est en mode modification
        if (isset($_['id'])) {
            $selected = $radioRelayManager->getById($_['id']);
        }
        $icons = array('fa fa-lightbulb-o', 'fa fa-power-off', 'fa fa-flash', 'fa fa-gears', 'fa fa-align-justify', 'fa fa-adjust', 'fa fa-arrow-circle-o-right', 'fa fa-desktop', 'fa fa-music', 'fa fa-bell-o', 'fa fa-beer', 'fa fa-bullseye', 'fa fa-automobile', 'fa fa-book', 'fa fa-bomb', 'fa fa-clock-o', 'fa fa-cutlery', 'fa fa-microphone', 'fa fa-tint');
        ?>

		<div class="span9 userBloc">

			<h1>Relais</h1>
			<p>Gestion des relais radios</p>  

			<fieldset>
			    <legend>Ajouter/Modifier un relais radio</legend>

			    <div class="left">

				    <label for="nameRadioRelay">Nom</label>
				    <input type="hidden" id="id" value="<?php 
        echo $selected->id;
        ?>
">
				    <input type="text" id="nameRadioRelay" value="<?php 
        echo $selected->name;
        ?>
" placeholder="Lumiere Canapé…"/>
				    
				    <label for="descriptionRadioRelay">Description</label>
				    <input type="text"  value="<?php 
        echo $selected->description;
        ?>
" id="descriptionRadioRelay" placeholder="Relais sous le canapé…" />

					<label for="iconRadioRelay">Icone</label>
				    <input type="hidden"  value="<?php 
        echo $selected->icon;
        ?>
" id="iconRadioRelay"  />
					
					<div>
						<div style='margin:5px;'>
						<?php 
        foreach ($icons as $i => $icon) {
            if ($i % 6 == 0) {
                echo '</div><div style="margin:5px;">';
            }
            ?>
							<i style="width:25px;" onclick="plugin_radiorelay_set_icon(this,'<?php 
            echo $icon;
            ?>
');" class="<?php 
            echo $icon;
            ?>
 btn <?php 
            echo $selected->icon == $icon ? 'btn-success' : '';
            ?>
"></i>
						<?php 
        }
        ?>
 
						</div>
					</div>

					<label for="radioCodeRadioRelay">Code radio</label>
					<input type="text" value="<?php 
        echo $selected->radiocode;
        ?>
" name="radioCodeRadioRelay" id="radioCodeRadioRelay" placeholder="1234,1111,0022..." />

				    <label for="onRadioRelay">Commande vocale "ON" associée</label>
				    <?php 
        echo $conf->get('VOCAL_ENTITY_NAME');
        ?>
, <input type="text" id="onRadioRelay" value="<?php 
        echo $selected->onCommand;
        ?>
" placeholder="Allume la lumière, Ouvre le volet…"/>
				   
				    
				    <label for="offRadioRelay">Commande vocale "OFF" associée</label>
				    <?php 
        echo $conf->get('VOCAL_ENTITY_NAME');
        ?>
, <input type="text" id="offRadioRelay" value="<?php 
        echo $selected->offCommand;
        ?>
" placeholder="Eteinds la lumière, Ferme le volet…"/>
				    
				    
				    <label for="roomRadioRelay">Pièce de la maison</label>
				    <select id="roomRadioRelay">
				    	<?php 
        foreach ($rooms as $room) {
            ?>
				    	<option <?php 
            if ($selected->room == $room->getId()) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $room->getId();
            ?>
"><?php 
            echo $room->getName();
            ?>
</option>
				    	<?php 
        }
        ?>
				    </select>
				   <label for="pinRadioRelay">Mode impulsion (micro secondes)</label>
				   <input type="number" value="<?php 
        echo $selected->pulse;
        ?>
" id="pulseRadioRelay" placeholder="0" />
				   <small>laisser à zéro pour désactiver le mode impulsion</small>
				</div>

	  			<div class="clear"></div>
			    <br/><button onclick="plugin_radiorelay_save(this)" class="btn">Enregistrer</button>
		  	</fieldset>
			<br/>


			<fieldset>
				<legend>Consulter les relais radios existants</legend>
				<table class="table table-striped table-bordered table-hover">
				    <thead>
					    <tr>
					    	<th>Nom</th>
						    <th>Description</th>
						    <th>Code</th>
						    
						    <th>Pièce</th>
						    <th colspan="2">Impulsion</th>
						    
					    </tr>
				    </thead>
			    
			    	<?php 
        foreach ($radioRelays as $radioRelay) {
            $room = $roomManager->load(array('id' => $radioRelay->room));
            ?>
					<tr>
				    	<td><?php 
            echo $radioRelay->name;
            ?>
</td>
					    <td><?php 
            echo $radioRelay->description;
            ?>
</td>
					    <td><?php 
            echo $radioRelay->radiocode;
            ?>
</td>
					    
					    <td><?php 
            echo $room->getName();
            ?>
</td>
					    <td><?php 
            echo $radioRelay->pulse;
            ?>
</td>
					    <td>
					    	<a class="btn" href="setting.php?section=radioRelay&id=<?php 
            echo $radioRelay->id;
            ?>
"><i class="fa fa-pencil"></i></a>
					    	<div class="btn" onclick="plugin_radiorelay_delete(<?php 
            echo $radioRelay->id;
            ?>
,this);"><i class="fa fa-times"></i></div>
					    </td>
					    </td>
			    	</tr>
			    <?php 
        }
        ?>
			    </table>
			</fieldset>
		</div>

<?php 
    }
}
function radioRelay_plugin_setting_page()
{
    global $_, $myUser, $conf;
    if (isset($_['section']) && $_['section'] == 'radioRelay') {
        if ($myUser != false) {
            $radioRelayManager = new RadioRelay();
            $radioRelays = $radioRelayManager->populate();
            $roomManager = new Room();
            $rooms = $roomManager->populate();
            //Si on est en mode modification
            if (isset($_['id'])) {
                $id_mod = $_['id'];
                $selected = $radioRelayManager->getById($id_mod);
                $description = $selected->GetName();
                $button = "Modifier";
            } else {
                $description = "Ajout d'un relais";
                $button = "Ajouter";
            }
            ?>

			<div class="span9 userBloc">


				<h1>Relais</h1>
				<p>Gestion des relais radio</p>  
				<form action="action.php?action=radioRelay_add_radioRelay" method="POST">
					<fieldset>
						<legend><?php 
            echo $description;
            ?>
</legend>

						<div class="left">
							<label for="nameRadioRelay">Nom</label>
							<?php 
            if (isset($selected)) {
                echo '<input type="hidden" name="id" value="' . $id_mod . '">';
            }
            ?>
							<input type="text" id="nameRadioRelay" value="<?php 
            if (isset($selected)) {
                echo $selected->getName();
            }
            ?>
" onkeyup="$('#vocalCommand').html($(this).val());" name="nameRadioRelay" placeholder="Lumiere Canapé…"/>
							<small>Commande vocale associée : "<?php 
            echo $conf->get('VOCAL_ENTITY_NAME');
            ?>
, allume <span id="vocalCommand"></span>"</small>
							<label for="descriptionRadioRelay">Description</label>
							<input type="text" value="<?php 
            if (isset($selected)) {
                echo $selected->getDescription();
            }
            ?>
" name="descriptionRadioRelay" id="descriptionRadioRelay" placeholder="Relais sous le canapé…" />
							<label for="radioCodeRadioRelay">Code radio</label>
							<input type="text" value="<?php 
            if (isset($selected)) {
                echo $selected->getRadioCode();
            }
            ?>
" name="radioCodeRadioRelay" id="radioCodeRadioRelay" placeholder="0,1,2…" />
							<label for="roomRadioRelay">Pièce</label>
							<select name="roomRadioRelay" id="roomRadioRelay">
								<?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>
							<label for="pulseRadioRelay">Mode impulsion (laisser à zéro pour désactiver le mode impulsion ou definir un temps d'impulsion en milli-seconde)</label>
							<input type="text" name="pulseRadioRelay" value="<?php 
            if (isset($selected)) {
                echo $selected->getPulse();
            } else {
                echo "0";
            }
            ?>
" id="pulseWireRelay" placeholder="0" />
			    
							</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>Nom</th>
								<th>Description</th>
								<th>Code radio</th>
								<th>Pièce</th>
								<th>Impulsion</th>
								<th></th>
							</tr>
						</thead>

						<?php 
            foreach ($radioRelays as $radioRelay) {
                $room = $roomManager->load(array('id' => $radioRelay->getRoom()));
                ?>
							<tr>
								<td><?php 
                echo $radioRelay->getName();
                ?>
</td>
								<td><?php 
                echo $radioRelay->getDescription();
                ?>
</td>
								<td><?php 
                echo $radioRelay->getRadioCode();
                ?>
</td>
								<td><?php 
                echo $room->getName();
                ?>
</td>
								<td><?php 
                echo $radioRelay->getPulse();
                ?>
</td>
								<td><a class="btn" href="action.php?action=radioRelay_delete_radioRelay&id=<?php 
                echo $radioRelay->getId();
                ?>
"><i class="fa fa-times"></i></a>
									<a class="btn" href="setting.php?section=radioRelay&id=<?php 
                echo $radioRelay->getId();
                ?>
"><i class="fa fa-pencil"></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 
        }
    }
}
function ipcam_plugin_setting_page()
{
    global $_, $myUser, $conf;
    if (isset($_['section']) && $_['section'] == 'ipcam') {
        require_once 'Camera.class.php';
        if (!$myUser) {
            throw new Exception('Vous devez être connecté pour effectuer cette action');
        }
        $cameraManager = new Camera();
        $cameras = $cameraManager->populate();
        $roomManager = new Room();
        $rooms = $roomManager->populate();
        $selected = new Camera();
        //Si on est en mode modification
        if (isset($_['id'])) {
            $selected = $cameraManager->getById($_['id']);
        }
        ?>

		<div class="span9 userBloc">

			<h1>Camera</h1>
			<p>Gestion des cameras IP</p>  

			<fieldset>
			    <legend>Ajouter/Modifier une camera</legend>

			    <div class="left">

				    <label for="labelCamera">Nom</label>
				    <input type="hidden" id="id" value="<?php 
        echo $selected->id;
        ?>
">
				    <input type="text" id="labelCamera" value="<?php 
        echo $selected->label;
        ?>
" placeholder="Sonde du salon"/>
			
				    <label for="ipCamera">IP</label>
				    <input type="text" value="<?php 
        echo $selected->ip;
        ?>
" id="ipCamera" placeholder="192.168.11.27:87" />
				    
					<label for="loginCamera">Login</label>
				    <input type="text" value="<?php 
        echo $selected->login;
        ?>
" id="loginCamera" placeholder="" />
				    
				    <label for="passwordCamera">Password</label>
				    <input type="text" value="<?php 
        echo $selected->password;
        ?>
" id="passwordCamera" placeholder="" />
				    
				    <label for="locationCamera">Pièce de la maison</label>
				    <select id="locationCamera">
				    	<?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_ipcam_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>IP</th>
						    <th>Pièce</th>
						    <th colspan="2"></th>
						    
					    </tr>
				    </thead>
			    
			    	<?php 
        foreach ($cameras as $camera) {
            $room = $roomManager->load(array('id' => $camera->location));
            ?>
					<tr>
				    	<td><?php 
            echo $camera->label;
            ?>
</td>
					    <td><?php 
            echo $camera->ip;
            ?>
</td>
					    <td><?php 
            echo $room->getName();
            ?>
</td>
					    <td>
					    	<a class="btn" href="setting.php?section=ipcam&id=<?php 
            echo $camera->id;
            ?>
"><i class="fa fa-pencil"></i></a>
					    	<div class="btn" onclick="plugin_ipcam_delete(<?php 
            echo $camera->id;
            ?>
,this);"><i class="fa fa-times"></i></div>
					    </td>
					    </td>
			    	</tr>
			    <?php 
        }
        ?>
			    </table>
			</fieldset>
		</div>

<?php 
    }
}
Exemple #4
0
function kodi_plugin_setting_page()
{
    global $_, $myUser;
    if (isset($_['section']) && $_['section'] == 'kodiCmd') {
        if ($myUser != false) {
            $kodiManager = new KodiCmd();
            $kodiCmds = $kodiManager->populate();
            $roomManager = new Room();
            $rooms = $roomManager->populate();
            ?>

		<div class="span9 userBloc">


		<h1>KODI</h1>
		<p>Gestion media-center</p>  
		<ul class="nav nav-tabs">
			<li <?php 
            echo !isset($_['block']) || $_['block'] == 'cmd' ? 'class="active"' : '';
            ?>
 > <a href="setting.php?section=kodiCmd&amp;block=cmd"><i class="fa fa-angle-right"></i> Commandes Vocales</a></li>
			<li <?php 
            echo isset($_['block']) && $_['block'] == 'new' ? 'class="active"' : '';
            ?>
 > <a href="setting.php?section=kodiCmd&amp;block=new"><i class="fa fa-angle-right"></i> Ajouter une Commande</a></li>
		</ul>

		<?php 
            if (isset($_['section']) && $_['section'] == 'kodiCmd' && @$_['block'] == 'new') {
                ?>
		<form action="action.php?action=kodiCmd_add_kodiCmd" method="POST">
		<fieldset>
		    <div class="left">
			    <label for="name">Nom</label>
			    <input type="text" id="name" onkeyup="$('#vocalCommand').html($(this).val());" name="name" placeholder="musique suivante"/> <small>Commande vocale associée : "<span id="vocalCommand"></span>"</small></label>
			    
			    <label for="description">Description</label>
			    <input type="text" name="description" id="description" placeholder="Lire la prochaine musique" />
			    <label for="kodiJsonCode">Code json de la commande</label>
			    <input type="text" name="kodiJsonCode" id="kodiJsonCode" placeholder='"method":"Input.Right","id":"1"' /> <a href="http://wiki.kodi.org/index.php?title=JSON-RPC_API/v6" target="_blank" >JSON-RPC_API-V6-WIKI </a>
                            <label for="room">Pièce</label>
                            <select name="room" id="room">
			    	<?php 
                foreach ($rooms as $room) {
                    ?>
			    	<option value="<?php 
                    echo $room->getId();
                    ?>
" <?php 
                    echo $room->getName() == "KODI" ? "selected" : "";
                    ?>
><?php 
                    echo $room->getName();
                    ?>
</option>
			    	<?php 
                }
                ?>
			    </select>   
                            <label for="confidence">Confidence</label>
                            <select name="confidence" id="confidence">
                                <?php 
                for ($confidence = 1; $confidence <= 9; $confidence++) {
                    ?>
                                
                                    <option value=0.<?php 
                    echo $confidence;
                    ?>
 <?php 
                    echo $confidence == 8 ? "selected" : "";
                    ?>
>0.<?php 
                    echo $confidence;
                    ?>
</option>
                                <?php 
                }
                ?>
                            </select>                          
			</div>

  			<div class="clear"></div>
		    <br/><button type="submit" class="btn">Ajouter</button>
	  	</fieldset>
		<br/>
	</form>
	
		<?php 
            }
            if (isset($_['section']) && $_['section'] == 'kodiCmd' && @$_['block'] == 'edit') {
                $kodiCmd = new KodiCmd();
                $kodiCmd = $kodiCmd->getById($_['id']);
                ?>
		<form action="action.php?action=kodiCmd_edit_kodiCmd" method="POST">
		<fieldset>
		    <div class="left">
			    <label for="name">Nom</label>
				<input type="hidden" name="id" value="<?php 
                echo $kodiCmd->getId();
                ?>
" />
			    <input type="text" id="name" onkeyup="$('#vocalCommand').html($(this).val());" value="<?php 
                echo $kodiCmd->getName();
                ?>
" name="name" /> <small>Commande vocale associée : "<span id="vocalCommand"></span>"</small></label>
			    
			    <label for="description">Description</label>
			    <input type="text" name="description" value="<?php 
                echo $kodiCmd->getDescription();
                ?>
" id="description"  />
			    <label for="kodiJsonCode">Code json de la commande</label>
			    <input type="text" name="kodiJsonCode" id="kodiJsonCode" value='<?php 
                echo $kodiCmd->getJson();
                ?>
' /> <a href="http://wiki.kodi.org/index.php?title=JSON-RPC_API/v6" target="_blank" >JSON-RPC_API-V6-WIKI </a>
                <label for="room">Pièce</label>
                <select name="room" id="room">
			    	<?php 
                foreach ($rooms as $room) {
                    ?>
			    	<option value="<?php 
                    echo $room->getId();
                    ?>
" <?php 
                    echo $room->getId() == $kodiCmd->getRoom() ? "selected" : "";
                    ?>
><?php 
                    echo $room->getName();
                    ?>
</option>
			    	<?php 
                }
                ?>
			    </select>   
                <label for="confidence">Confidence</label>
                <select name="confidence" id="confidence">
                                <?php 
                for ($confidence = 1; $confidence <= 9; $confidence++) {
                    ?>
                                
                                    <option value=0.<?php 
                    echo $confidence;
                    ?>
 <?php 
                    echo '0.' . $confidence == $kodiCmd->getConfidence() ? "selected" : "";
                    ?>
>0.<?php 
                    echo $confidence;
                    ?>
</option>
                                <?php 
                }
                ?>
                </select>                          
			</div>

  			<div class="clear"></div>
		    <br/><button type="submit" class="btn">Modifier</button>
	  	</fieldset>
		<br/>
	</form>
	
		<?php 
            }
            if (isset($_['section']) && $_['section'] == 'kodiCmd' && (@$_['block'] == 'cmd' || @$_['block'] == '')) {
                ?>

		<table class="table table-striped table-bordered table-hover">
	    <thead>
	    <tr>
	    	<th>Nom</th>
		    <th>Description</th>
		    <th>Code json de la commande</th>
            <th>Confidence</th>
		    <th>Pièce</th>
			<th>Actions</th>
	    </tr>
	    </thead>
	    
	    <?php 
                foreach ($kodiCmds as $kodiCmd) {
                    $room = $roomManager->load(array('id' => $kodiCmd->getRoom()));
                    ?>
	    <tr>
	    	<td><?php 
                    echo $kodiCmd->getName();
                    ?>
</td>
		    <td><?php 
                    echo $kodiCmd->getDescription();
                    ?>
</td>
		    <td><?php 
                    echo $kodiCmd->getJson();
                    ?>
</td>  
            <td><?php 
                    echo $kodiCmd->getConfidence();
                    ?>
</td>
		    <td><?php 
                    echo $room->getName();
                    ?>
</td>                    
            <td>
				<a class="btn" href="setting.php?section=kodiCmd&amp;block=edit&id=<?php 
                    echo $kodiCmd->getId();
                    ?>
"><i class="fa fa-pencil-square-o fa-lg"></i></a>
										
				<a class="btn" href="action.php?action=kodiCmd_delete_kodiCmd&id=<?php 
                    echo $kodiCmd->getId();
                    ?>
"><i class="fa fa-trash-o fa-lg"></i></a></td>
	    </tr>
	    <?php 
                }
                ?>
	    </table>
		</div>

<?php 
            }
        } else {
            header('location:index.php?connexion=ko');
        }
    }
}
function door_plugin_setting_page()
{
    global $_, $myUser;
    if (isset($_['section']) && $_['section'] == 'door') {
        if ($myUser != false) {
            $doorManager = new Door();
            $doors = $doorManager->populate();
            $roomManager = new Room();
            $rooms = $roomManager->populate();
            ?>

		<div class="span9 userBloc">


		<h1>Porte</h1>
		<p>Gestion des portes</p>  

		<form action="action.php?action=door_add_door" method="POST">
		<fieldset>
		    <legend>Ajout d'un porte</legend>

		    <div class="left">
			    <label for="nameDoor">Nom</label>
			    <input type="text" id="nameDoor" onkeyup="$('#vocalCommand').html($(this).val());" name="nameDoor" placeholder="Lumiere Canapé…"/>
			    <small>Commande vocale associée : "YANA, ouvre <span id="vocalCommand"></span>"</small>
			    <label for="descriptionDoor">Description</label>
			    <input type="text" name="descriptionDoor" id="descriptionDoor" placeholder="Porte de l'entrée…" />
			    <label for="pinDoorRelay">Pin GPIO verouillage (relais)</label>
			    <input type="text" name="pinDoorRelay" id="pinDoorRelayRelay" placeholder="0,1,2…" />
			    <label for="pinDoorRelay">Pin GPIO etat (capteur hall)</label>
			    <input type="text" name="pinDoorCaptor" id="pinDoorCaptor" placeholder="0,1,2…" />
			    <label for="roomDoor">Pièce</label>
			    <select name="roomDoor" id="roomDoor">
			    	<?php 
            foreach ($rooms as $room) {
                ?>
			    	<option value="<?php 
                echo $room->getId();
                ?>
"><?php 
                echo $room->getName();
                ?>
</option>
			    	<?php 
            }
            ?>
			    </select>
			</div>

  			<div class="clear"></div>
		    <br/><button type="submit" class="btn">Ajouter</button>
	  	</fieldset>
		<br/>
	</form>

		<table class="table table-striped table-bordered table-hover">
	    <thead>
	    <tr>
	    	<th>Nom</th>
		    <th>Description</th>
		    <th>Pin GPIO verouillage</th>
		    <th>Pin GPIO etat</th>
		    <th>Pièce</th>
	    </tr>
	    </thead>
	    
	    <?php 
            foreach ($doors as $door) {
                $room = $roomManager->load(array('id' => $door->getRoom()));
                ?>
	    <tr>
	    	<td><?php 
                echo $door->getName();
                ?>
</td>
		    <td><?php 
                echo $door->getDescription();
                ?>
</td>
		    <td><?php 
                echo $door->getPinRelay();
                ?>
</td>
		    <td><?php 
                echo $door->getPinCaptor();
                ?>
</td>
		    <td><?php 
                echo $room->getName();
                ?>
</td>
		    <td><a class="btn" href="action.php?action=door_delete_door&id=<?php 
                echo $door->getId();
                ?>
"><i class="icon-remove"></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 
        }
    }
}
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&egrave;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 
        }
    }
}