Loading module/Application/src/Application/Controller/StatistiqueController.php +96 −2 Changes for module/Application/src/Application/Controller/StatistiqueController.php: 96 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -2,20 +2,114 @@ namespace Application\Controller; use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareInterface; use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; use Application\Service\Etablissement\EtablissementServiceAwareInterface; use Application\Service\Etablissement\EtablissementServiceAwareTrait; use Application\Service\These\TheseServiceAwareInterface; use Application\Service\These\TheseServiceAwareTrait; use Application\Service\UniteRecherche\UniteRechercheServiceAwareInterface; use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use Doctrine\ORM\QueryBuilder; use DateTime; use Zend\Validator\Date; use Zend\View\Model\ViewModel; class StatistiqueController extends AbstractController implements TheseServiceAwareInterface implements TheseServiceAwareInterface, EcoleDoctoraleServiceAwareInterface, UniteRechercheServiceAwareInterface, EtablissementServiceAwareInterface { use TheseServiceAwareTrait; use EcoleDoctoraleServiceAwareTrait; use UniteRechercheServiceAwareTrait; use EtablissementServiceAwareTrait; public function indexAction() { $theses = $this->theseService->getRepository()->findAll(); $qb = $this->theseService->getRepository()->createQueryBuilder("t"); //filtrer les thèses en fonction d'une structure // --> dans la table thèse on peut utiliser les champs ETABLISSEMENT_ID, ECOLE_DOCT_ID, et UNITE_RECH_ID //filtrer les thèses en fonction d'une période // --> utiliser les dates d'inscriptions ou de soutenances ? $structureType = $this->params()->fromQuery("structure_type"); $structureId = $this->params()->fromQuery("structure_id"); $qb = $this->decorateWithStructure($qb, $structureType, $structureId); $dateType = $this->params()->fromQuery("date"); $dateDebut = $this->params()->fromQuery("debut"); $dateFin = $this->params()->fromQuery("fin"); $qb = $this->decorateWithDate($qb, $dateType, $dateDebut, $dateFin); $theses = $qb->getQuery()->execute(); $ecoles = $this->ecoleDoctoraleService->getEcolesDoctorales(); $unites = $this->uniteRechercheService->getUnitesRecherches(); $etablissements = $this->etablissementService->getEtablissements(); return new ViewModel([ 'theses' => $theses, 'ecoles' => $ecoles, 'unites' => $unites, 'etablissements' => $etablissements, ]); } private function decorateWithStructure(QueryBuilder $qb, $type = null, $id = null) { if ($type !== null && $id !== null) { switch($type) { case "ED" : $ecole = $this->ecoleDoctoraleService->getEcoleDoctoraleById($id); var_dump($ecole->getLibelle()); return $qb->andWhere("t.ecoleDoctorale = :ed") ->setParameter(":ed", $ecole); case "UR" : $unite = $this->uniteRechercheService->getUniteRechercheById($id); var_dump($unite->getLibelle()); return $qb->andWhere("t.uniteRecherche = :ur") ->setParameter(":ur", $unite); case "Etab" : $etablissement = $this->etablissementService->getEtablissementById($id); var_dump($etablissement->getLibelle()); return $qb->andWhere("t.etablissement = :etab") ->setParameter("etab", $etablissement); } } return $qb; } private function decorateWithDate(QueryBuilder $qb, $type = null, $debut = null, $fin = null) { if ($debut !== null) $debut .= "-01-01"; if ($fin !== null) $fin .= "-12-31"; if ($type !== null) { switch($type) { case "soutenance" : if ($debut !== null) { $qb->andWhere("t.dateSoutenance >= :debut") ->setParameter("debut", new DateTime($debut)); } if ($fin !== null) { $qb->andWhere("t.dateSoutenance <= :fin") ->setParameter("fin", new DateTime($fin)); } return $qb; case "inscription" : if ($debut !== null) { $qb->andWhere("t.datePremiereInscription >= :debut") ->setParameter("debut", new DateTime($debut)); } if ($fin !== null) { $qb->andWhere("t.datePremiereInscription <= :fin") ->setParameter("fin", new DateTime($fin)); } return $qb; } } return $qb; } } No newline at end of file module/Application/view/application/statistique/index.phtml +177 −136 Changes for module/Application/view/application/statistique/index.phtml: 177 added lines, 136 removed lines. Original line number Diff line number Diff line Loading @@ -3,10 +3,18 @@ use Application\View\Renderer\PhpRenderer; use Application\Entity\Db\These; use Application\Entity\Db\EcoleDoctorale; use Application\Entity\Db\UniteRecherche; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Structure; /** * @var PhpRenderer $this * @var These[] $theses * @var EcoleDoctorale[] $ecoles * @var UniteRecherche[] $unites * @var Etablissement[] $etablissements */ const DEBUG = true; Loading @@ -19,19 +27,82 @@ function display_debug($texte) { } ?> <?php $this->headTitle($this->translate("Statistiques")) ?> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <?php $this->headTitle($this->translate("Statistiques")) ?> <!--<script src="public/js/charts.js/chart/Chart.Bar.js"></script>--> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <h1 class="page-header first"><?php echo $this->translate("Statistiques") ?> <span class="badge"><?php echo count($theses) ?></span></h1> <form id="selection" method="post" action=""> <input type="radio" id="structure_type" name="structure_type" value="Aucun"> Aucun <input type="radio" id="structure_type" name="structure_type" value="Etab"> Etablissement <input type="radio" id="structure_type" name="structure_type" value="ED"> Ecole doctorale <input type="radio" id="structure_type" name="structure_type" value="UR"> Unité de recherche <div id='structure_selector'> <select id='structure_id'></select>; </div> <input id='filtrage' type='button' value='filter'/> </form> <div id="linku"> ... </div> <script> $(document).ready(function(){ $('#structure_id').on('change', function() { alert( this.value ); }) $('input[type=radio][name=structure_type]').change(function() { //alert(this.value); if (this.value == "Aucun") { // alert("Aucun"); document.getElementById('structure_selector').innerHTML = ""; } else { // alert("Pas Aucun : " + this.value); } if (this.value == "ED") { // var form = "ED"; var form = " <?php echo generateStructureSelector($ecoles); ?> "; document.getElementById('structure_selector').innerHTML = form; } if (this.value == "UR") { // alert("UR"); var form = " <?php echo generateStructureSelector($unites); ?> "; document.getElementById('structure_selector').innerHTML = form; } if (this.value == "Etab") { // alert("Etab"); var form = " <?php echo generateStructureSelector($etablissements); ?> "; document.getElementById('structure_selector').innerHTML = form; } }); $('#filtrage').click(function() { var selected_structure_type = document.querySelector('input[name="structure_type"]:checked').value; var selected_structure_id = document.getElementById("structure_id").value; alert("clicked! " + selected_structure_type + " " + selected_structure_id); document.getElementById("linku").innerHTML = " <a href='/statistique?structure_type=" + selected_structure_type + "& structure_id=" + selected_structure_id + "'>clique donc</a>"; }); }); //document.getElementById('structure_selector').innerHTML = <?php //generateEDSelector($ecoles); ?>// ; </script> <?php function generateStructureSelector($structures) { $texte = ""; $texte .= "<select id='structure_id'>"; $texte .= "<option value=''> Aucune </option>"; /** @var Structure $structure */ foreach ($structures as $structure) { $texte .= "<option value='".$structure->getId()."'>". $structure->getLibelle() ."</option>"; } $texte .= "</select>"; return $texte; } ?> <?php $validInscriptionTheses = []; $validSoutenanceTheses = []; foreach($theses as $these) { Loading @@ -39,37 +110,9 @@ foreach($theses as $these) { if ($these->getDateSoutenance() !== null) $validSoutenanceTheses[] = $these; } ?> <!--Nombre de thèses valides :--> <!--<ul>--> <!-- <li> Inscription : --><?php //echo count($validInscriptionTheses); ?><!-- </li>--> <!-- <li> Soutenance : --><?php //echo count($validSoutenanceTheses); ?><!-- </li>--> <!--</ul>--> <?php usort($validInscriptionTheses, function (These $a, These $b) {return $a->getDatePremiereInscription() > $b->getDatePremiereInscription();}); usort($validSoutenanceTheses, function (These $a, These $b) {return $a->getDateSoutenance() > $b->getDateSoutenance();}); ?> <!--Etalement dans le temps :--> <!--<ul>--> <!-- <li> Inscription :--> <!-- --><?php //echo $validInscriptionTheses[0]->getDatePremiereInscription()->format("d/m/Y"); ?> <!-- →--> <!-- --><?php //echo end($validInscriptionTheses)->getDatePremiereInscription()->format("d/m/Y"); ?> <!-- </li>--> <!-- <li> Soutenance :--> <!-- --><?php //echo $validSoutenanceTheses[0]->getDateSoutenance()->format("d/m/Y"); ?> <!-- →--> <!-- --><?php //echo end($validSoutenanceTheses)->getDateSoutenance()->format("d/m/Y"); ?> <!-- </li>--> <!--</ul>--> <?php $end = (new DateTime())->format("Y"); $start = $end - 20; Loading @@ -95,15 +138,68 @@ foreach ($theses as $these) { if ($these->getDateSoutenance()) array_push($effectifsSoutenance[$these->getDateSoutenance()->format("Y")], $these); } ?> <?php $google_data = []; $data_insc_sout = []; for($current = $start ; $current <= $end ; $current++) { $google_data[] = [$current , count($effectifsInscription[$current]), count($effectifsSoutenance[$current])]; $inscriptions = (empty($effectifsInscription[$current])) ? 0 : count($effectifsInscription[$current]); $soutenances = (empty($effectifsSoutenance[$current])) ? 0 : count($effectifsSoutenance[$current]); $data_insc_sout[] = [$current , $inscriptions, $soutenances]; } $dureeTheses = []; for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { $dureeTheses[$annee] = array(); } for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { foreach($effectifsSoutenance[$annee] as $these) { if ($these->getDatePremiereInscription()) { $duree = $these->getDateSoutenance()->diff($these->getDatePremiereInscription()); $dureeTheses[$annee][] = $duree->m + $duree->y*12; } } sort($dureeTheses[$annee]); } $google_data = []; for ($annee = $start; $annee <= $end ; $annee++) { if (! empty($dureeTheses[$annee])) { $nb = count($dureeTheses[$annee]); $position_q0 = $nb*0.00; $position_q1 = $nb*0.25; $position_q2 = $nb*0.50; $position_q3 = $nb*0.75; $position_q4 = $nb*1.00-1; $row = [ $annee]; foreach ($dureeTheses[$annee] as $data) { $row[] = $dureeTheses[$annee][$position_q0]; $row[] = $dureeTheses[$annee][$position_q1]; $row[] = $dureeTheses[$annee][$position_q3]; $row[] = $dureeTheses[$annee][$position_q4]; } $google_data[] = $row; } } $homme = 0; $femme = 0; $discipline = []; $discipline["Autres"] = 0; $threshold = 5; foreach($effectifsInscription[$end-2] as $these) { if ($these->getDoctorant()->getIndividu()->estUneFemme()) { $femme++; } else { $homme++; } $discipline[$these->getLibelleDiscipline()]++; } $effectifParPays = generateEffectifParPays($effectifsInscription, $start, $end); ?> <script> var do_drawing = true; </script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -112,7 +208,7 @@ foreach ($theses as $these) { var data = google.visualization.arrayToDataTable([ ['Année', '#Inscriptions', '#Soutenances'], <?php foreach($google_data as $row) { foreach($data_insc_sout as $row) { echo "[\"" . $row[0] . "\"," . $row[1] . "," . $row[2] . "],"; } ?> Loading @@ -128,10 +224,11 @@ foreach ($theses as $these) { } }; if (do_drawing) { var chart = new google.visualization.LineChart(document.getElementById('Inscriptions/Soutenances')); chart.draw(data, options); } } </script> <div class="box panel panel-info"> <div class="panel-heading"> Loading @@ -142,43 +239,6 @@ foreach ($theses as $these) { <div id="Inscriptions/Soutenances" style="width: 925px; height: 500px"></div> </div> <?php $dureeTheses = []; for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { $dureeTheses[$annee] = array(); } for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { foreach($effectifsSoutenance[$annee] as $these) { if ($these->getDatePremiereInscription()) { $duree = $these->getDateSoutenance()->diff($these->getDatePremiereInscription()); $dureeTheses[$annee][] = $duree->m + $duree->y*12; } } sort($dureeTheses[$annee]); } $google_data = []; for ($annee = $start; $annee <= $end ; $annee++) { if (! empty($dureeTheses[$annee])) { $nb = count($dureeTheses[$annee]); $position_q0 = $nb*0.00; $position_q1 = $nb*0.25; $position_q2 = $nb*0.50; $position_q3 = $nb*0.75; $position_q4 = $nb*1.00-1; $row = [ $annee]; foreach ($dureeTheses[$annee] as $data) { $row[] = $dureeTheses[$annee][$position_q0]; $row[] = $dureeTheses[$annee][$position_q1]; //$row[] = $dureeTheses[$annee][$position_q2]; //que faire de la mediane ??? $row[] = $dureeTheses[$annee][$position_q3]; $row[] = $dureeTheses[$annee][$position_q4]; } $google_data[] = $row; } } ?> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -205,12 +265,12 @@ for ($annee = $start; $annee <= $end ; $annee++) { } }; if (do_drawing) { var chart = new google.visualization.CandlestickChart(document.getElementById('duree')); chart.draw(data, options); } } </script> <div class="box panel panel-info"> <div class="panel-heading"> <h2 class="first"> Loading @@ -220,22 +280,6 @@ for ($annee = $start; $annee <= $end ; $annee++) { <div id="duree" style="width: 925px; height: 500px;"></div> </div> <?php $homme = 0; $femme = 0; $discipline = []; $discipline["Autres"] = 0; $threshold = 5; foreach($effectifsInscription[$end-2] as $these) { if ($these->getDoctorant()->getIndividu()->estUneFemme()) { $femme++; } else { $homme++; } $discipline[$these->getLibelleDiscipline()]++; } ?> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -255,12 +299,12 @@ foreach($effectifsInscription[$end-2] as $these) { }; if (do_drawing) { var chart = new google.visualization.PieChart(document.getElementById('Repartition/Sexe')); chart.draw(data, options); } } </script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -284,13 +328,12 @@ foreach($effectifsInscription[$end-2] as $these) { legend: 'none', }; if (do_drawing) { var chart = new google.visualization.PieChart(document.getElementById('Repartition/Discipline')); chart.draw(data, options); } } </script> <div class="box panel panel-info" style="height: 550px;"> <div class="panel-heading"> <h2 class="first"> Loading @@ -302,10 +345,41 @@ foreach($effectifsInscription[$end-2] as $these) { </div> <script type="text/javascript"> google.charts.load('current', { 'packages':['geochart'], 'mapsApiKey': 'AIzaSyAZPWFm-VDkkiToc-s7Z982XQ6b6bDp428' }); google.charts.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() { var data = google.visualization.arrayToDataTable([ ['Country', 'Popularity'], <?php foreach($effectifParPays as $country => $number) { echo "[ '{$country}' , $number ],"; }?> ]); var options = { colorAxis: { maxValue: 100 } }; if (do_drawing) { var chart = new google.visualization.GeoChart(document.getElementById('regions_div')); chart.draw(data, options); } } </script> <div class="box panel panel-info" style="height: 550px;"> <div class="panel-heading"> <h2 class="first"> Provenance des doctorants inscrits entre <?php echo ($start) ?> et <? echo $end?> </h2> </div> <div id="regions_div" style="width: 900px; height: 500px;"></div> </div> <?php function generateEffectifParPays($effectifsInscription, $start , $end) { $code = []; $code["ALGERIEN(NE)"] = "Algeria"; $code["ALLEMAND(E)"] = "Germany"; Loading Loading @@ -382,7 +456,7 @@ $code["POLONAIS(E)"] = "Poland"; $code["PORTUGAIS(E)"] = "Portugal"; $code["ROUMAIN(E)"] = "Romania"; $code["RUANDAIS(E)"] = "Rwanda"; $code["RUSSE"] = "Ruusia"; $code["RUSSE"] = "Russia"; $code["SAOUDIEN(NE)"] = "Saudi Arabia"; $code["SENEGALAIS(E)"] = "Senegal"; $code["SERBE"] = "Serbia"; Loading @@ -406,6 +480,7 @@ $code["ZAIROIS(E)"] = "Zaire"; $effectifParPays = []; $nope = 0; for ($annee = $start ; $annee <= $end ; $annee++ ) { if (!empty($effectifsInscription[$annee])) { foreach ($effectifsInscription[$annee] as $these) { $nationalite = $these->getDoctorant()->getIndividu()->getNationalite(); if (isset($code[$nationalite])) { Loading @@ -416,42 +491,8 @@ $code["ZAIROIS(E)"] = "Zaire"; } } } } if ($nope > 0) echo $nope; ?> <script type="text/javascript"> google.charts.load('current', { 'packages':['geochart'], // Note: you will need to get a mapsApiKey for your project. // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings 'mapsApiKey': 'AIzaSyAZPWFm-VDkkiToc-s7Z982XQ6b6bDp428' }); google.charts.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() { var data = google.visualization.arrayToDataTable([ ['Country', 'Popularity'], <?php foreach($effectifParPays as $country => $number) { echo "[ '{$country}' , $number ],"; }?> ]); var options = { colorAxis: { maxValue: 100 } }; var chart = new google.visualization.GeoChart(document.getElementById('regions_div')); chart.draw(data, options); return $effectifParPays; } </script> <div class="box panel panel-info" style="height: 550px;"> <div class="panel-heading"> <h2 class="first"> Provenance des doctorants inscrits entre <?php echo ($start) ?> et <? echo $end?> </h2> </div> <div id="regions_div" style="width: 900px; height: 500px;"></div> </div> ?> No newline at end of file Loading
module/Application/src/Application/Controller/StatistiqueController.php +96 −2 Changes for module/Application/src/Application/Controller/StatistiqueController.php: 96 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -2,20 +2,114 @@ namespace Application\Controller; use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareInterface; use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; use Application\Service\Etablissement\EtablissementServiceAwareInterface; use Application\Service\Etablissement\EtablissementServiceAwareTrait; use Application\Service\These\TheseServiceAwareInterface; use Application\Service\These\TheseServiceAwareTrait; use Application\Service\UniteRecherche\UniteRechercheServiceAwareInterface; use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use Doctrine\ORM\QueryBuilder; use DateTime; use Zend\Validator\Date; use Zend\View\Model\ViewModel; class StatistiqueController extends AbstractController implements TheseServiceAwareInterface implements TheseServiceAwareInterface, EcoleDoctoraleServiceAwareInterface, UniteRechercheServiceAwareInterface, EtablissementServiceAwareInterface { use TheseServiceAwareTrait; use EcoleDoctoraleServiceAwareTrait; use UniteRechercheServiceAwareTrait; use EtablissementServiceAwareTrait; public function indexAction() { $theses = $this->theseService->getRepository()->findAll(); $qb = $this->theseService->getRepository()->createQueryBuilder("t"); //filtrer les thèses en fonction d'une structure // --> dans la table thèse on peut utiliser les champs ETABLISSEMENT_ID, ECOLE_DOCT_ID, et UNITE_RECH_ID //filtrer les thèses en fonction d'une période // --> utiliser les dates d'inscriptions ou de soutenances ? $structureType = $this->params()->fromQuery("structure_type"); $structureId = $this->params()->fromQuery("structure_id"); $qb = $this->decorateWithStructure($qb, $structureType, $structureId); $dateType = $this->params()->fromQuery("date"); $dateDebut = $this->params()->fromQuery("debut"); $dateFin = $this->params()->fromQuery("fin"); $qb = $this->decorateWithDate($qb, $dateType, $dateDebut, $dateFin); $theses = $qb->getQuery()->execute(); $ecoles = $this->ecoleDoctoraleService->getEcolesDoctorales(); $unites = $this->uniteRechercheService->getUnitesRecherches(); $etablissements = $this->etablissementService->getEtablissements(); return new ViewModel([ 'theses' => $theses, 'ecoles' => $ecoles, 'unites' => $unites, 'etablissements' => $etablissements, ]); } private function decorateWithStructure(QueryBuilder $qb, $type = null, $id = null) { if ($type !== null && $id !== null) { switch($type) { case "ED" : $ecole = $this->ecoleDoctoraleService->getEcoleDoctoraleById($id); var_dump($ecole->getLibelle()); return $qb->andWhere("t.ecoleDoctorale = :ed") ->setParameter(":ed", $ecole); case "UR" : $unite = $this->uniteRechercheService->getUniteRechercheById($id); var_dump($unite->getLibelle()); return $qb->andWhere("t.uniteRecherche = :ur") ->setParameter(":ur", $unite); case "Etab" : $etablissement = $this->etablissementService->getEtablissementById($id); var_dump($etablissement->getLibelle()); return $qb->andWhere("t.etablissement = :etab") ->setParameter("etab", $etablissement); } } return $qb; } private function decorateWithDate(QueryBuilder $qb, $type = null, $debut = null, $fin = null) { if ($debut !== null) $debut .= "-01-01"; if ($fin !== null) $fin .= "-12-31"; if ($type !== null) { switch($type) { case "soutenance" : if ($debut !== null) { $qb->andWhere("t.dateSoutenance >= :debut") ->setParameter("debut", new DateTime($debut)); } if ($fin !== null) { $qb->andWhere("t.dateSoutenance <= :fin") ->setParameter("fin", new DateTime($fin)); } return $qb; case "inscription" : if ($debut !== null) { $qb->andWhere("t.datePremiereInscription >= :debut") ->setParameter("debut", new DateTime($debut)); } if ($fin !== null) { $qb->andWhere("t.datePremiereInscription <= :fin") ->setParameter("fin", new DateTime($fin)); } return $qb; } } return $qb; } } No newline at end of file
module/Application/view/application/statistique/index.phtml +177 −136 Changes for module/Application/view/application/statistique/index.phtml: 177 added lines, 136 removed lines. Original line number Diff line number Diff line Loading @@ -3,10 +3,18 @@ use Application\View\Renderer\PhpRenderer; use Application\Entity\Db\These; use Application\Entity\Db\EcoleDoctorale; use Application\Entity\Db\UniteRecherche; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Structure; /** * @var PhpRenderer $this * @var These[] $theses * @var EcoleDoctorale[] $ecoles * @var UniteRecherche[] $unites * @var Etablissement[] $etablissements */ const DEBUG = true; Loading @@ -19,19 +27,82 @@ function display_debug($texte) { } ?> <?php $this->headTitle($this->translate("Statistiques")) ?> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <?php $this->headTitle($this->translate("Statistiques")) ?> <!--<script src="public/js/charts.js/chart/Chart.Bar.js"></script>--> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <h1 class="page-header first"><?php echo $this->translate("Statistiques") ?> <span class="badge"><?php echo count($theses) ?></span></h1> <form id="selection" method="post" action=""> <input type="radio" id="structure_type" name="structure_type" value="Aucun"> Aucun <input type="radio" id="structure_type" name="structure_type" value="Etab"> Etablissement <input type="radio" id="structure_type" name="structure_type" value="ED"> Ecole doctorale <input type="radio" id="structure_type" name="structure_type" value="UR"> Unité de recherche <div id='structure_selector'> <select id='structure_id'></select>; </div> <input id='filtrage' type='button' value='filter'/> </form> <div id="linku"> ... </div> <script> $(document).ready(function(){ $('#structure_id').on('change', function() { alert( this.value ); }) $('input[type=radio][name=structure_type]').change(function() { //alert(this.value); if (this.value == "Aucun") { // alert("Aucun"); document.getElementById('structure_selector').innerHTML = ""; } else { // alert("Pas Aucun : " + this.value); } if (this.value == "ED") { // var form = "ED"; var form = " <?php echo generateStructureSelector($ecoles); ?> "; document.getElementById('structure_selector').innerHTML = form; } if (this.value == "UR") { // alert("UR"); var form = " <?php echo generateStructureSelector($unites); ?> "; document.getElementById('structure_selector').innerHTML = form; } if (this.value == "Etab") { // alert("Etab"); var form = " <?php echo generateStructureSelector($etablissements); ?> "; document.getElementById('structure_selector').innerHTML = form; } }); $('#filtrage').click(function() { var selected_structure_type = document.querySelector('input[name="structure_type"]:checked').value; var selected_structure_id = document.getElementById("structure_id").value; alert("clicked! " + selected_structure_type + " " + selected_structure_id); document.getElementById("linku").innerHTML = " <a href='/statistique?structure_type=" + selected_structure_type + "& structure_id=" + selected_structure_id + "'>clique donc</a>"; }); }); //document.getElementById('structure_selector').innerHTML = <?php //generateEDSelector($ecoles); ?>// ; </script> <?php function generateStructureSelector($structures) { $texte = ""; $texte .= "<select id='structure_id'>"; $texte .= "<option value=''> Aucune </option>"; /** @var Structure $structure */ foreach ($structures as $structure) { $texte .= "<option value='".$structure->getId()."'>". $structure->getLibelle() ."</option>"; } $texte .= "</select>"; return $texte; } ?> <?php $validInscriptionTheses = []; $validSoutenanceTheses = []; foreach($theses as $these) { Loading @@ -39,37 +110,9 @@ foreach($theses as $these) { if ($these->getDateSoutenance() !== null) $validSoutenanceTheses[] = $these; } ?> <!--Nombre de thèses valides :--> <!--<ul>--> <!-- <li> Inscription : --><?php //echo count($validInscriptionTheses); ?><!-- </li>--> <!-- <li> Soutenance : --><?php //echo count($validSoutenanceTheses); ?><!-- </li>--> <!--</ul>--> <?php usort($validInscriptionTheses, function (These $a, These $b) {return $a->getDatePremiereInscription() > $b->getDatePremiereInscription();}); usort($validSoutenanceTheses, function (These $a, These $b) {return $a->getDateSoutenance() > $b->getDateSoutenance();}); ?> <!--Etalement dans le temps :--> <!--<ul>--> <!-- <li> Inscription :--> <!-- --><?php //echo $validInscriptionTheses[0]->getDatePremiereInscription()->format("d/m/Y"); ?> <!-- →--> <!-- --><?php //echo end($validInscriptionTheses)->getDatePremiereInscription()->format("d/m/Y"); ?> <!-- </li>--> <!-- <li> Soutenance :--> <!-- --><?php //echo $validSoutenanceTheses[0]->getDateSoutenance()->format("d/m/Y"); ?> <!-- →--> <!-- --><?php //echo end($validSoutenanceTheses)->getDateSoutenance()->format("d/m/Y"); ?> <!-- </li>--> <!--</ul>--> <?php $end = (new DateTime())->format("Y"); $start = $end - 20; Loading @@ -95,15 +138,68 @@ foreach ($theses as $these) { if ($these->getDateSoutenance()) array_push($effectifsSoutenance[$these->getDateSoutenance()->format("Y")], $these); } ?> <?php $google_data = []; $data_insc_sout = []; for($current = $start ; $current <= $end ; $current++) { $google_data[] = [$current , count($effectifsInscription[$current]), count($effectifsSoutenance[$current])]; $inscriptions = (empty($effectifsInscription[$current])) ? 0 : count($effectifsInscription[$current]); $soutenances = (empty($effectifsSoutenance[$current])) ? 0 : count($effectifsSoutenance[$current]); $data_insc_sout[] = [$current , $inscriptions, $soutenances]; } $dureeTheses = []; for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { $dureeTheses[$annee] = array(); } for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { foreach($effectifsSoutenance[$annee] as $these) { if ($these->getDatePremiereInscription()) { $duree = $these->getDateSoutenance()->diff($these->getDatePremiereInscription()); $dureeTheses[$annee][] = $duree->m + $duree->y*12; } } sort($dureeTheses[$annee]); } $google_data = []; for ($annee = $start; $annee <= $end ; $annee++) { if (! empty($dureeTheses[$annee])) { $nb = count($dureeTheses[$annee]); $position_q0 = $nb*0.00; $position_q1 = $nb*0.25; $position_q2 = $nb*0.50; $position_q3 = $nb*0.75; $position_q4 = $nb*1.00-1; $row = [ $annee]; foreach ($dureeTheses[$annee] as $data) { $row[] = $dureeTheses[$annee][$position_q0]; $row[] = $dureeTheses[$annee][$position_q1]; $row[] = $dureeTheses[$annee][$position_q3]; $row[] = $dureeTheses[$annee][$position_q4]; } $google_data[] = $row; } } $homme = 0; $femme = 0; $discipline = []; $discipline["Autres"] = 0; $threshold = 5; foreach($effectifsInscription[$end-2] as $these) { if ($these->getDoctorant()->getIndividu()->estUneFemme()) { $femme++; } else { $homme++; } $discipline[$these->getLibelleDiscipline()]++; } $effectifParPays = generateEffectifParPays($effectifsInscription, $start, $end); ?> <script> var do_drawing = true; </script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -112,7 +208,7 @@ foreach ($theses as $these) { var data = google.visualization.arrayToDataTable([ ['Année', '#Inscriptions', '#Soutenances'], <?php foreach($google_data as $row) { foreach($data_insc_sout as $row) { echo "[\"" . $row[0] . "\"," . $row[1] . "," . $row[2] . "],"; } ?> Loading @@ -128,10 +224,11 @@ foreach ($theses as $these) { } }; if (do_drawing) { var chart = new google.visualization.LineChart(document.getElementById('Inscriptions/Soutenances')); chart.draw(data, options); } } </script> <div class="box panel panel-info"> <div class="panel-heading"> Loading @@ -142,43 +239,6 @@ foreach ($theses as $these) { <div id="Inscriptions/Soutenances" style="width: 925px; height: 500px"></div> </div> <?php $dureeTheses = []; for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { $dureeTheses[$annee] = array(); } for ($annee = $dateMinimum; $annee <= $dateMaximum ; $annee++) { foreach($effectifsSoutenance[$annee] as $these) { if ($these->getDatePremiereInscription()) { $duree = $these->getDateSoutenance()->diff($these->getDatePremiereInscription()); $dureeTheses[$annee][] = $duree->m + $duree->y*12; } } sort($dureeTheses[$annee]); } $google_data = []; for ($annee = $start; $annee <= $end ; $annee++) { if (! empty($dureeTheses[$annee])) { $nb = count($dureeTheses[$annee]); $position_q0 = $nb*0.00; $position_q1 = $nb*0.25; $position_q2 = $nb*0.50; $position_q3 = $nb*0.75; $position_q4 = $nb*1.00-1; $row = [ $annee]; foreach ($dureeTheses[$annee] as $data) { $row[] = $dureeTheses[$annee][$position_q0]; $row[] = $dureeTheses[$annee][$position_q1]; //$row[] = $dureeTheses[$annee][$position_q2]; //que faire de la mediane ??? $row[] = $dureeTheses[$annee][$position_q3]; $row[] = $dureeTheses[$annee][$position_q4]; } $google_data[] = $row; } } ?> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -205,12 +265,12 @@ for ($annee = $start; $annee <= $end ; $annee++) { } }; if (do_drawing) { var chart = new google.visualization.CandlestickChart(document.getElementById('duree')); chart.draw(data, options); } } </script> <div class="box panel panel-info"> <div class="panel-heading"> <h2 class="first"> Loading @@ -220,22 +280,6 @@ for ($annee = $start; $annee <= $end ; $annee++) { <div id="duree" style="width: 925px; height: 500px;"></div> </div> <?php $homme = 0; $femme = 0; $discipline = []; $discipline["Autres"] = 0; $threshold = 5; foreach($effectifsInscription[$end-2] as $these) { if ($these->getDoctorant()->getIndividu()->estUneFemme()) { $femme++; } else { $homme++; } $discipline[$these->getLibelleDiscipline()]++; } ?> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -255,12 +299,12 @@ foreach($effectifsInscription[$end-2] as $these) { }; if (do_drawing) { var chart = new google.visualization.PieChart(document.getElementById('Repartition/Sexe')); chart.draw(data, options); } } </script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); Loading @@ -284,13 +328,12 @@ foreach($effectifsInscription[$end-2] as $these) { legend: 'none', }; if (do_drawing) { var chart = new google.visualization.PieChart(document.getElementById('Repartition/Discipline')); chart.draw(data, options); } } </script> <div class="box panel panel-info" style="height: 550px;"> <div class="panel-heading"> <h2 class="first"> Loading @@ -302,10 +345,41 @@ foreach($effectifsInscription[$end-2] as $these) { </div> <script type="text/javascript"> google.charts.load('current', { 'packages':['geochart'], 'mapsApiKey': 'AIzaSyAZPWFm-VDkkiToc-s7Z982XQ6b6bDp428' }); google.charts.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() { var data = google.visualization.arrayToDataTable([ ['Country', 'Popularity'], <?php foreach($effectifParPays as $country => $number) { echo "[ '{$country}' , $number ],"; }?> ]); var options = { colorAxis: { maxValue: 100 } }; if (do_drawing) { var chart = new google.visualization.GeoChart(document.getElementById('regions_div')); chart.draw(data, options); } } </script> <div class="box panel panel-info" style="height: 550px;"> <div class="panel-heading"> <h2 class="first"> Provenance des doctorants inscrits entre <?php echo ($start) ?> et <? echo $end?> </h2> </div> <div id="regions_div" style="width: 900px; height: 500px;"></div> </div> <?php function generateEffectifParPays($effectifsInscription, $start , $end) { $code = []; $code["ALGERIEN(NE)"] = "Algeria"; $code["ALLEMAND(E)"] = "Germany"; Loading Loading @@ -382,7 +456,7 @@ $code["POLONAIS(E)"] = "Poland"; $code["PORTUGAIS(E)"] = "Portugal"; $code["ROUMAIN(E)"] = "Romania"; $code["RUANDAIS(E)"] = "Rwanda"; $code["RUSSE"] = "Ruusia"; $code["RUSSE"] = "Russia"; $code["SAOUDIEN(NE)"] = "Saudi Arabia"; $code["SENEGALAIS(E)"] = "Senegal"; $code["SERBE"] = "Serbia"; Loading @@ -406,6 +480,7 @@ $code["ZAIROIS(E)"] = "Zaire"; $effectifParPays = []; $nope = 0; for ($annee = $start ; $annee <= $end ; $annee++ ) { if (!empty($effectifsInscription[$annee])) { foreach ($effectifsInscription[$annee] as $these) { $nationalite = $these->getDoctorant()->getIndividu()->getNationalite(); if (isset($code[$nationalite])) { Loading @@ -416,42 +491,8 @@ $code["ZAIROIS(E)"] = "Zaire"; } } } } if ($nope > 0) echo $nope; ?> <script type="text/javascript"> google.charts.load('current', { 'packages':['geochart'], // Note: you will need to get a mapsApiKey for your project. // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings 'mapsApiKey': 'AIzaSyAZPWFm-VDkkiToc-s7Z982XQ6b6bDp428' }); google.charts.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() { var data = google.visualization.arrayToDataTable([ ['Country', 'Popularity'], <?php foreach($effectifParPays as $country => $number) { echo "[ '{$country}' , $number ],"; }?> ]); var options = { colorAxis: { maxValue: 100 } }; var chart = new google.visualization.GeoChart(document.getElementById('regions_div')); chart.draw(data, options); return $effectifParPays; } </script> <div class="box panel panel-info" style="height: 550px;"> <div class="panel-heading"> <h2 class="first"> Provenance des doctorants inscrits entre <?php echo ($start) ?> et <? echo $end?> </h2> </div> <div id="regions_div" style="width: 900px; height: 500px;"></div> </div> ?> No newline at end of file