<?php
session_start();
header("Access-Control-Allow-Headers: Authorization, Content-Type");
header("Access-Control-Allow-Origin: *");
include_once('Library/Basededonnees.php');
$databaseu = new Basededonnees('africawebstudent_universite');
$bddg = $databaseu->getBdd();

$uid = $_GET["uid"] ;
$sqlu = "SELECT * FROM uid_student where uid = :uid";
$statementu = $bddg->prepare($sqlu);
$statementu->bindParam(':uid', 	$uid, PDO::PARAM_STR);
$statementu->execute();
$rowu=$statementu->fetch(PDO::FETCH_ASSOC);
$acad 		= $rowu['annee_acad'];											
$periode 	= $rowu['periode'];	

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

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

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

$token	= trim($rowu["code_preinscription"]);

$session_etudiant   =   $rowu["matricule"];

$idEtablissement    =   $rowu["idEtablissement"];

$idFiliere          =   $rowu["idFiliere"];

$annee              =   $rowu["annee"];

$niveau	= $rowu["niveauFormation"];

include('/home/africawebstudent/public_html/gs/progicielgeststudent/configuration_etabli.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";

//**********
date_default_timezone_set('Africa/Porto-Novo'); 
$d = getdate();

$y = $d["year"];
$mo = $d["mon"];
$wd = $d["mday"];

$h = $d["hours"];
$m = $d["minutes"];
$s = $d["seconds"];

$dateTransaction = "$y-$mo-$wd $h:$m:$s";

include('Library/Identite.php');
include('footer.php');
$aff = 'YES';
$sql0 = "SELECT * FROM academique where idEtablissement = :idEtablissement AND affiche = :aff ORDER BY annee_acad DESC";
$statement0 = $bdd->prepare($sql0);
$statement0->bindParam(':idEtablissement', 	$idEtablissement, PDO::PARAM_STR);
$statement0->bindParam(':aff', 	$aff, PDO::PARAM_STR);
$statement0->execute();
$row=$statement0->fetch(PDO::FETCH_ASSOC);
$acad 		= $row['annee_acad'];											
$periode 	= $row['periode'];	
$select     = "<option data-tokens='ketchup mustard' value=\"$acad\">$periode</option>";										


/*$DB_DATABASEG = 'iitech_universite';
$databaseg = new Basededonnees($DB_DATABASEG);
$bddg = $databaseg->getBdd();*/

/*$sql1 = "SELECT * FROM `tabinscription` where code_preinscription= :token";
$statement1 = $bdd->prepare($sql1);
$statement1->bindParam(':token', $token, PDO::PARAM_STR);
$statement1->execute();
$row1=$statement1->fetch(PDO::FETCH_ASSOC);*/
//$acad = $row1['annee_acad'];

//Cherchons le code de préinscription de l'etudiant
$statement1= $bdd->prepare('SELECT * FROM tabinscription WHERE matricule=? AND idFiliere=? AND annee_acad=? AND annee=?');
$statement1->execute(array($session_etudiant,$idFiliere,$acad ,$annee)) or die(print_r($precode->errorInfo()));
$row1=$statement1->fetch();
$idStatutEtudiant=$row1['statut'];
$nb=$statement1->rowCount();
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:index.php");

	exit();
}

//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,$idStatutEtudiant));
$Montant    = $resMontant->fetch();
$montant 	    = $Montant['scolarite'] + $Montant['fraisInscription']; //scolarite de l'année en cours

$montantDu = 0; //pour chaque annee
$montTotaleDu = 0; //pour l'ensemble des années
/** Pour chaque étudiant, on fait la recherche de ces dettes antérieures */
$sqlm 	 = "SELECT * FROM tabinscription WHERE annee_acad < :acad AND matricule =:matr";
$resm     = $bdd -> prepare($sqlm);
$resm     ->execute(array('acad'=>$acad, 'matr'=>$session_etudiant)) or die(print_r($resm->errorInfo()));
while($donneem=$resm->fetch()) {
	//Déterminer le montant
	$resMontantm = $bdd->prepare('SELECT * FROM montant WHERE idEtablissement=? AND idFiliere =? AND annee =? AND periode =? AND idStatut =?');
	$resMontantm->execute(array($idEtablissement,$donneem['idFiliere'],$donneem['annee'],$donneem['annee_acad'],$donneem['statut']));
	$Montantm= $resMontantm->fetch();
	$fraism          	= $Montantm['scolarite'] + $Montantm['fraisInscription'];
	$p = ($donneem['annee_acad']-1).'-'.$donneem['annee_acad'];
	$montantDu = $fraism - $donneem['montant'];
	$montTotaleDu = $montTotaleDu + $montantDu;
}
$montTotaleDu = $montTotaleDu + $montant;

$reste = $montTotaleDu - $row1['montant'];
?>
<!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">
	<!--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 active"><i class="mdi  mdi-currency-usd 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"><i class="mdi  mdi-currency-usd 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>
                <!-- /.row -->
                <!-- ============================================================== -->
                <!-- Different data widgets -->
                <!-- ============================================================== -->

                <!-- ============================================================== -->
                <!-- Blog-component -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-md-offset-3 col-md-6">
                        <div class="panel panel-info white-box">
                            <div class="panel-heading">Veuillez sélectionner les données s'il vous plait.</div>
                            <div class="panel-wrapper collapse in" aria-expanded="true">
                                <div id = "listereclamations" class="panel-body">
                                    <form  enctype="multipart/form-data" method = "POST"  id = "fmomo"  class="form-horizontal form-bordered"
									data-fv-framework="bootstrap"
									data-fv-icon-valid="glyphicon glyphicon-ok"
									data-fv-icon-invalid="glyphicon glyphicon-remove"
									data-fv-icon-validating="glyphicon glyphicon-refresh">
                                        <div class="form-body">											
                                            <div class="row">
                                                <div class="col-md-6 col-sm-6">
                                                    <label >Matricule</label>
													<input readonly name = "matricule"  id = "matricule" type = "number" value = "<?php echo $_SESSION["etudiant_i"]; ?>" class="form-control">
													<input name = "idFiliere"  id = "idFiliere" type = "hidden" value = "<?php echo $idFiliere; ?>" class="form-control">
													<input name = "niveau"  id = "niveau" type = "hidden" value = "<?php echo $niveau; ?>" class="form-control">
													<input name = "annee"  id = "annee" type = "hidden" value = "<?php echo $annee; ?>" class="form-control">
													<input name = "token"  id = "token" type = "hidden" value = "<?php echo $token; ?>" class="form-control">
                                                </div>
                                                <div class="col-sm-6">
                                                    <label >Académique <font color = red>*</font></label>
                                                    <select  name = "academique"  id = "academique"  class="form-control">
                                                        <?php echo $select; ?>
                                                    </select>
                                                </div>
                                            </div>
                                            
                                            <br />
                                            
                                            <div class="row">
                                                <div class="col-md-6 col-sm-6">
                                                    <label>Pays <font color = red>*</font></label>
                                                    <select class="form-control" name="pays" id="pays">
                                                        <option value="229" selected>Bénin (+229) </option>
                                                        <option disabled value="228"> Togo (+228) </option>
                                                        <option disabled value="225"> Côte d'Ivoire (+225) </option>                                        
                                                    </select>
                                                </div>
                                                <div class="col-md-6 col-sm-6">
                                                    <label>Téléphone <font color = red>*</font></label>
                                                    <input type="number" class="form-control" name="tel" id="tel" value="" required maxlength="8" minlength="8" />
                                                </div>
                                            </div>

                                            <br />
                                            
                                            <div class="row">
                                                <div class="col-sm-6">
                                                     <label>Montant <font color = red>*</font></label>
                                                    <input class="form-control" name="montant" id="montant" type="number" min = '0'  value="" required />
                                                    <input type="hidden" name="montantmax" id="montantmax"  value="<?php echo $reste; ?>"/>
                                                    <input type="hidden" name="dateTransaction" id="dateTransaction"  value="<?php echo $dateTransaction; ?>"/>
                                                </div>
                                                <div class="col-sm-6">
                                                    <u>Type paiement</u>
                                                    <select class="form-control" name="type" id="type" required >
                                                        <!-- option value=""> Choisir le type de paiement </option-->
                                                        <option value="1"> MoMo (Mobile Money MTN) </option>
                                                        <option value="2" disabled="disabled"> MoovMoney (Mobile Money MOOV) </option>
                                                        <option value="3" disabled="disabled"> VISA (Carte Prépayées VISA) </option>                                        
                                                    </select>
                                                </div>
                                            </div>
                                            
                                            <br />
                                            
                                            <div class="row">
                                                <div class="col-sm-6">
                                                    <u>Nature opération</u>
                                                    <select class="form-control" name="nature" id="nature" required >
                                                        <option value="Paiement de la scolarite"> Paiement de la scolarité </option>
                                                        <option value="Paiement des frais de soutenance"> Paiement des frais de soutenance </option>
                                                        <option value="Autre" disabled="disabled"> Autre </option>                                        
                                                    </select>
                                                </div>
                                                <div class="col-md-6 col-sm-6">
                                                    <u>Nom & prénom</u>
                                                    <input type="text" class="form-control" name="nameetu" id="nameetu" value="" placeholder="Nom & prenom de l'étudiant si paiement effectué par une tiers personne!!!"  />
                                                </div>
                                            </div>
                                             
                                       </div>                                       
                                       <br />
                                       <div class="form-actions">
                                            <div class="row">
                                                <div class="col-sm-6">
                                                    <u>Devise</u>
                                                    <input readonly class="form-control" name="devise" value="XOF"/>
                                                </div>
                                                <div class="col-sm-6"><br/>
                                                    <button type="button" id = "btn_manuelle"  class="btn btn-success btn-block btn-info"> 
                                                        <span class="glyphicon glyphicon-ok-sign"></span> Payer                                        
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </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>
	<!-- 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'
							},
						}
					},					
					type: {
						validators: {
							notEmpty: {
								message: 'Le mode de paiement est requis'
							},
						}
					},					
					montant: {
						/*validators: {
							callback: {
								//message: 'Le montant est requis',
								callback: function(value, validator, $field) {
									// Get the selected options
									var val = validator.getFieldElements('montant').val();
									var montantmax = validator.getFieldElements('montantmax').val();
									var diff = value - montantmax;
                                    // The password doesn't contain any uppercase character
                                    if (montantmax < value) {
                                        return {
                                            valid: false,
                                            message: 'Dépassement de montant autorisé à hauteur de :'+(diff)
                                        }
                                    }
                                    /*if (val > montantmax) {
                                        alert(value);
                                        return true;
                                    }*/
									
									//alert(montantmax);
									//return (options != '');
								//}
						//	}
						//}
					    
						validators: {
							notEmpty: {
								message: 'Le montant est requis'
							},
						}
					}
					
				}
            });
                
        });
        
    	$( "#btn_manuelle" ).click(function() {
			$( document ).ready(function() {
				data = new FormData($("#fmomo")[0]); //$("#frm_"+action).serializeArray();
				if($('#montant').val()<='0' || $('#tel').val()=='' || ($('#tel').val()).length != 8 ||  $('#academique').val()=='' || $('#type').val()=='' || $('#type').val()=='3'){
					swal({
						title: "",
					    width: 100,
						text: "Veuillez controler les champs!!!",
						type: "error",
						closeOnConfirm: false,
						//showLoaderOnConfirm: true,
						confirmButtonClass: "btn-danger",
						confirmButtonText: "OK",
						confirmButtonColor: "#ec6c62"
					 });				
				}else{
					var message = "<font color = red size=5><i>Bien vouloir confirmer cette opération.</i></font>";
					var x  = $('#montant').val();
					//var x  = Math.round((x*1.2)/100);
					//var x  = Math.ceil((x*100)/97);
					swal({
					  html:true,
					  title: ""+message,
					  text: "<b>Montant à prélever</b> : <font color = red><b>"+x+ " FCFA</b></font>",
					  type: "warning",
					  showCancelButton: true,
					  confirmButtonColor: "#DD6B55",
					  confirmButtonText: "Oui!",
					  cancelButtonText: "Non!",
					  closeOnConfirm: true,
					  closeOnCancel: true
					},
					function(isConfirm){
						if (isConfirm) {
							$.blockUI({ 
								centerY: 0, 
								css: { top: '10px', left: '', right: '10px',  border: '3px solid #a00' } 
							}); 
							$.ajax({
								type: "POST",  
								url: "payer.php",  
								data: data,
								processData: false,  // tell jQuery not to process the data
								contentType: false ,  // tell jQuery not to set contentType
								dataType: "json",       
								success: function(data)  
								{
									swal({
										  title: "",
										  text: "Le payement est initié. Veuillez valider l'opération sur votre Mobile Money d'abord et cliquer sur le bouton <OK> pour consulter le statut de l'opération!!!",
										  type: "info",
                    					  showCancelButton: false,
                    					  confirmButtonColor: "#ec6c62",
                    					  confirmButtonText: "Ok!",
                    					  cancelButtonText: "No!",
                    					  closeOnConfirm: true,
                    					  closeOnCancel: true
									},
									function(isConfirm){
									    if (isConfirm) {
                                            window.open(
                                              'statutoperation.php',
                                              '_blank' // <- This is what makes it open in a new window.
                                            );
                                            /*window.open(
                                              'statutoperation.php?<?php echo "uid=$dateTransaction&u=$session_etudiant&e=$idEtablissement&f=$idFiliere&a=$annee&n=$niveau"; ?>',
                                              '_blank' // <- This is what makes it open in a new window.
                                            );*/
                                            //window.location.reload();
									    }else{
									       //swal("Oops", "Consultation statut annulé... :)", "error"); 
									       //window.location.reload();
									    }
									});
								}, 
								complete: function() { 
									//$('#decodeimage').html('<div class="form-group" id="decodeimage"><label class="control-label col-md-3">Reçu bank info</label><div class="col-md-6"><input name = "decode"  id = "decode" type = "text" class="form-control" readonly ></div></div>');	
									// unblock when remote call returns 
									$.unblockUI(); 
								}, 
								error: function(jqXHR, exception){
									swal({
										html:true,
										title: "<font color = red size=5><i>Erreur dans le traitement de votre requête.</i></font>",
										text: jqXHR.responseText,
										type: "error",
										closeOnConfirm: false,
										showLoaderOnConfirm: true,
										confirmButtonClass: "btn-danger",
										confirmButtonText: "OK",
										confirmButtonColor: "#ec6c62"
									 });				
								}
							});
						}else{
							//swal("Oops", "Opération annulée... :)", "error");
						}
					});
				}	
			});					
		});
        
		// 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 
		}; 				
    </script>
        
</body>

</html>
