233 lines
5.8 KiB
JavaScript
Executable File
233 lines
5.8 KiB
JavaScript
Executable File
<!--
|
|
|
|
|
|
|
|
/********************************/
|
|
/* GESTION DE L'AFFINAGE PAR UE */
|
|
/********************************/
|
|
var selectList = document.querySelectorAll("#CONTAINER > section[name] > .p > select[name=annee]");
|
|
var partList = document.querySelectorAll("#CONTAINER > section[name] > table.partlist[name=UE], "+
|
|
"#CONTAINER > section[name] > table.partlist[name=semestre], "+
|
|
"#CONTAINER > section[name] > table.partlist[name=formation], "+
|
|
"#CONTAINER > section[name] > .p > div.partlist[name=semestre] > span[data-stre][data-frm]");
|
|
|
|
for( var i = 0 ; i < partList.length ; i++ ){
|
|
|
|
partList[i].addEventListener('click', function(e){
|
|
var tableauParent = e.target.parentNode.parentNode.parentNode;
|
|
|
|
if( tableauParent.tagName == 'TABLE' && e.target.dataset.hasOwnProperty('value') ){
|
|
|
|
/* SI c'est une affinage par FORMATION */
|
|
if( tableauParent.getAttribute('name') == 'formation' ){
|
|
pageM.vars[1] = 'f:'+e.target.dataset.value;
|
|
if( pageM.vars.length > 2 ) // si un deuxième affinage existe, on le supprime lors du choix de la formation
|
|
pageM.vars.pop();
|
|
}
|
|
|
|
/* SI c'est une affinage par SEMESTRE */
|
|
if( tableauParent.getAttribute('name') == 'semestre' )
|
|
if( /^a:/.test(pageM.vars[2]) )
|
|
pageM.vars[3] = 's:'+e.target.dataset.value;
|
|
else
|
|
pageM.vars[2] = 's:'+e.target.dataset.value;
|
|
|
|
/* SI c'est un affinage par UE */
|
|
if( tableauParent.getAttribute('name') == 'UE' )
|
|
if( /^a:/.test(pageM.vars[2]) )
|
|
pageM.vars[3] = 'u:'+e.target.dataset.value;
|
|
else
|
|
pageM.vars[2] = 'u:'+e.target.dataset.value;
|
|
|
|
}else if( e.target.parentNode.getAttribute('name') == 'semestre' && e.target.dataset.hasOwnProperty('stre') && e.target.dataset.hasOwnProperty('frm') ){
|
|
pageM.vars[1] = 'f:'+e.target.dataset.frm;
|
|
if( /^a:/.test(pageM.vars[2]) )
|
|
pageM.vars[3] = 's:'+e.target.dataset.stre;
|
|
else
|
|
pageM.vars[2] = 's:'+e.target.dataset.stre;
|
|
}
|
|
|
|
// si la formation n'est pas définie, on l'active
|
|
if( !/^f:/.test(pageM.vars[1]) )
|
|
if( document.querySelector('#CONTAINER > section[name] > table.partlist[name=formation] td[data-value].active') != null )
|
|
pageM.vars[1] = 'f:'+document.querySelector('#CONTAINER > section[name] > table.partlist[name=formation] td[data-value].active').dataset.value;
|
|
|
|
// si on a '*' comme valeur, on l'enlève
|
|
while( /\*$/.test(pageM.vars[pageM.vars.length-1]) )
|
|
pageM.vars.pop();
|
|
|
|
reload();
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GESTION DE L'AFFINAGE PAR ANNEE //
|
|
for( var i = 0 ; i < selectList.length ; i++ ){
|
|
|
|
selectList[i].addEventListener('change', function(e){
|
|
|
|
if( e.target.tagName == 'SELECT' ){
|
|
|
|
if( e.target.getAttribute('name') == 'annee' )
|
|
pageM.vars[2] = 'a:'+e.target.value;
|
|
|
|
// si la formation n'est pas définie, on l'active
|
|
if( !/^f:/.test(pageM.vars[1]) )
|
|
if( document.querySelector('#CONTAINER > section[name] > table.partlist[name=formation] td[data-value].active') != null )
|
|
pageM.vars[1] = 'f:'+document.querySelector('#CONTAINER > section[name] > table.partlist[name=formation] td[data-value].active').dataset.value;
|
|
|
|
// si on a '*' comme valeur, on l'enlève
|
|
while( /\*$/.test(pageM.vars[pageM.vars.length-1]) )
|
|
pageM.vars.pop();
|
|
|
|
reload();
|
|
}
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
|
/*****************************************/
|
|
/* LIEN VERS LA PAGE "CREER UN SEMESTRE" */
|
|
/*****************************************/
|
|
var lienSemestre = document.getElementById('link_semestre');
|
|
if( lienSemestre != null ){ // si l'élément est sur la page
|
|
|
|
lienSemestre.addEventListener('click', function(e){
|
|
|
|
pageM.vars[0] = 'createsemestre';
|
|
reload();
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************/
|
|
/* GESTION DE L'IMPORT DE MCC */
|
|
/******************************/
|
|
var importMcc = document.getElementById('import_mcc');
|
|
if( importMcc != null ){
|
|
|
|
importMcc.addEventListener('change', function(e){
|
|
|
|
var semestre = importMcc.parentNode.dataset.stre;
|
|
|
|
console.log(semestre);
|
|
|
|
addClass( importMcc.parentNode, 'loading' );
|
|
|
|
var file = importMcc.files[0];
|
|
|
|
/* [1] IMPORTATION DU FICHIER
|
|
=======================================*/
|
|
var fd = new FormData();
|
|
fd.append('filename', 'import_mcc');
|
|
fd.append('file', file, file.name);
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('POST', 'manager/import.php', true);
|
|
|
|
xhr.onreadystatechange = function(){
|
|
if( xhr.readyState == 4 && [0, 200].indexOf(xhr.status) > -1 )
|
|
if( xhr.responseText == 'success' ){
|
|
|
|
|
|
/* [2] LECTURE DU FICHIER
|
|
=======================================*/
|
|
var request = { level_0: 'phpExcel', level_1: 'import_mcc' };
|
|
API.send(request, function(e){
|
|
if( e.request == 'success' ){
|
|
|
|
/* [3] INTÉGRATION À LA BDD
|
|
=======================================*/
|
|
requestIntegration = { level_0: 'career', level_1: 'setMCC', semestre: semestre, mcc: e.mcc };
|
|
API.send( requestIntegration, function(f){
|
|
if( f.request == 'success' ){
|
|
console.log('mcc intégré');
|
|
reload();
|
|
}
|
|
});
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xhr.send(fd);
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************/
|
|
/* GESTION DE LA CRÉATION DE SEMESTRE */
|
|
/**************************************/
|
|
var creerSemestre = document.getElementById('creer_semestre');
|
|
creerSemestre.addEventListener('click', function(e){
|
|
|
|
addClass( creerSemestre, 'loading' );
|
|
|
|
var form = creerSemestre.parentNode;
|
|
var fAnnee = form.children[2].value;
|
|
var fFormation = form.children[4].value;
|
|
var fLibelle = form.children[6].value;
|
|
var fSemestre = form.children[8].value;
|
|
var fRang = form.children[10].value;
|
|
|
|
var request = {
|
|
level_0: 'career',
|
|
level_1: 'creerSemestre',
|
|
annee: fAnnee,
|
|
formation: fFormation,
|
|
nom_formation: fLibelle,
|
|
semestre: fSemestre,
|
|
rang: fRang
|
|
}
|
|
|
|
API.send(request, function(e){
|
|
if( e.request == 'success' )
|
|
reload();
|
|
});
|
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
--> |