Browse Source

pop up script js qui marche pas

dorian 10 months ago
parent
commit
43a4518f4c
5 changed files with 329 additions and 42 deletions
  1. 15 37
      ajout-client.php
  2. 12 0
      css/styles.css
  3. 231 0
      index.php
  4. 58 0
      infos.php
  5. 13 5
      js/scripts.js

+ 15 - 37
ajout-client.php

@@ -1,41 +1,19 @@
 <?php
 <?php
-$serveur = "intra.easytelecoms.fr";
-$utilisateur = "admin";
-$mot_de_passe = "Bdtbdt17?";
-$base_de_donnees = "intra";
-
-// Connexion à la base de données MySQL
-$connexion = new mysqli($serveur, $utilisateur, $mot_de_passe, $base_de_donnees);
-
-// Vérifier la connexion
-if ($connexion->connect_error) {
-    die("La connexion à la base de données a échoué : " . $connexion->connect_error);
-}
-
-// Vérifier si le formulaire a été soumis
+// var_dump($_POST);
 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-    // Récupération des données du formulaire
-    $nom = $_POST['nom'];
-    $bdt_nav = $_POST['bdt_nav'];
-    $localisation = $_POST['localisation'];
-    $departement = $_POST['departement'];
-    $date_start = $_POST['date_start'];
-
-    // Préparer la requête d'insertion
-    $requete = $connexion->prepare("INSERT INTO BDT_NAVISTA (nom, bdt_nav, localisation, departement, date_start) VALUES (?, ?, ?, ?, ?)");
-
-    // Associer les valeurs et exécuter la requête
-    $requete->bind_param("sssss", $nom, $bdt_nav, $localisation, $departement, $date_start);
-    $requete->execute();
-
-    // Fermer la requête
-    $requete->close();
-
-    // Redirection vers la page d'accueil ou une autre page
-    header('Location: index.html');
-    exit();
+    $hostname = "localhost";
+    $username = "root";
+    $password = "Bdtbdt17?";
+    $port = "3306";
+    $db = "intra";
+    $dbconnect=mysqli_connect($hostname,$username,$password,$db,$port);
+    $q = 'INSERT INTO client (name, type, localisation, departement) VALUES ("%s","%s","%s","%s")';
+    $query = mysqli_query($dbconnect, sprintf($q,$_POST["name"],$_POST["type"],$_POST["localisation"],$_POST["departement"]))
+            or die (mysqli_error($dbconnect));
+
+    $dbconnect->close();
+
+    header('Location: index.php');
 }
 }
 
 
-// Fermer la connexion à la base de données
-$connexion->close();
-?>
+?>

+ 12 - 0
css/styles.css

@@ -11,6 +11,18 @@
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  */
  */
 
 
+.popup {
+  display: none;
+  position: fixed;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  padding: 20px;
+  background-color: #fff;
+  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
+  z-index: 1000;
+}
+
 :root {
 :root {
   --bs-blue: #0d6efd;
   --bs-blue: #0d6efd;
   --bs-indigo: #6610f2;
   --bs-indigo: #6610f2;

+ 231 - 0
index.php

@@ -0,0 +1,231 @@
+<!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, shrink-to-fit=no" />
+        <meta name="description" content="" />
+        <meta name="author" content="" />
+        <title>Dashboard - SB Admin</title>
+        <link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.min.css" rel="stylesheet" />
+        <link href="css/styles.css" rel="stylesheet" />
+        <script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
+    </head>
+    <body class="sb-nav-fixed">
+        <nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
+            <!-- Navbar Brand-->
+            <a class="navbar-brand ps-3" href="index.html">Start Bootstrap</a>
+            <!-- Sidebar Toggle-->
+            <button class="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" id="sidebarToggle" href="#!"><i class="fas fa-bars"></i></button>
+            <!-- Navbar Search-->
+            <form class="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
+            </form>
+            <!-- Navbar-->
+            <ul class="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
+                <li class="nav-item dropdown">
+                    <a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fas fa-user fa-fw"></i></a>
+                    <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
+                        <li><a class="dropdown-item" href="#!">Settings</a></li>
+                        <li><a class="dropdown-item" href="#!">Activity Log</a></li>
+                        <li><hr class="dropdown-divider" /></li>
+                        <li><a class="dropdown-item" href="#!">Logout</a></li>
+                    </ul>
+                </li>
+            </ul>
+        </nav>
+        <div id="layoutSidenav">
+            <div id="layoutSidenav_nav">
+                <nav class="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
+                    <div class="sb-sidenav-menu">
+                        <div class="nav">
+                            <div class="sb-sidenav-menu-heading">Core</div>
+                            <a class="nav-link" href="index.html">
+                                <div class="sb-nav-link-icon"><i class="fas fa-tachometer-alt"></i></div>
+                                Dashboard
+                            </a>
+                            <div class="sb-sidenav-menu-heading">Interface</div>
+                            <a class="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapseLayouts" aria-expanded="false" aria-controls="collapseLayouts">
+                                <div class="sb-nav-link-icon"><i class="fas fa-columns"></i></div>
+                                Layouts
+                                <div class="sb-sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
+                            </a>
+                            <div class="collapse" id="collapseLayouts" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordion">
+                                <nav class="sb-sidenav-menu-nested nav">
+                                    <a class="nav-link" href="layout-static.html">Static Navigation</a>
+                                    <a class="nav-link" href="layout-sidenav-light.html">Light Sidenav</a>
+                                </nav>
+                            </div>
+                            <a class="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapsePages" aria-expanded="false" aria-controls="collapsePages">
+                                <div class="sb-nav-link-icon"><i class="fas fa-book-open"></i></div>
+                                Pages
+                                <div class="sb-sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
+                            </a>
+                            <div class="collapse" id="collapsePages" aria-labelledby="headingTwo" data-bs-parent="#sidenavAccordion">
+                                <nav class="sb-sidenav-menu-nested nav accordion" id="sidenavAccordionPages">
+                                    <a class="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#pagesCollapseAuth" aria-expanded="false" aria-controls="pagesCollapseAuth">
+                                        Authentication
+                                        <div class="sb-sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
+                                    </a>
+                                    <div class="collapse" id="pagesCollapseAuth" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordionPages">
+                                        <nav class="sb-sidenav-menu-nested nav">
+                                            <a class="nav-link" href="login.html">Login</a>
+                                            <a class="nav-link" href="register.html">Register</a>
+                                            <a class="nav-link" href="password.html">Forgot Password</a>
+                                        </nav>
+                                    </div>
+                                    <a class="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#pagesCollapseError" aria-expanded="false" aria-controls="pagesCollapseError">
+                                        Error
+                                        <div class="sb-sidenav-collapse-arrow"><i class="fas fa-angle-down"></i></div>
+                                    </a>
+                                    <div class="collapse" id="pagesCollapseError" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordionPages">
+                                        <nav class="sb-sidenav-menu-nested nav">
+                                            <a class="nav-link" href="401.html">401 Page</a>
+                                            <a class="nav-link" href="404.html">404 Page</a>
+                                            <a class="nav-link" href="500.html">500 Page</a>
+                                        </nav>
+                                    </div>
+                                </nav>
+                            </div>
+                            <div class="sb-sidenav-menu-heading">Addons</div>
+                            <a class="nav-link" href="charts.html">
+                                <div class="sb-nav-link-icon"><i class="fas fa-chart-area"></i></div>
+                                Charts
+                            </a>
+                            <a class="nav-link" href="tables.html">
+                                <div class="sb-nav-link-icon"><i class="fas fa-table"></i></div>
+                                Tables
+                            </a>
+                        </div>
+                    </div>
+                    <div class="sb-sidenav-footer">
+                        <div class="small">Logged in as:</div>
+                        Start Bootstrap
+                    </div>
+                </nav>
+            </div>
+            <div id="layoutSidenav_content">
+                <main>
+                    <div class="container-fluid px-4">
+                        <h1 class="mt-4">Dashboard</h1>
+                        <ol class="breadcrumb mb-4">
+                            <li class="breadcrumb-item active">Dashboard</li>
+                        </ol>
+                        <div class="row">
+                            <div class="col-xl-6">
+                                <div class="card mb-4">
+                                    <div class="card-header">
+                                        <i class="fas fa-chart-area me-1"></i>
+                                        Area Chart Example
+                                    </div>
+                                    <div class="card-body"><canvas id="myAreaChart" width="100%" height="40"></canvas></div>
+                                </div>
+                            </div>
+                            <div class="col-xl-6">
+                                <div class="card mb-4">
+                                    <div class="card-header">
+                                        <i class="fas fa-chart-bar me-1"></i>
+                                        Bar Chart Example
+                                    </div>
+                                    <div class="card-body"><canvas id="myBarChart" width="100%" height="40"></canvas></div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="card mb-4">
+                            <div class="card-header">
+                                <i class="fas fa-table me-1"></i>
+                                DataTable Example
+                            </div>
+                            <div class="card-body">
+                                <form action="ajout-client.php" method="post">
+                                    <table id="datatablesSimple">
+                                        <thead>
+                                            <tr>
+                                                <th>ID</th>
+                                                <th>Nom</th>
+                                                <th>BDT/NAV</th>
+                                                <th>Localisation</th>
+                                                <th>Département</th>
+                                                <!-- <th>Date création</th> -->
+                                            </tr>
+                                        </thead>
+                                        <tfoot>
+                                            <tr>
+                                                <th>ID</th>
+                                                <th>Nom</th>
+                                                <th>BDT/NAV</th>
+                                                <th>Localisation</th>
+                                                <th>Département</th>
+                                                <!-- <th>Date création</th> -->
+                                            </tr>
+                                        </tfoot>
+                                        <tbody>
+                                            <?php
+                                            $hostname = "localhost";
+                                            $username = "root";
+                                            $password = "Bdtbdt17?";
+                                            $port = "3306";
+                                            $db = "intra";
+                                            
+                                            $dbconnect=mysqli_connect($hostname,$username,$password,$db,$port);
+                                            $q = 'SELECT * FROM client';
+                                            $query = mysqli_query($dbconnect, $q)
+                                                or die(mysqli_error($dbconnect));
+
+                                            while ($row = mysqli_fetch_array($query)) {
+
+                                                echo "<tr>
+                                                        <td onclick='redirectToInfos({$row['id']})'>{$row['id']}</td>
+                                                        <td onclick='redirectToInfos({$row['id']})'>{$row['name']}</td>
+                                                        <td onclick='redirectToInfos({$row['id']})'>".mysqli_fetch_array($dbconnect->query('SELECT name FROM type WHERE id="'.$row['type'].'"'))['0']."</td>
+                                                        <td onclick='redirectToInfos({$row['id']})'>{$row['localisation']}</td>
+                                                        <td onclick='redirectToInfos({$row['id']})'>{$row['departement']}</td>
+                                                    </tr>";
+                                            }
+                                            $dbconnect->close();
+                                            header('Location: index.php');
+                                            ?>
+                                            <tr>
+                                                <td>Ajout client</td>
+                                                <td><input type="text" name="name" required></td>
+                                                <td><select id="client" type="text" name="type" required>
+                                                    <option value="1">BDT</option>
+                                                    <option value="2">NAVISTA</option></select></td>
+                                                <td><input type="text" name="localisation"></td>
+                                                <td><input type="text" name="departement"></td>
+                                            </tr>
+                                        </tbody>
+                                    </table>
+                                    <button type="submit">Ajouter client</button>
+                                </form>
+                            </div>
+                        </div>
+                    </div>
+                </main>
+                <footer class="py-4 bg-light mt-auto">
+                    <div class="container-fluid px-4">
+                        <div class="d-flex align-items-center justify-content-between small">
+                            <div class="text-muted">Copyright &copy; Your Website 2023</div>
+                            <div>
+                                <a href="#">Privacy Policy</a>
+                                &middot;
+                                <a href="#">Terms &amp; Conditions</a>
+                            </div>
+                        </div>
+                    </div>
+                </footer>
+            </div>
+        </div>
+        <script>
+            function redirectToInfos(id) {
+                window.location.href = 'intra/infos.php?id=' + id;
+            }
+        </script>
+        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
+        <script src="js/scripts.js"></script>
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
+        <script src="assets/demo/chart-area-demo.js"></script>
+        <script src="assets/demo/chart-bar-demo.js"></script>
+        <script src="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/umd/simple-datatables.min.js" crossorigin="anonymous"></script>
+        <script src="js/datatables-simple-demo.js"></script>
+    </body>
+</html>

+ 58 - 0
infos.php

@@ -0,0 +1,58 @@
+<!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, shrink-to-fit=no" />
+        <meta name="description" content="" />
+        <meta name="author" content="" />
+        <title>Dashboard - SB Admin</title>
+        <link href="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/style.min.css" rel="stylesheet" />
+        <link href="css/styles.css" rel="stylesheet" />
+        <script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
+    </head>
+    <body class="sb-nav-fixed">
+    <?php
+        $hostname = "localhost";
+        $username = "root";
+        $password = "Bdtbdt17?";
+        $port = "3306";
+        $db = "intra";
+
+        $dbconnect = mysqli_connect($hostname, $username, $password, $db, $port);
+
+        // Vérifie si l'ID est présent dans l'URL
+        if (isset($_GET['id'])) {
+            $id = mysqli_real_escape_string($dbconnect, $_GET['id']);
+
+            // Effectuez votre requête pour récupérer les informations du client avec l'ID donné
+            $q = "SELECT * FROM client WHERE id = '$id'";
+            $query = mysqli_query($dbconnect, $q) or die(mysqli_error($dbconnect));
+
+            if ($row = mysqli_fetch_array($query)) {
+                // Affichez les informations du client dans la page infos.php
+                echo "<h1>Informations sur le client</h1>";
+                echo "<p>ID: {$row['id']}</p>";
+                echo "<p>Nom: {$row['name']}</p>";
+                echo "<p>Type: " . mysqli_fetch_array($dbconnect->query('SELECT name FROM type WHERE id="' . $row['type'] . '"'))['0'] . "</p>";
+                echo "<p>Localisation: {$row['localisation']}</p>";
+                echo "<p>Département: {$row['departement']}</p>";
+            } else {
+                echo "<p>Client non trouvé.</p>";
+            }
+        } else {
+            echo "<p>Paramètre ID manquant dans l'URL.</p>";
+        }
+
+        $dbconnect->close();
+    ?>
+
+        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
+        <script src="js/scripts.js"></script>
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
+        <script src="assets/demo/chart-area-demo.js"></script>
+        <script src="assets/demo/chart-bar-demo.js"></script>
+        <script src="https://cdn.jsdelivr.net/npm/simple-datatables@7.1.2/dist/umd/simple-datatables.min.js" crossorigin="anonymous"></script>
+        <script src="js/datatables-simple-demo.js"></script>
+    </body>
+</html>

+ 13 - 5
js/scripts.js

@@ -25,10 +25,18 @@ window.addEventListener('DOMContentLoaded', event => {
 
 
 });
 });
 
 
-// function afficherPopup(nom, client) {
-//     var popupMessage = "Nom: " + nom + "\nClient: " + client;
-//     alert(popupMessage);
-//     // Vous pouvez également utiliser d'autres méthodes pour créer une fenêtre pop-up, comme l'utilisation de modaux.
-//     };
+// // Fonction pour ouvrir la fenêtre pop-up
+// function openPopup() {
+//     document.getElementById('popup').style.display = 'block';
+// }
+
+// // Fonction pour fermer la fenêtre pop-up
+// function closePopup() {
+//     document.getElementById('popup').style.display = 'none';
+// }
+
+// function redirectToInfos(id) {
+//     window.location.href = 'intra/infos.php?id=' + id;
+// }