<?php

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

	if ( $_SESSION['level'] < 8 ) {
		header('Location: ' . $root_dir . '/M2/gestion_users.php');
		exit();
	}

	include("../M0/communs_en_tete_HTML.html") ;
	$back_link = "../M2/gestion_users.php";
	include('../M0/communs_en_tete_home_back.html');

	$return_path = "/M2/gestion_users.php" ;
	include('../M0/display_user_site_without_BAT_NIV.php'); 

	$user_level_to_js = $_SESSION['level'] ;

?>

<form name="form2" id="form2" method="post" action="">

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

	<tr align="center">
		<td>

			<div><label style="display: block;font-size:24px; color:lightblue;padding-top:10px;" >
			<u>- modification de plusieurs utilisateurs -</u>
			</label></div>

			<table width="99%" align="center">
			
				<font size="1" face="Arial, Helvetica, sans-serif">&nbsp;</font>
				
				<tr>
				
					<td align="center">
					
						<?php

							
							$aujourdhui  			= mktime(0, 0, 0, date("m")  , date("d"), date("Y"));
							$aujourdhui_string	= date("d/m/Y", $aujourdhui);
							$JJ_MM_AA_strings	= explode("/", $aujourdhui_string);
							
							$p_aqcm_SITE_ID = $_SESSION['SITE_ID'] ;
							include('../M0/get_users_of_1_site.php');
							
							if ( $get_users_of_one_site_erreur == 0 ) {
								
								if ( sizeof($aqcm_USER_ID) >= 1 ) {
									
									echo( '<select name="select_users_name[]" id="select_users_name" size="7" 
									style="width: 90%; font-size:18px; font-family: Arial;"  class="txtField_A"  multiple="multiple" onclick="koko_1()"  >' ) ;
									for ($i = 0; $i < sizeof($aqcm_USER_ID); $i++) {
										
										if ( $_SESSION['level'] > $aqcm_USER_LEVEL[$i] ) {
											
											echo( '<option value="' . $aqcm_USER_ID[$i] . '"' ) ; 
											echo( '>' ) ;
											echo( 	$aqcm_USER_ID[$i] );
											echo( '</option>' ) ;
											
										}

									}
									echo( '</select>' ) ;
									
								}
								else {
								echo( '<label>' ) ;
								echo( 'erreur : la liste des utilisateurs est vide !!!' ) ;
								echo( '</label>' ) ;
								}
								
							}
							else {
								echo( '<label>' ) ;
								echo( 'erreur (' . strval( $get_users_of_one_site_erreur ) . ') !!!' ) ;
								echo( '</label>' ) ;
							}


						?>
						
					</td>
					
				</tr>
				
				<tr>
					<td colspan="2">
						<?php include("./modify_some_users_of_one_site_target_a.php"); ?>
					</td>
				</tr>
				
				<tr>
					<td align="center" colspan="2">
					
						<?php

							if ( $get_users_of_one_site_erreur == 0 ) {
								echo( '<input type="submit" id="submit_form" onclick="my_confirm_function()" value="modifier les utilisateurs sélectionnés" class="button_A" disabled >' ) ;
							}
						?>
							
					</td>
				</tr>
				
			</table>
			
			<font size="1" face="Arial, Helvetica, sans-serif">&nbsp;</font>
			
		</td>
	</tr>
	
</table>

</form>

<script>

function my_confirm_function() {
	var msg="attention : voulez-vous vraiment modifier les utilisateurs sélectionnés ?";
	var txt;
	var r = confirm(msg);
	if (r == true) {
		txt = "./modify_some_users_of_one_site_target_execute.php";
	} else {
		txt = "./modify_some_users_of_one_site_target.php";
	}
	document.getElementById("form2").action = txt;

}

function koko_1() {
	
	var user_level  = <?php echo($user_level_to_js);  ?>;

	var b = document.getElementById("aqcm_USER_LEVEL_checkbox");
	var a = document.getElementById("aqcm_STATUT_checkbox");
	var d = document.getElementById("aqcm_WEEK_MAIL_checkbox");
	var e = document.getElementById("aqcm_RX_WARNING_checkbox");
	var c = document.getElementById("aqcm_T_LIMIT_checkbox");

	var f = document.getElementById("submit_form");

	var bb = document.getElementById("aqcm_USER_LEVEL");
	var aa = document.getElementById("aqcm_STATUT");
	var dd = document.getElementById("aqcm_WEEK_MAIL");
	var ee = document.getElementById("aqcm_RX_WARNING");
	var ccdate = document.getElementById("aqcm_USER_T_MAX");

	var options = document.getElementById("select_users_name").options, count = 0;
	for (var i=0; i < options.length; i++) {
	  if (options[i].selected) count++;
	}

	if ( ! b.checked ) {
		bb.disabled = true;
	} else {
		bb.disabled = false;
	}

	if ( ! a.checked ) {
		aa.disabled = true;
	} else {
		aa.disabled = false;
	}

	if ( ! d.checked ) {
		dd.disabled = true;
	} else {
		dd.disabled = false;
	}

	if ( ! e.checked ) {
		ee.disabled = true;
	} else {
		ee.disabled = false;
	}

	if ( ! c.checked ) {
		ccdate.disabled = true;
	} else {
		ccdate.disabled = false;
	}
	/*
	*/

	if ( ( ( a.checked ) || ( b.checked ) || ( c.checked ) || ( d.checked ) || ( e.checked ) ) && ( count > 0 ) ) {
		f.disabled = false;
	} else {
		f.disabled = true;
	}

}

</script>


 </body>
</html>