1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
| <?php
session_start(); // AU TOUT DEBUT du fichier
// ----------------------
// Connexion BDD
include('include_db.php');
// ----------------------
if (empty($_SESSION['Prenom'])) {
header('Location: index.php');
}
// ----------------------
// REQUETE : Construction
$sql_requete = "SELECT * FROM BDD";
$sql_params = array();
// ----------------------
// Traitement : Recherche ?
if (!empty($_POST['Search'])) {
$search = str_replace(' ', '', $_POST['Search']);
if (is_numeric($search)) { // nombres
$sql_requete .= " WHERE Telephone LIKE ? OR CodePostale LIKE ?";
$sql_params = array('%'. $search . '%' , '%' . $search . '%');
} else { // chaine
$sql_requete .= " WHERE Prenom LIKE ? OR Nom LIKE ? OR Ville LIKE ? OR Email LIKE ? OR Adresse LIKE ?";
$sql_params = array( '%' . $search . '%' , '%' . $search . '%', '%' . $search . '%', '%' . $search . '%', '%' . $search . '%');
}
}
// ----------------------
// Supprimer des utilisateurs
if (!empty($_POST["delete"])) {
$ids = implode(",", (array)$_POST["delete"]);
$final = $db->prepare("DELETE FROM `BDD` WHERE Id IN ($ids)");
$final->execute();
}
// ----------------------
// Requête : TOUT
$requete_total = $db->prepare($sql_requete);
$requete_total->execute($sql_params);
$elem_total = $requete_total->rowCount();
// ----------------------
// Pagination
$elem_page = 10;
$page_total = ceil($elem_total/ $elem_page);
if (!empty($_GET['page']) && $_GET['page'] > 0) {
$pageCourante = intval($_GET['page']);
} else {
$pageCourante = 1;
}
if ($pageCourante>$page_total) {
$pageCourante = $page_total;
}
$depart_page = ($pageCourante-1) * $elem_page;
// ----------------------
// Requête : pour cette page
$sql_requete_page = $sql_requete . " LIMIT ".$depart_page." , ".$elem_page." ";
$requete_page = $db->prepare($sql_requete_page);
$requete_page->execute($sql_params);
// ----------------------
?>
<!DOCTYPE html>
<html>
<head>
<title>PA - Liste des utilisateurs</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="css/list.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="icon" href="https://www.proactiveacademy.fr/wp-content/uploads/2018/01/cropped-favicon-32x32.png" sizes="32x32" />
<link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">
</head>
<body class="d-flex flex-column justify-content-center">
<div id="page-content">
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand"><img src="http://www.proactiveacademy.fr/wp-content/uploads/2018/01/p-proactive-1.png" class="img-fluid" alt="Responsive image"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav mx-auto">
<li class="nav-item">
<a class="nav-link" href="add.php"><i class="fas fa-user-plus"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="add_csv.php"><i class="fas fa-users"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="logout.php"><i class="fas fa-sign-out-alt"></i></a>
</li>
</ul>
</div>
<span class="navbar-text right-align" style="text-align: right;">Bienvenue, <?php echo $_SESSION['Prenom']?></span>
</nav>
</header>
<?php
if (!empty($_POST["delete"])) {
echo "<div class=\"alert alert-success \"><center><strong>Parfait !</strong><class=\"alert-link\"> Les ou les utilisateurs ont bien été supprimés</a>.</center></div>";
}
?>
<main class="flex-fill justify-content-center align-items-center">
<div class="main"></br></br>
<div class="container-fluid"><br/><br/>
<div class="options">
<div class="form-group has-search">
<span class="fa fa-search form-control-feedback"></span>
<form method="post" action="list.php">
<div class="searchbar"><input type="text" class="form-control" value="Rechercher un utilisateur" name="Search" onclick="this.value='';"></div></form>
<form method="post" action="list.php">
<input type="submit" class="btn btn-danger" style="width: 130px;" value="Supprimer" name="supprimer">
</div>
</div>
<div class="row h-1">
<div class="col-sm-13 mx-auto">
<table class="table table-striped table-responsive table-hover" id="myTable">
<thead class="thead-dark" style="width:10%;">
<tr>
<th style="width:2%;" id="Choix"></th>
<th id="Nom" class="selection" data-tri="1" data-type="num">NOM</th>
<th id="Prenom">PRÉNOM</th>
<th id="Sexe">SEXE</th>
<th id="Telephone" >TELEPHONE</th>
<th id="E-mail">EMAIL</th>
<th id="Code-Postale" scope="col">CODE POSTALE</th>
<th id="Adresse" scope="col">ADRESSE</th>
<th id="Ville" scope="col">VILLE</th>
<th id="QPV" scope="col">QPV</th>
<th id="DernierDiplome" scope="col">DERNIER DIPLÔME</th>
<th id="Formationvise" scope="col">FORMATION VISEE</th>
<th id="Specialitee" scope="col">SPECIALITEE</th>
<th id="Niveau" scope="col">NIVEAU DE FORMATION VISE</th>
<th id="Metier" scope="col">METIER</th>
<th id="Contratvise" scope="col">CONTRAT VISE</th>
<th id="Rythme" scope="col">RYTHME D'ALTERNANCE</th>
<th id="Structure" scope="col">STRUCTURE</th>
<th id="CV" style="width:6%" scope="col">UPLOAD</th>
<th style="width:7%;" id="Edit" scope="col">MODIFICATION</th>
<th id="CV" style="width:5%" scope="col">CV</th>
</tr>
</thead>
<tbody>
<?php while ($donne = $requete_page->fetch()) { ?>
<tr>
<td class="w-25"><input type="checkbox" name="delete[]" value="<?php echo $donne['Id']; ?>" /></td>
<td class="w-25"><?php echo $donne['Nom']; ?></td>
<td class="w-25"><?php echo $donne['Prenom']; ?></td>
<td><?php echo $donne['Sexe']; ?></td>
<td><?php echo $donne['Telephone']; ?></td>
<td><?php echo $donne['Email']; ?></td>
<td><?php echo $donne['CodePostale']; ?></td>
<td><?php echo $donne['Adresse']; ?></td>
<td><?php echo $donne['Ville']; ?></td>
<td><?php echo $donne['QPV']; ?></td>
<td><?php echo $donne['Dernierdiplome']; ?></td>
<td><?php echo $donne['Formationvise']; ?></td>
<td><?php echo $donne['Specialitee']; ?></td>
<td><?php echo $donne['Niveau']; ?></td>
<td><?php echo $donne['Metier']; ?></td>
<td><?php echo $donne['Contratvise']; ?></td>
<td><?php echo $donne['Rythme']; ?></td>
<td><?php echo $donne['Structure']; ?></td>
<td class="w-25"><a class="btnEdit btn btn-primary btn-sm" href="upload.php?id=<?php echo $donne['Id']; ?>">Upload</a></td>
<td><a class="btnEdit btn btn-primary btn-sm" href="edit.php?id=<?php echo $donne['Id']; ?>">Editer</a></td>
<td><a class="btnEdit btn btn-primary btn-sm" href="cv/<?php echo $donne['Id']; echo ".docx";?>">DL</a></td>
</tr>
<?php } ?>
</tbody>
</table>
<ul class="pagination justify-content-center">
<li class="page-item">
<?php for ($i=1; $i<=$page_total; $i++) { ?>
<li class="page-item"><a class="page-link" href="list.php?page=<?php echo $i; ?>"><?php echo "$i"; ?></a>
<?php }?>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</main>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
<div class="footer">
<div class="footer-copyright text-center py-3"><hr class="my-4" style="margin: auto;width: 40%;"></br><p class="text-muted">© <?php echo date("Y"); ?> Codé par Ethan</small></p></div>
</div>
</div>
</html> |
Partager