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

	<?php 

		//-------------------------------------------------------------------
		$aqcm_CO2_TRIG_LOW			= $_SESSION['aqcm_CO2_TRIG_LOW'] ;
		$aqcm_CO2_TRIG_HIGH			= $_SESSION['aqcm_CO2_TRIG_HIGH'] ;
		
		$aqcm_SPL_TRIG_MOY			= $_SESSION['aqcm_SPL_TRIG_MOY'] ;
		$aqcm_SPL_TRIG_MAX			= $_SESSION['aqcm_SPL_TRIG_MAX'] ;
		$aqcm_SPL_TRIG_MODE_BIQUO	= $_SESSION['aqcm_SPL_TRIG_MODE_BIQUO'] ;
		$aqcm_SCHEDULER 				= $_SESSION['aqcm_SCHEDULER'] ;
		//echo($aqcm_SCHEDULER); echo("</br>");
		
		for ($i=1; $i < 8; $i++) {
			
			$db_schedule_str = substr($aqcm_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>";
		
	?>


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

		<tr>
		<td width="100%">
		
			<table align="left" width="100%">

				<?php
					if ( $_SESSION['ONE_SONDE_CONSULT_ERREUR'] != "" ) {
						
						echo('<tr>');
						echo('<td align="center" colspan="2" style="padding-top:5px;padding-bottom:5px;" >');
						echo('<label>');
						echo('<font size="3" color="salmon" face="Arial, Helvetica, sans-serif">');
						echo($_SESSION["ONE_SONDE_CONSULT_ERREUR"]);
						echo('</font>');
						echo('</label>');
						echo('</td>');
						echo('</tr>');
						
						$_SESSION['ONE_SONDE_CONSULT_ERREUR'] = "";
					}
				?>

				<tr>
					<td align="center" colspan="2" style="padding-top:10px;padding-bottom:15px;" >
						<label>
							<font size="5" color="lightblue" face="Arial, Helvetica, sans-serif">
								<u>- mise à jour des bilans -</u>
							</font>
						</label>
					</td>
				</tr>

				<tr>
					<td width="17%" align="right">
						sonde : 
					</td>
					
					<td align="left" colspan="3">

						<?php

							//-----------------------------------------------------------------------------------------------------------------
							echo('<select name="aqcm_SONDE_PARAMS" size="1" onchange="one_sonde_icone_change()" class="txtField_A" style="width:233px;" >');

							if ( ( $_SESSION['SITE_ID'] != "00001_001" ) && ( $NB_sondes >= 1 ) ) {
									
								for ($i = 0; $i < sizeof($aqcm_NAME); $i++) {
									echo( '<option ' );
									if ( $aqcm_MAC[$i] == $_SESSION['SONDE_MAC'] ) { echo("selected "); }
									echo( 'value="' . $aqcm_MAC[$i] . ',' . $aqcm_NAME[$i] . ',' . $aqcm_SERVER_PWD[$i] . '">' );
									echo( $aqcm_NAME[$i] );
									echo( '</option>' ) ;
								}

							}
							else {
								echo('<option value="' . '00_00_00_00_00_00' . ',' . 'None' . ',' . '12345678' . '">' . 'None' . '</option>') ;
							}
							
							echo('</select>'); 

						?>

					</td>
				</tr>
					
				<tr>
					<td align="right">
					date : 
					</td>
					<td align="left" colspan="3">
					
						<?php
						
							$debut_periode  			= mktime(0, 0, 0, $_SESSION['aqcm_MOIS']  , $_SESSION['aqcm_JOUR'], $_SESSION['aqcm_ANNEE']);
							$annee_debut_periode	= date("Y", $debut_periode);
							$mois_debut_periode 	= date("m", $debut_periode);
							$jour_debut_periode 	= date("d", $debut_periode);
							
							$date_debut_periode		= date_create($annee_debut_periode."-".$mois_debut_periode."-".$jour_debut_periode);
							$is_bissextile			= ( date_format($date_debut_periode, 'L') == "1" ) ? true : false ;

							$lundis_string = [];
							$lundis_value = [];
							$timestamp_first_monday = strtotime('first monday of ' . $_SESSION['aqcm_ANNEE'] . '-' . $_SESSION['aqcm_MOIS'] ) ;
							$timestamp_last_monday  = strtotime('last monday of '  . $_SESSION['aqcm_ANNEE'] . '-' . $_SESSION['aqcm_MOIS'] ) ;
							$last_lundi_value = intval( date("d", $timestamp_last_monday) ) ;
							
							$i = 0 ;
							$lundis_value[$i]  = intval( date("d", $timestamp_first_monday) ) ;
							$lundis_string[$i] = str_pad($lundis_value[$i] , 2 , "0" , STR_PAD_LEFT);	
							
							while ( ( $lundis_value[$i] + 7 ) <= $last_lundi_value ) {
								$lundis_value[$i+1] = $lundis_value[$i] + 7 ;
								$lundis_string[$i+1] = str_pad($lundis_value[$i+1] , 2 , "0" , STR_PAD_LEFT);
								$i++;
							}
							
							echo('<select name="aqcm_JOUR" id="aqcm_JOUR" size="1" onchange="one_sonde_icone_change()" class="txtField_A" style="width:75px;" >');
							for ($i = 0; $i < sizeof($lundis_string); $i++) {
								echo( '<option ' ) ;
								if ( $_SESSION['aqcm_JOUR'] == $lundis_string[$i] ) echo( "selected " ) ;
								echo( '>' ) ;
								echo( $lundis_string[$i] ) ;
								echo( '</option>' ) ;
							}
							echo('</select>');

							echo('<select id="aqcm_MOIS" name="aqcm_MOIS" size="1" onchange="one_sonde_icone_change()" class="txtField_A" style="width:75px;" >');
							include ("../M0/selection_mois_0.php");
							echo('</select>');

							echo('<select id="aqcm_ANNEE" name="aqcm_ANNEE" size="1" onchange="one_sonde_icone_change()" class="txtField_A" style="width:75px;" >');
							include ("../M0/selection_annee_0.php");
							echo('</select>');
							
						?>
						
					</td>
				</tr>

				<tr>
					<td width="22%" align="right">

						durée :

					</td>
					
					<td align="left" colspan="3">

						<?php
						echo('<select name="aqcm_NB_WEEKS" id="aqcm_NB_WEEKS" size="1" onChange="myFunction_2()" class="txtField_A" style="width:233px;" >');
						include ("../M0/selection_NB_WEEKS.php");
						echo('</select>');
						?>

						&nbsp;semaine(s)
						
					
					</td>
				</tr>

				<tr>
					<td align="right">
						<input id="UPDATE_CO2_BIQUO"  name="UPDATE_CO2_BIQUO" type="checkbox" onclick="myFunction()" > : 
					</td>
					<td align="left" colspan="3">
						<label for="UPDATE_CO2_BIQUO"  class="txtField_B" >
						</br>forcer la mise à jour des présences</br>
						</label>
					</td>
				</tr>

				<tr>
					<td align="center" colspan="4">
						<input type="submit" formaction="./scheduler_execute_sonde_wait.php" value="mettre à jour les bilans pour cette sonde" class="button_A" style="width:400px;" >

					</td>
				</tr>

			</table>
			
		</td>
		</tr>

	</table>

</form>

