From a45904c75177bda52207f20963fe2a2b6beefb62 Mon Sep 17 00:00:00 2001 From: Cedric Date: Wed, 18 Nov 2015 09:48:36 +0100 Subject: [PATCH] ok --- manager/xlsx.php | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ page/groups.php | 51 ++++++----------------------------- 2 files changed, 77 insertions(+), 43 deletions(-) diff --git a/manager/xlsx.php b/manager/xlsx.php index e69de29..5cff401 100644 --- a/manager/xlsx.php +++ b/manager/xlsx.php @@ -0,0 +1,69 @@ +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; + } + +} + +?> \ No newline at end of file diff --git a/page/groups.php b/page/groups.php index a5c5fc0..a074277 100755 --- a/page/groups.php +++ b/page/groups.php @@ -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 "
"; +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 "
"; + $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'); -// } +} ?> \ No newline at end of file