Mon commit initial
This commit is contained in:
14
static/js/Untitled-1.py
Normal file
14
static/js/Untitled-1.py
Normal file
@@ -0,0 +1,14 @@
|
||||
table.setFilter("colors", "keywords", "red green blue"); //returns rows with a colors filed containing either the word "red", "green", or "blue"
|
||||
|
||||
table.setFilter("colors", "keywords", "red green blue", {matchAll:true}); //returns rows with a colors filed containing ALL the words "red", "green" & "blue"
|
||||
|
||||
function customFilter(data, filterParams){
|
||||
//data - the data for the row being filtered
|
||||
//filterParams - params object passed to the filter
|
||||
|
||||
return data.name == "bob" && data.height < filterParams.height; //must return a boolean, true if it passes the filter.
|
||||
}
|
||||
|
||||
table.setFilter(customFilter, {height:3});
|
||||
|
||||
table.refreshFilter();
|
||||
7
static/js/bootstrap.min.js
vendored
Normal file
7
static/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
25
static/js/carnet_carburant.js
Normal file
25
static/js/carnet_carburant.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const tableau_carnet = new Tabulator("#tableau-carnet", {
|
||||
columns: [
|
||||
{"title": "Date", "field": "date"},
|
||||
{"title": "Nom de la station-service", "field": "nom_station"},
|
||||
{"title": "Type de carburant", "field": "type_carburant"},
|
||||
{"title": "Litres", "field": "litre"},
|
||||
{"title": "Litre/Prix (GNF)", "field": "prix"},
|
||||
{"title": "Montant total (GNF)", "field": "montant_total"},
|
||||
{"title": "Kilometrage", "field": "kilometrage"},
|
||||
{"title": "Observation", "field": "observation"},
|
||||
{"title": "Nom du chauffeur", "field": "nom_chauffeur"},
|
||||
]
|
||||
})
|
||||
|
||||
$("filtreMois").addEventListener("change", function () {
|
||||
tableau_carnet.setData(
|
||||
`${$("filtreMois").dataset.url}`,
|
||||
{
|
||||
"id_vehicule": $("id_vehicule").value,
|
||||
"mois": this.value
|
||||
}
|
||||
)
|
||||
})
|
||||
23
static/js/carnet_sortie_vehicule.js
Normal file
23
static/js/carnet_sortie_vehicule.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const tableau_carnet = new Tabulator("#tableau-sortie-vehicule", {
|
||||
columns: [
|
||||
{"title": "Nom du passager", "field": "nom_passager"},
|
||||
{"title": "Lieu de depart", "field": "lieu_depart"},
|
||||
{"title": "Heure de départ prévue", "field": "heure_depart_prevu"},
|
||||
{"title": "Heure effectif de départ", "field": "heure_depart_effectif"},
|
||||
{"title": "Lieu d'arrivé", "field": "lieu_arrive"},
|
||||
{"title": "Heure d'arrivée", "field": "heure_arrive"},
|
||||
{"title": "Nom du chauffeur", "field": "nom_chauffeur"},
|
||||
]
|
||||
})
|
||||
|
||||
$("filtreMois").addEventListener("change", function () {
|
||||
tableau_carnet.setData(
|
||||
`${$("filtreMois").dataset.url}`,
|
||||
{
|
||||
"id_vehicule": $("id_vehicule").value,
|
||||
"mois": this.value
|
||||
}
|
||||
)
|
||||
})
|
||||
9
static/js/detail_course.js
Normal file
9
static/js/detail_course.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const course_terminer = $("course-terminer").dataset.state;
|
||||
if(course_terminer === "True"){
|
||||
$("course-terminer").checked = true;
|
||||
document.querySelectorAll(".enregistrerButton").forEach(button => {
|
||||
button.style.display = "none";
|
||||
});
|
||||
}
|
||||
24
static/js/detail_gestion_vehicule.js
Normal file
24
static/js/detail_gestion_vehicule.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// document.getElementById("id_mois_concerne").addEventListener("change", function () {
|
||||
// fetch(`/gestion-produit/recuperer-fournisseur-categorie/${this.value}`)
|
||||
// .then(response => response.json())
|
||||
// .then(data => {
|
||||
// champs_fournisseur.innerHTML = "";
|
||||
// data.forEach(fournisseur => {
|
||||
// const option = document.createElement("option");
|
||||
// option.value = fournisseur.id;
|
||||
// option.text = fournisseur.nom_fournisseur;
|
||||
// champs_fournisseur.appendChild(option);
|
||||
// });
|
||||
// })
|
||||
// })
|
||||
|
||||
carnetBordMois = document.querySelector("#carnetBordForm #id_mois_concerne");
|
||||
|
||||
carnetBordMois.addEventListener("change", function () {
|
||||
fetch (`/gestion-vehicule/carnet-vehicule-information/${carnetBordMois.value}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
document.getElementById("id_km_debut_mois").value = data.km_debut;
|
||||
document.getElementById("id_km_fin_mois").value = data.km_fin;
|
||||
})
|
||||
})
|
||||
24
static/js/details_fournisseur.js
Normal file
24
static/js/details_fournisseur.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const tableau_livraison = new Tabulator("#liste-livraison", {
|
||||
layout: "fitColumns",
|
||||
columns: [
|
||||
{ title: "Date de livraison", field: "date", sorter: "date" },
|
||||
{ title: "Produit", field: "produit" },
|
||||
{ title: "Quantité commandée", field: "quantite" },
|
||||
{ title: "Montant", field: "prix_achat", formatter: "money" },
|
||||
{ title: "Montant total", field: "montant_total", formatter: "money" },
|
||||
{ title: "Statut", field: "statut", formatter: "tickCross" },
|
||||
],
|
||||
responsiveLayout: "hide",
|
||||
pagination: true,
|
||||
paginationSize: 10,
|
||||
ajaxURL: document.getElementById("liste-livraison").dataset.url,
|
||||
})
|
||||
|
||||
document.getElementById("filtreMois").addEventListener("change", function() {
|
||||
const mois = this.value;
|
||||
if (mois) {
|
||||
tableau_livraison.setFilter("date", "like", mois);
|
||||
} else {
|
||||
tableau_livraison.clearFilter();
|
||||
}
|
||||
});
|
||||
34
static/js/gestion_fournisseur_index.js
Normal file
34
static/js/gestion_fournisseur_index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const tableau_liste_fournisseur = new Tabulator("#liste_fournisseur", {
|
||||
layout:"fitColumns",
|
||||
ajaxURL: `${$('liste_fournisseur').dataset.url}`,
|
||||
columns:[
|
||||
{title:"Nom de l'entreprise", field:"nom_entreprise"},
|
||||
{title:"Nom et prénom du representant", field:"representant"},
|
||||
{title:"Fonction", field:"fonction"},
|
||||
{title:"Téléphone", field:"telephone"},
|
||||
{title:"E-mail", field:"email"},
|
||||
// {title:"Note", field:"note", formatter: "star"},
|
||||
],
|
||||
});
|
||||
|
||||
document.getElementById("searchFournisseur").addEventListener("keyup", function () {
|
||||
if(this.value){
|
||||
tableau_liste_fournisseur.setFilter("nom_entreprise", "like", this.value)
|
||||
}else{
|
||||
tableau_liste_fournisseur.clearFilter();
|
||||
}
|
||||
})
|
||||
|
||||
document.getElementById("filterCategorie").addEventListener("change", function (e) {
|
||||
if(this.value === ""){
|
||||
tableau_liste_fournisseur.setData(`${$('liste_fournisseur').dataset.url}`)
|
||||
}else{
|
||||
tableau_liste_fournisseur.setData("/gestion-fournisseur/liste-fournisseur-categorie", {"c": this.value})
|
||||
}
|
||||
})
|
||||
|
||||
tableau_liste_fournisseur.on("rowClick", function(e, row){
|
||||
location.href = `details-fournisseur/${row.getData().id}`;
|
||||
});
|
||||
231
static/js/gestion_produit.js
Normal file
231
static/js/gestion_produit.js
Normal file
@@ -0,0 +1,231 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const voirBtns = document.querySelectorAll('.voir-demande');
|
||||
const modal = new bootstrap.Modal($('enregistrerDetailDemande'));
|
||||
|
||||
voirBtns.forEach(btn => {
|
||||
btn.addEventListener('click', function () {
|
||||
const produitId = this.dataset.id;
|
||||
|
||||
fetch(`/gestion-produit/detailDemande/${produitId}/`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
$('detailNom').value = data.detailNom;
|
||||
$('detailCategorie').value = data.detailCategorie;
|
||||
$('detailmotif').textContent = data.detailmotif;
|
||||
$('detailDateDemande').value = data.detailDeMiseADispo;
|
||||
$('detailARendre').checked = data.detailARendre ? true : false;
|
||||
|
||||
// Sauvegarde de l’ID pour les boutons d’action
|
||||
if(data.chef_departement){
|
||||
$('confirmerBtn').dataset.id = produitId;
|
||||
$('refuserBtn').dataset.id = produitId;
|
||||
}
|
||||
|
||||
modal.show();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function updateStatut(demandeId, action) {
|
||||
fetch('/gestion-produit/update-demande', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `id=${demandeId}&action=${action}&emetteur=chef`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert(`Demande ${action} avec succès !`);
|
||||
location.reload(); // recharge la page pour voir le nouveau statut
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Erreur :', error));
|
||||
}
|
||||
|
||||
try{
|
||||
$('confirmerBtn').addEventListener('click', function () {
|
||||
updateStatut(this.dataset.id, '1'); // '1' pour confirmer
|
||||
});
|
||||
|
||||
$('refuserBtn').addEventListener('click', function () {
|
||||
updateStatut(this.dataset.id, '0'); // '0' pour refuser
|
||||
});
|
||||
}catch{
|
||||
|
||||
}
|
||||
|
||||
|
||||
const tabulator = new Tabulator("#listeDemandeTable", {
|
||||
columns: [
|
||||
{ title: "Nom Produit", field: "produit", sorter: "string" },
|
||||
// { title: "Catégorie", field: "categorie", sorter: "string" },
|
||||
{ title: "Motif", field: "motifs", sorter: "string" },
|
||||
{ title: "Date de mise à disposition souhaitée", field: "dateDeMiseADispoSouhaite", sorter: "date" },
|
||||
{ title: "À Rendre", field: "a_rendre", sorter: "boolean", formatter: "tickCross" },
|
||||
{ title: "Validé par le supérieur", field: "valider_par_chef", sorter: "boolean", formatter: "tickCross", formatterParams: {
|
||||
allowEmpty: true
|
||||
}
|
||||
},
|
||||
{ title: "Valider par la logistique", field: "valider_par_logisticien", sorter: "boolean", formatter: "tickCross", formatterParams: {
|
||||
allowEmpty: true
|
||||
}},
|
||||
{ title: "Motif de refus", field: "motifs_refus"},
|
||||
],
|
||||
ajaxURL: `${$("listeDemandeTable").dataset.url}`,
|
||||
})
|
||||
|
||||
// ----------------------------------------------------------- FILTRE
|
||||
$('searchInput').addEventListener('keyup', function() {
|
||||
const filter = this.value.toLowerCase();
|
||||
const cards = document.querySelectorAll('.card');
|
||||
cards.forEach(card => {
|
||||
const title = card.querySelector('.card-title').textContent.toLowerCase();
|
||||
if (title.includes(filter)) {
|
||||
card.style.display = '';
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// Enregistrement de commande
|
||||
const listeCommanderButton = document.querySelectorAll(".listeCommanderButton");
|
||||
const modalCommander = new bootstrap.Modal($("commanderModal"));
|
||||
|
||||
listeCommanderButton.forEach(commanderButton => {
|
||||
commanderButton.addEventListener("click", function (e) {
|
||||
const idProduit = this.dataset.id;
|
||||
const champs_produit = $("id_produit");
|
||||
const champs_fournisseur = $("id_fournisseur");
|
||||
champs_produit.value = idProduit;
|
||||
// champs_produit.disabled = true;
|
||||
|
||||
fetch(`/gestion-produit/recuperer-fournisseur-categorie/${idProduit}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
champs_fournisseur.innerHTML = "";
|
||||
data.forEach(fournisseur => {
|
||||
const option = document.createElement("option");
|
||||
option.value = fournisseur.id;
|
||||
option.text = fournisseur.nom_fournisseur;
|
||||
champs_fournisseur.appendChild(option);
|
||||
});
|
||||
})
|
||||
|
||||
modalCommander.show();
|
||||
})
|
||||
});
|
||||
|
||||
const listeDemandeButton = document.querySelectorAll(".listeDemandeButton");
|
||||
const demanderModal = new bootstrap.Modal($("demanderModal"));
|
||||
|
||||
listeDemandeButton.forEach(demanderButton => {
|
||||
demanderButton.addEventListener("click", function() {
|
||||
const produitCommanderId = this.dataset.id;
|
||||
const champs_produit = document.querySelector("#demanderModal #id_produit");
|
||||
// champs_produit.disabled = true;
|
||||
|
||||
champs_produit.value = produitCommanderId;
|
||||
|
||||
demanderModal.show();
|
||||
})
|
||||
});
|
||||
|
||||
$("filterCategorie").addEventListener("change", function(){
|
||||
const card = document.querySelectorAll(".card");
|
||||
const filtre = this.value;
|
||||
if(filtre === ""){
|
||||
card.forEach(carte => {
|
||||
carte.style.display = "";
|
||||
});
|
||||
}else{
|
||||
card.forEach(carte => {
|
||||
categorie = carte.querySelector(".categorie-produit").textContent.toLowerCase();
|
||||
if(parseInt(categorie) === parseInt(filtre)){
|
||||
carte.style.display = "";
|
||||
}else{
|
||||
carte.style.display = 'none'
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
$("enregistrement-produit-form").addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
const url = this.dataset.url;
|
||||
// const csrf =
|
||||
fetch(
|
||||
url,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
body: new FormData(form)
|
||||
}
|
||||
)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const messageZone = $("messageZone");
|
||||
if(data.success){
|
||||
messageZone.innerHTML = `
|
||||
<div class="alert alert-success">
|
||||
${data.message}
|
||||
</div>
|
||||
`;
|
||||
form.reset();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$('enregistrerProduit').addEventListener("hidden.bs.modal", function () {
|
||||
location.reload()
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
// --------------------------------- Tableau categorie
|
||||
const url_liste_categorie = $("listecategorie").dataset.url;
|
||||
const tableau_categorie = new Tabulator("#listecategorie", {
|
||||
columns: [
|
||||
{title: "Nom de la catégorie", field: "categorie"}
|
||||
],
|
||||
ajaxURL: url_liste_categorie
|
||||
})
|
||||
|
||||
$("enregistrer-categorie").addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
const url = this.dataset.url;
|
||||
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
headers:{
|
||||
"X-Requested-With": "XMLHttpResponse"
|
||||
},
|
||||
body: new FormData(form)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.success){
|
||||
const messageBox = $("message-creation-categorie");
|
||||
messageBox.innerHTML = `
|
||||
<div class="alert alert-success">
|
||||
Categorie crée avec succès
|
||||
</div>
|
||||
`;
|
||||
tableau_categorie.setData(url_liste_categorie);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$("enregistrerCategorie").addEventListener("hidden.bs.modal", function () {
|
||||
location.reload();
|
||||
})
|
||||
166
static/js/gestion_vehicule.js
Normal file
166
static/js/gestion_vehicule.js
Normal file
@@ -0,0 +1,166 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const tableau_demande_vehicule = new Tabulator("#tableau-demande-vehicule", {
|
||||
columns: [
|
||||
{title: "Nom du passager", field: "nom_passager"},
|
||||
{title: "Lieu de depart", field: "lieu_depart"},
|
||||
{title: "Date et heure de départ", field: "date_heure_depart"},
|
||||
{title: "Lieu d'arrivée", field: "lieu_arrivee"},
|
||||
{title: "Statut de validation", field: "validation", formatter: "tickCross", formatterParams: {
|
||||
allowEmpty: true
|
||||
}},
|
||||
],
|
||||
ajaxURL: `${$("tableau-demande-vehicule").dataset.url}`,
|
||||
pagination: true,
|
||||
paginationSize: 8
|
||||
})
|
||||
|
||||
function valider(statut) {
|
||||
if(statut == "valider"){
|
||||
$("affichage-formulaire").style.display = "block";
|
||||
$("refus").style.display = "none";
|
||||
}else if(statut == "refuser"){
|
||||
$("affichage-formulaire").style.display = "none";
|
||||
$("refus").style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
$("radioValider").addEventListener("input", function () {
|
||||
valider("valider");
|
||||
})
|
||||
|
||||
$("radioRefuser").addEventListener("input", function () {
|
||||
valider("refuser");
|
||||
})
|
||||
|
||||
tableau_demande_vehicule.on("rowClick", function (row, rowData) {
|
||||
const data = rowData.getData();
|
||||
const modal = new bootstrap.Modal($("confirmerDemandeModal"));
|
||||
|
||||
$("id-demande").value = data.id_demande;
|
||||
$("nom-passager").value = data.nom_passager;
|
||||
$("lieu-depart").value = data.lieu_depart;
|
||||
$("lieu-arrivee").value = data.lieu_arrivee;
|
||||
$("date-heure-depart").value = data.date_heure_depart;
|
||||
|
||||
chauffeur_champs = $("chauffeur");
|
||||
chauffeur_champs.innerHTML = "";
|
||||
|
||||
data.chauffeurs.forEach(chauffeur => {
|
||||
const option = document.createElement("option");
|
||||
option.value = chauffeur.chauffeur_id;
|
||||
option.text = chauffeur.chauffeur_name;
|
||||
chauffeur_champs.appendChild(option);
|
||||
});
|
||||
|
||||
$("radioValider").disabled = false;
|
||||
$("radioValider").checked = false;
|
||||
$("radioRefuser").disabled = false;
|
||||
$("radioRefuser").checked = false;
|
||||
// $("courseTermine").disabled = false;
|
||||
// $("courseTermine").checked = false;
|
||||
$("motif-refus").textContent = "";
|
||||
|
||||
if(data.validation == true){
|
||||
$("radioValider").checked = true;
|
||||
$("radioValider").disabled = true;
|
||||
$("radioRefuser").disabled = true;
|
||||
valider("valider");
|
||||
|
||||
if(data.course_terminer){
|
||||
$("courseTermine").checked = true;
|
||||
$("courseTermine").disabled = true;
|
||||
$("date_heure_retour").value = data.heure_course_termine;
|
||||
$("demanderValiderEnregistrer").disabled = true;
|
||||
}
|
||||
}else if (data.validation == false){
|
||||
valider("refuser");
|
||||
// $("radioRefuser").disabled = true;
|
||||
$("radioValider").disabled = true;
|
||||
$("radioRefuser").checked = true;
|
||||
|
||||
$("demanderValiderEnregistrer").disabled = true;
|
||||
|
||||
$("motif-refus").textContent = data.motif_refus;
|
||||
$("motif-refus").style.disabled = true;
|
||||
}else{
|
||||
$("affichage-formulaire").style.display = "none";
|
||||
$("refus").style.display = "none";
|
||||
$("radioValider").checked = false;
|
||||
$("radioRefuser").checked = false;
|
||||
}
|
||||
|
||||
const vehiculeHTML = $("vehicule");
|
||||
vehiculeHTML.innerHTML = "";
|
||||
|
||||
data.vehicule.forEach(vehicule => {
|
||||
const option = document.createElement("option");
|
||||
option.value = vehicule.id;
|
||||
option.textContent = vehicule.immatriculation;
|
||||
vehiculeHTML.appendChild(option);
|
||||
});
|
||||
|
||||
$("validation-sortie-footer").style.display = "none";
|
||||
|
||||
if(data.is_logisticien){
|
||||
$("validation-sortie-footer").style.display = "";
|
||||
}
|
||||
|
||||
if(data.validation & (data.is_logisticien | data.is_chauffeur)){
|
||||
location.href = `detail-course/${data.id_demande}`
|
||||
}else{
|
||||
modal.show();
|
||||
}
|
||||
})
|
||||
|
||||
$("filtreStatutDemande").addEventListener("change", function () {
|
||||
option_filtre = this.value;
|
||||
if(option_filtre === "valider"){
|
||||
tableau_demande_vehicule.setFilter("validation", '=', true);
|
||||
}else if(option_filtre === "refuser"){
|
||||
tableau_demande_vehicule.setFilter("validation", '=', false);
|
||||
}else if(option_filtre === "attente"){
|
||||
tableau_demande_vehicule.setFilter("validation", '=', null);
|
||||
}else if(option_filtre === "terminer"){
|
||||
tableau_demande_vehicule.setFilter("course_terminer", '=', true);
|
||||
}else if(option_filtre === "mes_demandes"){
|
||||
tableau_demande_vehicule.setFilter("user_id", "=", $("tableau-demande-vehicule").dataset.userid)
|
||||
}
|
||||
else{
|
||||
tableau_demande_vehicule.clearFilter();
|
||||
}
|
||||
})
|
||||
|
||||
$("enregistrer-demande-form").addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const url = this.dataset.url;
|
||||
const form = this;
|
||||
|
||||
fetch(
|
||||
url,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Requested-With": "XMTHttpRequest"
|
||||
},
|
||||
body: new FormData(form)
|
||||
}
|
||||
)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const messageZone = $("messageZone");
|
||||
if(data.success){
|
||||
messageZone.innerHTML = `
|
||||
<div class="alert alert-success">
|
||||
${data.message}
|
||||
</div>
|
||||
`;
|
||||
form.reset();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$("enregistrerDemandeModal").addEventListener("hidden.bs.modal", function () {
|
||||
location.reload();
|
||||
})
|
||||
197
static/js/index.js
Normal file
197
static/js/index.js
Normal file
@@ -0,0 +1,197 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const table_demandes = new Tabulator("#demande_produit", {
|
||||
layout:"fitColumns",
|
||||
ajaxURL:`${$('demande_produit').dataset.url}`,
|
||||
pagination: true,
|
||||
paginationSize: 8,
|
||||
columns:[
|
||||
{title:"Libellé", field:"produit"},
|
||||
{title:"Quantité", field:"quantite"},
|
||||
{title:"A rendre", field:"a_rendre", formatter: "tickCross"},
|
||||
],
|
||||
});
|
||||
|
||||
table_demandes.on("rowClick", function(e, row){
|
||||
let data = row.getData();
|
||||
console.log("Data", data);
|
||||
const modal = new bootstrap.Modal($('listeDemandesModal'));
|
||||
$('produit').value = data.produit;
|
||||
$("demandeur").value = data.demandeur;
|
||||
$('quantite').value = data.quantite;
|
||||
$('motifs').textContent = data.motifs;
|
||||
$('date_demande').value = data.date_de_mise_a_dispo_souhaite;
|
||||
$('a_rendre').checked = data.a_rendre ? true : false;
|
||||
$('valider_par_chef').checked = data.valider_par_chef ? true : false;
|
||||
$("radioRefuser").dataset.id = data.id_demande;
|
||||
$("radioValider").dataset.id = data.id_demande;
|
||||
|
||||
$("radioRefuser").addEventListener("click", (e) =>{
|
||||
$("box-motif-refus").classList.remove("d-none");
|
||||
$("box-motif-refus").classList.add("d-block");
|
||||
})
|
||||
|
||||
$("radioValider").addEventListener("click", (e) =>{
|
||||
$("box-motif-refus").classList.remove("d-block");
|
||||
$("box-motif-refus").classList.add("d-none");
|
||||
})
|
||||
|
||||
if(data.is_logisticien){
|
||||
modal.show();
|
||||
}
|
||||
});
|
||||
|
||||
const table_commande = new Tabulator("#commande_attentes", {
|
||||
layout:"fitColumns",
|
||||
ajaxURL:`${$('commande_attentes').dataset.url}`,
|
||||
pagination: true,
|
||||
paginationSize: 8,
|
||||
columns:[
|
||||
{title:"Libellé", field:"produit"},
|
||||
{title:"Fournisseur", field:"fournisseur"},
|
||||
{title:"Date de livraison", field:"date_livraison"},
|
||||
],
|
||||
});
|
||||
|
||||
const tableau_produit_rupture = new Tabulator("#tableau-produit-rupture", {
|
||||
layout: "fitcolumns",
|
||||
ajaxURL: `${$("tableau-produit-rupture").dataset.url}`,
|
||||
ajaxParams: {
|
||||
type: "rupture"
|
||||
},
|
||||
pagination: true,
|
||||
paginationSize: 8,
|
||||
columns: [
|
||||
{title: "Libellé", field:"libelle"},
|
||||
// {title: "Catégorie", field:"categorie"},
|
||||
{title: "Conditionnement", field:"conditionnement"},
|
||||
{title: "Quantité en stock", field:"stockActuel"},
|
||||
]
|
||||
})
|
||||
|
||||
$("produit_rupture").addEventListener("click", function () {
|
||||
produitRuptureModal = new bootstrap.Modal($("produitRuptureModal"));
|
||||
tableau_produit_rupture.setData(`${$("tableau-produit-rupture").dataset.url}`, {type: "rupture"})
|
||||
$("produitRuptureModalLabel").innerHTML = "Produit en rupture"
|
||||
produitRuptureModal.show();
|
||||
})
|
||||
|
||||
$("produit_pre_rupture").addEventListener("click", function() {
|
||||
produitRuptureModal = new bootstrap.Modal($("produitRuptureModal"));
|
||||
tableau_produit_rupture.setData(`${$("tableau-produit-rupture").dataset.url}`, {type: "pre_rupture"})
|
||||
$("produitRuptureModalLabel").innerHTML = "Produit en pré-rupture"
|
||||
produitRuptureModal.show()
|
||||
})
|
||||
|
||||
|
||||
$("produit_normal").addEventListener("click", function() {
|
||||
produitRuptureModal = new bootstrap.Modal($("produitRuptureModal"));
|
||||
tableau_produit_rupture.setData(`${$("tableau-produit-rupture").dataset.url}`, {type: "normal"})
|
||||
$("produitRuptureModalLabel").innerHTML = "Produit en quantité suffisante"
|
||||
produitRuptureModal.show()
|
||||
})
|
||||
|
||||
function updateStatut(demandeId, action, motifRefus='') {
|
||||
const url = $("radioRefuser").dataset.url;
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `id=${demandeId}&action=${action}&emetteur=logisticien&motif_refus=${motifRefus}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert(`Demande ${action} avec succès !`);
|
||||
location.reload(); // recharge la page pour voir le nouveau statut
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Erreur :', error));
|
||||
}
|
||||
|
||||
$('enregistrerModifs').addEventListener('click', function () {
|
||||
if($("radioRefuser").checked){
|
||||
updateStatut(
|
||||
$("radioRefuser").dataset.id,
|
||||
'0',
|
||||
$("motifs_refus").value
|
||||
); // '0' pour refuser
|
||||
}else{
|
||||
updateStatut(
|
||||
$("radioValider").dataset.id,
|
||||
'1',
|
||||
); // '1' pour confirmer
|
||||
}
|
||||
});
|
||||
|
||||
table_commande.on("rowClick", function(e, row){
|
||||
let data = row.getData();
|
||||
const modal = new bootstrap.Modal($('listeCommandesModal'));
|
||||
$('produitCommande').value = data.produit;
|
||||
$('fournisseur').value = data.fournisseur;
|
||||
$('quantiteCommande').value = data.quantite;
|
||||
$('date_commande').value = data.date_commande;
|
||||
$('date_livraison').value = data.date_livraison;
|
||||
|
||||
$("enregistrerModifsCommande").dataset.id = data.id_commande;
|
||||
|
||||
if(data.is_logisticien){
|
||||
modal.show();
|
||||
}
|
||||
});
|
||||
|
||||
$('enregistrerModifsCommande').addEventListener('click', function () {
|
||||
if($("produit_livre").checked){
|
||||
fetch(`${$("enregistrerModifsCommande").dataset.url}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `id_commande=${$("enregistrerModifsCommande").dataset.id}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.status === "success") {
|
||||
alert(data.message);
|
||||
location.reload(); // recharge la page pour voir le nouveau statut
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Erreur :', error));
|
||||
}
|
||||
});
|
||||
|
||||
const tableau_equipement_rendre = new Tabulator("#tableau-equipement-rendre", {
|
||||
layout:"fitColumns",
|
||||
ajaxURL: `${$("tableau-equipement-rendre").dataset.url}`,
|
||||
pagination: true,
|
||||
paginationSize: 8,
|
||||
columns:[
|
||||
{title:"Libellé", field:"produit"},
|
||||
{title:"Quantite", field:"quantite"},
|
||||
{title:"Detenteur", field:"detenteur"},
|
||||
// {title:"Departement", field:"detenteur"},
|
||||
{title:"Rendu", field:"action", formatter:"tickCross", editor: true},
|
||||
],
|
||||
})
|
||||
|
||||
$("equipementARendreEnregistrer").addEventListener("click", function () {
|
||||
const information_equipement = tableau_equipement_rendre.getData();
|
||||
fetch(`${$("equipementARendreEnregistrer").dataset.url}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(information_equipement)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
tableau_equipement_rendre.setData("/equipement-a-rendre");
|
||||
// tableau_equipement_rendre.clearEditedData();
|
||||
})
|
||||
.catch(error => console.error(error))
|
||||
})
|
||||
52
static/js/mouvement_stock.js
Normal file
52
static/js/mouvement_stock.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const tableau_entre = new Tabulator("#tableau-stock-entree", {
|
||||
columns: [
|
||||
{title: "Produit", field: "produit"},
|
||||
{title: "Catégorie", field: "categorie"},
|
||||
{title: "Conditionnement", field: "conditionnement"},
|
||||
{title: "Fournisseur", field: "fournisseur"},
|
||||
{title: "Date de commande", field: "date_commande"},
|
||||
{title: "Date de livraison", field: "date_livraison"},
|
||||
{title: "Quantité commandée", field: "quantite_commander"},
|
||||
],
|
||||
})
|
||||
|
||||
const tableau_sortie = new Tabulator("#tableau-stock-sortie", {
|
||||
columns: [
|
||||
{title: "Produit", field: "produit"},
|
||||
{title: "Catégorie", field: "categorie"},
|
||||
{title: "Conditionnement", field: "conditionnement"},
|
||||
{title: "Date de la demande", field: "date_demande"},
|
||||
// {title: "Date de mise à disposition", field: "date_mise_a_dispo"},
|
||||
{title: "Quantité demandée", field: "quantite_demander"},
|
||||
]
|
||||
})
|
||||
|
||||
const filtreMois = $("filtreMois");
|
||||
|
||||
filtreMois.addEventListener("change", function () {
|
||||
tableau_entre.setData(`${filtreMois.dataset.url}`, {
|
||||
dateFiltre: filtreMois.value,
|
||||
typeFiltre: $("type_operation").value
|
||||
})
|
||||
|
||||
tableau_sortie.setData(`${filtreMois.dataset.url}`, {
|
||||
dateFiltre: filtreMois.value,
|
||||
typeFiltre: $("type_operation").value
|
||||
})
|
||||
})
|
||||
|
||||
$("type_operation").addEventListener("change", function () {
|
||||
if(this.value === "entree"){
|
||||
$("tableau-stock-entree").style.display = "";
|
||||
$("tableau-stock-sortie").style.display = "none";
|
||||
}
|
||||
})
|
||||
|
||||
$("type_operation").addEventListener("change", function () {
|
||||
if(this.value === "sortie"){
|
||||
$("tableau-stock-entree").style.display = "none";
|
||||
$("tableau-stock-sortie").style.display = "";
|
||||
}
|
||||
})
|
||||
3
static/js/tabulator.min.js
vendored
Normal file
3
static/js/tabulator.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user