forked from mougnibas/archinsa
bouton suppression d'ensembles en attente de validation
This commit is contained in:
parent
c867505f42
commit
94e777d031
5 changed files with 50 additions and 6 deletions
9
api.php
9
api.php
|
@ -181,6 +181,15 @@
|
||||||
echo( json_encode(["status"=> "0","msg"=> $e->getMessage() ]) );
|
echo( json_encode(["status"=> "0","msg"=> $e->getMessage() ]) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "supprimer_ensemble":
|
||||||
|
try{
|
||||||
|
supprimer_ensemble($_POST["ensemble_id"]);
|
||||||
|
echo(json_encode(["status"=>"1","msg"=>"Ensemble supprimé."]));
|
||||||
|
}catch(Exception $e){
|
||||||
|
echo( json_encode(["status"=> "0","msg"=> $e->getMessage() ]) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
echo(json_encode(["status"=> "2","msg"=> "Opération inconnue."]));
|
echo(json_encode(["status"=> "2","msg"=> "Opération inconnue."]));
|
||||||
}
|
}
|
||||||
|
|
15
bdd.php
15
bdd.php
|
@ -176,8 +176,8 @@ function saveFilesFromPost($postData,$id_ensemble) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensuite, on enregistre les qui lui sont associés
|
// ensuite, on enregistre les qui lui sont associés
|
||||||
$sql= 'INSERT INTO exercices_themes (exercice_id,theme_id) VALUES(?,?)';
|
$sql= 'INSERT INTO exercices_themes (exercice_id,ensemble_id,theme_id) VALUES(?,?,?)';
|
||||||
$result = $conn->execute_query($sql,array($id_exo,$id_theme));
|
$result = $conn->execute_query($sql,array($id_exo,$id_ensemble,$id_theme));
|
||||||
echo("enregistrement d'un exercice");
|
echo("enregistrement d'un exercice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,9 +256,16 @@ function RechercheExercices($query, $length, $tags)
|
||||||
|
|
||||||
function valider_ensemble($ensembleId) {
|
function valider_ensemble($ensembleId) {
|
||||||
|
|
||||||
$updateQuery = "UPDATE ensembles SET valide = 1 WHERE id = $ensembleId";
|
$sql = "UPDATE ensembles SET valide = 1 WHERE id = $ensembleId";
|
||||||
global $conn;
|
global $conn;
|
||||||
$conn->execute_query($updateQuery);
|
$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";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -51,8 +51,10 @@ $sql = "
|
||||||
CREATE TABLE IF NOT EXISTS exercices_themes (
|
CREATE TABLE IF NOT EXISTS exercices_themes (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
exercice_id INT,
|
exercice_id INT,
|
||||||
|
ensemble_id INT,
|
||||||
theme_id INT,
|
theme_id INT,
|
||||||
FOREIGN KEY (exercice_id) REFERENCES exercices(id),
|
FOREIGN KEY (exercice_id) REFERENCES exercices(id),
|
||||||
|
FOREIGN KEY (ensemble_id) REFERENCES ensembles(id),
|
||||||
FOREIGN KEY (theme_id) REFERENCES themes(id)
|
FOREIGN KEY (theme_id) REFERENCES themes(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ D'autres fonctionnalités seront ajoutées petit à petit. (si vous avez des sug
|
||||||
| Column | Type | Constraints |
|
| Column | Type | Constraints |
|
||||||
|--------------|--------|-------------------------------------------|
|
|--------------|--------|-------------------------------------------|
|
||||||
| exercice_id | INT | FOREIGN KEY (exercice_id) REFERENCES exercises(id) |
|
| exercice_id | INT | FOREIGN KEY (exercice_id) REFERENCES exercises(id) |
|
||||||
|
| ensemble_id | INT | FOREIGN KEY (ensemble_id) REFERENCES ensembles(id) |
|
||||||
| theme_id | INT | FOREIGN KEY (theme_id) REFERENCES themes(id) |
|
| theme_id | INT | FOREIGN KEY (theme_id) REFERENCES themes(id) |
|
||||||
| id | INT | AUTO_INCREMENT, PRIMARY KEY |
|
| id | INT | AUTO_INCREMENT, PRIMARY KEY |
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ function displayDocuments() {
|
||||||
|
|
||||||
// complète le formulaire du dernier ensemble itéré
|
// complète le formulaire du dernier ensemble itéré
|
||||||
echo "<p><a href='#' onclick='valider_ensemble({$ens_id})'>Valider l'ensemble</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>";
|
echo "</div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,12 +79,12 @@ function displayDocuments() {
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Document Validation Dashboard</title>
|
<title>Validation des documents</title>
|
||||||
<!-- Include your CSS styles here -->
|
<!-- Include your CSS styles here -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h2>Document Validation Dashboard</h2>
|
<h2>Validation des documents</h2>
|
||||||
|
|
||||||
<!-- Display documents -->
|
<!-- Display documents -->
|
||||||
<?php displayDocuments(); ?>
|
<?php displayDocuments(); ?>
|
||||||
|
@ -109,6 +111,29 @@ function displayDocuments() {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function supprimer_ensemble(ensembleId) {
|
||||||
|
|
||||||
|
fetch('api.php/supprimer_ensemble', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
body: 'ensemble_id=' + ensembleId,
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 1) {
|
||||||
|
alert(data.msg)
|
||||||
|
}else{
|
||||||
|
alert(data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue