<?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_TEC.php'); ?>
<?php include_once('sidebar3.php'); ?>
<?php include_once('alert.php'); ?>
<?php
$connect = mysqli_connect("localhost", "e-learning", "E-learning@2020@ENSS", "std_db");
//$connect = mysqli_connect("localhost", "root", "enss2016", "std_db");
$anneeId = '';
$query = "SELECT anneeId FROM affectation_module GROUP BY anneeId ORDER BY anneeId ASC";
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($result))
{
 $anneeId .= '<option value="'.$row["anneeId"].'">'.$row["anneeId"].'</option>';
}
?>
<style>

.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;
}

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

}

/* 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>


<div class="content-wrapper">
    <section class="content-header">
    	<h1>
        	Absences
            <small>Absences</small>
        </h1>
        <ol class="breadcrumb">
        	<li><a href="#"><i class="fa fa-dashboard"></i> Accueil</a></li>
            <li><a href="#">Les absences des etudiants</a></li>
        </ol>
	</section>

	<section class="content" > 
    	<div class="row" id="table1">
        	<div class="col-md-13">
            	<div class="box">
                	<div class="box-header">
                  		<h3 class="box-title">Les absences des etudiants</h3>
                	</div>
					    <div class="box-body" >
                  	 	<div class="form-group" id="divGender">
                
                        
						<form>
	                        <div class="col-xs-1">
                      			<label for="exampleInputPassword1">Spécialité:</label>
                    		</div>
							
                    		<div class="col-xs-3" id="divGender1">	
                            <select name="anneeId" id="anneeId" class="form-control action">
                                       <option value="">Sélectionnez Spécialité..</option>
                                       <?php echo $anneeId; ?>
                            </select>
                            </div>	
                    	    <div class="col-xs-1">
                      			<label for="exampleInputPassword1">Du</label>
                    		</div>
							
                    		<div class="col-xs-2" id="divGender1">	
                                <input  name="date_debut" id="date_debut" type="date" name="party" min="2016-01-01" max="2040-01-01" required>
                            </div>
							
							
                   	        <div class="col-xs-1">
                      			<label for="exampleInputPassword1">au</label>
                    		</div>
                    		<div class="col-xs-2" id="divGender1">	
                             <input  name="date_fin" id="date_fin" type="date" name="party" min="2016-01-01" max="2040-01-01">
                            </div>
                  	</div><!-- /.box-body -->
					</div>

                  	<div class="box-footer">
					    <button type="submit" value="Envoyer" class="btn btn-primary" >Afficher</button>
                        <button id="exportButton"  class="btn btn-primary" >Exporter en excel</button>	
                    </div>						
                    </form>	
					
					
                	<div class="box-body table-responsive">
                		<table id="example1" class="table table-bordered table-striped">
                            <thead>
							    <th class="col-md-1" >ID</th>
                                <th class="col-md-1">N_inscription</th>
                                <th class="col-md-1">Nom</th>
                                <th class="col-md-1">Prenom</th>
                                <th class="col-md-3" style="text-align:center;">Module</th>
                                <th class="col-md-2" style="text-align:center;">Date</th>
                                <th class="col-md-2" style="text-align:center;">Statut</th>
								<th class="col-md-2" style="text-align:center;">Justification</th>
								<th class="col-md-2" style="text-align:center;">Spécialité</th>
								<th class="col-md-2" style="text-align:right;">الاسم</th>
								<th class="col-md-2" style="text-align:right;">اللقب</th>
                            </thead>
                        	<tbody>
<?php
if((isset($_GET['anneeId']) AND !empty($_GET['anneeId'])) and (isset($_GET['date_debut']) AND !empty($_GET['date_debut'])) and (isset($_GET['date_fin']) AND !empty($_GET['date_fin']))) 
{
$anneeId = $_GET['anneeId'] ;
$date_debut= $_GET['date_debut'] ;
$date_fin= $_GET['date_fin'] ;
include_once('../controller/config.php');   
	 $sql="select absences.nins as ab_nins, absences.justifie as ab_justifie, absences.justificatin as ab_justificatin,absences.moduleId as ab_moduleId,absences.date as ab_date,modules.Designation as s_name,modules.moduleId as s_moduleId,modules.anneeId as s_anneeId,
	  etudiants.nins as etu_nins,etudiants.nom as etu_nom,etudiants.prenom as etu_prenom,etudiants.noma as etu_noma,etudiants.prenoma as etu_prenoma,etudiants.anneeId as etu_anneeId
	  from absences
      inner join etudiants
      on absences.nins= etudiants.nins
      inner join modules
      on absences.moduleId=modules.moduleId 
	  where etudiants.anneeId = '$anneeId' and absences.date BETWEEN '$date_debut' AND '$date_fin'
      order by ab_moduleId "; 
$result=mysqli_query($conn,$sql);
$count = 0;
$current_date_number=date("d");

if(mysqli_num_rows($result) > 0) {
	while($row=mysqli_fetch_assoc($result)){
		$count++;

?>   
                                <tr>
                                    <td><?php echo $count; ?></td>
                                    <td><?php echo $row['ab_nins']; ?></td>
                                    <td ><?php echo $row['etu_nom']; ?></td>
                                    <td><?php echo $row['etu_prenom']; ?></td>
			                        <td style="text-align:center;"><?php echo $row['s_name']; ?></td>
									<td style="text-align:center;"><?php echo $row['ab_date']; ?></td>
                                    <td style="text-align:center;"><?php if($row ['ab_justifie']>"0" ) {echo 'Justifié'; }  else { echo 'Non justifié';}  ?></td>	
                                    <td style="text-align:center;"><?php  if($row ['ab_justificatin']<>"" ) {echo $row ['ab_justificatin']; }  else { echo '/';}  ?></td>
			                        <td style="text-align:center;"><?php echo $row['s_anneeId']; ?></td> 
                                    <td style="text-align:right;"><?php echo $row['etu_noma']; ?></td>
                                    <td style="text-align:right;"><?php echo $row['etu_prenoma']; ?></td>									
                            	</tr>
<?php } } }?>
                        	</tbody>
                    	</table>
                	</div>
            	</div>
        	</div> 
    	</div>
	</section>  	
</div>
            
<link rel="stylesheet" type="text/css" href="/Content/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="http://www.shieldui.com/shared/components/latest/css/light/all.min.css" />
<script type="text/javascript" src="http://www.shieldui.com/shared/components/latest/js/shieldui-all.min.js"></script>
<script type="text/javascript" src="http://www.shieldui.com/shared/components/latest/js/jszip.min.js"></script>

<script type="text/javascript">
    jQuery(function ($) {
        $("#exportButton").click(function () {
            // parse the HTML table element having an id=exportTable
            var dataSource = shield.DataSource.create({
                data: "#example1",
                schema: {
                    type: "table",
                    fields: {
						ID: { type: String },
                        N_inscription: { type: String },
                        Nom: { type: String },
                        Prenom: { type: String },
					    Module: { type: String },
                        Date: { type: String },
                        Statut: { type: String },
						Justification: { type: String },
                        Spécialité: { type: String },
                        الاسم: { type: String },
                        اللقب: { type: String },
                    }
                }
            });

            // when parsing is done, export the data to Excel
            dataSource.read().then(function (data) {
                new shield.exp.OOXMLWorkbook({
                    author: "PrepBootstrap",
                    worksheets: [
                        {
                            name: "PrepBootstrap Table",
                            rows: [
                                {
                                    cells: [
									
									    {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "ID"
                                        },
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "N_inscription"
                                        },
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Nom"
                                        },
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Prenom"
                                        },
										{
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Module"
                                        }
										,
										  {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Date"
                                        },
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Statut"
                                        },
										
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Justification"
                                        }
										,
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "Spécialité"
                                        }
										,
										
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "الاسم"
                                        }
										,
                                        {
                                            style: {
                                                bold: true
                                            },
                                            type: String,
                                            value: "اللقب"
                                        }
									
                                    ]
                                }
                            ].concat($.map(data, function(item) {
                                return {
                                    cells: [
									    { type: String, value: item.ID },
                                        { type: String, value: item.N_inscription },
                                        { type: String, value: item.Nom },
                                        { type: String, value: item.Prenom },
										{ type: String, value: item.Module },
									    { type: String, value: item.Date },
                                        { type: String, value: item.Statut },
										{ type: String, value: item.Justification },
                                        { type: String, value: item.Spécialité },
										{ type: String, value: item.الاسم },
                                        { type: String, value: item.اللقب }
                                    ]
                                };
                            }))
                        }
                    ]
                }).saveAs({
                    fileName: "Les absences des etudiants"
                });
            });
        });
    });
</script>
              
<?php include_once('footer.php');?>