<style>
    #div1{
        margin-left:950px;
    }
</style>
<?php
 define('PAR_PAGE',3);
    $servername="mysql:host=94.23.252.168;dbname=ersendb";
    $username="root";
    $password="prose@111";
    $connexion = new pdo($servername,$username,$password);
?>

<!DOCTYPE html>
<html lang="fr">
<head>
     <meta charset="UTF-8">
     <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="crossorigin="anonymous"></script> 
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
     <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
     <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    <title>Autre tableau</title>
    </head>
<body>
    <br><br>
    <div class="container">
        <div class="row">
            <div class="col-6">
                <form action="" method="POST">
                    <select name="selctMenu" id="">
                        <option value="">----Selectionnez pour voir ses details----</option>
                        <option value="1">Centrales</option>
                        <option value="2">Projets</option>
                        <option value="3">villages polarisés</option>
                        <option value="4">Opérateurs</option>
                    </select>
                    <input type="submit" name="submit" id="" value="Afficher">
                </form>

            </div>
        </div>

    </div>
    <?php
        if(isset($_POST["submit"])){
            if(isset($_POST["selctMenu"])){
                $selctMenu= $_POST["selctMenu"];
                    switch($selctMenu){
                        case '1':?>
                            <div class="container">
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-2"><br/>
                                        <h4 style="margin-left:200px;">les centrales disponible</h4>
                                            <table class="table table-bordred table-hover" id='mytable'style="width:900px;height:100px;">
                                                <thead style="background-color: #1E88E5; color: white;">
                                                        <td style="height: 50px; width: 100px;">Nom</td>
                                                        <td style="height: 50px; width: 100px;">Adresse</td>
                                                        <td style="height: 50px; width: 100px;">Type</td>
                                                        <td style="height: 50px; width: 100px;">Date demarrage</td>
                                                        <td style="height: 50px; width: 100px;">Village</td>
                                                </thead>
                                                <tbody>
                                                <?php
                                                    $query="SELECT c.nom AS nom,c.adresse AS adresse,t.libelle AS libelletype,c.datedemarrage datedemarrage,v.libelle AS village 
                                                    FROM ersen_centrale c,ersen_typecentrale t,ersen_villagequartier v
                                                    WHERE c.typecentrale=t.id
                                                    AND c.village=v.id";
                                                    $sql=$connexion->query($query);
                                                    while($data=$sql->fetch()){?>
                                                        <tr style="background-color: #8C9EFF;color:black;height: 50px; width: 100px;">
                                                            <td style="background-color: #8C9EFF;color:black;height: 50px; width: 100px;"><?php echo $data['nom']?></td>
                                                            <td style="background-color: #8C9EFF;color:black;height: 50px; width: 100px;"><?php echo $data['adresse']?></td>
                                                            <td style="background-color: #8C9EFF;color:black;height: 50px; width: 100px;"><?php echo $data['libelletype']?></td>
                                                            <td style="background-color: #8C9EFF;color:black;height: 50px; width: 100px;"><?php echo $data['datedemarrage']?></td>
                                                            <td style="background-color: #8C9EFF;color:black;height: 50px; width: 100px;"><?php echo $data['village']?></td>
                                                            </tr>
                                                            
                                                            <?php
                                                        }
                                                    ?> 
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

                                    </div>
                                <script>
                                    $(document).ready(function(){
                                        $('#mytable').DataTable();
                                    });
                                </script>
                                <?php
                            break;
                        case '2':?>
                            <div class="container">
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-2"><br/>
                                        <h4 style="margin-left:200px">les projets</h4>
                                        <table class="table table-bordred table-hover" id='mytable' style="width:900px;height:100px;">
                                            <thead style="background-color: #1E88E5; color: white;">
                                            <td>nom</td>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    $query="SELECT * FROM ersen_projet";
                                                    $sql=$connexion->query($query);
                                                    while($data=$sql->fetch()){?>
                                                    <tr style="background-color: #8C9EFF;color:black;">
                                                    <td style="background-color: #8C9EFF;color:black;"><?php echo $data['nom']?></td>
                                                    </tr>
                                                            
                                                        <?php
                                                        }
                                                    ?> 
                                            </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            <script>
                                $(document).ready(function(){
                                    $('#mytable').DataTable();
                                });
                            </script>
                            <?php
                            break;
                        case '3':
                            ?>
                            
                             <div class="container">
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-2"><br/>
                                        <h4 style="margin-left:200px">les villages</h4>
                                        <table class="table table-bordred table-hover" id='mytable' style="width:900px;height:100px;">
                                        <thead style="background-color: #1E88E5; color: white;">
                                        <td>Village</code></td>
                                        <td>Etat</td>
                                        <td>Centrale</td>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $query="SELECT vq.libelle AS libelle,vp.etat AS etat,c.nom AS nom
                                            FROM ersen_village_polarise vp,ersen_villagequartier vq,ersen_centrale c
                                            WHERE vp.villagequartier=vq.id
                                            AND vp.centrale=c.id";
                                                    $sql=$connexion->query($query);
                                            while($data=$sql->fetch()){?>
                                                <tr style="background-color: #8C9EFF;color:black;">
                                                    <td style="background-color: #8C9EFF;color:black;"><?php echo $data['libelle']?></td>
                                                    <td style="background-color: #8C9EFF;color:black;"><?php echo $data['etat']?></td>
                                                    <td style="background-color: #8C9EFF;color:black;"><?php echo $data['nom']?></td>
                                                </tr>
                                                        
                                                        <?php
                                                    }
                                                ?> 
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                </div>
                            <script>
                                $(document).ready(function(){
                                    $('#mytable').DataTable();
                                });
                            </script>
                            <?php
                            break;

                        case '4':?>
                            <div class="container">
                                <div class="row">
                                    <div class="col-md-8 col-md-offset-2"><br/>
                                        <h4 style="margin-left:200px">les operateurs</h4>
                                            <table class="table table-bordred table-hover" id='mytable' style="width:900px;height:100px;">
                                                <thead style="background-color: #1E88E5; color: white;">
                                                    <td>nom</td>
                                                    <td>adresse</td>
                                                    <td>Responsable</td>
                                                </thead>
                                                <tbody>
                                                <?php
                                                    $query="SELECT * FROM ersen_operateur";
                                                    $sql=$connexion->query($query);
                                                    while($data=$sql->fetch()){?>
                                                        <tr style="background-color: #8C9EFF;color:black;">
                                                            <td style="background-color: #8C9EFF;color:black;"><?php echo $data['nom']?></td>
                                                            <td style="background-color: #8C9EFF;color:black;"><?php echo $data['adresse']?></td>
                                                            <td style="background-color: #8C9EFF;color:black;"><?php echo $data['responsable']?></td>
                                                        </tr>
                                                        
                                                        <?php
                                                    }
                                                ?> 
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                </div>
                            <script>
                                $(document).ready(function(){
                                    $('#mytable').DataTable();
                                });
                            </script>
                            <?php
                            break;
                        default:
                            echo "Aucun objet n'est selectionné !";
                            break;
                            
    
                    }
            }
        }
    ?>
</body>
</html>