diff --git a/manager/excel.php b/manager/excel.php index 9f36979..22519b2 100755 --- a/manager/excel.php +++ b/manager/excel.php @@ -451,14 +451,19 @@ class excelManager{ // [5] Écriture des valeurs dans le document Excel $index = 5; - foreach($request->grouplist as $group){ + foreach($request->grouplist as $GROUP){ $index++; - foreach($group->userlist as $student){ - $sheet->setCellValue('A'.$index, $student->identifiant); - $sheet->setCellValue('B'.$index, $group->formation); - $sheet->setCellValue('C'.$index, $group->nom); - $sheet->setCellValue('D'.$index, '[À compléter]'); + foreach($GROUP->userlist as $USER){ + $sheet->setCellValue('A'.$index, $USER->identifiant); + $sheet->setCellValue('B'.$index, $GROUP->formation); + $sheet->setCellValue('C'.$index, $GROUP->nom); + if( $USER->mention != null ) // si mention déjà spécifiée, on l'affiche + $sheet->setCellValue('D'.$index, $USER->mention); + else // sinon, on met "[À compléter]" + $sheet->setCellValue('D'.$index, '[À compléter]'); + + $index++; } } @@ -486,45 +491,48 @@ class excelManager{ /************************************/ case 'import_jury': - if(isset($request->docPath)) { + + $filePath = __EXCEL_PATH__.$_SESSION['identifiant'].'_import_jury.xlsx'; - // Récupération du nom du fichier + // si on a pas le droit d'écriture, on quitte // + if( !is_readable($filePath) ){ $answer->request = 'read_permission'; return; } + + // Charger le fichier en tant que document Excel + $objPHPExcel = PHPExcel_IOFactory::load($filePath); + + // Get sur la première case + $sheet = $objPHPExcel->getSheet(0); + $juryData = $sheet->rangeToArray('A6:'.'D'.$sheet->getHighestRow()); + - $inputFileName = $request->docPath; - - // Chargement du fichier + $jury = array(); // contiendra le tableau de retour + $mentionsPossibles = array('ADM', 'ADJ', 'RDB', 'RFS'); - $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); - - // Placement du curseur sur la première case + /****************************/ + /* TRAITEMENT SUR LES CASES */ + /****************************/ + foreach($juryData as $line){ - $sheet = $objPHPExcel->getSheet(0); - $mccData = $sheet->rangeToArray('A2:'.$sheet->getHighestColumn().''.$sheet->getHighestRow()); + /* [1] On récupère pour chaque étudiant si le format est bon + =========================================================================*/ + if( checkParam($line[0], 'utilisateur.identifiant') && in_array($line[3], $mentionsPossibles) ){ // bon format pour l'identifiant et la mention - // Varaible stack pour les résultats du jury + array_push( // on ajoute l'étudiant et sa mention + $jury, + array( + 'etudiant' => $line[0], + 'mention' => $line[3] + ) + ); - $resultatJury = array(); + } - // Boucle sur le format suivant : ligne[0] : [IDETUDIANT] / ligne[1] : [DECISION JURY] + } - $i = 0; + $answer->jury = $jury; + $answer->request = 'success'; - foreach($mccData as $line) { - - $resultatJury[$i++] = array($line[0],$line[1]); - } - - $answer->resultatJury = $resultatJury; - $asnwer->request = 'success'; - } - - // Erreur de paramètre(s) - - else { - - $answer->request='param_error'; - } - break; + break; @@ -537,7 +545,7 @@ class excelManager{ default: $answer->request = 'unknown_level_1'; break; - } + } }