274 lines
11 KiB
JavaScript
274 lines
11 KiB
JavaScript
import "@nextcloud/dialogs/dist/index.css";
|
|
import "datatables.net-dt/css/jquery.dataTables.css";
|
|
import "../css/mycss.css";
|
|
|
|
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
|
import "./listener/main_listener";
|
|
import { setDefuntCover, setBijouxPhoto,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
|
|
|
|
let bibliotheques = [];
|
|
let sortedBibliotheques = [];
|
|
let bibliothequesObs = [];
|
|
let sortedBibliothequesObs = [];
|
|
let bibliothequesProduits = [];
|
|
let sortedBibliothequesProduits = [];
|
|
|
|
window.addEventListener("DOMContentLoaded", function () {
|
|
var defuntid = $('#defuntid').data('id');
|
|
|
|
|
|
globalConfiguration();
|
|
getBibliotheques(loadBibliotheques);
|
|
getObservationsById();
|
|
getBijouxById();
|
|
getHypodermiquesyId();
|
|
|
|
let observations = document.getElementById("observations");
|
|
let hypodermiques = document.getElementById("hypodermiques");
|
|
let corpulenceInput = document.getElementById("corpulence-input");
|
|
let rigiditeInput = document.getElementById("rigidite-input");
|
|
let lividiteInput = document.getElementById("lividite-input");
|
|
let accesInput = document.getElementById("acces-input");
|
|
let injectionInput = document.getElementById("injection-input");
|
|
let preinjectionInput = document.getElementById("preinjection-input");
|
|
let coinjectionInput = document.getElementById("coinjection-input");
|
|
let drainageInput = document.getElementById("drainage-input");
|
|
let ponctionInput = document.getElementById("ponction-input");
|
|
let caviteInput = document.getElementById("cavite-input");
|
|
let desinfectionInput = document.getElementById("desinfection-input");
|
|
let lavageInput = document.getElementById("lavage-input");
|
|
let cosmetiquesInput = document.getElementById("cosmetiques-input");
|
|
let surInput = document.getElementById("sur-input");
|
|
|
|
accesInput.addEventListener("keyup", (e) => autocomplete("acces"));
|
|
rigiditeInput.addEventListener("keyup", (e) => autocomplete("rigidite"));
|
|
lividiteInput.addEventListener("keyup", (e) => autocomplete("lividite"));
|
|
corpulenceInput.addEventListener("keyup", (e) => autocomplete("corpulence"));
|
|
preinjectionInput.addEventListener("keyup", (e) => autocompleteProduits("preinjection"));
|
|
injectionInput.addEventListener("keyup", (e) => autocompleteProduits("injection"));
|
|
coinjectionInput.addEventListener("keyup", (e) => autocompleteProduits("coinjection"));
|
|
drainageInput.addEventListener("keyup", (e) => autocomplete("drainage"));
|
|
ponctionInput.addEventListener("keyup", (e) => autocomplete("ponction"));
|
|
caviteInput.addEventListener("keyup", (e) => autocomplete("cavite"));
|
|
desinfectionInput.addEventListener("keyup", (e) => autocompleteProduits("desinfection"));
|
|
lavageInput.addEventListener("keyup", (e) => autocomplete("lavage"));
|
|
cosmetiquesInput.addEventListener("keyup", (e) => autocomplete("cosmetiques"));
|
|
surInput.addEventListener("keyup", (e) => autocomplete("sur"));
|
|
|
|
observations.addEventListener("keyup", (e) => {
|
|
if(e.target.className.includes("editable-obs")) {
|
|
autocompleteObs(e.target.id);
|
|
}
|
|
})
|
|
|
|
hypodermiques.addEventListener("keyup", (e) => {
|
|
if(e.target.className.includes("editable-hypo")) {
|
|
autocompleteHypo(e.target.id);
|
|
} else if(e.target.className.includes("editable-hsur")) {
|
|
autocompleteHypoSur(e.target.id);
|
|
}
|
|
});
|
|
|
|
var pacemakerBtn = document.getElementById("pacemakerBtn");
|
|
var rapportSoinBtn = document.getElementById("rapportSoinBtn");
|
|
var exportCareCertificateButton = document.getElementById("exportCareCertificate");
|
|
var setDefuntCoverButton = this.document.getElementById("coverProductsRadioButton");
|
|
|
|
var showRapportBijouxExportModalButton = this.document.getElementById("showRapportBijouxExportModal");
|
|
var closeRapportBijouxModalButton = this.document.getElementById("closeRapportBijouxModal");
|
|
|
|
closeRapportBijouxModalButton.addEventListener("click",function(){
|
|
$('#saveRapportBijouxModal').hide();
|
|
})
|
|
showRapportBijouxExportModalButton.addEventListener("click",function(){
|
|
$('#saveRapportBijouxModal').show();
|
|
})
|
|
|
|
$(document).on("click", "#exportBijouxRapport", function () {
|
|
const rapportWithPhotosRadio = document.getElementsByName('withPhotos');
|
|
let selectedValue = "0";
|
|
for (const radio of rapportWithPhotosRadio) {
|
|
if (radio.checked) {
|
|
selectedValue = radio.value;
|
|
break;
|
|
}
|
|
}
|
|
saveRapportBijoux({
|
|
numdefunt: defuntid,
|
|
withPhotos: selectedValue
|
|
});
|
|
$('#saveRapportBijouxModal').hide();
|
|
});
|
|
|
|
setDefuntCoverButton.addEventListener("click",function(){
|
|
const productCoverRadios = document.getElementsByName('coverProductsRadioButton');
|
|
let selectedValue = null;
|
|
for (const radio of productCoverRadios) {
|
|
if (radio.checked) {
|
|
selectedValue = radio.value;
|
|
break;
|
|
}
|
|
}
|
|
setDefuntCover({
|
|
defuntId : defuntid,
|
|
productId : selectedValue
|
|
});
|
|
})
|
|
|
|
exportCareCertificateButton.addEventListener("click",function(){
|
|
exportCareCertificate({defuntId : defuntid});
|
|
})
|
|
pacemakerBtn.addEventListener("click", function(){
|
|
saveAttestationPacemaker({ defuntId: defuntid });
|
|
});
|
|
|
|
rapportSoinBtn.addEventListener("click", function(){
|
|
saveRapportSoin({ numdefunt: defuntid });
|
|
});
|
|
|
|
$(document).on("change", ".photoBijouUpload", function () {
|
|
let fileInput = this;
|
|
let file = fileInput.files[0];
|
|
let bijouxId = $(this).data("id");
|
|
setBijouxPhoto(bijouxId,file);
|
|
});
|
|
});
|
|
|
|
function loadBibliotheques(response) {
|
|
bibliotheques = [];
|
|
$.each(JSON.parse(response), function (arrayID, myresp) {
|
|
let element = document.createElement("span");
|
|
element.innerHTML = myresp.contenu;
|
|
bibliotheques.push(element.innerText);
|
|
});
|
|
sortedBibliotheques = bibliotheques.sort();
|
|
getproduits(loadBibliothequesObs);
|
|
}
|
|
|
|
function loadBibliothequesObs(response) {
|
|
bibliothequesObs = [];
|
|
$.each(JSON.parse(response), function (arrayID, myresp) {
|
|
let element = document.createElement("span");
|
|
element.innerHTML = myresp.reference+' - '+myresp.description;
|
|
bibliothequesObs.push(element.innerText);
|
|
bibliothequesProduits.push(element.innerText);
|
|
});
|
|
bibliothequesObs = [
|
|
...bibliothequesObs,
|
|
...bibliotheques
|
|
];
|
|
sortedBibliothequesObs = bibliothequesObs.sort();
|
|
sortedBibliothequesProduits = bibliothequesProduits.sort();
|
|
}
|
|
|
|
function autocomplete(id) {
|
|
removeElements();
|
|
let input = document.getElementById(`${id}-input`);
|
|
for (let i of sortedBibliotheques) {
|
|
if(i.toLocaleLowerCase().startsWith(input.value.toLowerCase()) && input.value != "") {
|
|
let listItem = document.createElement("li");
|
|
listItem.classList.add("list-items");
|
|
listItem.style.cursor = "pointer";
|
|
listItem.addEventListener("click", function() {
|
|
input.value = i;
|
|
updateDB(input.dataset.table, input.dataset.column, input.value, input.dataset.id)
|
|
removeElements();
|
|
});
|
|
let word = "<b>"+ i.substring(0, input.value.length) +"</b>"
|
|
word += i.substring(input.value.length);
|
|
listItem.innerHTML = word;
|
|
document.querySelector(`.${id}-list`).appendChild(listItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
function autocompleteObs(id) {
|
|
removeElements();
|
|
let input = document.getElementById(`${id}`);
|
|
for (let i of sortedBibliothequesObs) {
|
|
if(i.toLocaleLowerCase().startsWith(input.value.toLowerCase()) && input.value != "") {
|
|
let listItem = document.createElement("li");
|
|
listItem.classList.add("list-items");
|
|
listItem.style.cursor = "pointer";
|
|
listItem.addEventListener("click", function() {
|
|
input.value = i;
|
|
updateDB(input.dataset.table, input.dataset.column, input.value, input.dataset.id)
|
|
removeElements();
|
|
});
|
|
let word = "<b>"+ i.substring(0, input.value.length) +"</b>"
|
|
word += i.substring(input.value.length);
|
|
listItem.innerHTML = word;
|
|
document.querySelector(`.${id}-list`).appendChild(listItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
function autocompleteHypo(id) {
|
|
removeElements();
|
|
let input = document.getElementById(`${id}`);
|
|
for (let i of sortedBibliothequesProduits) {
|
|
if(i.toLocaleLowerCase().startsWith(input.value.toLowerCase()) && input.value != "") {
|
|
let listItem = document.createElement("li");
|
|
listItem.classList.add("list-items");
|
|
listItem.style.cursor = "pointer";
|
|
listItem.addEventListener("click", function() {
|
|
input.value = i;
|
|
updateDB(input.dataset.table, input.dataset.column, input.value, input.dataset.id)
|
|
removeElements();
|
|
});
|
|
let word = "<b>"+ i.substring(0, input.value.length) +"</b>"
|
|
word += i.substring(input.value.length);
|
|
listItem.innerHTML = word;
|
|
document.querySelector(`.${id}-list`).appendChild(listItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
function autocompleteHypoSur(id) {
|
|
removeElements();
|
|
let input = document.getElementById(`${id}`);
|
|
for (let i of sortedBibliotheques) {
|
|
if(i.toLocaleLowerCase().startsWith(input.value.toLowerCase()) && input.value != "") {
|
|
let listItem = document.createElement("li");
|
|
listItem.classList.add("list-items");
|
|
listItem.style.cursor = "pointer";
|
|
listItem.addEventListener("click", function() {
|
|
input.value = i;
|
|
updateDB(input.dataset.table, input.dataset.column, input.value, input.dataset.id)
|
|
removeElements();
|
|
});
|
|
let word = "<b>"+ i.substring(0, input.value.length) +"</b>"
|
|
word += i.substring(input.value.length);
|
|
listItem.innerHTML = word;
|
|
document.querySelector(`.${id}-list`).appendChild(listItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
function autocompleteProduits(id) {
|
|
removeElements();
|
|
let input = document.getElementById(`${id}-input`);
|
|
for (let i of sortedBibliothequesProduits) {
|
|
if(i.toLocaleLowerCase().startsWith(input.value.toLowerCase()) && input.value != "") {
|
|
let listItem = document.createElement("li");
|
|
listItem.classList.add("list-items");
|
|
listItem.style.cursor = "pointer";
|
|
listItem.addEventListener("click", function() {
|
|
input.value = i;
|
|
updateDB(input.dataset.table, input.dataset.column, input.value, input.dataset.id)
|
|
removeElements();
|
|
});
|
|
let word = "<b>"+ i.substring(0, input.value.length) +"</b>"
|
|
word += i.substring(input.value.length);
|
|
listItem.innerHTML = word;
|
|
document.querySelector(`.${id}-list`).appendChild(listItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
function removeElements() {
|
|
let items = document.querySelectorAll(".list-items");
|
|
items.forEach((item) => {
|
|
item.remove();
|
|
})
|
|
} |