forked from mougnibas/archinsa
petites améliorations
This commit is contained in:
parent
ea47fc9efe
commit
e5b1676d82
3 changed files with 39 additions and 12 deletions
39
bdd.php
39
bdd.php
|
@ -217,13 +217,19 @@ function RechercheExercices($query, $length, $tags)
|
|||
global $conn;
|
||||
|
||||
// Build the SQL query based on the search parameters
|
||||
$sql = "SELECT * FROM documents AS d INNER JOIN ensembles AS e ON d.ensemble_id = e.id WHERE e.valide=TRUE AND ";
|
||||
$sql = "SELECT * FROM documents AS d INNER JOIN ensembles AS e ON d.ensemble_id = e.id WHERE e.valide=TRUE ";
|
||||
|
||||
$conditions = [];
|
||||
|
||||
if (!empty($query)) {
|
||||
|
||||
// va essayer de retrouver tout les mots de la requête dans le titre
|
||||
$query = htmlspecialchars($query);
|
||||
$conditions[] = "titre LIKE '%$query%'";
|
||||
$query_words = preg_split("[ ]",$query);
|
||||
|
||||
foreach ($query_words as $word) {
|
||||
$conditions[] = "AND titre LIKE '%$word%'";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($length)) {
|
||||
|
@ -274,11 +280,28 @@ function valider_ensemble($ensembleId) {
|
|||
$conn->execute_query($sql);
|
||||
}
|
||||
|
||||
function supprimer_ensemble($ensembleId){
|
||||
$sql = "DELETE FROM exercices WHERE ensemble_id=$ensembleId";
|
||||
$sql = "DELETE FROM documents WHERE ensemble_id=$ensembleId";
|
||||
$sql = "DELETE FROM exercices_themes WHERE ensemble_id=$ensembleId";
|
||||
$sql = "DELETE FROM ensembles WHERE id=$ensembleId";
|
||||
function supprimer_ensemble($ensemble_id){
|
||||
|
||||
|
||||
global $conn;
|
||||
|
||||
// premièrement, enlever tout les documents téléversés appartenant à l'ensemble
|
||||
$sql = "SELECT upload_path FROM documents WHERE ensemble_id=?";
|
||||
$res = $conn->execute_query($sql,array($ensemble_id));
|
||||
|
||||
while($tmp=$res->fetch_assoc()){
|
||||
unlink($tmp["upload_path"]);
|
||||
}
|
||||
|
||||
// deuxièmement, supprimer toutes les traces de l'ensemble dans la bdd
|
||||
$sql = "DELETE FROM exercices_themes WHERE ensemble_id=$ensemble_id";
|
||||
$conn->execute_query($sql);
|
||||
$sql = "DELETE FROM exercices WHERE ensemble_id=$ensemble_id";
|
||||
$conn->execute_query($sql);
|
||||
$sql = "DELETE FROM documents WHERE ensemble_id=$ensemble_id";
|
||||
$conn->execute_query($sql);
|
||||
$sql = "DELETE FROM ensembles WHERE id=$ensemble_id";
|
||||
$conn->execute_query($sql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,7 +310,7 @@ function generer_chronologie(){
|
|||
global $conn;
|
||||
|
||||
// on va choper les 10 derniers trucs televerses par les gens
|
||||
$sql = "SELECT * FROM ensembles ORDER BY date_televersement DESC";
|
||||
$sql = "SELECT * FROM ensembles WHERE valide=1 ORDER BY date_televersement DESC ";
|
||||
|
||||
$res = $conn->execute_query($sql);
|
||||
$i = 0;
|
||||
|
|
|
@ -19,8 +19,10 @@ $csrf = new CSRF();
|
|||
|
||||
<form id="uploadForm">
|
||||
<input type="file" id="fileInput" multiple>
|
||||
<br>
|
||||
<input type="text" placeholder="titre" id="titre"></input>
|
||||
|
||||
<label for="titre">N'hésitez pas à bien mettre 1A, 2A, ... et la maitère concernée dans le titre.</label>
|
||||
<br>
|
||||
<select id="select_type" onchange="changer_mode()">
|
||||
<option value="1" >annale</option>
|
||||
<option value="2" >fiche_revision</option>
|
||||
|
@ -28,6 +30,7 @@ $csrf = new CSRF();
|
|||
</select>
|
||||
|
||||
<input type="text" placeholder="commentaires généraux sur l'ensemble des documents" id="commentaire_auteur"></input>
|
||||
<br>
|
||||
<div id="selectedImages"></div>
|
||||
|
||||
<div id="corrige_checkbox_wrapper">
|
||||
|
@ -43,8 +46,7 @@ $csrf = new CSRF();
|
|||
<button onclick="ajouter_details_exo()">Ajouter les détails d'un exercice</button>
|
||||
|
||||
</div>
|
||||
<!-- Button to open the camera -->
|
||||
<button onclick="openCamera()">Open Camera</button>
|
||||
<button onclick="openCamera()">Prendre des photos</button>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ function displayDocuments() {
|
|||
|
||||
|
||||
if (($row["ensemble_id"] != $ens_id) && ($ens_id != -1) ) {
|
||||
echo "<p><a href='#' onclick='valider_ensemble({$ens_id})'>Valider l'ensembre</a></p>";
|
||||
echo "<p><a href='#' onclick='valider_ensemble({$ens_id})'>Valider l'ensemble</a></p>";
|
||||
echo "<p><a href='#' onclick='supprimer_ensemble({$ens_id})'>Supprimer l'ensemble</a></p>";
|
||||
echo "</div>";
|
||||
$ens_id = $row["ensemble_id"];
|
||||
}
|
||||
|
@ -131,6 +132,7 @@ function displayDocuments() {
|
|||
.then(data => {
|
||||
if (data.status == 1) {
|
||||
alert(data.msg)
|
||||
document.location.reload();
|
||||
}else{
|
||||
alert(data.msg)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue