<form name="one_sonde_consult_2_form" id="one_sonde_consult_2_form" method="post" action="./one_sonde_consult.php">

	<input type="hidden" id="aqcm_JOUR_TAMPON"  name="aqcm_JOUR_TAMPON"  value="" />
	<input type="hidden" id="aqcm_MOIS_TAMPON"  name="aqcm_MOIS_TAMPON"  value="" />
	<input type="hidden" id="aqcm_ANNEE_TAMPON" name="aqcm_ANNEE_TAMPON" value="" />
	
	<table align="center" width="<?php echo $tables_width ; ?>"  border="2" cellspacing="2" cellpadding="2" bordercolor="#ffffff" bgcolor="#000033">	
		<tr>
			<td>

				<table align="center">
				
					<?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>- historique des mesures -</u>
								</font>
							</label>
						</td>
					</tr>

					<tr>

						<td align="right" width="23%">
							<label>
								sonde : 
							</label>
						</td>
						
						<td align="left" width="58%">
							&nbsp;
							<?php
							
								echo('<select name="aqcm_SONDE_PARAMS" size="1" class="txtField_A" onChange="one_sonde_consult_2_change()"  style="width:238px;">');
								
								if ( $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">
							<label>
								début :
							</label>
						</td>
						
						<td>
						
							&nbsp;
							
							<?php
						
								//-----------------------------------------------------------------------------
								if ( isset( $_POST['aqcm_JOUR_TAMPON'] ) && ( $_POST['aqcm_JOUR_TAMPON'] != '' ) ) 
									$_SESSION['aqcm_JOUR'] = $_POST['aqcm_JOUR_TAMPON'] ;
								if ( isset( $_POST['aqcm_MOIS_TAMPON'] ) && ( $_POST['aqcm_MOIS_TAMPON'] != '' ) ) 
									$_SESSION['aqcm_MOIS']  = $_POST['aqcm_MOIS_TAMPON'] ;
								if ( isset( $_POST['aqcm_ANNEE_TAMPON'] ) && ( $_POST['aqcm_ANNEE_TAMPON'] != '' ) ) 
									$_SESSION['aqcm_ANNEE'] = $_POST['aqcm_ANNEE_TAMPON'] ;
								
								//-----------------------------------------------------------------------------
								include("../M0/sonde_site_consult.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] = strval($lundis_value[$i]) ;
								$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_consult_2_change()" class="txtField_A" style="width:75px;" >');
								
								if ( ( $_SESSION['aqcm_T_SCALE'] == "1 jour" ) or ( $_SESSION['aqcm_T_SCALE'] == "2 jours" ) ) {
									include ("../M0/selection_jour_0.php");
								}
								else {
									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_consult_2_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_consult_2_change()" class="txtField_A"style="width:80px;"  >');
								include ("../M0/selection_annee_0.php");
								echo('</select>');
								
								//-----------------------------------------------------------------------------

							?>
							
						</td>

					</tr>
					
					<tr align="center" valign="middle" bordercolor="#666666">
					
						<td align="right">
							<label>
								durée :
							</label>
						</td>
						
						<td align="left">
							&nbsp;
							<select id="echelle_temps" name="echelle_temps" size="1" class="txtField_A" style="width:238px;" onChange="myFunction_1()" > 
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "1 jour" ) echo("selected");  ?> >1 jour </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "2 jours" ) echo("selected");  ?> >2 jours </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "1 semaine" ) echo("selected");  ?> >1 semaine </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "2 semaines" ) echo("selected");  ?> >2 semaines </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "1 mois" ) echo("selected");  ?> >1 mois </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "2 mois" ) echo("selected");  ?> >2 mois </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "3 mois" ) echo("selected");  ?> >3 mois </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "6 mois" ) echo("selected");  ?> >6 mois </option>
							  <option <?php if ( $_SESSION['aqcm_T_SCALE'] == "1 an" ) echo("selected");  ?> >1 an </option>
							</select>
						</td>

					</tr>
							
					<tr align="center" valign="middle" bordercolor="#666666">
					
						<td align="right">
							<label>
								présence :
							</label>
						</td>
						
						<td align="left" colspan="2">
							&nbsp;
							<select id="presence" name="presence" onChange="myFunction_1()" size="1" class="txtField_A" style="width:238px;" >
							  <option <?php if ( $_SESSION['PRESENCE']=="sans" )    echo("selected"); ?> >sans</option>
							  <option <?php if ( $_SESSION['PRESENCE']=="sonde" )   echo("selected"); ?> >sonde</option>
							  <option <?php if ( $_SESSION['PRESENCE']=="serveur" ) echo("selected"); ?> >serveur</option>
							</select>

						</td>
						
					</tr>
							
					<tr align="center" valign="middle" bordercolor="#666666">
					
						<td colspan="2">
							<label>
								&nbsp;
							</label>
						</td>
					</tr>

					<tr align="center" valign="middle" bordercolor="#666666">
					
						<td align="right">
							<label>
								T<sub>&nbsp;seuil</sub> :
							</label>
						</td>
						
						<td align="left" colspan="2">
							&nbsp;
							<input type="text" id="GRAPH_T_SEUIL" name="GRAPH_T_SEUIL" value="<?php echo($_SESSION['GRAPH_T_SEUIL']); ?>" size="2" maxlength="4" onkeypress="return (event.charCode !=8 && event.charCode ==0 || ( event.charCode == 45 || event.charCode == 46 || (event.charCode >= 48 && event.charCode <= 57) ) )" class="txtField_M1" style="width:75px;" >
							&nbsp;°C
						</td>
						
					</tr>
							
					<tr align="center" valign="middle" bordercolor="#666666">
					
						<td align="right">
							<label>
								HR<sub>&nbsp;seuil</sub> :
							</label>
						</td>
						
						<td align="left" colspan="2">
							&nbsp;
							<input type="text" id="GRAPH_HR_SEUIL" name="GRAPH_HR_SEUIL" value="<?php echo($_SESSION['GRAPH_HR_SEUIL']); ?>" size="2" maxlength="4" onkeypress="return (event.charCode !=8 && event.charCode ==0 || ( event.charCode == 45 || event.charCode == 46 || (event.charCode >= 48 && event.charCode <= 57) ) )" class="txtField_M1" style="width:75px;" >
							&nbsp;%
						</td>
						
					</tr>
							
				</table>

				<?php
				
					if ( 
							( $_SESSION['SITE_ID'] != "05130_131" ) && 
							( $_SESSION['SITE_ID'] != "05130_132" ) && 
							( $_SESSION['SITE_ID'] != "05130_133" ) ) {
								
						include("./one_sonde_consult_get_sondes_ok_2.php");
						
					}
					
				?>

				<table align="center" width="98%">

					<tr>
						<td align="center">

							<input type="submit" class="button_A" name="lancer"  value="afficher les mesures" formtarget="_blank" formaction="./one_sonde_consult_selection.php" >

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

	</table>

</form>
