2015-11-18 08:48:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function xlsx_switch_lvl1($request, $answer){
|
|
|
|
|
|
|
|
//inclusion des classes de PHPExcel et des fichiers necessaires
|
|
|
|
require_once __ROOT__.DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("src", "phpexcel", "Classes", "PHPExcel.php"));
|
|
|
|
require_once __ROOT__.DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("src", "phpexcel", "Classes", "PHPExcel", "Writer", "Excel2007.php"));
|
|
|
|
|
|
|
|
|
|
|
|
//TABLE DE ROUTAGE DE LA FONCTION
|
|
|
|
switch ($request->level_1) {
|
|
|
|
|
|
|
|
//EXPORTATION DES LISTE D'ELEVE DE L'ANNEEE EN FORMAT EXCEL
|
|
|
|
case 'export_userlist_group':
|
2015-11-19 09:18:43 +00:00
|
|
|
|
|
|
|
//Si on a bien les listes de groupes
|
|
|
|
if(isset($request->grouplist) && $request->grouplist != null){
|
|
|
|
|
|
|
|
//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 défini les paramètresdu document
|
|
|
|
$workbook->getProperties()->setCreator($_SESSION['identifiant']);
|
|
|
|
$workbook->getProperties()->setLastModifiedBy('ACGA');
|
|
|
|
$workbook->getProperties()->setTitle('Liste étudiants '.$_SESSION['annee']);
|
|
|
|
|
|
|
|
//On définit les
|
|
|
|
$sheet->getColumnDimension('B')->setWidth(20);
|
|
|
|
$sheet->getColumnDimension('C')->setWidth(20);
|
|
|
|
$sheet->getColumnDimension('D')->setWidth(15);
|
|
|
|
$sheet->getColumnDimension('E')->setWidth(8);
|
|
|
|
$sheet->getColumnDimension('F')->setWidth(35);
|
|
|
|
$sheet->getColumnDimension('G')->setWidth(12);
|
|
|
|
$sheet->getColumnDimension('H')->setWidth(12);
|
|
|
|
|
|
|
|
//on prépare le tableau
|
|
|
|
$sheet->setCellValue('B1', "GROUPE DES ETUDIANTS DE L'ANNEE ".$_SESSION['annee']);
|
|
|
|
$sheet->setCellValue('A2', date("d/m/Y G:m"));
|
|
|
|
$sheet->setCellValue('A4', 'Numéro');
|
|
|
|
$sheet->setCellValue('B4', 'Nom');
|
|
|
|
$sheet->setCellValue('C4', 'Prénom');
|
|
|
|
$sheet->setCellValue('D4', 'Identifiant');
|
|
|
|
$sheet->setCellValue('E4', 'Sexe');
|
|
|
|
$sheet->setCellValue('F4', 'Mail étudiant');
|
|
|
|
$sheet->setCellValue('G4', 'Code IAE');
|
|
|
|
$sheet->setCellValue('H4', 'IAE Etape');
|
|
|
|
|
|
|
|
//On remplie le tableau des valeurs récupérée dans la requ^te
|
|
|
|
$index = 5;
|
|
|
|
foreach ($request->grouplist as $group) {
|
2015-11-18 08:48:36 +00:00
|
|
|
$groupeName = $group['nom'];
|
2015-11-19 09:18:43 +00:00
|
|
|
$formation = $group['formation'];
|
|
|
|
foreach ($group['userlist'] as $student) {
|
|
|
|
$sheet->setCellValue('A'.$index, $index-4);
|
2015-11-18 08:48:36 +00:00
|
|
|
$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']);
|
2015-11-19 09:18:43 +00:00
|
|
|
$sheet->setCellValue('G'.$index, $formation);
|
|
|
|
$sheet->setCellValue('H'.$index, $groupeName);
|
|
|
|
$index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//On enregistre ce nouveau fichier, et on lance son téléchargement
|
|
|
|
$docPath = DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("page", "excelTemplates",
|
|
|
|
"Liste Etudiant ".$_SESSION['annee'].".xlsx"));
|
|
|
|
if(file_exists (__ROOT__.$docPath)){
|
|
|
|
$index = 1;
|
|
|
|
$titleLen = strlen($docPath) - 5;
|
|
|
|
while(file_exists (__ROOT__.$docPath)){
|
|
|
|
$docPath = mb_strimwidth($docPath, 0, $titleLen, "")." (".$index.").xlsx";
|
2015-11-18 08:48:36 +00:00
|
|
|
$index++;
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 09:18:43 +00:00
|
|
|
$writer->save(__ROOT__.$docPath);
|
|
|
|
$answer->docPath = $docPath;
|
2015-11-18 08:48:36 +00:00
|
|
|
}
|
|
|
|
|
2015-11-19 09:18:43 +00:00
|
|
|
//Si on a pas le tableau
|
|
|
|
else {
|
|
|
|
$answer->request = 'param_error';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IMPORTATION DES LISTE D'ELEVE DE L'ANNEEE EN FORMAT EXCEL
|
|
|
|
case 'import_userlist_group':
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// EXPORTATION DE NOTES POUR UN CONTROLE DONNEE, UNE FORMATION DONNEE ET UN GROUPE DONNE
|
|
|
|
case 'export_notes':
|
|
|
|
|
|
|
|
//vérificationd es paramètres en entrée
|
|
|
|
if(isset($request->formation) && isset($request->groupe) && isset($request->controle)){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Si il y a un problème dans les paramètres
|
|
|
|
else {
|
|
|
|
$answer->request='param_error';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IMPORTATION DE NOTES POUR UN CONTROLE DONNEE, UNE FORMATION DONNEE ET UN GROUPE DONNE
|
|
|
|
case 'import_notes':
|
|
|
|
//code
|
|
|
|
break;
|
2015-11-18 08:48:36 +00:00
|
|
|
|
|
|
|
|
2015-11-19 09:18:43 +00:00
|
|
|
|
|
|
|
// DEFAULT
|
|
|
|
default:
|
|
|
|
$answer->request = 'unknown_level_1';
|
|
|
|
break;
|
|
|
|
}
|
2015-11-18 08:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|