Assiduites : download list #732

This commit is contained in:
Iziram 2023-09-15 09:13:25 +02:00
parent 82187a818a
commit 0cc1aaf760
7 changed files with 108 additions and 4 deletions

View File

@ -544,6 +544,17 @@
background-image: url(../icons/filter.svg); background-image: url(../icons/filter.svg);
} }
.download {
background-image: url(../icons/download.svg);
}
.iconline {
display: flex;
justify-content: flex-start;
gap: min(2%, 15px);
align-items: center;
}
[name='destroyFile'] { [name='destroyFile'] {
-webkit-appearance: none; -webkit-appearance: none;
appearance: none; appearance: none;

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000"><path d="M6 20h12M12 4v12m0 0l3.5-3.5M12 16l-3.5-3.5" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>

After

Width:  |  Height:  |  Size: 322 B

View File

@ -6,7 +6,10 @@
<section class="nonvalide"> <section class="nonvalide">
<!-- Tableaux des justificatifs à valider (attente / modifié ) --> <!-- Tableaux des justificatifs à valider (attente / modifié ) -->
<h4>Justificatifs en attente (ou modifiés)</h4> <h4>Justificatifs en attente (ou modifiés)</h4>
<a class="icon filter" onclick="filterJusti(true)"></a> <span class="iconline">
<a class="icon filter" onclick="filterJusti(true)"></a>
<a class="icon download" onclick="downloadJusti()"></a>
</span>
{% include "assiduites/widgets/tableau_justi.j2" %} {% include "assiduites/widgets/tableau_justi.j2" %}
</section> </section>
@ -45,7 +48,11 @@
async_get( async_get(
path, path,
(data, status) => { (data, status) => {
justificatifCallBack(data); if (action) {
action(data)
} else {
justificatifCallBack(data);
}
}, },
(data, status) => { (data, status) => {
console.error(data, status) console.error(data, status)

View File

@ -4,10 +4,16 @@
<h2>Liste de l'assiduité et des justificatifs de <span class="rouge">{{sco.etud.nomprenom}}</span></h2> <h2>Liste de l'assiduité et des justificatifs de <span class="rouge">{{sco.etud.nomprenom}}</span></h2>
{% include "assiduites/widgets/tableau_base.j2" %} {% include "assiduites/widgets/tableau_base.j2" %}
<h3>Assiduités :</h3> <h3>Assiduités :</h3>
<a class="icon filter" onclick="filterAssi()"></a> <span class="iconline">
<a class="icon filter" onclick="filterAssi()"></a>
<a class="icon download" onclick="downloadAssi()"></a>
</span>
{% include "assiduites/widgets/tableau_assi.j2" %} {% include "assiduites/widgets/tableau_assi.j2" %}
<h3>Justificatifs :</h3> <h3>Justificatifs :</h3>
<a class="icon filter" onclick="filterJusti()"></a> <span class="iconline">
<a class="icon filter" onclick="filterJusti()"></a>
<a class="icon download" onclick="downloadJusti()"></a>
</span>
{% include "assiduites/widgets/tableau_justi.j2" %} {% include "assiduites/widgets/tableau_justi.j2" %}
<ul id="contextMenu" class="context-menu"> <ul id="contextMenu" class="context-menu">
<li id="detailOption">Detail</li> <li id="detailOption">Detail</li>

View File

@ -441,5 +441,11 @@
getAllAssiduitesFromEtud(etudid, assiduiteCallBack) getAllAssiduitesFromEtud(etudid, assiduiteCallBack)
}, () => { }, "#7059FF"); }, () => { }, "#7059FF");
} }
function downloadAssi() {
try { getAllAssiduitesFromEtud(etudid, (d) => { toCSV(d, filterAssiduites) }, true, true, assi_limit_annee) } catch (_) { }
}
</script> </script>

View File

@ -345,6 +345,73 @@
} }
} }
function downloadStr(data, name) {
const blob = new Blob([data], { type: 'text/csv' });
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.setAttribute('href', url)
a.setAttribute('download', name);
a.click()
a.remove()
}
function askDownload(data) {
const div = document.createElement('div');
const head = document.createElement('h3');
const input = document.createElement('input');
head.textContent = "Veuillez nommer le fichier qui sera téléchargé (sera au format CSV)"
input.type = "text";
input.placeholder = "liste.csv"
div.appendChild(head)
div.appendChild(input)
openPromptModal("Préparation du téléchargement", div, () => {
downloadStr(data, input.value ? input.value : "download.csv")
}, () => { }, "green");
}
function toCSV(array, filters) {
array = filterArray(array, filters.filters)
let csv = filters.columns.map((c) => columnTranslator(c)).join(',') + "\n";
array.forEach((a) => {
let line = ""
filters.columns.forEach((c) => {
switch (c) {
case "fichier":
line += a[c] ? "Oui," : "Non,"
break;
case "etudid":
const e = getEtudiant(a.etudid);
line += `${e.nom.toUpperCase()} ${e.prenom.capitalize()},`
break;
case "formsemestre":
line += a.hasOwnProperty("formsemestre") ? a.formsemestre.title : ""
line += ","
break;
case "est_just":
line += a[c] ? "Oui," : "Non,"
break;
case "moduleimpl_id":
line += `${getModuleImpl(a)},`
break;
default:
line += `${a[c]},`;
break;
}
})
line = line.substring(0, line.lastIndexOf(',')) + "\n"
csv += line;
})
askDownload(csv);
}
</script> </script>
<style> <style>

View File

@ -649,6 +649,12 @@
}, () => { }, "#7059FF"); }, () => { }, "#7059FF");
} }
function downloadJusti() {
try { getAllJustificatifsFromEtud(etudid, (d) => { toCSV(d, filterJustificatifs) }, true, assi_limit_annee) } catch {
try { getDeptJustificatifsFromPeriod((d) => { toCSV(d, filterJustificatifs) }) } catch { }
}
}
</script> </script>
<style> <style>
.fich-file { .fich-file {