This commit is contained in:
parent
5695586a90
commit
a45904c751
|
@ -0,0 +1,69 @@
|
|||
<?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':
|
||||
|
||||
//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');
|
||||
|
||||
|
||||
//on récupère l'ensemble des étudiants
|
||||
$req = new stdClass();
|
||||
$ans = new stdClass();
|
||||
|
||||
$req->level_1 = 'grouplistForYear';
|
||||
$req->annee = $_SESSION['annee'];
|
||||
groups_switch_level_1($req, $ans);
|
||||
|
||||
//Si l'execution s'est proprement effectuée
|
||||
$index = 2;
|
||||
if($ans->req == 'success') {
|
||||
foreach ($ans->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 lance le téléchargement du fichier
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename="file.xls"');
|
||||
$writer->save('php://output');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -544,53 +544,18 @@ if( permission('admin') ){ // si l'utilisateur est connecté et que c'est un adm
|
|||
/*********************************/
|
||||
/*** IMPORTATION FICHIER EXCEL ***/
|
||||
/*********************************/
|
||||
// if( permission('admin') ){
|
||||
// echo "<section name='importexcel' title='Importation/Export' class='basic'>";
|
||||
if( permission('admin') ){
|
||||
|
||||
// //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);
|
||||
require_once __ROOT__.DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, array("manager", "xlsx.php"));
|
||||
|
||||
// //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');
|
||||
echo "<section name='importexcel' title='Importation/Export' class='basic'>";
|
||||
|
||||
$answer = new stdClass();
|
||||
$request = new stdClass();
|
||||
|
||||
// //on récupère l'ensemble des étudiants
|
||||
// $request = new stdClass();
|
||||
// $answer = new stdClass();
|
||||
$request->level_1 = 'export_userlist_group';
|
||||
|
||||
// $request->level_1 = 'grouplistForYear';
|
||||
// $request->annee = $_SESSION['annee'];
|
||||
// groups_switch_level_1($request, $answer);
|
||||
xlsx_switch_lvl1($request, $answer);
|
||||
|
||||
// //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 enregistre le fichier
|
||||
// $writer->save('test.xlsx');
|
||||
// }
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue