Ajout de l'interface exportation groupes@excel

This commit is contained in:
xdrm-brackets 2015-11-19 14:08:40 +01:00
parent 804cfd85db
commit 9b81ac29ec
7 changed files with 227 additions and 71 deletions

View File

@ -8,6 +8,7 @@
.hidden{ display: none !important; }
.center{ text-align: center; }
/* .unstressed */
span.unstressed{ color: #aaa; }
@ -139,7 +140,8 @@ table.basic tr.transparentbg > td{ color: inherit; }
/******************/
/*** PARAGRAPHS ***/
/******************/
#CONTAINER section > p{
#CONTAINER section > p,
#CONTAINER section div.p{
/* position */
padding: 1em;
margin: 1em;
@ -276,6 +278,11 @@ select.active + .confirm,
background-image: url(../src/validate.svg);
}
.confirm.center{
position: relative;
margin: 1em;
}
/* tr@hover */
body.trHoverActivated tr:hover td select.active + .confirm,
@ -320,10 +327,16 @@ tr.grayscale input:focus{
/* border */
border-spacing: 0;
}
#CONTAINER > section > .partlist td{
#CONTAINER > section div.partlist{
/* position */
display: inline;
margin: 2em;
}
#CONTAINER > section > .partlist td,
#CONTAINER > section div.partlist > span{
/* position */
padding: .7em 2em;
@ -348,21 +361,26 @@ tr.grayscale input:focus{
-o-transition: .2s ease-in-out;
}
#CONTAINER > section div.partlist > span{ padding: .7em; }
/* @radius */
#CONTAINER > section > .partlist td:first-child{
#CONTAINER > section > .partlist td:first-child,
#CONTAINER > section div.partlist > span:first-child{
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
/* @border + @radius */
#CONTAINER > section > .partlist td:last-child{
#CONTAINER > section > .partlist td:last-child,
#CONTAINER > section div.partlist > span:last-child{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-right: 1px solid #2dcc70;
}
#CONTAINER > section > .partlist td.active{
#CONTAINER > section > .partlist td.active,
#CONTAINER > section div.partlist > span.active{
background-color: #2dcc70;
color: #fff;
}

View File

@ -132,6 +132,28 @@ class DataBase{
return 'error';
}
/* retourne la liste des semestres de la BDD par annnées
*
* @return annees<Array> retourne la liste des années contenant chacunes leurs semestres
*
*/
public static function getListeSemestres(){
$listeAnnees = semestreRepo::getAnnees();
foreach($listeAnnees as $iter_a=>$annee){
$listeAnnees[$iter_a]['semestres'] = semestreRepo::forYear($annee['annee']);
foreach($listeAnnees[$iter_a]['semestres'] as $iter_s=>$semestre)
$listeAnnees[$iter_a]['semestres'][$iter_s]['nb_etudiants'] = semestreRepo::nbEtuForSemestre($semestre['id']);
}
return $listeAnnees;
}
/**********************************************************/
/* _____ _____ ____ _ _ _____ ______ _____ */
/* / ____| __ \ / __ \| | | | __ \| ____|/ ____| */

View File

@ -212,6 +212,19 @@ require_once __ROOT__.'/manager/database.php';
$answer->request = 'permission_error';
break;
/****************************************************************/
/* retourne la liste des semestres/années présentes dans la BDD */
/****************************************************************/
case 'getSemestres': if( permission('admin') ){
$answer->yearList = DataBase::getInstance()->getListeSemestres();
$answer->request = 'success';
}else
$answer->request = 'permission_error';
break;
/**********************************************/
/* retourne le nom du groupe d'un utilisateur */
/**********************************************/

View File

@ -70,6 +70,19 @@ class semestreRepo extends DBAccess{
/* RENVOIE LA LISTE DES ANNÉES PRÉSENTES DANS LA BDD
*
* @return annees<Array> retourne la liste des années contenues dans la bdd
* @return FALSE<Boolean> retourne FALSE si aucune année n'est trouvée
*
*/
public static function getAnnees(){
$getAnneesList = DataBase::getPDO()->query("SELECT DISTINCT annee FROM semestre ORDER BY annee DESC");
return DataBase::delNumeric( $getAnneesList->fetchAll() );
}
@ -160,6 +173,25 @@ class semestreRepo extends DBAccess{
}
/* RETOURNE LE NOMBRE D'ÉLÈVES D'UN SEMESTRE
*
* @semestre<int> l'UID du semestre en question
*
*
* @return nbEtu<int> retourne le nombre d'étudiants du semestre
*
*/
public static function nbEtuForSemestre($semestre){
$getNbEtu = DataBase::getPDO()->prepare("SELECT count(distinct id_appartenance) as nb_etudiants
FROM appartenance
WHERE id_semestre = :semestre");
$getNbEtu->execute(array( ':semestre' => $semestre ));
if( !($nb = $getNbEtu->fetch()) )
return 0; // si on en trouve pas, on retourne 0
else
return (int) $nb['nb_etudiants']; // sinon on retourne le nombre
}
}

View File

@ -71,13 +71,16 @@ if( document.querySelector('#CONTAINER section[name=movestudents]') != null ){ /
/**********************************************************************/
/*** GESTION DES SELECT/TABLES D'AFFINAGES POUR AFFINER LES GROUPES ***/
/**********************************************************************/
var selectList = document.querySelectorAll("#CONTAINER > section[name] > select[name=groupe]");
var partList = document.querySelectorAll("#CONTAINER > section[name] > table.partlist[name=semestre], #CONTAINER > section[name] > table.partlist[name=formation]");
var selectList = document.querySelectorAll("#CONTAINER > section[name] > select[name=groupe], #CONTAINER > section[name] > .p > select[name=annee]");
var partList = document.querySelectorAll("#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]");
// GESTION DE L'AFFINAGE PAR SEMESTRE //
// GESTION DE L'AFFINAGE PAR FORMATION/SEMESTRE //
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') ){
@ -93,17 +96,21 @@ for( var i = 0 ; i < partList.length ; i++ ){
if( tableauParent.getAttribute('name') == 'semestre' )
pageM.vars[2] = 's:'+e.target.dataset.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;
// affinage par semestre (exportation)
}else if( e.target.parentNode.getAttribute('name') == 'semestre' && e.target.dataset.hasOwnProperty('stre') )
pageM.vars[2] = 's:'+e.target.dataset.stre;
// si on a '*' comme valeur, on l'enlève
if( /\*$/.test(pageM.vars[2]) )
pageM.vars.pop();
// si la formation n'est pas définie, on l'active
if( !/^[fa]:/.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
if( /\*$/.test(pageM.vars[2]) )
pageM.vars.pop();
reload();
reload();
}
}, false);
}
@ -112,13 +119,18 @@ for( var i = 0 ; i < partList.length ; i++ ){
// GESTION DE L'AFFINAGE PAR GROUPE //
for( var i = 0 ; i < selectList.length ; i++ ){
selectList[i].addEventListener('change', function(e){
selectList[i].addEventListener('change', function(e){
if( e.target.tagName == 'SELECT' && e.target.getAttribute('name') == 'groupe' ){
pageM.vars[2] = 'g:'+e.target.value;
if( e.target.tagName == 'SELECT' ){
if( e.target.getAttribute('name') == 'groupe' )
pageM.vars[2] = 'g:'+e.target.value;
if( e.target.getAttribute('name') == 'annee' )
pageM.vars[1] = 'a:'+e.target.value;
// si la formation n'est pas définie, on l'active
if( !/^f:/.test(pageM.vars[1]) )
if( !/^[fa]:/.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;

View File

@ -38,11 +38,11 @@ require_once __ROOT__.'/manager/career.php';
}
$controleOpt = ($controleOpt == null || $controleOpt == '*') ? null : $controleOpt;
$groupeOpt = ($groupeOpt == null || $groupeOpt == '*') ? null : $groupeOpt;
$etudiantOpt = ($etudiantOpt == null || $etudiantOpt == '*') ? null : $etudiantOpt;
$ueOpt = ($ueOpt == null || $ueOpt == '*') ? null : $ueOpt;
$semestreOpt = ($semestreOpt == null || $semestreOpt == '*') ? null : $semestreOpt;
$controleOpt = ($controleOpt == null || $controleOpt == '*') ? null : $controleOpt;
$groupeOpt = ($groupeOpt == null || $groupeOpt == '*') ? null : $groupeOpt;
$etudiantOpt = ($etudiantOpt == null || $etudiantOpt == '*') ? null : $etudiantOpt;
$ueOpt = ($ueOpt == null || $ueOpt == '*') ? null : $ueOpt;
$semestreOpt = ($semestreOpt == null || $semestreOpt == '*') ? null : $semestreOpt;
$formationOpt = ($formationOpt == null || $formationOpt == '*') ? null : $formationOpt;
/****************************************

View File

@ -22,6 +22,7 @@ require_once __ROOT__.'/manager/groups.php';
$semestreOpt = null;
$groupeOpt = null;
$formationOpt = null;
$anneeOpt = null;
// on cherche dans toutes les variables _get si on trouve des paramètres
foreach($_POST as $k=>$v){
@ -35,11 +36,15 @@ require_once __ROOT__.'/manager/groups.php';
if( preg_match('/^f:(.+)$/', $k, $m) ) // f:codeFormation
$formationOpt = $m[1];
if( preg_match('/^a:(.+)$/', $k, $m) ) // a:annee
$anneeOpt = $m[1];
}
$groupeOpt = ($groupeOpt == null || $groupeOpt == '*') ? null : $groupeOpt;
$semestreOpt = ($semestreOpt == null || $semestreOpt == '*') ? null : $semestreOpt;
$formationOpt = ($formationOpt == null || $formationOpt == '*') ? null : $formationOpt;
$anneeOpt = ($anneeOpt == null || $anneeOpt == '*') ? null : $anneeOpt;
/************************/
/*** TOUS LES GROUPES ***/
@ -531,56 +536,110 @@ if( permission('admin') ){ // si l'utilisateur est connecté et que c'est un adm
<?php
function anneeScolaire($year){ return $year.' - '.($year+1); }
/*********************************/
/*** IMPORTATION FICHIER EXCEL ***/
/*********************************/
// if( permission('admin') ){
// echo "<section name='importexcel' data-title='Importation/Export' class='basic'>";
// //inclusion des classes de PHPExcel
// include __ROOT__.DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("src", "phpexcel", "Classes", "PHPExcel.php"));
// include __ROOT__.DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("src", "phpexcel", "Classes", "PHPExcel", "Writer", "Excel2007.php"));
// //On crée une instance du fichier xls, ainsi que de la feuille active
// $workbook = new PHPExcel();
// $sheet = $workbook->getActiveSheet();
// $writer = new PHPExcel_Writer_Excel2007($workbook);
// //on prépare le tableau
// $sheet->setCellValue('A1', 'IAE Etape');
// $sheet->setCellValue('B1', 'Nom');
// $sheet->setCellValue('C1', 'Prénom');
// $sheet->setCellValue('D1', 'Identifiant');
// $sheet->setCellValue('E1', 'Sexe');
// $sheet->setCellValue('F1', 'Mail étudiant');
if( permission('admin') ){
echo "<section name='importexcel' data-title='Importation/Export' class='basic'>";
debug();
// //on récupère l'ensemble des étudiants
// $request = new stdClass();
// $answer = new stdClass();
/* [1] Exportation
==========================================*/
// $request->level_1 = 'grouplistForYear';
// $request->annee = $_SESSION['annee'];
// groups_switch_level_1($request, $answer);
// si annéeOpt n'est pas définie, on le fait
if( $anneeOpt == null ) $anneeOpt = $_SESSION['annee'];
// //Si l'execution s'est proprement effectuée
// $index = 2;
// if($answer->request == 'success') {
// foreach ($answer->grouplist as $group) {
// $groupeName = $group['nom'];
// foreach ($group->userlist as $student) {
// $sheet->setCellValue('A'.$index, $groupeName);
// $sheet->setCellValue('B'.$index, $student['nom']);
// $sheet->setCellValue('C'.$index, $student['prenom']);
// $sheet->setCellValue('D'.$index, $student['identifiant']);
// //$sheet->setCellValue('E'.$index, $student['sexe']);
// $sheet->setCellValue('F'.$index, $student['mail']);
// $index++;
// }
// }
// }
/* ON RÉCUPÈRE LA LISTE DES SEMESTRES EN FONCTION DE L'ANNEE */
$request = new stdClass(); $answer = new stdClass();
$request->level_1 = 'getSemestres';
groups_switch_level_1($request, $answer); // on fait la requête pour les groupes en fonction des filtres si définis
if( $answer->request == 'success' ){ // si pas d'erreur
echo "<div class='p center'>";
$anneesListe = array();
$semestresListe = array();
/**********************/
/* AFFINAGE PAR ANNEE */
/**********************/
echo "Exportation des listes d'étudiants<br>";
echo "<span style='font-size:.8em;'>(Format compatible Microsoft Office, Open Office et Libre Office)</span><br><br>";
/* AFFINAGE POUR LES 5 ANNEES SUIVANTES */
echo "<select name='annee'>";
foreach($answer->yearList as $annee){ if( !in_array($annee['annee'], $anneesListe) ){ // pour éviter les doublons
if( $anneeOpt == $annee['annee'] ) // on préselectionne l'année selectionnée
echo "<option value='".$annee['annee']."' selected>".anneeScolaire($annee['annee'])."</option>";
else
echo "<option value='".$annee['annee']."'>".anneeScolaire($annee['annee'])."</option>";
array_push($anneesListe, $annee['annee']);
}}
echo "</select><br><br>";
/*************************/
/* AFFINAGE PAR SEMESTRE */
/*************************/
foreach($answer->yearList as $annee){ if( $anneeOpt == $annee['annee'] ){ // on récupère la liste des ids
foreach($annee['semestres'] as $semestre){ if( !in_array($semestre['id'], $semestresListe) ){
array_push($semestresListe, $semestre['id']);
}}
}}
// si semestreOpt n'est pas cohérent (pas pour cette année)
if( !in_array($semestreOpt, $semestresListe) ) $semestreOpt = null;
echo "<div class='partlist' name='semestre'>";
if( $semestreOpt == null ) echo "<span data-stre='*' class='active'>Tous</span>";
else echo "<span data-stre='*'>Tous</span>";
/* On récupère la liste des SEMESTRES en accord avec l'ANNEE sélectionnée */
foreach($answer->yearList as $annee){ if( $anneeOpt == $annee['annee'] ){
foreach($annee['semestres'] as $semestre){ if( in_array($semestre['id'], $semestresListe) ){
if( $semestre['id'] == $semestreOpt ) // si c'est le semestre séléctionné
echo "<span data-year='".$annee['annee']."' data-stre='".$semestre['id']."' class='active'>".$semestre['formation']." - ".$semestre['nom'].'</span>';
else // sinon on affiche normalement
echo "<span data-year='".$annee['annee']."' data-stre='".$semestre['id']."'>".$semestre['formation']." - ".$semestre['nom'].'</span>';
}}
}}
echo "</div><br><br>";
// si on a selectionné un semestre
if( $semestreOpt != null )
foreach($answer->yearList as $annee){ if( $anneeOpt == $annee['annee'] ){ foreach($annee['semestres'] as $semestre){ if( $semestreOpt == $semestre['id'] ){
echo "<span class='unstressed'>".$semestre['nb_etudiants']." étudiants</span><br>";
}}}}
else{ // si on a selectionné "Tous"
$nbTotal = 0;
foreach($answer->yearList as $annee){ if( $anneeOpt == $annee['annee'] ){ foreach($annee['semestres'] as $semestre){
$nbTotal += $semestre['nb_etudiants'];
}}}
echo "<span class='unstressed'>".$nbTotal." étudiants</span><br>";
}
echo "<div data-yr='".$anneeOpt."'' data-stre='".$semestre['id']."' class='confirm active center'>Générer le fichier</div>";
echo "<div data-yr='".$anneeOpt."'' data-stre='".$semestre['id']."' class='confirm active center'>Télécharger le fichier</div>";
echo "</div>";
}else
echo "<p>Erreur interne</p>";
echo "<section>";
}
// //On enregistre le fichier
// $writer->save('test.xlsx');
// }
?>