
<?php 

	// https://www.aqcm.fr/v2/icone_dev/SONDE_setup_scheduler.php

	$aqcm_SCHEDULER = "000000000000000011111111000111111111111100000000000000000000000011111111000111111111111100000000000000000000000011111111000111111111111100000000000000000000000011111111000111111111111100000000000000000000000011111111000111111111111100000000000000000000000011111111000111111111111100000000000000000000000011111111000111111111111100000000" ;

	for ($i=1; $i < 8; $i++) {
		$db_schedule_str = substr($aqcm_SCHEDULER, 48*($i-1), 48);

		$db_schedule_string[$i] = strval($i) . " :[" ;
		for ($j=0; $j < 48; $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>";
//
?>


<div align="center">

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

	<form name="form2" method="post" action="SONDE_set_scheduler.php">
	
	<font size="3" color="white" face="Arial, Helvetica, sans-serif">
	<table width="1024" border="2" cellspacing="2" cellpadding="2" bordercolor="#999999" bgcolor="#000033">	
		
		<label>
			<input type="hidden" id="aqcm_SCHEDULER" name="aqcm_SCHEDULER"  size="50" value="<?php echo($aqcm_LCD_SCHEDULER_2);?>"  >
		</label>



		<tr align="left" valign="middle" bordercolor="#666666"> 
			<td colspan="3">

				<script src="./jquery.min.js"></script>

				<script src="./scheduler.js"></script>

				<table id="LED_SCHEDULE"></table>
				
				<script>
				
					$('#LED_SCHEDULE').scheduler({
						disabled: false,
						data: { <?php echo $SONDE_SCHEDULER; ?>
						}
					});

					$('#LED_SCHEDULE').scheduler({
					accuracy: 2
					});

					$('#get_schedule').on('click', function () {
						var get_txt = $('#LED_SCHEDULE').scheduler('val');
						var get_txt_str = $.fn.scheduler.util.serialize(get_txt,2);
						//document.getElementById("get_text_scheduler").innerHTML = get_txt_str;
						//$('#get_text_scheduler').html(get_txt_str);
						document.getElementById("aqcm_SCHEDULER").value = get_txt_str;
					});

				</script>

			</td>
		</tr>

				<?php
					if ( $aqcm_MESURES[8] == "Y" ) {
						include "AQCM_scheduler_setup_seuils_SPL.html" ;
					}
				?>

		<tr>
			<td align="center" colspan="3">
				<button type="button" onclick="SetDefaultsValues()" class="button_12">&nbsp;réinitialiser les valeurs</button>
				<hr>
				<input type="submit" onclick="GetScheduleValues()"  value="enregistrer ces valeurs" class="button_13" >
			</td>
		</tr>




			
	</table>
	</font>					
	</form>

</div>

<p>
<?php include('./communs_bouton_retour.html'); ?>
</p>

<script>
function SetDefaultsValues() {
	$('#LED_SCHEDULE').scheduler('onReset');
	document.getElementById("aqcm_SPL_TRIG_EN").checked = false;
	document.getElementById("aqcm_SPL_TRIG_MOY").value = "35.0";
	document.getElementById("aqcm_SPL_TRIG_MAX").value = "45.0";
	document.getElementById("aqcm_SPL_TRIG_ET_OU").checked = false;
}
function GetScheduleValues() {
	var get_txt = $('#LED_SCHEDULE').scheduler('val');
	var get_txt_str = $.fn.scheduler.util.serialize(get_txt,2);
	document.getElementById("aqcm_SCHEDULER").value = get_txt_str;
	
}
</script>

</body>
</html>