<?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 = "../M6_b/gestion_admins.php";
	include('../M0/communs_en_tete_home_back.html');

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

?>

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

<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;padding-bottom:10px;" >
			<u>- suppression des utilisateurs -</u>
			</label></div>

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

							$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: 85%"  class="txtField_A" 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_LEVEL[$i] . '] ' . $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">
						<font size="1" face="Arial, Helvetica, sans-serif">&nbsp;</font>
					</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="supprimer 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 supprimer les utilisateurs sélectionnés ?";
	var txt;
	var r = confirm(msg);
	if (r == true) {
		txt = "./delete_some_users_of_one_site_target_execute.php";
	} else {
		txt = "./delete_some_users_of_one_site_target.php";
	}
	document.getElementById("form2").action = txt;

}


function koko_1() {
	
	var f = document.getElementById("submit_form");

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

	if ( count == 0 ) {
		f.disabled = true;
	} else {
		f.disabled = false;
	}

}

</script>


 </body>
</html>