<?php 

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

	$back_link = "../M5/gestion_sondes.php";

	for ($i=1; $i < 8; $i++) {
		
		$db_schedule_str = substr($_SESSION['SONDE_SCHEDULER'], 144*($i-1), 144);

		$db_schedule_string[$i] = strval($i) . " :[" ;
		for ($j=0; $j < 144; $j++) {
			if ($db_schedule_str[$j] == "1") {
				$db_schedule_string[$i] = $db_schedule_string[$i] . strval($j) . "," ;
			}
		}
		if ( substr($db_schedule_string[$i], strlen($db_schedule_string[$i]) - 1, 1) == "[" ) {
			$db_schedule_string[$i] = $db_schedule_string[$i] . "]" ;
		}
		else if ( substr($db_schedule_string[$i], strlen($db_schedule_string[$i]) - 1, 1) == "," ) {
			$db_schedule_string[$i][strlen($db_schedule_string[$i])-1] = "]" ;
		}
	}

	$SONDE_SCHEDULER = "" ;
	for ($i=1; $i < 7; $i++) {
		$SONDE_SCHEDULER = $SONDE_SCHEDULER . $db_schedule_string[$i] . "," ;
	}
	$SONDE_SCHEDULER = $SONDE_SCHEDULER . $db_schedule_string[$i] ;

	//echo($SONDE_SCHEDULER) . "</br>";
	
?>


<form name="myform" id="myform" method="post" action="./index.php">

	<table align="center" width="<?php echo($tables_width_large); ?>" border="2" cellspacing="2" cellpadding="2" bordercolor="#999999" bgcolor="#000033">	

		<font size="3" color="white" face="Arial, Helvetica, sans-serif">

			<tr align="center" valign="middle" style="border-style: hidden;" > 

				<td align="left" style="border-style: hidden;" >
					<a href="../M1/index_2.php" title="accueil" class="a_icone" style="margin-left:0px" >
					<img src="../styles/home.jpg" border="0" height="36" align="right" /></a>
				</td>
			
				<td style="border-style: hidden;" width="700px;" > 

					<?php

						//-----------------------------------------------------------------------------------------------------------------
						/*
						*/
						echo('&nbsp;site : ');
						echo('<select name="select_site_id" id="select_site_id" size="1" onchange="My_Change()" class="txtField_A" >');
						for ($i = 0; $i < sizeof($_SESSION['list_sites']); $i++) {
							
							echo( '<option' ) ;
							if ( $_SESSION['SITE_ID'] == $_SESSION['list_sites'][$i] ) {
								echo( ' ' ) ;
								echo('selected');
							}
							echo( '>' ) ;
							echo( $_SESSION['list_sites'][$i] ) ;
							echo( '</option>' ) ;

						}
						echo('</select>');

						//-----------------------------------------------------------------------------------------------------------------
						echo('&nbsp;&nbsp;bâtiment : ');
						echo('<select name="aqcm_BAT" id="aqcm_BAT" size="1" onchange="My_Change()" class="txtField_A">');
						include ("../M0/selection_BAT.php");
						echo('</select>');

						//-----------------------------------------------------------------------------------------------------------------
						echo('&nbsp;&nbsp;étage : ');
						echo('<select name="aqcm_NIVEAU" id="aqcm_NIVEAU" size="1" onchange="My_Change()" class="txtField_A">');
						include ("../M0/selection_NIVEAU.php");
						echo('</select>');

						//-----------------------------------------------------------------------------------------------------------------
						include ("../M0/get_sondes.php");
						
						echo('&nbsp;&nbsp;sonde : ');
						echo('<select name="aqcm_SONDE_PARAMS" size="1" onchange="My_Change()" class="txtField_A">');

						if ( ( $_SESSION['SITE_ID'] != "00001_001" ) && ( $NB_sondes >= 1 ) ) {
								
							$SUBMIT_DISABLE = false ;
							
							for ($i = 0; $i < sizeof($aqcm_NAME); $i++) {
								echo('<option '); 
								if ( $_SESSION['SONDE_NAME'] == $aqcm_NAME[$i] ) { echo( "selected " ) ; } 
								echo('value="' . $aqcm_MAC[$i] . ',' . $aqcm_NAME[$i] . '">' );
								echo( $aqcm_NAME[$i] ) ;
								echo( '</option>' ) ;
							}
						}
						else {
								
							$SUBMIT_DISABLE = true ;
							echo('<option value="' . '00_00_00_00_00_00' . ',' . 'None' . '">' . 'None' . '</option>') ;
						}
						
						echo('</select>');

						//-----------------------------------------------------------------------------------------------------------------

					?>

				</td>

				<td align="right" style="border-style: hidden;" >
					<a href="<?php echo($back_link); ?>" title="retour" class="a_icone" style="margin-right:0px" >
					<img src="../styles/back.png" border="0" height="36" align="left" /></a>
				</td>

			</tr>
			
		</font>
	</table>

	<?php
		include("./index_a.php") ;
	?>

</form>


<script>

	function My_Change(){
		
		var get_txt = $('#LED_SCHEDULE').scheduler('val');
		var get_txt_str = $.fn.scheduler.util.serialize(get_txt,6);
		document.getElementById("aqcm_SCHEDULER").value = get_txt_str;

		document.getElementById("myform").requestSubmit();
	}

	function SetDefaultsValues() {
		$('#LED_SCHEDULE').scheduler('onReset');
		document.getElementById("aqcm_SPL_TRIG_MODE_BIQUO").value = "SPL(PHP)";
		document.getElementById("aqcm_SPL_TRIG_MOY").value = "35.0";
		document.getElementById("aqcm_SPL_TRIG_MAX").value = "55.0";
		document.getElementById("aqcm_CO2_TRIG_LOW").value = "800";
		document.getElementById("aqcm_CO2_TRIG_HIGH").value = "1500";
	}
	
	function GetScheduleValues() {
		var get_txt = $('#LED_SCHEDULE').scheduler('val');
		var get_txt_str = $.fn.scheduler.util.serialize(get_txt,6);
		document.getElementById("aqcm_SCHEDULER").value = get_txt_str;
	
}

</script>

</body>
</html>