forked from ScoDoc/ScoDoc
Assiduites : download list #732
This commit is contained in:
parent
82187a818a
commit
0cc1aaf760
@ -544,6 +544,17 @@
|
||||
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'] {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
|
1
app/static/icons/download.svg
Normal file
1
app/static/icons/download.svg
Normal 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 |
@ -6,7 +6,10 @@
|
||||
<section class="nonvalide">
|
||||
<!-- Tableaux des justificatifs à valider (attente / modifié ) -->
|
||||
<h4>Justificatifs en attente (ou modifiés)</h4>
|
||||
<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" %}
|
||||
</section>
|
||||
|
||||
@ -45,7 +48,11 @@
|
||||
async_get(
|
||||
path,
|
||||
(data, status) => {
|
||||
if (action) {
|
||||
action(data)
|
||||
} else {
|
||||
justificatifCallBack(data);
|
||||
}
|
||||
},
|
||||
(data, status) => {
|
||||
console.error(data, status)
|
||||
|
@ -4,10 +4,16 @@
|
||||
<h2>Liste de l'assiduité et des justificatifs de <span class="rouge">{{sco.etud.nomprenom}}</span></h2>
|
||||
{% include "assiduites/widgets/tableau_base.j2" %}
|
||||
<h3>Assiduités :</h3>
|
||||
<span class="iconline">
|
||||
<a class="icon filter" onclick="filterAssi()"></a>
|
||||
<a class="icon download" onclick="downloadAssi()"></a>
|
||||
</span>
|
||||
{% include "assiduites/widgets/tableau_assi.j2" %}
|
||||
<h3>Justificatifs :</h3>
|
||||
<span class="iconline">
|
||||
<a class="icon filter" onclick="filterJusti()"></a>
|
||||
<a class="icon download" onclick="downloadJusti()"></a>
|
||||
</span>
|
||||
{% include "assiduites/widgets/tableau_justi.j2" %}
|
||||
<ul id="contextMenu" class="context-menu">
|
||||
<li id="detailOption">Detail</li>
|
||||
|
@ -441,5 +441,11 @@
|
||||
getAllAssiduitesFromEtud(etudid, assiduiteCallBack)
|
||||
|
||||
}, () => { }, "#7059FF");
|
||||
|
||||
}
|
||||
|
||||
function downloadAssi() {
|
||||
try { getAllAssiduitesFromEtud(etudid, (d) => { toCSV(d, filterAssiduites) }, true, true, assi_limit_annee) } catch (_) { }
|
||||
}
|
||||
|
||||
</script>
|
@ -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>
|
||||
|
||||
<style>
|
||||
|
@ -649,6 +649,12 @@
|
||||
|
||||
}, () => { }, "#7059FF");
|
||||
}
|
||||
|
||||
function downloadJusti() {
|
||||
try { getAllJustificatifsFromEtud(etudid, (d) => { toCSV(d, filterJustificatifs) }, true, assi_limit_annee) } catch {
|
||||
try { getDeptJustificatifsFromPeriod((d) => { toCSV(d, filterJustificatifs) }) } catch { }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.fich-file {
|
||||
|
Loading…
Reference in New Issue
Block a user