<?php
session_start();
header("Access-Control-Allow-Headers: Authorization, Content-Type");
header("Access-Control-Allow-Origin: *");

$_SESSION["idEtablissement"] = $_POST["idEtablissement"] ;

$_SESSION['eta_i'] = $_POST["idEtablissement"];

$_SESSION["etudiant_i"]	= $_POST["matricule"];

$token	= $_POST["token"];

$uid	= $_POST["uid"];

$session_etudiant   =   $_POST["matricule"];

$idEtablissement    =   $_POST["idEtablissement"];

$idFiliere          =   $_POST["idFiliere"];

$annee              =   $_POST["annee"];

$niveau	            = $_POST["niveau"];

$acad               = $_POST["academique"];

include('/home/africawebstudent/public_html/gs/progicielgeststudent/configuration_etabli.php');

include_once('Library/Basededonnees.php');

$DB_DATABASE = $_SESSION["DB_DATABASE"];

$database = new Basededonnees($DB_DATABASE);

$bdd = $database->getBdd();

$lien = "https://e-services.africawebstudent.org/makep.php?uid=$uid";

$lien2 = "https://e-services.africawebstudent.org/f_listepayement.php?uid=$uid";

include('Library/Identite.php');
include('footer.php');
$sql1 = "SELECT * FROM `tabinscription` where matricule= :m";
$statement1 = $bdd->prepare($sql1);
$statement1->bindParam(':m', $session_etudiant, PDO::PARAM_STR);
$statement1->execute();
$row1=$statement1->fetch(PDO::FETCH_ASSOC);
$statutetud     = $row1['statut'];	
$nb=$statement1->rowCount();


//Déterminer le montant
$resMontant = $bdd->prepare('SELECT * FROM montant WHERE idEtablissement=? AND idFiliere =? AND annee =? AND periode =? AND idStatut =?');
$resMontant->execute(array($idEtablissement,$idFiliere,$annee,$acad,$statutetud));
$Montant    = $resMontant->fetch();
$montant 	    = $Montant['scolarite'] + $Montant['fraisInscription']; //scolarite de l'année en cours

if($nb == 0) {
	// On écrase le tableau de session
	$_SESSION = array();
	 
	// On détruit la session
	session_destroy();
	 
	// On redirige le visiteur vers la page d'accueil
	header("Location:./");

	exit();
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" type="image/png" sizes="16x16" href="https://progiciel.africawebstudent.org/plugins/images/favicon.png">
    <title>GestStudentPay</title>
    <!-- Bootstrap Core CSS -->
    <link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Menu CSS -->
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/sidebar-nav/dist/sidebar-nav.min.css" rel="stylesheet">
    <!-- toast CSS -->
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/toast-master/css/jquery.toast.css" rel="stylesheet">
    <!-- morris CSS -->
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/morrisjs/morris.css" rel="stylesheet">
    <!-- chartist CSS -->
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/chartist-js/dist/chartist.min.css" rel="stylesheet">
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/chartist-plugin-tooltip-master/dist/chartist-plugin-tooltip.css" rel="stylesheet">
    <!-- Calendar CSS -->
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/calendar/dist/fullcalendar.css" rel="stylesheet" />
    <!-- animation CSS -->
    <link href="css/animate.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/style.css" rel="stylesheet">
    <!-- color CSS -->
    <link href="css/colors/megna-dark.css" id="theme" rel="stylesheet">
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
    <link href="https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css" />
	<!--alerts CSS -->
    <link href="https://progiciel.africawebstudent.org/plugins/bower_components/sweetalert/sweetalert.css" rel="stylesheet" type="text/css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
        <style>

            body {
                font-family: "Lucida Sans", Verdana, sans-serif;
                background-size:cover;
                padding-top:0px;
            }

            .white-boxx{background:#fff;padding:25px;margin-bottom:30px;border: 3px solid rgba(255, 0, 0, 0.55);}
            .white-box{background:#fff;padding:25px;margin-bottom:30px;border: 3px solid rgba(0, 0, 255, 1);}
        </style>
</head>

<body class="fix-header">
    <!-- ============================================================== -->
    <!-- Preloader -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
        </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Wrapper -->
    <!-- ============================================================== -->
    <div id="wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
        <nav class="navbar navbar-default navbar-static-top m-b-0">
            <div class="navbar-header">
                <div class="top-left-part">
                    <!-- Logo -->
                    <a class="logo" href="accueil.php">
                        <!-- Logo icon image, you can use font-icon also --><b><span class="hidden-xs">
                        <!--This is light logo icon--><img srcset="https://progiciel.africawebstudent.org/plugins/images/gs_36.png 36w, https://progiciel.africawebstudent.org/plugins/images/gsr2.png 196w" sizes="(max-width: 320px) 30px, 100px, (max-width: 480px) 36px, 110px" src="https://progiciel.africawebstudent.org/plugins/images/gsr2.png" alt="home" class="light-logo"/>
						</span> </b>
					</a>
                </div>
                <!-- /Logo -->
                <!-- Search input and Toggle icon -->
                <ul class="nav navbar-top-links navbar-left">
                    <li><a href="javascript:void(0)" class="open-close waves-effect waves-light visible-xs"><i class="ti-close ti-menu"></i></a></li>
                    <!-- .Task dropdown -->
                
                    <!-- .Megamenu -->

                    <!-- /.Megamenu -->
                </ul>
                <ul class="nav navbar-top-links navbar-right pull-right">
                    <li>
                        <form role="search" class="app-search hidden-sm hidden-xs m-r-10">
                            <input type="text" placeholder="Search..." class="form-control"> <a href=""><i class="fa fa-search"></i></a> </form>
                    </li>
                    <li class="dropdown">
                        <?php
							include('include/affiche_identite.php');
                        ?>
                        <!-- /.dropdown-user -->
                    </li>
                    <!-- /.dropdown -->
                </ul>
            </div>
            <!-- /.navbar-header -->
            <!-- /.navbar-top-links -->
            <!-- /.navbar-static-side -->
        </nav>
        <!-- End Top Navigation -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <div class="navbar-default sidebar" role="navigation">
            <div class="sidebar-nav">
                <div class="sidebar-head">
                    <h3><span class="fa-fw open-close"><i class="ti-menu hidden-xs"></i><i class="ti-close visible-xs"></i></span> <span class="hide-menu">Navigation</span></h3> </div>
                <ul class="nav" id="side-menu">
                    <li class="user-pro">
                        <a href="javascript:void(0)" class="waves-effect"><img src="img/profil.png" alt="user-img" class="img-circle"> <span class="hide-menu"><?php echo $infoEtudiant['nom'].'  '.$infoEtudiant['prenom']?> <span class="fa arrow"></span></span>
                        </a>
                    </li>
                    <li> <a href="<?php echo "$lien"; ?>" class="waves-effect"><i class="mdi mdi-av-timer fa-fw" data-icon="v"></i> <span class="hide-menu"> Procéder au payement! <span class="fa arrow"></span> <span class="label label-rouded label-inverse pull-right"></span></span></a>
                    </li>
                    <li> <a href="<?php echo "$lien2"; ?>" class="waves-effect active"><i class="mdi mdi-av-timer fa-fw" data-icon="v"></i> <span class="hide-menu"> Liste de mes payements <span class="fa arrow"></span> <span class="label label-rouded label-inverse pull-right"></span></span></a>
                    </li>
                </ul>
            </div>
        </div>

        <!-- ============================================================== -->
        <!-- End Left Sidebar -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page Content -->
        <!-- ============================================================== -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row bg-title">
                    <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
                        <h4 class="page-title"> PAYER </h4> </div>
                    <div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
                        <ol class="breadcrumb">
                            <li><a href="javascript:void(0)">ACCUEIL</a></li>
                            <li class="active">PAYER VOTRE SCOLARITE</li>
                        </ol>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
				<div id="delete-modal" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								<h4 class="modal-title text-danger" id="myModalLabel">Confirmer l'impression</h4> </div>
							<div class="modal-body">
								<form id="delete-form" class="form-horizontal form-material" action="tcpdf/pdf/imprime-recu.php"  method = "POST">
									<div class="form-group">
										<label for="dmatricule" class="col-sm-3 control-label">Matricule : </label>
										<div class="col-sm-9">
											<input id = "matricule" readonly type="text" class="form-control" value="" name = "matricule"> 
										</div>

										<label for="nom" class="col-sm-3 control-label">Nom : </label>
										<div class="col-sm-9">
											<input id = "nom" readonly type="text" class="form-control" value="" name = "nom" required> 
										</div>

										<label for="prenom" class="col-sm-3 control-label">Prénom : </label>
										<div class="col-sm-9">
											<input id = "prenom" readonly type="text" class="form-control" value="" name = "prenom" required> 
										</div>

										<label for="refFacture" class="col-sm-3 control-label">refFacture : </label>
										<div class="col-sm-9">
											<input id = "refFacture" readonly type="text" class="form-control" value="" name = "refFacture" required> 
										</div>
										<input type="hidden" id="montant" name = "montant" value="">
										<input type="hidden" id="annee" name = "annee" value="">
										<input type="hidden" id="niveau" name = "niveau" value="">
										<input type="hidden" id="idFiliere" name = "idFiliere" value="">
										<input type="hidden" id="type" name = "type" value="">
										<input type="hidden" id="statut" name = "statut" value="">
										<input type="hidden" id="academique" name = "academique" value="">
									</div>
									
        							<div class="modal-footer">
        								<button class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
        								<input type="submit" class="btn btn-danger pull-right" value="Imprimer PDF" /><br/><br/>
        								
        							</div>
								</form>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
                </div>
                <!-- /.row -->
                <!-- ============================================================== -->
                <!-- Different data widgets -->
                <!-- ============================================================== -->

                <!-- ============================================================== -->
                <!-- Blog-component -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-sm-12">
                        <div class="white-box">
                            <h3 class="box-title m-b-0">Data Export</h3>
                            <p class="text-muted m-b-30">Export data to Copy, CSV, Excel, PDF & Print</p>
                            <div class="table-responsive">
                                <table id="examtable" class="display nowrap" data-order='[[ 2, "asc" ]]'  cellspacing="0" width="100%">
                                    <thead>
                                        <tr>
                                            <th>Matricule</th>
                                            <th>Nom & Prénom</th>
                                            <th>Niv/Filière</th>
                                            <th>Période</th>
                                            <th>Date transaction</th>
                                            <th>Réf transaction</th>
											<th>Montant</th>
                                            <th>Type</th>
                                            <th>Statut</th>
                                            <th>Date validation</th>
											<th>Impr</th>
											<th>Vérifier statut</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                            <th>Matricule </th>
                                            <th>Nom & Prénom</th>
                                            <th>Niv/Filière</th>
                                            <th>Période</th>
                                            <th>Date transaction</th>
                                            <th>Réf transaction</th>
											<th>Montant</th>
                                            <th>Type</th>
                                            <th>Statut</th>
                                            <th>Date validation</th>
											<th>Impr</th>
											<th>Vérifier statut</th>
                                        </tr>
                                    </tfoot>
                                    <tbody>
										
										<?php
										$d = 0;
										$periode = ($acad-1).'-'.$acad;
										try{
											$sql = "SELECT * FROM `facture` AS f INNER JOIN tabetudiant AS t ON t.matricule = f.matricule  WHERE (f.`annee_acad` = :acad ";
											$sql .= "AND  f.idFiliere = :fil AND f.niveau = :niv AND f.annee = :an AND f.matricule = :m) ";
											$sql .= " ORDER BY dateValidation ASC";
											$statement = $bdd->prepare($sql);
											$statement->bindParam(':acad',  			$acad, PDO::PARAM_STR);
											$statement->bindParam(':fil',  			    $idFiliere, PDO::PARAM_STR);
											$statement->bindParam(':niv',  			    $niveau, PDO::PARAM_STR);
											$statement->bindParam(':an',  			    $annee, PDO::PARAM_STR);
											$statement->bindParam(':m',  			    $session_etudiant, PDO::PARAM_STR);
    									    $statement->execute();
											$niveau = '';
											$cumul = 0;
											
											while($row=$statement->fetch(PDO::FETCH_ASSOC)) {
												$sql1 = "SELECT sigleFilieres FROM `filieres` WHERE `idFiliere` = :id";
												$statement1 = $bdd->prepare($sql1);
												$statement1->bindParam(':id',  			$idFiliere, PDO::PARAM_STR);
												$statement1->execute();
												$row1=$statement1->fetch(PDO::FETCH_ASSOC);
												if($row['niveau'] == 1) {
													$niveau = 'Licence';
												}else if($row['niveau'] == 2) {
													$niveau = 'Master';
												}else{
													$niveau = 'Doctorat';
												}
												$linkstatut = '';
												if($row['statutOperation'] ==1){
                                                    $suppr = 'disabled';
												    $statutOperation = 'En attente';
												    $linkstatut = '<a href="statutoperation.php?uid='.$row['uidmomo'].'" target = "_blank" title="Vérifier le statut de la transaction!"><button type="button"  class="btn btn-info btn-outline btn-circle btn-lg m-r-5 modifier" data-toggle="modal" data-target="#update-domiane"><i class="glyphicon glyphicon-cog"></i></button>';
												}else if($row['statutOperation'] ==0){ //Si l'opération a réussie....
												    $suppr = '';
												    $statutOperation = 'Succès';
                                                    if($row['typefacture'] == 'FV') {
                                                        $cumul += $row['montant'];
                                                    }else{
                                                        $cumul -= $row['montant'];
                                                    }
												}else{
												    $suppr = 'disabled';
												    $statutOperation = 'Echec';
												}

												//$cumul += $row['montant'];
											    $nomprenom = $row['prenom'].' '.$row['nom'];
												echo '<tr>
													<td align = center><a href = "javascript:void(0)"  >'.$row['matricule'].'</a></td>
													<td><a href = "javascript:void(0)"  >'.$row['nom'].' '.$row['prenom'].'</a></td>
													<td><a href = "javascript:void(0)"  >'.$niveau.''.$row['annee'].'/'.$row1['sigleFilieres'].'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$periode.'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$row['dateTransaction'].'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$row['refFacture'].'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$row['montant'].'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$row['typeOperation'].'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$statutOperation.'</a></td>
													<td align = center><a href = "javascript:void(0)"  >'.$row['dateValidation'].'</a></td>
													<td align = center><button type="button" '.$suppr.' class="btn btn-danger btn-outline btn-circle btn-lg m-r-5 supprimer" data-toggle="modal" data-target="#delete-transaction"><i class="glyphicon glyphicon-print"></i></button></td>
													<td align = center>'.$linkstatut.'</td>
													<input type="hidden" class="matricule" value="'.$row['matricule'].'">
													<input type="hidden" class="nom" value="'.$row['nom'].'">
													<input type="hidden" class="prenom" value="'.$row['prenom'].'">
													<input type="hidden" class="annee" value="'.$row['annee'].'">
													<input type="hidden" class="niveau" value="'.$row['niveau'].'">
													<input type="hidden" class="idFiliere" value="'.$row['idFiliere'].'">
													<input type="hidden" class="refFacture" value="'.$row['refFacture'].'">
													<input type="hidden" class="academique" value="'.$acad.'">
													<input type="hidden" class="statut" value="'.$statutOperation.'">
													<input type="hidden" class="type" value="'.$row['typeOperation'].'">
													<input type="hidden" class="montant" value="'.$row['montant'].'">
												</tr>';
											}
											$reste = $montant - $cumul;
											echo '<tr>
												<td align = center></td>
												<td align = center></td>
												<td></td>
												<td align = center>RESTE A PAYER</td>
												<td align = center><font color = red><b>'.$reste.'</b></font></td>
												<td align = center>TOTAL PAYEMENT<font color = red><b></b></font</td>
												<td align = center><font color = red><b></b>'.$cumul.'</font</td>
												<td></td>
												<td></td>
												<td align = center><font color = red><b></b></font</td>
												<td align = center><font color = red><b></b></font</td>
												<td align = center><font color = red><b></b></font</td>
											</tr>';
											echo '<tfoot><tr>
												<td align = center></td>
												<td align = center></td>
												<td></td>
												<td align = center>RESTE A PAYER</td>
												<td align = center><font color = red><b>'.$reste.'</b></font></td>
												<td align = center>TOTAL PAYEMENT<font color = red><b></b></font</td>
												<td align = center><font color = red><b></b>'.$cumul.'</font</td>
												<td></td>
												<td></td>
												<td align = center><font color = red><b></b></font</td>
												<td align = center><font color = red><b></b></font</td>
												<td align = center><font color = red><b></b></font</td>
											</tr></tfoot>';
										}catch(PDOException  $e ){
											//echo notifierErreur2($e->getCode( ), $e->getMessage( ));
										}
										?>										
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
				<div id="erreur-examen-fini"></div>
                <!-- ============================================================== -->
                <!-- chats, message & profile widgets -->
                <!-- ============================================================== -->

                <!-- ============================================================== -->
                <!-- start right sidebar -->
                <!-- ============================================================== -->
                <div class="right-sidebar">
                    <div class="slimscrollright">
                        <div class="rpanel-title"> Service Panel <span><i class="ti-close right-side-toggle"></i></span> </div>
                        <div class="r-panel-body">
                            <ul id="themecolors" class="m-t-20">
                                <li><b>With Light sidebar</b></li>
                                <li><a href="javascript:void(0)" data-theme="default" class="default-theme">1</a></li>
                                <li><a href="javascript:void(0)" data-theme="green" class="green-theme">2</a></li>
                                <li><a href="javascript:void(0)" data-theme="gray" class="yellow-theme">3</a></li>
                                <li><a href="javascript:void(0)" data-theme="blue" class="blue-theme">4</a></li>
                                <li><a href="javascript:void(0)" data-theme="purple" class="purple-theme">5</a></li>
                                <li><a href="javascript:void(0)" data-theme="megna" class="megna-theme">6</a></li>
                                <li class="full-width"><b>With Dark sidebar</b></li>
                                <li><a href="javascript:void(0)" data-theme="default-dark" class="default-dark-theme">7</a></li>
                                <li><a href="javascript:void(0)" data-theme="green-dark" class="green-dark-theme">8</a></li>
                                <li><a href="javascript:void(0)" data-theme="gray-dark" class="yellow-dark-theme">9</a></li>
                                <li><a href="javascript:void(0)" data-theme="blue-dark" class="blue-dark-theme">10</a></li>
                                <li><a href="javascript:void(0)" data-theme="purple-dark" class="purple-dark-theme">11</a></li>
                                <li><a href="javascript:void(0)" data-theme="megna-dark" class="megna-dark-theme working">12</a></li>
                            </ul>
                            <ul class="m-t-20 chatonline">
                                <li><b>Chat option</b></li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/varun.jpg" alt="user-img" class="img-circle"> <span>Varun Dhavan <small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/genu.jpg" alt="user-img" class="img-circle"> <span>Genelia Deshmukh <small class="text-warning">Away</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/ritesh.jpg" alt="user-img" class="img-circle"> <span>Ritesh Deshmukh <small class="text-danger">Busy</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/arijit.jpg" alt="user-img" class="img-circle"> <span>Arijit Sinh <small class="text-muted">Offline</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/govinda.jpg" alt="user-img" class="img-circle"> <span>Govinda Star <small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/hritik.jpg" alt="user-img" class="img-circle"> <span>John Abraham<small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/john.jpg" alt="user-img" class="img-circle"> <span>Hritik Roshan<small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="https://progiciel.africawebstudent.org/plugins/images/users/pawandeep.jpg" alt="user-img" class="img-circle"> <span>Pwandeep rajan <small class="text-success">online</small></span></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- end right sidebar -->
                <!-- ============================================================== -->
            </div>
            <!-- /.container-fluid -->
            <?php echo footer(); ?>
        </div>
        <!-- ============================================================== -->
        <!-- End Page Content -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- Menu Plugin JavaScript -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/sidebar-nav/dist/sidebar-nav.min.js"></script>
    <!--slimscroll JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Counter js -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/waypoints/lib/jquery.waypoints.js"></script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/counterup/jquery.counterup.min.js"></script>
    <!-- chartist chart -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/chartist-js/dist/chartist.min.js"></script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/chartist-plugin-tooltip-master/dist/chartist-plugin-tooltip.min.js"></script>
    <!-- Calendar JavaScript -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/moment/moment.js"></script>
    <script src='https://progiciel.africawebstudent.org/plugins/bower_components/calendar/dist/fullcalendar.min.js'></script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/calendar/dist/cal-init.js"></script>
    <!-- Custom Theme JavaScript -->
    <script src="js/custom.min.js"></script>
	<!-- Custom JavaScript 
    <script src="js/custom/accueil.js"></script>-->
    <!-- Custom tab JavaScript -->
    <script src="js/cbpFWTabs.js"></script>
    <script type="text/javascript">
    (function() {
        [].slice.call(document.querySelectorAll('.sttabs')).forEach(function(el) {
            new CBPFWTabs(el);
        });
    })();
    </script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/toast-master/js/jquery.toast.js"></script>
    <!--Style Switcher -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/styleswitcher/jQuery.style.switcher.js"></script>
	<!-- Sweet-Alert  -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/sweetalert/sweetalert.min.js"></script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/sweetalert/jquery.sweet-alert.custom.js"></script>
    <!-- FormValidation -->
    <link rel="stylesheet" href="https://progiciel.africawebstudent.org/plugins/bower_components/jquery-wizard-master/libs/formvalidation/formValidation.min.css">
    <!-- FormValidation plugin and the class supports validating Bootstrap form -->
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/jquery-wizard-master/libs/formvalidation/formValidation.min.js"></script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/jquery-wizard-master/libs/formvalidation/bootstrap.min.js"></script>
    <script src="https://progiciel.africawebstudent.org/plugins/bower_components/datatables/jquery.dataTables.min.js"></script>
    <!-- start - This is for export functionality only -->
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.flash.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
    <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
    <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>
    <!-- end - This is for export functionality only -->
	<!-- include BlockUI -->
	<script src="https://progiciel.africawebstudent.org/blockui/jquery.blockUI.js"></script>
    
	<script type="text/javascript">		
        $(document).ready(function() {
			$('#fmomo').formValidation({
				framework: 'bootstrap',
				excluded: ':disabled',
				icon: {
					valid: 'glyphicon glyphicon-ok',
					invalid: 'glyphicon glyphicon-remove',
					validating: 'glyphicon glyphicon-refresh'
				},
				fields: {																		
					matricule: {
						validators: {
							notEmpty: {
								message: 'Le matricule est requis'
							},
						}
					},					
					academique: {
						validators: {
							notEmpty: {
								message: 'L\'année académique est requise'
							},
						}
					},					
					pays: {
						validators: {
							notEmpty: {
								message: 'Le pays est requis'
							},
						}
					},					
					tel: {
						validators: {
							notEmpty: {
								message: 'Le téléphone est requis'
							},
						}
					},					
					montant: {
						validators: {
							notEmpty: {
								message: 'Le montant est requis'
							},
						}
					}
					
				}
            });
                
        });
        
		// override these in your code to change the default behavior and style 
		$.blockUI.defaults = { 
			// message displayed when blocking (use null for no message) 
			message:  '<h3>Please wait...</h3>', 
		 
			title: null,        // title string; only used when theme == true 
			draggable: true,    // only used when theme == true (requires jquery-ui.js to be loaded) 
		 
			theme: false, // set to true to use with jQuery UI themes 
		 
			// styles for the message when blocking; if you wish to disable 
			// these and use an external stylesheet then do this in your code: 
			// $.blockUI.defaults.css = {}; 
			css: { 
				padding:        0, 
				margin:         0, 
				width:          '30%', 
				top:            '4%', 
				left:           '66%', 
				textAlign:      'center', 
				color:          '#000', 
				border:         '3px solid #aaa', 
				backgroundColor:'#fff', 
				cursor:         'wait' 
			}, 
		 
			// minimal style set used when themes are used 
			themedCSS: { 
				width:  '30%', 
				top:    '40%', 
				left:   '35%' 
			}, 
		 
			// styles for the overlay 
			overlayCSS:  { 
				backgroundColor: '#f00', 
				opacity:         0.6, 
				cursor:          'wait' 
			}, 
		 
			// style to replace wait cursor before unblocking to correct issue 
			// of lingering wait cursor 
			cursorReset: 'default', 
		 
			// styles applied when using $.growlUI 
			growlCSS: { 
				width:    '250px', 
				top:      '10px', 
				left:     '', 
				right:    '10px', 
				border:   'none', 
				padding:  '5px', 
				opacity:   0.6, 
				cursor:    null, 
				color:    '#fff', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius':    '10px' 
			}, 
			 
			// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w 
			// (hat tip to Jorge H. N. de Vasconcelos) 
			iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', 
		 
			// force usage of iframe in non-IE browsers (handy for blocking applets) 
			forceIframe: false, 
		 
			// z-index for the blocking overlay 
			baseZ: 1000, 
		 
			// set these to true to have the message automatically centered 
			centerX: true, // <-- only effects element blocking (page block controlled via css above) 
			centerY: true, 
		 
			// allow body element to be stetched in ie6; this makes blocking look better 
			// on "short" pages.  disable if you wish to prevent changes to the body height 
			allowBodyStretch: true, 
		 
			// enable if you want key and mouse events to be disabled for content that is blocked 
			bindEvents: true, 
		 
			// be default blockUI will supress tab navigation from leaving blocking content 
			// (if bindEvents is true) 
			constrainTabKey: true, 
		 
			// fadeIn time in millis; set to 0 to disable fadeIn on block 
			fadeIn:  200, 
		 
			// fadeOut time in millis; set to 0 to disable fadeOut on unblock 
			fadeOut:  400, 
		 
			// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock 
			timeout: 0, 
		 
			// disable if you don't want to show the overlay 
			showOverlay: true, 
		 
			// if true, focus will be placed in the first available input field when 
			// page blocking 
			focusInput: true, 
		 
			// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) 
			// no longer needed in 2012 
			// applyPlatformOpacityRules: true, 
		 
			// callback method invoked when fadeIn has completed and blocking message is visible 
			onBlock: null, 
		 
			// callback method invoked when unblocking has completed; the callback is 
			// passed the element that has been unblocked (which is the window object for page 
			// blocks) and the options that were passed to the unblock call: 
			//   onUnblock(element, options) 
			onUnblock: null, 
		 
			// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 
			quirksmodeOffsetHack: 4, 
		 
			// class name of the message block 
			blockMsgClass: 'blockMsg', 
		 
			// if it is already blocked, then ignore it (don't unblock and reblock) 
			ignoreIfBlocked: false 
		}; 	

		$(".supprimer").on('click',function(){
			var ele =$(this).parent();
			//Remplir le modal avant de l'afficher
			let matricule 	= ele.siblings(".matricule").val().trim();
			let nom 		= ele.siblings(".nom").val().trim();
			let prenom 		= ele.siblings(".prenom").val().trim();
			let annee 		= ele.siblings(".annee").val().trim();
			let niveau 		= ele.siblings(".niveau").val().trim();
			let idFiliere 	= ele.siblings(".idFiliere").val().trim();
			let academique 	= ele.siblings(".academique").val().trim();
			let refFacture 	= ele.siblings(".refFacture").val().trim();
			let montant 	= ele.siblings(".montant").val().trim();
			let type     	= ele.siblings(".type").val().trim();
			let statut   	= ele.siblings(".statut").val().trim();
			
			//console.log(matricule); 
			
			$("#delete-form #matricule").val(matricule);
			$("#delete-form #nom").val(nom);
			$("#delete-form #prenom").val(prenom);
			$("#delete-form #refFacture").val(refFacture);
			$("#delete-form #annee").val(annee);
			$("#delete-form #niveau").val(niveau);
			$("#delete-form #idFiliere").val(idFiliere);
			$("#delete-form #academique").val(academique);
			$("#delete-form #montant").val(montant);
			$("#delete-form #type").val(type);
			$("#delete-form #statut").val(statut);

			$("#delete-modal").modal('show');
		});
					
		/*$('#infoDelete').click(function () {
			$.post(
				'tcpdf/pdf/imprime-recu.php',
				{
					matricule: $('#matricule').val(),
					refFacture: $('#refFacture').val(),
					montant: $('#montant').val(),
					annee : $('#annee ').val(),
					niveau: $('#niveau').val(),
					idFiliere: $('#idFiliere').val(),
					academique: $('#academique').val()
				},
				function (data) {
					$('#delete-modal .modal-content').html(data);
				},
				'html'
				);
		});*/
		
		$('#examtable').DataTable({
			dom: 'Blfrtip',
			lengthMenu: [
				[ 10, 25, 50, -1 ],
				[ '10', '25', '50', 'All' ]
			],		
			buttons: [
				{
					extend: 'excel',
					exportOptions: {
						columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
					}               
				},
				{
					extend: 'pdf',
					exportOptions: {
						columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
					},
					pageSize: 'A3'              
				},
				{
					extend: 'print',
					customize: function ( win ) {
						$(win.document.body)
							.css( 'font-size', '10pt' )
							.prepend(
								'<img src="https://progiciel.africawebstudent.org/images/iitech-logo.png" style="position:absolute; top:0; right:0; width:100;" />'
							);
	 
						$(win.document.body).find( 'table' )
							.addClass( 'compact' )
							.css( 'font-size', '8pt' );
					},
					exportOptions: {
						columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
					}              
				}
			]				
		});			
		
    </script>
        
</body>

</html>
