<?php
session_start();

?>

<?php 
include'dbcon.php';
	$query=mysqli_query($conn,"select * from tbl_excel where numinscription ='$_SESSION[password]'")or die(mysqli_error($conn));
	 while($row=mysqli_fetch_array($query)){
						
						
						
							?>
                        

<!doctype html>
<html lang="en">

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  
    <meta name="csrf-token" content="A4ZbzBd2H2KhywWjI8v5kjoQiULtD2nJ6gPLmmvc">
            <meta name="description" content="Online Application Portal for Moi University">
        <title>Inscription- Université du burundi </title>
    <!-- Scripts -->
    <script src="../js/app.js" defer></script>
	<script src="../../ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <!-- Fonts -->
    <link rel="dns-prefetch" href="http://fonts.gstatic.com/">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
    <!-- Styles -->
    <link href="../css/app.css" rel="stylesheet">
    <link href="../css/custom.css" rel="stylesheet">
    <link href="../css/all.min.css" rel="stylesheet">
    <link rel="icon" href="../logub.PNG">
	
	<style>
	
.bg-theme-color1{

background-color:#922B21;
color:white;
}


 </style>
        </head>
<body>
    <div id="app">
                    <nav class="navbar navbar-expand-md navbar-light bg-theme-color shadow-sm fixed-top p-0">
    <div class="container">
        <!-- Branding Image -->
        <I><FONT SIZE=6><strong>UNIVERSITE DU BURUNDI 'RUMURI'</strong></FONT></I>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <!-- Left Side Of Navbar -->
            <ul class="navbar-nav mr-auto">

            </ul>
            <!-- Right Side Of Navbar -->
            <ul class="navbar-nav ml-auto">
                <!-- Authentication Links -->
                
                    <li class="nav-item">
                        <a class="nav-link " href="../logout.php" title="Déconnexion">
                            <span class="d-none d-md-block d-lg-none"><i class="fas fa-sign-in-alt"></i> </span>
                            <span class="d-md-none d-lg-block"><?php echo $row['nom']; ?> <?php echo $row['prenom']; ?>,    Déconnexion</span>
                        </a>
                    </li>
                            </ul>
        </div>
    </div>
</nav>
            <div class="container-fluid" style="margin-top:12vh !important;min-height:75vh">
                <div class="container" style="max-width:75%">
</div>                <div class="alert alert-info">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><strong><font color='blue'><center><?php echo $row['nom']; ?> <?php echo $row['prenom']; ?>,&nbsp;&nbsp;Bienvenue au formulaire d'inscription à l'Université du Burundi</center></font></strong> 
     
</div>
<div class="panel border-theme-color customPanel">
    <div class="panel-heading bg-theme-color1 text-center">
        Vos informations 
    </div>
    <div class="panel-body pb-2">
        <form action=""  method="POST">
                
			
			
			<div class="row">
                <!--Email-->
                <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Nom </label>
                        <input type="text"class="form-control "  value="<?php echo $row['nom']; ?>" readonly required>
                    </div>
                </div>
                <!--surname-->
                <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Prénom</label>
                        <input type="text"class="form-control "   value="<?php echo $row['prenom']; ?>" readonly required>
                    </div>
                </div>
                <!--other_names-->
                <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Direction Provinciale de l'Enseignement (DPE)</label>
                        <input type="text"class="form-control "  value="<?php echo $row['dpe']; ?>" readonly required>
                    </div>
                </div>
                <!--gender-->
                <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Direction Communale de l'Enseignement (DCE)</label>
                        <input type="text"class="form-control "   value="<?php echo $row['dce']; ?>" readonly required>
                    </div>
                </div>
                <!--dob-->
                <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Ecole d'origine</label>
                        <input type="text"class="form-control "   value="<?php echo $row['ecole']; ?>" readonly required>
                    </div>
                </div>
                <!--Nationality-->
               <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Section fréquentée</label>
                        <input type="text"class="form-control "   value="<?php echo $row['section']; ?>" readonly required>
                    </div>
                </div>
                <!--id_number-->
               <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Numéro d'inscription</label>
                        <input type="text"class="form-control "   value="<?php echo $row['numinscription']; ?>" readonly required>
                    </div>
                </div>
                <!--passport_no-->
                 <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Sexe</label>
                        <input type="text"class="form-control "   value="<?php echo $row['sexe']; ?>" readonly required>
                    </div>
                </div>
				
				 <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Notes total obtenus</label>
                        <input type="text"class="form-control "  value="<?php echo $row['total']; ?>" readonly required>
                    </div>
                </div>
				
				 <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Notes en pourcentage obtenus</label>
                        <input type="text"class="form-control "   value="<?php echo $row['notes']; ?>" readonly required>
                    </div>
                </div>
                <!--birtCertificateNo-->
                <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Edition</label>
                        <input type="text"class="form-control "   value="<?php echo $row['edition']; ?>" readonly required>
                    </div>
                </div>
                <!--phone number-->
              
				
				 </br> </br>
				<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Numero d'ordre</label>
                        <input type="text"class="form-control " name="phone_number" placeholder="e.g 0712345678" value="<?php echo $row['numero']; ?>" readonly required>
                    </div>
                </div>
                
                	<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column">
                    <div class="form-group">
                        <label class="control-label">Faculte ou Institut</label>
                        <input type="text"class="form-control " name="phone_number" placeholder="e.g FSI" value="<?php echo $row['choixfac']; ?>" readonly required>
                    </div>
                </div>
            </div><!--/row-biodata-->
			
			
			
	       <input type="hidden"class="form-control "name='nom'  value="<?php echo $row['nom']; ?>" readonly required>
			 <input type="hidden"class="form-control "name='prenom'  value="<?php echo $row['prenom']; ?>" readonly required>
			  <input type="hidden"class="form-control "name='genre'  value="<?php echo $row['sexe']; ?>" readonly required>
	        <input type="hidden"class="form-control "name='dpe'  value="<?php echo $row['dpe']; ?>" readonly required>
			 <input type="hidden"class="form-control "name='dce'  value="<?php echo $row['dce']; ?>" readonly required>
			  <input type="hidden"class="form-control "name='anneeAcademique'  value="2022-2023" readonly required>
			   <input type="hidden"class="form-control "name='numero_inscription' value="<?php echo $row['numinscription']; ?>" readonly required>
			   
				 <?php
				$conn = new mysqli('localhost', 'root', '', 'dbvalidationinscription') or die(mysqli_error());	
				?>
										 <select id = "group" class = "form-control" name = "faculte1" required = "required">
												<option value = "">Select a group</option>
								<?php
									$g_animal = $conn->prepare("SELECT * FROM `firiere` GROUP BY `faculte`");
									if($g_animal->execute()){
										$g_result = $g_animal->get_result();
									}
									while($f_ganimal = $g_result->fetch_array()){
								?>
									<option value = "<?php echo $f_ganimal['faculte']?>"><?php echo $f_ganimal['faculte']?></option>
								<?php
										}
									$conn->close();	
								?>
							</select>
							
							
							
							<label>Animal:</label>
							<select  id = "dep" name = "departement"  class = "form-control" disabled = "disabled" required = "required">
								<option value = "">Select an animal</option>
							</select>
			
			
			 <div class="col-xs-12 col-md-6">
  <input type="submit" name="save" value="Valider l'inscription" class="btn btn-info" tabindex="7">   
  </div>
     
							
							
        </form>
		
		
		 <style>
		 
		 .tel{
			 margin-left:600px;
			 
			 
            }



		 
		  </style>
		
		
		
		<div class="tel">
                      
             <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 column" id="password">
                    <div class="form-group">
                        
					    <?php 
      
	$query=mysqli_query($conn,"SELECT * FROM etudiant where numero_inscription ='$_SESSION[password]'")or die(mysqli_error($conn));
	 while($row=mysqli_fetch_array($query))
	            {
					$numinscription=$row['numero_inscription'];
                    
                    if($numinscription!=NULL)    					
					{?>
				       <div class="form-group">
     					<input type="submit" name="send" class="form-control button btn-primary" value="votre Code d'Inscription">
     					
     				   </div>
					<?php	
					}
					
					else
					{
					 	
					}
						
								
				}

							?>
						 
					    
                    </div>
                </div>        
   
        
</div>
   
                    </br> </br>
                    
                   
                    
                    
                    
                    
                </div>
		
		
		
	</div>
</div>

            </div>
            <hr>
            <div class="container-fluid footer mt-3 pt-4 pb-0 bg-theme-color d-flex justify-content-center">
			<div class="m-0 p-0">
				<p class="text-center m-0"><h6>Université du Burundi .&copy 2023 Tous les droits réservés</h6></p>
		   
			</div>
</div>            </div>
    <script>
        function toggleSidebar(){
            var sidebarActions = document.getElementById('rootWrapper');
            sidebarActions.classList.toggle("toggled");
        }
    </script>
    </body>


<?php
include('../dbcon.php');
if (isset($_POST['save'])){
	
$no = $_POST['nom'];
$pre = $_POST['prenom'];	
$dpe = $_POST['dpe'];
$dce = $_POST['dce'];
$num = $_POST['numero_inscription'];
$an = $_POST['anneeAcademique'];
$sex = $_POST['genre'];
$fac = $_POST['facultefreq'];

		
$query = mysqli_query($conn,"select * from etudiant where numero_inscription='$num' and dpe='$dpe' and dce='$dce' and anneeAcademique='$an'")or die(mysqli_error());
$count = mysqli_num_rows($query);

if ($count > 0){ 

?>
<script>
alert("Désolé!!! Vous ne pouvez pas vous inscrire deux fois. Merci.")  
window.location = "register.php";
</script>
<?php
}else{
	
mysqli_query($conn,"INSERT INTO etudiant(nom,prenom,genre,anneeAcademique,dpe,dce,numero_inscription,facultefreq) VALUES('$no','$pre','$sex','$an','$dpe','$dce','$num','$fac')")or die(mysqli_error($conn));
?>
<script>
alert("Merci!!!Vous etez bien inscrit.L'Université du Burundi vous souhaite le Bienvenu.");
window.location = "codeinscription.php";
</script>

<?php
}
}
}

?>



<script src = "js/jquery-3.1.1.js"></script>
<script type = "text/javascript">
	$(document).ready(function(){
		$('#group').on('change', function(){
				if($('#group').val() == ""){
					$('#dep').empty();
					$('<option value = "">Select an animal</option>').appendTo('#dep');
					$('#dep').attr('disabled', 'disabled');
				}else{
					$('#dep').removeAttr('disabled', 'disabled');
					$('#dep').load('animal_get.php?faculte=' + $('#group').val());
				}
		});
	});
</script>

</html>