<?php
if(!isset($_SERVER['HTTP_REFERER'])){
    // redirect them to your desired location
    header('location:../index.php');
    exit;
}
?>
<?php include_once('head.php'); ?>
<?php include_once('header_student.php'); ?>
<?php include_once('sidebar1.php');
////$sql="select*from etudiants,groupes,annees,specialites where etudiants.groupeId=groupes.groupeId and annees.anneeid=groupes.anneeid and specialites.speId=annees.speId and  etudiants.nins='$index'";

 ?>

<style>

body { 

	overflow-y:scroll;
}


.modal-content1 {
	
   position: absolute;
   left: 125px; 
}
@media only screen and (max-width: 500px) {

	.modal-content1 {
   		
		position:static;
   
	}
}

.form-control-feedback {
  
   pointer-events: auto;
  
}

.set-width-tooltip + .tooltip > .tooltip-inner { 
  
     min-width:180px;
}
.set-color-tooltip + .tooltip > .tooltip-inner { 
  
     min-width:180px;
	 background-color:red;
}
.image-error{
	border:1px solid #f44336;
	
}

.image-success{
	border:1px solid #009900;
	
}

.msk-fade {  
      
    -webkit-animation-name: animatetop;
    -webkit-animation-duration: 0.4s;
    animation-name: animatetop;
    animation-duration: 0.4s

}

body.modal-open-noscroll1
{
    overflow:hidden;
	
 
}
/* Add Animation */
@-webkit-keyframes animatetop {
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1}
}

@keyframes animatetop {
    from {top:-300px; opacity:0}
    to {top:0; opacity:1}
}


</style>

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
	<!-- Content Header (Page header) -->
    <section class="content-header">
    	<h1>
        	Examen
            <small>Aperçu</small>
        </h1>
        <ol class="breadcrumb">
        	<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Examen</a></li>
            <li><a href="#">Mes notes d'examen</a></li>
        </ol>
	</section>


	<!-- Main content -->
<section class="content">
    	<div class="row">
        	<!-- left column -->
            <div class="col-md-11">
            	<!-- general form elements -->
              	<div class="box box-primary">
                	<div class="box-header with-border">
                  		<h3 class="box-title">Mes notes d'examen</h3>
                	</div><!-- /.box-header -->
                  	<div class="box-body">

<?php 
//******************************************************************
include_once('../controller/config.php');
$my_index= $_SESSION["index_number"];




//**************************************************************************************************************************************************************************
//******************************************************
$sql2="select * from etudiants,groupes,annees,specialites where etudiants.groupeId=groupes.groupeId and annees.anneeid=groupes.anneeid and specialites.speId=annees.speId and  etudiants.nins='$my_index'";
$result2=mysqli_query($conn,$sql2);
$row2=mysqli_fetch_assoc($result2);
$nins=$row2['nins'];
$nom=$row2['nom'];
$prenom=$row2['prenom'];
//**************************************************************************************************************************************************************************


//**************************************************************************************************************************************************************************
   			$sql_query3 = "select etudiants.anneeId as etanneid,etudiants.nins as etunins,annees.designation as anndes,annees.anneeId as AneeID,annees.speId as annspe,specialites.speId as sspeid,specialites.designation as spedes,
            groupes.designation as groupeetu,groupes.anneeId			
			from annees,specialites,etudiants,groupes
	        where  annees.speId=specialites.speId and annees.anneeId = etudiants.anneeId and etudiants.anneeId=groupes.anneeId  and etudiants.nins='$my_index'";
            $resultset3 = mysqli_query($conn, $sql_query3) or die("database error:". mysqli_error($conn));
			$row3 = mysqli_fetch_assoc($resultset3);
			//$row = mysqli_fetch_assoc($resultset);
//**************************************************************************************************************************************************************************

	






//**************************************************************************************************************************************************************************
	$sql_query = "select * from  etudiants  , noteets ,modules
	where etudiants.nins = noteets.nins  and modules.moduleId =noteets.moduleId and  etudiants.nins='$my_index'
	ORDER BY  modules.Designation  ASC";
           
			$resultset = mysqli_query($conn, $sql_query) or die("database error:". mysqli_error($conn));
			//$row = mysqli_fetch_assoc($resultset);
		 ?>
<h4 align="left"> <?php echo $row3['spedes']; echo '  -   '; echo $row3['anndes']; ?></h4> 
<h5 align="left" class="box-title"> Groupe:<?php echo ' ';echo $row3['groupeetu'];?></h5>
<div align="right">
<h5 align="left" class="box-title"> N° inscription:<strong><span style="color:#149414;"> <?php echo $nins;?> </span></strong></h5>
<h5 align="left" class="box-title"> Nom et Prenom:<strong><span style="color:#149414;">  <?php echo $nom;echo'   ';echo $prenom;?> </span></strong></h5>
<h4></h4>
</div>   

<section class="content" > <!-- Start of table section -->
    	<div class="row" id="table1"><!--MSK-000132-1-->
        	<div class="col-md-11">
                <div class="table-responsive">
				
		<table id="data_table" class="table table-bordered table-striped">
		<thead>
		
			<tr>
				<th style="text-align:left;">Module</th>	
				<th style="text-align:center;">Coeff</th>
				<th style="text-align:center;">EMD1</th>	
				<th style="text-align:center;">EMD2</th>
		        <th style="text-align:center;">TD</th>
		        <th style="text-align:center;">TP</th>
				<th style="text-align:center;">SYN</th>
				<th style="text-align:center;">RATT</th>
				<th style="text-align:center;">Moyenne</th>
			</tr>
		</thead>
		<tbody>		
		<?php
		
			while( $row = mysqli_fetch_assoc($resultset) ) {
					 $Module =  $row['Designation'];
                     $coeff = $row['coeff'];
	                 $EMD1 = $row['EMD1'];
	                 $TD1 = $row['TD1'];
	                 $EMD2 = $row['EMD2'];
	                // $TD2 = $row['TD2'];
	                 $TP = $row['TP'];
	                 $SYN = $row['SYN'];
	                 $RATT = $row['RATT'];
					 $TDD=doubleval($TD1);
					 $TPP=doubleval($TP);
					 //******************* Moyenne **********************
					 $EMDD1=doubleval($EMD1);
					 $EMDD2=doubleval($EMD2);
					 if(($row ['avoirTD']=="1" ) and ($row ['avoirTP']=="1" )) {
						 $TDD=doubleval($TD1);
						 $TPP=doubleval($TP);
		                 $CC=( $TDD +  ($TPP)*2)/3;
					     $CA=doubleval($CC);
					     $MOY1 =  $EMDD1 +  $EMDD2 + $CA;
						 $MOY =  ($MOY1/3) ;
	                 } else 
						 if(($row ['avoirTD']=="1" ) and ($row ['avoirTP']=="0" )) {
		                  $CC= doubleval($TD1); 
						  $CA=doubleval($CC);
		                  $MOY1 =  $EMDD1 +  $EMDD2 + $CA;
						  $MOY =  ($MOY1/3) ;
	                    } else 
							if(($row ['avoirTD']=="0" ) and ($row ['avoirTP']=="1" )) {
		                       $CC= doubleval($TP);
							   $CA=doubleval($CC);
							   $MOY1 =  $EMDD1 +  $EMDD2 + $CA;
						       $MOY =  ($MOY1/3) ;
	                        }else {
								if(($row ['avoirTD']=="0" ) and ($row ['avoirTP']=="0" ))
								$MOY1 =  $EMDD1 +  $EMDD2;
						        $MOY =  ($MOY1/2) ;
			                    }					 
					 
                     $MOY = number_format($MOY, 2);
					 //*************************************************
					 	
					  $avoirTD =	$row['avoirTD'];
					  $avoirTP =	$row['avoirTP'];
			?>
	
            <tr >
			   
			   
			   <td>
			   <a href="#modalViewform" onClick="showModal1(this)" class=""  data-id="<?php echo $row["moduleId"];?>" data-toggle="modal">
			   <?php echo $row['Designation']; ?>
               </a>
			   </td>
			   
			   
			   <td style="text-align:center;">
			    <a href="#modalViewform"  onClick="showModal1(this)" class=""  data-id="<?php echo $row["moduleId"]; ?>" data-toggle="modal">
			   <?php echo $row['coeff']; ?>
               </a>
			   </td>
			   <?php//*****************************************  EMD1 **********************************************************?>
			   <?php
			   if ($EMDD1 > "0" ) {
			   ?>
		             <td  style="text-align:center; background-color:#90EE90;"><?php echo number_format(( $row ['EMD1']), 2, '.', ' '); ?></td> 
			   <?php	 
	           } else {
			   ?>
		            <td style="text-align:center;"><?php echo number_format(( $row ['EMD1']), 2, '.', ' '); ?></td>
			   <?php
	                                    } 
			   ?> 
			   <?php//***********************************************************************************************************?>
			    <?php//**************************************** EMD2 ***********************************************************?>
			   <?php
			   if ($EMDD2 > "0" ) {
			   ?>
		             <td style="text-align:center; background-color:#90EE90;"><?php echo number_format(( $row ['EMD2']), 2, '.', ' '); ?></td> 
			   <?php	 
	           } else {
			   ?>
		             <td style="text-align:center;"><?php echo number_format(( $row ['EMD2']), 2, '.', ' '); ?></td>
			   <?php
	                                    } 
			   ?> 
			   <?php//***********************************************************************************************************?>
			   	<?php//***********************************************************************************************************?>
				
			   <?php
			   if ($avoirTD =="1" ) {
			   ?>
			   
			   <?php//**************************************** TD ***********************************************************?>
			   <?php
			   if ($TDD > "0" ) {
			   ?>
		             <td style="text-align:center; background-color:#90EE90;"><?php echo number_format(( $row ['TD1']), 2, '.', ' '); ?></td> 
			   <?php	 
	           } else {
			   ?>
		             <td style="text-align:center;"><?php echo number_format(( $row ['TD1']), 2, '.', ' '); ?></td>
			   <?php
	                                    } 
			   ?> 
			   <?php//***********************************************************************************************************?>
 
			   <?php	 
	           } else {
			   ?>
		            <td style="text-align:center; background-color:grey ;"> </td>
			   <?php
	                                    } 
			   ?> 
			   <?php//***********************************************************************************************************?>
			   
			   
			   <?php
			   if ($avoirTP =="1" ) {
			   ?>
			    <?php//**************************************** TP ***********************************************************?>
			   <?php
			   if ($TPP > "0" ) {
			   ?>
		             <td style="text-align:center; background-color:#90EE90;"><?php echo number_format(( $row ['TP']), 2, '.', ' '); ?></td> 
			   <?php	 
	           } else {
			   ?>
		             <td style="text-align:center;"><?php echo number_format(( $row ['TP']), 2, '.', ' '); ?></td>
			   <?php
	                                    } 
			   ?> 
			   <?php//***********************************************************************************************************?>
			   <?php	 
	           } else {
			   ?>
		            <td style="text-align:center; background-color:grey ;"> </td>
			   <?php
	                                    } 
			   ?> 
			   
			 
			   <?php//*****************************************************************************************************?>

			   <?php
			 if ($MOY < 10 ) {
			  ?>
		             <td style="text-align:center;"><?php echo number_format(( $row ['SYN']), 2, '.', ' '); ?></td>
                     <?php					 
					 $SYN=doubleval($row ['SYN']);
					//$MOY=$SYN;
			               if ($SYN < 10 ) {
			               ?>
		                   <td style="text-align:center;"><?php echo number_format(( $row ['RATT']), 2, '.', ' '); ?></td> 
			               <?php	
						  // $MOY=$RATT;
	                       } else {
			               ?>
					       <td style="background-color:grey" ></td>
			               <?php
	                                    }       
	           } else {
			   ?>
		             <td style="background-color:grey" ></td>
					 <td style="background-color:grey" ></td>
			   <?php
	                                    } 
			   ?> 
			   <?php//***********************************************************************************************************?>
			  
			   <td style="text-align:center;"><?php echo '/'; ?></td>			  			    			   
		    </tr>

<?php } ?>



   
<?php


//****************************************************************************

 ?>
		</tbody>
		
    </table>
  
                </div><!-- /.box -->
            </div><!-- /.col-md-10 -->
        </div>
     </section> 
                  	</div><!-- /.box-body -->
            	</div><!-- /.box -->
        	</div>
    	</div>
	</section><!-- End of form section -->


<script>
function showModal1(Viewform){
	var Id = $(Viewform).data("id"); 
	var path = "../"; 
	
	var xhttp = new XMLHttpRequest();//MSK-00149-Start Ajax  
  		xhttp.onreadystatechange = function() {
    		if (this.readyState == 4 && this.status == 200) {
				//MSK-00150
				var myArray1 = eval( xhttp.responseText );
				

				document.getElementById("i_name2").innerHTML =myArray1[2];
				document.getElementById("email2").innerHTML =myArray1[6];
				document.getElementById("photo2").src ="../"+myArray1[7];	

				
				$('#id_Edit').data('id',myArray1[0]);
				$('#id_Delete').data('id',myArray1[0]);
			
    		}
			
  		};	
		
    xhttp.open("GET", "../model/get_myteacher.php?id=" + Id , true);												
  	xhttp.send();//MSK-00149--End Ajax
	 
};
</script>
<!-- Modal-View form //MSK-00148 --> 
	<div class="modal msk-fade" id="modalViewform" tabindex="-1" role="dialog" aria-labelledby="insert_alert1" aria-hidden="true" data-backdrop="static" data-keyboard="false">
		<div class="modal-dialog"><!--modal-dialog -->  
			<div class="container col-lg-12 "><!--modal-content --> 
      			<div class="row">
                    <div class="panel panel-info"><!--panel --> 
                        <div class="panel-heading">
                        	 <button type="button"  class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
                            <h3 class="panel-title" id="hname"></h3>
                        </div>
                        <div class="panel-body"><!--panel-body -->
                            <div class="row">
                                <div class="col-md-3"> 
                                	<img id="photo2" alt="User Pic" src="" class="img-circle img-responsive"> 
                                </div>
                                <div class=" col-md-9"> 
                                    <table class="table table-user-information">
                                        <tbody>

                                            <tr>
                                                <td>Nom et Prénom</td>
                                                <td id="i_name2"> </td>
                                            </tr>

                                            <tr>
                                                <td>E-mail</td>
                                                <td id="email2"> </td>
                                            </tr>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div><!--/.panel-body -->
                        <div class="panel-footer text-right"><!-- panel-footer-->
                           <span class="pull-right"> </span>
                        </div><!--/. panel-footer-->
                   </div><!--/. panel--> 
                </div><!--/.row --> 
            </div><!--/.modal-content -->
        </div><!--/.modal-dialog -->
    </div><!--/.modal -->    
 
 
 
<script>
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/history");
history.pushState(null, document.title, location.pathname);

window.addEventListener("popstate", function() {
  if(location.hash === "#!/history") {
    history.replaceState(null, document.title, location.pathname);
    setTimeout(function(){
      location.replace("../index.php");//path to when click back button
    },0);
  }
}, false);
}(window, location));
</script>
 	 	
</div><!-- /.content-wrapper -->  
                             
<?php include_once('footer.php');?>