Etape 1 : admin@création_semestre

This commit is contained in:
xdrm-brackets 2015-11-22 12:02:26 +01:00
parent 4744cb8df1
commit 9a013ef071
2 changed files with 91 additions and 49 deletions

View File

@ -83,15 +83,20 @@ for( var i = 0 ; i < selectList.length ; i++ ){
}
/*****************************************/
/* LIEN VERS LA PAGE "CREER UN SEMESTRE" */
var creerSemestre = document.getElementById('creer_semestre');
creerSemestre.addEventListener('click', function(e){
/*****************************************/
var lienSemestre = document.getElementById('link_semestre');
if( lienSemestre != null ){ // si l'élément est sur la page
pageM.vars[0] = 'createsemestre';
reload();
lienSemestre.addEventListener('click', function(e){
}, false);
pageM.vars[0] = 'createsemestre';
reload();
}, false);
}
@ -99,79 +104,116 @@ creerSemestre.addEventListener('click', function(e){
/******************************/
/* GESTION DE L'IMPORT DE MCC */
/******************************/
var importMcc = document.getElementById('import_mcc');
importMcc.addEventListener('change', function(e){
if( importMcc != null ){
var semestre = importMcc.parentNode.dataset.stre;
importMcc.addEventListener('change', function(e){
console.log(semestre);
var semestre = importMcc.parentNode.dataset.stre;
addClass( importMcc.parentNode, 'loading' );
console.log(semestre);
var file = importMcc.files[0];
addClass( importMcc.parentNode, 'loading' );
/* [1] IMPORTATION DU FICHIER
=======================================*/
var fd = new FormData();
fd.append('filename', 'import_mcc');
fd.append('file', file, file.name);
var file = importMcc.files[0];
var xhr = new XMLHttpRequest();
/* [1] IMPORTATION DU FICHIER
=======================================*/
var fd = new FormData();
fd.append('filename', 'import_mcc');
fd.append('file', file, file.name);
xhr.open('POST', 'manager/import.php', true);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if( xhr.readyState == 4 )
if( [0, 200].indexOf(xhr.status) > -1 )
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'
}
var request = { level_0: 'phpExcel', level_1: 'import_mcc' };
API.send(request, function(e){
if( e.request == 'success' ){ // si on a récupéré l'objet MCC, on lance maintenant l'intégration
if( e.request == 'success' ){
/* [3] INTÉGRATION À LA BDD
=======================================*/
requestIntegration = {
level_0 : 'career',
level_1 : 'setMCC',
semestre: semestre,
mcc : e.mcc
}
requestIntegration = { level_0: 'career', level_1: 'setMCC', semestre: semestre, mcc: e.mcc };
API.send( requestIntegration, function(f){
console.log( f );
if( f.request == 'success' ){
console.log('mcc intégré');
reload();
}else
console.log('Mcc non intégré');
}
});
}else
reload();
}
});
}
}
xhr.send(fd);
}, false);
}
/**************************************/
/* GESTION DE LA CRÉATION DE SEMESTRE */
/**************************************/
var creerSemestre = document.getElementById('creer_semestre');
creerSemestre.addEventListener('click', function(e){
var form = creerSemestre.parentNode;
var fAnnee = form.children[2].value;
var fCursus = 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: fCursus,
nom_formation: fLibelle,
semestre: fSemestre,
rang: fRang
}
xhr.send(fd);
API.send(request, function(e){
console.log( e );
});
}, false);
-->

View File

@ -663,7 +663,7 @@ if( permission('admin') ){
}}
if( $count == 0 )
echo "<span class='link' id='creer_semestre'>Créer un semestre</span><br><br>";
echo "<span class='link' id='link_semestre'>Créer un semestre</span><br><br>";