Compare commits
3 commits
59191f79a2
...
c782ccb0c0
Author | SHA1 | Date | |
---|---|---|---|
|
c782ccb0c0 | ||
|
3ac7c3d222 | ||
|
ea4b4ef503 |
11 changed files with 569 additions and 522 deletions
4
_partials/_footer.php
Normal file
4
_partials/_footer.php
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
$page = str_replace(".php","",basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
?>
|
||||||
|
<script src="js/<?=$page?>.js">
|
10
_partials/_head.php
Normal file
10
_partials/_head.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<?php
|
||||||
|
$page = str_replace(".php","",basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
?>
|
||||||
|
<title><?=$titre_page?></title>
|
||||||
|
<link rel="stylesheet" src="css/<?=$page?>.css">
|
||||||
|
|
||||||
|
</head>
|
48
ens.php
48
ens.php
|
@ -1,47 +1,13 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<?php
|
||||||
<meta charset="UTF-8">
|
$titre_page = "Ensemble de documents";
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
include "_partials/_head.php";
|
||||||
<title>Ensemble de documents</title>
|
?>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
<?php
|
||||||
<script>
|
include "_partials/footer.php";
|
||||||
|
?>
|
||||||
/*
|
|
||||||
|
|
||||||
pour les docs afficher un truc du même acabit que la php :
|
|
||||||
if (strtolower($extension) === 'pdf'):
|
|
||||||
echo "<embed src=\"{$doc['upload_path']}\" type=\"application/pdf\" width=\"100%\" height=\"600px\" />";
|
|
||||||
elseif (in_array(strtolower($extension), ['jpg', 'jpeg', 'png', 'gif'])):
|
|
||||||
echo "<img src=\"{$doc['upload_path']}\">";
|
|
||||||
else:
|
|
||||||
echo "<p>Oups ! Je ne sais pas afficher ce document :/ (Rales autant que tu veux je men fous) </p>".$doc['upload_path'];
|
|
||||||
endif;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// fetch l'api et afficher tout ce qu'elle nous rend
|
|
||||||
function querystring(key) {
|
|
||||||
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
|
|
||||||
var r=[], m;
|
|
||||||
while ((m=re.exec(document.location.search)) != null) r[r.length]=m[1];
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function gen_contenu(){
|
|
||||||
resp = await fetch("/annales/api.php/decomposer_ensemble?ensemble_id="+querystring("ensemble_id"));
|
|
||||||
data = await resp.json();
|
|
||||||
|
|
||||||
if(data["status"] == 1){
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</html>
|
</html>
|
189
index.php
189
index.php
|
@ -1,11 +1,10 @@
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<?php
|
||||||
<meta charset="UTF-8">
|
$tire_page = "Ach'INSA";
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
include "_patials/head.php"
|
||||||
<title>Document</title>
|
?>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@ -32,181 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<?php
|
||||||
async function test_auth(){
|
include "_partials/footer.php";
|
||||||
resp = await fetch("api.php/test_auth");
|
?>
|
||||||
data = await resp.json();
|
|
||||||
document.getElementById("user_status").innerText = data["msg"];
|
|
||||||
}
|
|
||||||
|
|
||||||
// fonction de test, innutile en prod
|
|
||||||
async function authenticate_user(){
|
|
||||||
resp = await fetch("api.php/auth");
|
|
||||||
data = await resp.json();
|
|
||||||
console.log("test");
|
|
||||||
if(data.status == 1){
|
|
||||||
document.getElementById("user_status").innerText = data["msg"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function unauthenticate_user(){
|
|
||||||
resp = await fetch("api.php/unauth");
|
|
||||||
data = await resp.json();
|
|
||||||
if(data.status == 1){
|
|
||||||
document.getElementById("user_status").innerText = data["msg"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function rechercher(){
|
|
||||||
var req = document.getElementById("recherche_input").value;
|
|
||||||
var themes = [];
|
|
||||||
Array.from(document.getElementsByClassName("theme")).forEach(function (el) {
|
|
||||||
// on encode en url pour pouvoir le passer dans la requete GET
|
|
||||||
themes.push(encodeURIComponent(el.innerText));
|
|
||||||
});
|
|
||||||
var duree =document.getElementById("duree_input").value
|
|
||||||
|
|
||||||
|
|
||||||
var url = "api.php/rechercher?req="+req;
|
|
||||||
if(themes.toString() != ""){
|
|
||||||
url = url +"&themes="+themes.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(duree != ""){
|
|
||||||
url = url +"duree="+duree;
|
|
||||||
|
|
||||||
}
|
|
||||||
console.log(url);
|
|
||||||
|
|
||||||
resp = await fetch(url);
|
|
||||||
|
|
||||||
data = await resp.json();
|
|
||||||
|
|
||||||
// vide d'abord les éléments présents dans la liste sur la page
|
|
||||||
document.getElementById("liste_resultats").innerHTML = "";
|
|
||||||
|
|
||||||
if(data.status == 1){
|
|
||||||
data.resultats.forEach(doc => {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// on affiche le titre du résultat parce qu'on est pas des sauvages
|
|
||||||
let titre_ensemble;
|
|
||||||
titre_ensemble = document.createElement("h2");
|
|
||||||
titre_ensemble.innerText = doc.titre;
|
|
||||||
titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
|
||||||
|
|
||||||
document.getElementById("liste_resultats").appendChild(titre_ensemble);
|
|
||||||
|
|
||||||
|
|
||||||
// images ou pdf ?
|
|
||||||
let ele;
|
|
||||||
if(doc.upload_path.toString().split(".").pop() == "pdf"){
|
|
||||||
ele = document.createElement("embed");
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
|
||||||
ele = document.createElement("img");
|
|
||||||
}
|
|
||||||
|
|
||||||
ele.src = doc.upload_path;
|
|
||||||
ele.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
|
||||||
document.getElementById("liste_resultats").appendChild(ele);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function gen_chronologie(){
|
|
||||||
var url = "api.php/generer_chronologie";
|
|
||||||
|
|
||||||
console.log(url);
|
|
||||||
|
|
||||||
resp = await fetch(url);
|
|
||||||
|
|
||||||
data = await resp.json();
|
|
||||||
console.log(data);
|
|
||||||
// vide d'abord les éléments présents dans la liste sur la page
|
|
||||||
document.getElementById("liste_resultats").innerHTML = "";
|
|
||||||
|
|
||||||
// ensuite on ajoute un petit titre à la chronologie
|
|
||||||
let titre = document.createElement("h1");
|
|
||||||
titre.innerText = "Documents récemment publiés";
|
|
||||||
document.getElementById("liste_resultats").appendChild(titre);
|
|
||||||
|
|
||||||
// et on remplis avec ce que l'api a généré
|
|
||||||
if(data.status == 1){
|
|
||||||
data.resultats.forEach(ens => {
|
|
||||||
|
|
||||||
ens.documents.forEach(doc=>{
|
|
||||||
// on affiche le titre du résultat parce qu'on est pas des sauvages
|
|
||||||
let titre_ensemble;
|
|
||||||
titre_ensemble = document.createElement("h2");
|
|
||||||
titre_ensemble.innerText = doc.titre;
|
|
||||||
titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
|
||||||
document.getElementById("liste_resultats").appendChild(titre_ensemble);
|
|
||||||
|
|
||||||
// fichiers spéciaux ?
|
|
||||||
let apercu;
|
|
||||||
let ext = doc.upload_path.toString().split(".").pop();
|
|
||||||
switch(ext){
|
|
||||||
case "pdf":
|
|
||||||
ele = document.createElement("embed");
|
|
||||||
break;
|
|
||||||
case "html":
|
|
||||||
ele = document.createElement("iframe");
|
|
||||||
ele.setAttribute("sandbox","allow-forms allow-modals allow-scripts");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ele = document.createElement("img");
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ele.src = doc.upload_path;
|
|
||||||
ele.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
|
||||||
document.getElementById("liste_resultats").appendChild(ele);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gen_chronologie();
|
|
||||||
|
|
||||||
test_auth();
|
|
||||||
document.getElementById("recherche_input").onkeydown =function(event) {
|
|
||||||
if (event.key === "Enter"){
|
|
||||||
rechercher();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.getElementById("themes_input").onkeydown =function(event) {
|
|
||||||
if (event.key === "Enter"){
|
|
||||||
var theme = document.createElement("div");
|
|
||||||
theme.setAttribute("class","theme");
|
|
||||||
theme.innerText = document.getElementById("themes_input").value;
|
|
||||||
|
|
||||||
document.getElementById("recherche_form").appendChild(theme);
|
|
||||||
document.getElementById("themes_input").value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
32
js/ens.js
Normal file
32
js/ens.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
pour les docs afficher un truc du même acabit que la php :
|
||||||
|
if (strtolower($extension) === 'pdf'):
|
||||||
|
echo "<embed src=\"{$doc['upload_path']}\" type=\"application/pdf\" width=\"100%\" height=\"600px\" />";
|
||||||
|
elseif (in_array(strtolower($extension), ['jpg', 'jpeg', 'png', 'gif'])):
|
||||||
|
echo "<img src=\"{$doc['upload_path']}\">";
|
||||||
|
else:
|
||||||
|
echo "<p>Oups ! Je ne sais pas afficher ce document :/ (Rales autant que tu veux je men fous) </p>".$doc['upload_path'];
|
||||||
|
endif;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// fetch l'api et afficher tout ce qu'elle nous rend
|
||||||
|
function querystring(key) {
|
||||||
|
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
|
||||||
|
var r=[], m;
|
||||||
|
while ((m=re.exec(document.location.search)) != null) r[r.length]=m[1];
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function gen_contenu(){
|
||||||
|
resp = await fetch("/annales/api.php/decomposer_ensemble?ensemble_id="+querystring("ensemble_id"));
|
||||||
|
data = await resp.json();
|
||||||
|
|
||||||
|
if(data["status"] == 1){
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
170
js/index.js
Normal file
170
js/index.js
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
async function test_auth(){
|
||||||
|
resp = await fetch("api.php/test_auth");
|
||||||
|
data = await resp.json();
|
||||||
|
document.getElementById("user_status").innerText = data["msg"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// fonction de test, innutile en prod
|
||||||
|
async function authenticate_user(){
|
||||||
|
resp = await fetch("api.php/auth");
|
||||||
|
data = await resp.json();
|
||||||
|
console.log("test");
|
||||||
|
if(data.status == 1){
|
||||||
|
document.getElementById("user_status").innerText = data["msg"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function unauthenticate_user(){
|
||||||
|
resp = await fetch("api.php/unauth");
|
||||||
|
data = await resp.json();
|
||||||
|
if(data.status == 1){
|
||||||
|
document.getElementById("user_status").innerText = data["msg"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async function rechercher(){
|
||||||
|
var req = document.getElementById("recherche_input").value;
|
||||||
|
var themes = [];
|
||||||
|
Array.from(document.getElementsByClassName("theme")).forEach(function (el) {
|
||||||
|
// on encode en url pour pouvoir le passer dans la requete GET
|
||||||
|
themes.push(encodeURIComponent(el.innerText));
|
||||||
|
});
|
||||||
|
var duree =document.getElementById("duree_input").value
|
||||||
|
|
||||||
|
|
||||||
|
var url = "api.php/rechercher?req="+req;
|
||||||
|
if(themes.toString() != ""){
|
||||||
|
url = url +"&themes="+themes.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(duree != ""){
|
||||||
|
url = url +"duree="+duree;
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log(url);
|
||||||
|
|
||||||
|
resp = await fetch(url);
|
||||||
|
|
||||||
|
data = await resp.json();
|
||||||
|
|
||||||
|
// vide d'abord les éléments présents dans la liste sur la page
|
||||||
|
document.getElementById("liste_resultats").innerHTML = "";
|
||||||
|
|
||||||
|
if(data.status == 1){
|
||||||
|
data.resultats.forEach(doc => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// on affiche le titre du résultat parce qu'on est pas des sauvages
|
||||||
|
let titre_ensemble;
|
||||||
|
titre_ensemble = document.createElement("h2");
|
||||||
|
titre_ensemble.innerText = doc.titre;
|
||||||
|
titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
||||||
|
|
||||||
|
document.getElementById("liste_resultats").appendChild(titre_ensemble);
|
||||||
|
|
||||||
|
|
||||||
|
// images ou pdf ?
|
||||||
|
let ele;
|
||||||
|
if(doc.upload_path.toString().split(".").pop() == "pdf"){
|
||||||
|
ele = document.createElement("embed");
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
ele = document.createElement("img");
|
||||||
|
}
|
||||||
|
|
||||||
|
ele.src = doc.upload_path;
|
||||||
|
ele.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
||||||
|
document.getElementById("liste_resultats").appendChild(ele);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async function gen_chronologie(){
|
||||||
|
var url = "api.php/generer_chronologie";
|
||||||
|
|
||||||
|
console.log(url);
|
||||||
|
|
||||||
|
resp = await fetch(url);
|
||||||
|
|
||||||
|
data = await resp.json();
|
||||||
|
console.log(data);
|
||||||
|
// vide d'abord les éléments présents dans la liste sur la page
|
||||||
|
document.getElementById("liste_resultats").innerHTML = "";
|
||||||
|
|
||||||
|
// ensuite on ajoute un petit titre à la chronologie
|
||||||
|
let titre = document.createElement("h1");
|
||||||
|
titre.innerText = "Documents récemment publiés";
|
||||||
|
document.getElementById("liste_resultats").appendChild(titre);
|
||||||
|
|
||||||
|
// et on remplis avec ce que l'api a généré
|
||||||
|
if(data.status == 1){
|
||||||
|
data.resultats.forEach(ens => {
|
||||||
|
|
||||||
|
ens.documents.forEach(doc=>{
|
||||||
|
// on affiche le titre du résultat parce qu'on est pas des sauvages
|
||||||
|
let titre_ensemble;
|
||||||
|
titre_ensemble = document.createElement("h2");
|
||||||
|
titre_ensemble.innerText = doc.titre;
|
||||||
|
titre_ensemble.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
||||||
|
document.getElementById("liste_resultats").appendChild(titre_ensemble);
|
||||||
|
|
||||||
|
// fichiers spéciaux ?
|
||||||
|
let apercu;
|
||||||
|
let ext = doc.upload_path.toString().split(".").pop();
|
||||||
|
switch(ext){
|
||||||
|
case "pdf":
|
||||||
|
ele = document.createElement("embed");
|
||||||
|
break;
|
||||||
|
case "html":
|
||||||
|
ele = document.createElement("iframe");
|
||||||
|
ele.setAttribute("sandbox","allow-forms allow-modals allow-scripts");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ele = document.createElement("img");
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ele.src = doc.upload_path;
|
||||||
|
ele.setAttribute("onclick","document.location.href='ens.php?ensemble_id="+doc.ensemble_id.toString()+"'");
|
||||||
|
document.getElementById("liste_resultats").appendChild(ele);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gen_chronologie();
|
||||||
|
|
||||||
|
test_auth();
|
||||||
|
document.getElementById("recherche_input").onkeydown =function(event) {
|
||||||
|
if (event.key === "Enter"){
|
||||||
|
rechercher();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById("themes_input").onkeydown =function(event) {
|
||||||
|
if (event.key === "Enter"){
|
||||||
|
var theme = document.createElement("div");
|
||||||
|
theme.setAttribute("class","theme");
|
||||||
|
theme.innerText = document.getElementById("themes_input").value;
|
||||||
|
|
||||||
|
document.getElementById("recherche_form").appendChild(theme);
|
||||||
|
document.getElementById("themes_input").value = "";
|
||||||
|
}
|
||||||
|
}
|
237
js/televerser.js
Normal file
237
js/televerser.js
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
function televerser_fichiers() {
|
||||||
|
const fileInput = document.getElementById('fileInput');
|
||||||
|
|
||||||
|
// Create FormData object to append files
|
||||||
|
const formData = new FormData();
|
||||||
|
|
||||||
|
formData.append("type",document.getElementById("select_type").value);
|
||||||
|
formData.append("titre",document.getElementById("titre").value);
|
||||||
|
formData.append("commentaire_auteur",document.getElementById("commentaire_auteur").value);
|
||||||
|
|
||||||
|
formData.append("corrige_inclu",document.getElementById("corrige_checkbox").value);
|
||||||
|
|
||||||
|
formData.append("date_conception",document.getElementById("date_conception_input").value);
|
||||||
|
|
||||||
|
//let ex = [{duree:"10",themes:["algèbre","analyse"],commentaire_exo:"ceci est un commenataire"},{duree:"15",themes:["elec analogique"],commentaire_exo:""}];
|
||||||
|
|
||||||
|
var ex = [];
|
||||||
|
// details des exos pour les annales
|
||||||
|
if(formData.get("type") == "1"){
|
||||||
|
var details = document.getElementsByClassName("input-details-exo");
|
||||||
|
|
||||||
|
for(let i=0;i<details.length;i = i + 3){
|
||||||
|
ex.push({
|
||||||
|
duree:details[i].value,
|
||||||
|
themes:details[i+1].value.split(","),
|
||||||
|
commentaire_exo:details[i+2].value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
formData.append("exercices",JSON.stringify(ex))
|
||||||
|
|
||||||
|
|
||||||
|
// Append each selected file to the FormData
|
||||||
|
let i = 0;
|
||||||
|
for (const file of fileInput.files) {
|
||||||
|
formData.append('fichier' + i, file);
|
||||||
|
i ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(ex);
|
||||||
|
|
||||||
|
//csrf token
|
||||||
|
formData.append("jeton-csrf",jeton_csrf);
|
||||||
|
|
||||||
|
// Append captured images as files to the FormData
|
||||||
|
const capturedImages = document.querySelectorAll('#selectedImages img');
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
capturedImages.forEach((img, index) => {
|
||||||
|
const imageDataUrl = img.src;
|
||||||
|
const blob = dataURLtoBlob(imageDataUrl);
|
||||||
|
const file = new File([blob], `camera_image_${index}.jpg`);
|
||||||
|
formData.append('fichier'+i, file);
|
||||||
|
i ++;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Make a POST request using Fetch API
|
||||||
|
fetch('api.php/aj_doc', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(data => {
|
||||||
|
console.log(data);
|
||||||
|
// Handle the response from the server
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function ouvrir_camera() {
|
||||||
|
// Open the camera and take pictures
|
||||||
|
// You can use the MediaDevices API to access the camera
|
||||||
|
navigator.mediaDevices.getUserMedia({ video: true })
|
||||||
|
.then(mediaStream => {
|
||||||
|
const video = document.createElement('video');
|
||||||
|
document.body.appendChild(video);
|
||||||
|
|
||||||
|
// Display the camera stream in a video element
|
||||||
|
video.srcObject = mediaStream;
|
||||||
|
video.play();
|
||||||
|
|
||||||
|
// Capture an image from the video stream
|
||||||
|
video.addEventListener('click', () => {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = video.videoWidth;
|
||||||
|
canvas.height = video.videoHeight;
|
||||||
|
const context = canvas.getContext('2d');
|
||||||
|
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
// Convert the canvas content to a data URL
|
||||||
|
const imageDataUrl = canvas.toDataURL('image/jpeg');
|
||||||
|
|
||||||
|
// Display the captured image
|
||||||
|
const img = document.createElement('img');
|
||||||
|
img.src = imageDataUrl;
|
||||||
|
img.style.maxWidth = '100px';
|
||||||
|
document.getElementById('selectedImages').appendChild(img);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// POUR FERMER LA CAMERA :
|
||||||
|
// mediaStream.getTracks().forEach(track => track.stop());
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error accessing camera:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function dataURLtoBlob(dataURL) {
|
||||||
|
const arr = dataURL.split(',');
|
||||||
|
const mime = arr[0].match(/:(.*?);/)[1];
|
||||||
|
const bstr = atob(arr[1]);
|
||||||
|
let n = bstr.length;
|
||||||
|
const u8arr = new Uint8Array(n);
|
||||||
|
while (n--) {
|
||||||
|
u8arr[n] = bstr.charCodeAt(n);
|
||||||
|
}
|
||||||
|
return new Blob([u8arr], { type: mime });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ajouter_details_exo(){
|
||||||
|
duree = document.createElement("input");
|
||||||
|
duree.setAttribute("type","number");
|
||||||
|
duree.setAttribute("placeholder","Entrez la durée de l'exercice en minutes.")
|
||||||
|
|
||||||
|
// classe imortante pour itérer sur toutes les input
|
||||||
|
// dans le bon ordre et les associer aux exos dans la requête post
|
||||||
|
duree.setAttribute("class","input-details-exo");
|
||||||
|
|
||||||
|
document.getElementById("exercices_details_wrapper").appendChild(duree);
|
||||||
|
|
||||||
|
|
||||||
|
themes = document.createElement("input");
|
||||||
|
themes.setAttribute("type","text");
|
||||||
|
themes.setAttribute("placeholder","Entrez les themes abordés par l'exercice séparés par une virgule.");
|
||||||
|
themes.setAttribute("class","input-details-exo");
|
||||||
|
|
||||||
|
document.getElementById("exercices_details_wrapper").appendChild(themes);
|
||||||
|
|
||||||
|
|
||||||
|
comm = document.createElement("input");
|
||||||
|
comm.setAttribute("type","text");
|
||||||
|
comm.setAttribute("placeholder","Un ptit commentaire sur l'exo ?");
|
||||||
|
comm.setAttribute("class","input-details-exo");
|
||||||
|
|
||||||
|
document.getElementById("exercices_details_wrapper").appendChild(comm);
|
||||||
|
|
||||||
|
|
||||||
|
// un peu de tendresse dans ce monde de brutes
|
||||||
|
br =document.createElement("br");
|
||||||
|
document.getElementById("exercices_details_wrapper").appendChild(br);
|
||||||
|
hr =document.createElement("hr");
|
||||||
|
document.getElementById("exercices_details_wrapper").appendChild(hr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function mode_html(){
|
||||||
|
|
||||||
|
document.getElementById("exercices_details_wrapper").setAttribute("hidden",true);
|
||||||
|
document.getElementById("corrige_checkbox_wrapper").setAttribute("hidden",true);
|
||||||
|
|
||||||
|
}
|
||||||
|
function mode_fiche(){
|
||||||
|
document.getElementById("exercices_details_wrapper").setAttribute("hidden",true);
|
||||||
|
document.getElementById("corrige_checkbox_wrapper").setAttribute("hidden",true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function mode_annale(){
|
||||||
|
document.getElementById("corrige_checkbox_wrapper").removeAttribute("hidden");
|
||||||
|
document.getElementById("exercices_details_wrapper").removeAttribute("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function changer_mode(){
|
||||||
|
|
||||||
|
|
||||||
|
switch(document.getElementById("select_type").value){
|
||||||
|
// annale
|
||||||
|
case "1":
|
||||||
|
mode_annale();
|
||||||
|
break;
|
||||||
|
// fiche
|
||||||
|
case "2":
|
||||||
|
mode_fiche();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// html personnalisé
|
||||||
|
case "3":
|
||||||
|
mode_html();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function init_date(){
|
||||||
|
var today = new Date();
|
||||||
|
var dd = today.getDate();
|
||||||
|
var mm = today.getMonth()+1;
|
||||||
|
var yyyy = today.getFullYear()-1; // pourquoi 2025 ?????
|
||||||
|
yyyy = parseInt(yyyy) + 1;
|
||||||
|
today = yyyy+"-"+mm+"-"+dd;
|
||||||
|
console.log(today);
|
||||||
|
document.getElementById("date_conception_input").setAttribute("value",today);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
|
init_date();
|
||||||
|
document.getElementById("select_type").addEventListener("change", (event) => {
|
||||||
|
changer_mode();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("btn-soumettre").addEventListener("click", (event) => {
|
||||||
|
televerser_fichiers();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("btn-camera").addEventListener("click", (event) => {
|
||||||
|
ouvrir_camera();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("btn-details-exo").addEventListener("click", (event) => {
|
||||||
|
ajouter_details_exo();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
74
js/validation.js
Normal file
74
js/validation.js
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
function valider_ensemble(ensembleId) {
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("jeton-csrf",jeton_valider_ensemble);
|
||||||
|
formData.append("ensemble_id",ensembleId);
|
||||||
|
fetch('api.php/valider_ensemble', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 1) {
|
||||||
|
alert(data.msg)
|
||||||
|
}else{
|
||||||
|
alert(data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function supprimer_ensemble(ensembleId) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("jeton-csrf",jeton_supprimer_ensemble);
|
||||||
|
formData.append("ensemble_id",ensembleId);
|
||||||
|
|
||||||
|
fetch('api.php/supprimer_ensemble', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 1) {
|
||||||
|
alert(data.msg)
|
||||||
|
document.location.reload();
|
||||||
|
}else{
|
||||||
|
alert(data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
|
|
||||||
|
let liens = document.getElementsByClassName('lien-valider-ens');
|
||||||
|
|
||||||
|
for (var i = 0; i < liens.length; i++) {
|
||||||
|
liens[i].addEventListener('click', function(event) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
valider_ensemble(liens[i].getAttribute("id_ens"));
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
liens = document.getElementsByClassName('lien-supprimer-ens');
|
||||||
|
|
||||||
|
for (var i = 0; i < liens.length; i++) {
|
||||||
|
liens[i].addEventListener('click', function(event) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
supprimer_ensemble(liens[i].getAttribute("id_ens"));
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -59,7 +59,7 @@ D'autres fonctionnalités seront ajoutées petit à petit. (si vous avez des sug
|
||||||
|
|
||||||
|
|
||||||
## TOUDOU :
|
## TOUDOU :
|
||||||
|
> Tester le code qui a été séparé en plusieurs fichiers différents (les pages pour utilisateurs)
|
||||||
|
|
||||||
|
|
||||||
### téléverser.php :
|
### téléverser.php :
|
||||||
|
|
250
televerser.php
250
televerser.php
|
@ -1,10 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<?php
|
||||||
<meta charset="UTF-8">
|
$titre_page = "Téléverser sur Arch'INSA";
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
include "_partials/_head.php";
|
||||||
<title>File Upload</title>
|
?>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include("session_verif.php");
|
include("session_verif.php");
|
||||||
|
@ -22,7 +21,7 @@ $csrf = new CSRF();
|
||||||
<input type="text" placeholder="titre" id="titre"></input>
|
<input type="text" placeholder="titre" id="titre"></input>
|
||||||
<label for="titre">N'hésitez pas à bien mettre 1A, 2A, ... et la matière concernée dans le titre.</label>
|
<label for="titre">N'hésitez pas à bien mettre 1A, 2A, ... et la matière concernée dans le titre.</label>
|
||||||
<br>
|
<br>
|
||||||
<select id="select_type" onchange="changer_mode()">
|
<select id="select_type">
|
||||||
<option value="1" >annale</option>
|
<option value="1" >annale</option>
|
||||||
<option value="2" >fiche_revision</option>
|
<option value="2" >fiche_revision</option>
|
||||||
<option value="3" >HTML personnalisé</option>
|
<option value="3" >HTML personnalisé</option>
|
||||||
|
@ -40,242 +39,19 @@ $csrf = new CSRF();
|
||||||
<input type="date" id="date_conception_input">
|
<input type="date" id="date_conception_input">
|
||||||
<label for="date_conception_input">Date de conception du/des documents (Mettez juste la bonne année si vous ne savez pas) </label>
|
<label for="date_conception_input">Date de conception du/des documents (Mettez juste la bonne année si vous ne savez pas) </label>
|
||||||
<br>
|
<br>
|
||||||
<button type="button" onclick="uploadFiles()">Téléverser les fichiers</button>
|
<button type="button" id="btn-soumettre">Téléverser les fichiers</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div id="exercices_details_wrapper">
|
<div id="exercices_details_wrapper">
|
||||||
<button onclick="ajouter_details_exo()">Ajouter les détails d'un exercice</button>
|
<button id="btn-details-exo">Ajouter les détails d'un exercice</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<button onclick="openCamera()">Prendre des photos</button>
|
<button id="btn-camera">Prendre des photos</button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function uploadFiles() {
|
|
||||||
const fileInput = document.getElementById('fileInput');
|
|
||||||
|
|
||||||
// Create FormData object to append files
|
|
||||||
const formData = new FormData();
|
|
||||||
|
|
||||||
formData.append("type",document.getElementById("select_type").value);
|
|
||||||
formData.append("titre",document.getElementById("titre").value);
|
|
||||||
formData.append("commentaire_auteur",document.getElementById("commentaire_auteur").value);
|
|
||||||
|
|
||||||
formData.append("corrige_inclu",document.getElementById("corrige_checkbox").value);
|
|
||||||
|
|
||||||
formData.append("date_conception",document.getElementById("date_conception_input").value);
|
|
||||||
|
|
||||||
//let ex = [{duree:"10",themes:["algèbre","analyse"],commentaire_exo:"ceci est un commenataire"},{duree:"15",themes:["elec analogique"],commentaire_exo:""}];
|
|
||||||
|
|
||||||
var ex = [];
|
|
||||||
// details des exos pour les annales
|
|
||||||
if(formData.get("type") == "1"){
|
|
||||||
var details = document.getElementsByClassName("input-details-exo");
|
|
||||||
|
|
||||||
for(let i=0;i<details.length;i = i + 3){
|
|
||||||
ex.push({
|
|
||||||
duree:details[i].value,
|
|
||||||
themes:details[i+1].value.split(","),
|
|
||||||
commentaire_exo:details[i+2].value
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
formData.append("exercices",JSON.stringify(ex))
|
|
||||||
|
|
||||||
|
|
||||||
// Append each selected file to the FormData
|
|
||||||
let i = 0;
|
|
||||||
for (const file of fileInput.files) {
|
|
||||||
formData.append('fichier' + i, file);
|
|
||||||
i ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(ex);
|
|
||||||
|
|
||||||
//csrf token
|
|
||||||
formData.append("jeton-csrf","<?=$csrf->string($context="televersement")?>");
|
|
||||||
|
|
||||||
// Append captured images as files to the FormData
|
|
||||||
const capturedImages = document.querySelectorAll('#selectedImages img');
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
capturedImages.forEach((img, index) => {
|
|
||||||
const imageDataUrl = img.src;
|
|
||||||
const blob = dataURLtoBlob(imageDataUrl);
|
|
||||||
const file = new File([blob], `camera_image_${index}.jpg`);
|
|
||||||
formData.append('fichier'+i, file);
|
|
||||||
i ++;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Make a POST request using Fetch API
|
|
||||||
fetch('api.php/aj_doc', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
})
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(data => {
|
|
||||||
console.log(data);
|
|
||||||
// Handle the response from the server
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCamera() {
|
|
||||||
// Open the camera and take pictures
|
|
||||||
// You can use the MediaDevices API to access the camera
|
|
||||||
navigator.mediaDevices.getUserMedia({ video: true })
|
|
||||||
.then(mediaStream => {
|
|
||||||
const video = document.createElement('video');
|
|
||||||
document.body.appendChild(video);
|
|
||||||
|
|
||||||
// Display the camera stream in a video element
|
|
||||||
video.srcObject = mediaStream;
|
|
||||||
video.play();
|
|
||||||
|
|
||||||
// Capture an image from the video stream
|
|
||||||
video.addEventListener('click', () => {
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
canvas.width = video.videoWidth;
|
|
||||||
canvas.height = video.videoHeight;
|
|
||||||
const context = canvas.getContext('2d');
|
|
||||||
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
||||||
|
|
||||||
// Convert the canvas content to a data URL
|
|
||||||
const imageDataUrl = canvas.toDataURL('image/jpeg');
|
|
||||||
|
|
||||||
// Display the captured image
|
|
||||||
const img = document.createElement('img');
|
|
||||||
img.src = imageDataUrl;
|
|
||||||
img.style.maxWidth = '100px';
|
|
||||||
document.getElementById('selectedImages').appendChild(img);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// POUR FERMER LA CAMERA :
|
|
||||||
// mediaStream.getTracks().forEach(track => track.stop());
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error accessing camera:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function dataURLtoBlob(dataURL) {
|
|
||||||
const arr = dataURL.split(',');
|
|
||||||
const mime = arr[0].match(/:(.*?);/)[1];
|
|
||||||
const bstr = atob(arr[1]);
|
|
||||||
let n = bstr.length;
|
|
||||||
const u8arr = new Uint8Array(n);
|
|
||||||
while (n--) {
|
|
||||||
u8arr[n] = bstr.charCodeAt(n);
|
|
||||||
}
|
|
||||||
return new Blob([u8arr], { type: mime });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function ajouter_details_exo(){
|
|
||||||
duree = document.createElement("input");
|
|
||||||
duree.setAttribute("type","number");
|
|
||||||
duree.setAttribute("placeholder","Entrez la durée de l'exercice en minutes.")
|
|
||||||
|
|
||||||
// classe imortante pour itérer sur toutes les input
|
|
||||||
// dans le bon ordre et les associer aux exos dans la requête post
|
|
||||||
duree.setAttribute("class","input-details-exo");
|
|
||||||
|
|
||||||
document.getElementById("exercices_details_wrapper").appendChild(duree);
|
|
||||||
|
|
||||||
|
|
||||||
themes = document.createElement("input");
|
|
||||||
themes.setAttribute("type","text");
|
|
||||||
themes.setAttribute("placeholder","Entrez les themes abordés par l'exercice séparés par une virgule.");
|
|
||||||
themes.setAttribute("class","input-details-exo");
|
|
||||||
|
|
||||||
document.getElementById("exercices_details_wrapper").appendChild(themes);
|
|
||||||
|
|
||||||
|
|
||||||
comm = document.createElement("input");
|
|
||||||
comm.setAttribute("type","text");
|
|
||||||
comm.setAttribute("placeholder","Un ptit commentaire sur l'exo ?");
|
|
||||||
comm.setAttribute("class","input-details-exo");
|
|
||||||
|
|
||||||
document.getElementById("exercices_details_wrapper").appendChild(comm);
|
|
||||||
|
|
||||||
|
|
||||||
// un peu de tendresse dans ce monde de brutes
|
|
||||||
br =document.createElement("br");
|
|
||||||
document.getElementById("exercices_details_wrapper").appendChild(br);
|
|
||||||
hr =document.createElement("hr");
|
|
||||||
document.getElementById("exercices_details_wrapper").appendChild(hr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function mode_html(){
|
|
||||||
|
|
||||||
document.getElementById("exercices_details_wrapper").setAttribute("hidden",true);
|
|
||||||
document.getElementById("corrige_checkbox_wrapper").setAttribute("hidden",true);
|
|
||||||
|
|
||||||
}
|
|
||||||
function mode_fiche(){
|
|
||||||
document.getElementById("exercices_details_wrapper").setAttribute("hidden",true);
|
|
||||||
document.getElementById("corrige_checkbox_wrapper").setAttribute("hidden",true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function mode_annale(){
|
|
||||||
document.getElementById("corrige_checkbox_wrapper").removeAttribute("hidden");
|
|
||||||
document.getElementById("exercices_details_wrapper").removeAttribute("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function changer_mode(){
|
|
||||||
|
|
||||||
|
|
||||||
switch(document.getElementById("select_type").value){
|
|
||||||
// annale
|
|
||||||
case "1":
|
|
||||||
mode_annale();
|
|
||||||
break;
|
|
||||||
// fiche
|
|
||||||
case "2":
|
|
||||||
mode_fiche();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// html personnalisé
|
|
||||||
case "3":
|
|
||||||
mode_html();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function init_date(){
|
|
||||||
var today = new Date();
|
|
||||||
var dd = today.getDate();
|
|
||||||
var mm = today.getMonth()+1;
|
|
||||||
var yyyy = today.getFullYear()-1; // pourquoi 2025 ?????
|
|
||||||
yyyy = parseInt(yyyy) + 1;
|
|
||||||
today = yyyy+"-"+mm+"-"+dd;
|
|
||||||
console.log(today);
|
|
||||||
document.getElementById("date_conception_input").setAttribute("value",today);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", (event) => {
|
|
||||||
init_date();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo $csrf->script($context='televersement', $name='jeton_csrf', $declaration='var', $time2Live=-1, $max_hashes=5);
|
||||||
|
include "_partials/_footer.php";
|
||||||
|
?>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -16,7 +16,7 @@ $conn = new mysqli($servername, $username, $password,$dbname);
|
||||||
|
|
||||||
|
|
||||||
// Function to fetch and display documents
|
// Function to fetch and display documents
|
||||||
function displayDocuments() {
|
function generer_chronologie() {
|
||||||
|
|
||||||
global $conn;
|
global $conn;
|
||||||
|
|
||||||
|
@ -73,8 +73,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 class='lien-valider-ens' id_ens='$ens_id' >Valider l'ensemble</a></p>";
|
||||||
echo "<p><a href='#' onclick='supprimer_ensemble({$ens_id})'>Supprimer l'ensemble</a></p>";
|
echo "<p><a class='lien-supp-ens' id_ens='$ens_id'>Supprimer l'ensemble</a></p>";
|
||||||
|
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
||||||
|
@ -84,68 +84,21 @@ function displayDocuments() {
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<?php
|
||||||
<meta charset="UTF-8">
|
$titre_page = "Validation des documents";
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
include "_partials/_head.php";
|
||||||
<title>Validation des documents</title>
|
?>
|
||||||
<!-- Include your CSS styles here -->
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h2>Validation des documents</h2>
|
<h2>Validation des documents</h2>
|
||||||
|
|
||||||
<!-- Display documents -->
|
<?php generer_chronologie(); ?>
|
||||||
<?php displayDocuments(); ?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
function valider_ensemble(ensembleId) {
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("jeton-csrf","<?=$csrf->string($context="valider_ensemble")?>");
|
|
||||||
formData.append("ensemble_id",ensembleId);
|
|
||||||
fetch('api.php/valider_ensemble', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData,
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
if (data.status == 1) {
|
|
||||||
alert(data.msg)
|
|
||||||
}else{
|
|
||||||
alert(data.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function supprimer_ensemble(ensembleId) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("jeton-csrf","<?=$csrf->string($context="supprimer_ensemble")?>");
|
|
||||||
formData.append("ensemble_id",ensembleId);
|
|
||||||
|
|
||||||
fetch('api.php/supprimer_ensemble', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData,
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
if (data.status == 1) {
|
|
||||||
alert(data.msg)
|
|
||||||
document.location.reload();
|
|
||||||
}else{
|
|
||||||
alert(data.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
<?php
|
||||||
|
echo $csrf->script($context='supprimer_ensemble', $name='jeton_supprimer_ensemble', $declaration='var', $time2Live=-1, $max_hashes=5);
|
||||||
|
echo $csrf->script($context='valider_ensemble', $name='jeton_valider_ensemble', $declaration='var', $time2Live=-1, $max_hashes=5);
|
||||||
|
|
||||||
|
include "_partials/_footer.php";
|
||||||
|
?>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue