Initial commit: CLEO ERP avec améliorations debug
- Configuration du debug conditionnel pour dev/recette - Fonction debug() globale avec niveaux - Logging des requêtes SQL - Handlers d'exceptions et d'erreurs globaux 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
163
pub/res/js/jinterface.js
Normal file
163
pub/res/js/jinterface.js
Normal file
@@ -0,0 +1,163 @@
|
||||
// jinterface.js
|
||||
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
console.log('#');
|
||||
|
||||
let elBtnAddInfo = document.getElementById("btnAddInfo");
|
||||
let elBtnModInfo = document.getElementsByClassName("btnModInfo");
|
||||
let elBtnSuppInfo = document.getElementsByClassName("btnSuppInfo");
|
||||
|
||||
let elBtnCancelModInfo = document.getElementById("btnCancelModInfo");
|
||||
let elBtnSaveModInfo = document.getElementById("btnSaveModInfo");
|
||||
|
||||
|
||||
let clickAddInfo = function () {
|
||||
document.getElementById("frmInfo").reset();
|
||||
document.getElementById("inpInfoRowid").value = 0;
|
||||
// On renseigne la date du jour par défaut dans la zone inpInfoDate
|
||||
document.getElementById("inpInfoDate").value = new Date().toISOString().slice(0, 10);
|
||||
|
||||
|
||||
document.getElementById("modInfosTitre").innerHTML = '<i class="fa fa-file-text"></i> Ajouter une information marchés';
|
||||
showModal(document.getElementById("modalEditInfos"));
|
||||
document.getElementById("inpInfoDate").focus();
|
||||
}
|
||||
|
||||
let clickModInfo = function () {
|
||||
|
||||
// On récupère les données de la ligne
|
||||
const infoId = this.getAttribute("data-rowid");
|
||||
showLoading();
|
||||
fetch('/jxpost/load_info',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({cid: infoId}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
'Accept': 'application/json;charset=utf-8',
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
showNotification("Erreur", "Le chargement des données de cette info n'a pas abouti", "error");
|
||||
} else {
|
||||
const ret = response.json();
|
||||
ret.then(function (data) {
|
||||
document.getElementById("frmInfo").reset();
|
||||
document.getElementById("inpInfoRowid").value = infoId;
|
||||
document.getElementById("inpInfoDate").value = data[0].date_infos;
|
||||
document.getElementById("inpInfoTitre").value = data[0].titre_infos;
|
||||
document.getElementById("inpInfoText").value = data[0].text_infos;
|
||||
if (data[0].chk_publie == "1") {
|
||||
document.getElementById('inpInfoChkPublie').checked = true;
|
||||
} else {
|
||||
document.getElementById('inpInfoChkPublie').checked = false;
|
||||
}
|
||||
document.getElementById("modInfosTitre").innerHTML = '<i class="fa fa-file-text"></i> Modifier cette information marchés';
|
||||
showModal(document.getElementById("modalEditInfos"));
|
||||
document.getElementById("inpInfoDate").focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
let clickSuppInfo = function () {
|
||||
if (confirm("Voulez-vous supprimer cette information ?")) {
|
||||
const infoId = this.getAttribute("data-rowid");
|
||||
showLoading();
|
||||
fetch('/jxpost/supp_info',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({cid: infoId}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
'Accept': 'application/json;charset=utf-8',
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
showNotification("Erreur", "La suppression de cette info n'a pas abouti", "error");
|
||||
} else {
|
||||
const ret = response.json();
|
||||
ret.then(function (data) {
|
||||
showNotification("Information", "Cette info a été supprimée", "success");
|
||||
// On recharge la page en cours
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 2000); // 2000 millisecondes = 2 secondes
|
||||
});
|
||||
}
|
||||
});
|
||||
hideLoading();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let clickCancelModInfo = function () {
|
||||
hideModal(document.getElementById("modalEditInfos"));
|
||||
}
|
||||
|
||||
let clickSaveModInfo = function () {
|
||||
// Contrôle des données saisies avant enregistrement
|
||||
if (document.getElementById("inpInfoDate").value == "") {
|
||||
showNotification("Erreur", "La date est obligatoire", "error");
|
||||
document.getElementById("inpInfoDate").focus();
|
||||
return false;
|
||||
}
|
||||
if (document.getElementById("inpInfoTitre").value == "") {
|
||||
showNotification("Erreur", "Le titre est obligatoire", "error");
|
||||
document.getElementById("inpInfoTitre").focus();
|
||||
return false;
|
||||
}
|
||||
if (document.getElementById("inpInfoText").value == "") {
|
||||
showNotification("Erreur", "Le texte est obligatoire", "error");
|
||||
document.getElementById("inpInfoText").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
// On récupère les données du formulaire
|
||||
const infoId = document.getElementById("inpInfoRowid").value;
|
||||
const infoDate = document.getElementById("inpInfoDate").value;
|
||||
const infoTitre = document.getElementById("inpInfoTitre").value;
|
||||
const infoTexte = document.getElementById("inpInfoText").value;
|
||||
const infoChkPublie = document.getElementById("inpInfoChkPublie").checked;
|
||||
showLoading();
|
||||
fetch('/jxpost/save_info',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({cid: infoId, cdate: infoDate, ctitre: infoTitre, ctexte: infoTexte, cpublie: infoChkPublie}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
'Accept': 'application/json;charset=utf-8',
|
||||
}
|
||||
}).then((response) => {
|
||||
if (!response.ok) {
|
||||
showNotification("Erreur", "L'enregistrement de cette info n'a pas abouti", "error");
|
||||
} else {
|
||||
const ret = response.json();
|
||||
ret.then(function (data) {
|
||||
showNotification("Succès", "Enregistrement de cette info effectué", "success");
|
||||
// On recharge la page en cours
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 2000); // 2000 millisecondes = 2 secondes
|
||||
});
|
||||
}
|
||||
});
|
||||
hideLoading();
|
||||
hideModal(document.getElementById("modalEditInfos"));
|
||||
return false;
|
||||
}
|
||||
|
||||
elBtnAddInfo.addEventListener('click', clickAddInfo);
|
||||
Array.from(elBtnModInfo).forEach(function (element) {
|
||||
element.addEventListener('click', clickModInfo);
|
||||
});
|
||||
Array.from(elBtnSuppInfo).forEach(function (element) {
|
||||
element.addEventListener('click', clickSuppInfo);
|
||||
});
|
||||
elBtnCancelModInfo.addEventListener('click', clickCancelModInfo);
|
||||
elBtnSaveModInfo.addEventListener('click', clickSaveModInfo);
|
||||
});
|
||||
Reference in New Issue
Block a user