diff --git a/manager/phpExcel.php b/manager/phpExcel.php new file mode 100644 index 0000000..92e3290 --- /dev/null +++ b/manager/phpExcel.php @@ -0,0 +1,164 @@ +level_1) { + + //EXPORTATION DES LISTE D'ELEVE DE L'ANNEEE EN FORMAT EXCEL + case 'export_userlist_group': + + //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ées dans la requête + $index = 5; + foreach ($request->grouplist as $group) { + $groupeName = $group['nom']; + $formation = $group['formation']; + foreach ($group['userlist'] as $student) { + $sheet->setCellValue('A'.$index, $index-4); + $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']); + $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"; + $index++; + } + } + $writer->save(__ROOT__.$docPath); + $answer->docPath = $docPath; + } + + //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; + + + case 'import_mcc': + + if(isset($request->docPath)) { + + $inputFileType = 'Excel2007'; + $inputFileName = $request->docPath; + + // Charger le fichier en tant que document Excel + $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); + + // Get sur la première case + $sheet = $objPHPExcel->getSheet(0); + + // Lecture rang MAX (A,B,C..) + $highestRow = $sheet->getHighestRow(); + + // Lecture de la colonne MAX (1) + $highestColumn = $sheet->getHighestColumn(); + + // Boucle sur chaque rang + for ($row = 1; $row <= $highestRow; $row++) { + + for( $col = 'A' ; $col <= $highestColumn ; $col++ ) + echo $col.''.$row.' = '.$sheet->rangeToArray($col.''.$row.':'.$col.''.$row)[0][0].'
'; + } + + } else { + + $answer->request = 'param_error'; + } + + break; + + + // DEFAULT + default: + $answer->request = 'unknown_level_1'; + break; + } +} + +?> \ No newline at end of file