<form name="one_sonde_consult_2_form" id="one_sonde_consult_2_form" method="post" action="./one_sonde_consult_2.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 width="98%">
					<tr>
					
						<td align="right" width="19%">
							<label>
								sonde : 
							</label>
						</td>
						
						<td align="left" width="58%">
							&nbsp;
							<?php
							
								echo('<select name="aqcm_SONDE_PARAMS" size="1" class="txtField_A"  style="width:200px;">');
								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>
						
						<td align="left">
							<input id="show_mini_maxi"  name="show_mini_maxi" type="checkbox" >
							<label for="show_mini_maxi"  class="txtField_B" >
								min/max
							</label>
						</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'] ;
								
								//-----------------------------------------------------------------------------
								date_default_timezone_set('Europe/Paris');
								$marqueur_temps_maintenant = time();
								
								$marqueur_temps_hier = mktime(0, 0, 0, date("m", $marqueur_temps_maintenant)  , date("d", $marqueur_temps_maintenant) - 1, date("Y", $marqueur_temps_maintenant) );
								$hier_jour  = date("d", $marqueur_temps_hier) ;
								$hier_mois  = date("m", $marqueur_temps_hier) ;
								$hier_annee = date("Y", $marqueur_temps_hier) ;

								$marqueur_temps_avant = mktime(0, 0, 0, date("m", $marqueur_temps_maintenant) - 1  , date("d", $marqueur_temps_maintenant), date("Y", $marqueur_temps_maintenant) );
								$avant_jour  = date("d", $marqueur_temps_avant) ;
								$avant_mois  = date("m", $marqueur_temps_avant) ;
								$avant_annee = date("Y", $marqueur_temps_avant) ;

								//-----------------------------------------------------------------------------
								$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" >');
								
								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" >');
								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" >');
								include ("../M0/selection_annee_0.php");
								echo('</select>');
								
								//-----------------------------------------------------------------------------

							?>
							
						</td>

						<td align="left">
							<input id="show_tooltip_status" name="show_tooltip_status" type="checkbox" >
							<label for="show_tooltip_status"  class="txtField_B" >
								infos
							</label>
						</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:120px;" 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>

						<td align="left">
							<input id="show_triggers" name="show_triggers" type="checkbox" >
							<label for="show_triggers"  class="txtField_B" >
								seuils
							</label>
						</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_2()" size="1" class="txtField_A" style="width:120px;" >
							  <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 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">
							&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">
							&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_4_a_1.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="./graphiques_one_sonde_particular.php" >

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

	</table>

</form>
