<?php

	include("../M0/session_start.php") ;

	if ( $_SESSION['level'] < 8 ) {
		header('Location: ' . $root_dir . '/M5/gestion_sondes.php');
		exit();
	}

	include("../M0/communs_en_tete_HTML.html") ;
	$back_link = "../M5/gestion_sondes.php";
	include('../M0/communs_en_tete_home_back.html');

	$return_path = "/M5/gestion_sondes.php" ;
	include('../M0/display_user_site.php'); 
?>

<font size="1" face="Arial, Helvetica, sans-serif">&nbsp;</font>

<form name="form2" id="form2" method="post" action="">

<table align="center" width="<?php echo $tables_width ; ?>"  border="2" cellspacing="2" cellpadding="2" bordercolor="#ffffff" bgcolor="#000033">	

	<tr align="center">
		<td colspan="2">
		
			<font size="4" color="lightblue" face="Arial, Helvetica, sans-serif">
					</br><u>- demande d'interaction avec les sondes -</u></br></br>
			</font>	
		
			<table width="98%" align="center">
			
				<tr>
				
					<td align="center">
					
						<?php

							$p_aqcm_SITE_ID = $_SESSION['SITE_ID'] ;
							include('../M0/get_sondes_of_one_site_firmware.php');
							
							if ( $get_sondes_of_one_site_erreur == 0 ) {
								
								if ( sizeof($aqcm_NAME) >= 1 ) {
									
									echo( '<select name="select_sonde_name[]" id="select_sonde_name" size="7" style="width: 85%"  class="txtField_A" multiple onclick="koko_1()" >' ) ;
									for ($i = 0; $i < sizeof($aqcm_NAME); $i++) {
										
										echo( '<option value="' . $aqcm_NAME[$i] . '"' ) ;
										echo( '>' ) ;
										echo( $aqcm_NAME[$i] . ' (' . $aqcm_FW_UPDATE_FF[$i] . ')' ) ;
										echo( '</option>' ) ;

									}
									echo( '</select>' ) ;
									
								}
								else {
								echo( '<label>' ) ;
								echo( 'erreur : liste des sondes vide !!!' ) ;
								echo( '</label>' ) ;
								}
								
							}
							else {
								echo( '<label>' ) ;
								//echo( 'erreur (' . strval( $get_sondes_of_one_site_erreur ) . ') !!!' ) ;
								echo( "</br><font color='salmon'>$get_sondes_of_one_site_message</font></br></br>" ) ;
								echo( '</label>' ) ;
							}


						?>
						
						
						
					</td>
					
				</tr>
				
				<tr>
					<td align="center" colspan="2">
					
						<table width="85%">
						
							<tr align="center">
								<td align="left" colspan="2">

									<div><p>
									<input type="radio" id="SONDE_Done" name="FW_UPDATE_FF" value="Done" checked >
									<label for="SONDE_Done">
									annuler toute interation demandée
									</label></br>
									<input type="radio" id="SONDE_Boot" name="FW_UPDATE_FF" value="Boot">
									<label for="SONDE_Boot">
									redémarrage ( reboot )
									</label></br>
									<input type="radio" id="SONDE_ToDo" name="FW_UPDATE_FF" value="ToDo">
									<label for="SONDE_ToDo">
									mise à jour du firmware depuis le serveur
									</label></br>
									<input type="radio" id="SONDE_R400" name="FW_UPDATE_FF" value="R400">
									<label for="SONDE_R400">
									auto-calibrage « air pur » ( 400ppm )</label></br>
									</p></div>

								</td>
							</tr>

						</table>
						
						
					</td>
				</tr>
				
				<tr>
					<td align="center" colspan="2">
					
						<?php

							if ( $get_sondes_of_one_site_erreur == 0 ) {
								echo( '<input type="submit" id="submit_form" onclick="my_confirm_function()" value="appliquer" disabled class="button_A" >' ) ;
							}
						?>
							
					</td>
				</tr>
				
			</table>
			
			<font size="1" face="Arial, Helvetica, sans-serif">&nbsp;</font>
			
		</td>
	</tr>
	
</table>

</form>

<script>

function my_confirm_function() {
	var msg="attention : voulez-vous vraiment interagir avec les sondes sélectionnées ?";
	var txt;
	var r = confirm(msg);
	if (r == true) {
		txt = "./update_some_sondes_of_one_site_target_execute.php";
	} else {
		txt = "./update_one_sonde_of_one_site_target.php";
	}
	document.getElementById("form2").action = txt;

}

function koko_1() {
	
	var f = document.getElementById("submit_form");

	var options = document.getElementById("select_sonde_name").options, count = 0;
	for (var i=0; i < options.length; i++) {
	  if (options[i].selected) count++;
	}

	if ( count == 0 ) {
		f.disabled = true;
	} else {
		f.disabled = false;
	}

}


</script>


 </body>
</html>