src/Controller/ConduiteController.php line 272

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  5. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use App\Ressources\metadata;
  9. class ConduiteController extends AbstractController
  10. {
  11.     //
  12.     // PAGE ACCUEUIL DE L'ESPACE CONDUITE
  13.     //
  14.     /**
  15.      * @Route("/conduite.html", name="conduite")
  16.      */
  17.     public function conduiteActionCond(): Response
  18.     {
  19.         $meta = array(
  20.             'title' => \App\Ressources\metadata::COND_TITLE,
  21.             'description' => \App\Ressources\metadata::COND_DESCRIPTION,
  22.             'keyword' => \App\Ressources\metadata::COND_KEYWORD
  23.         );
  24.         return $this->render('main/Pages/Conduite/conduite.html.twig', array(
  25.             'meta' => $meta
  26.         ));
  27.     }
  28.     //
  29.     // PAGE AUTO-ECOLE DU CEREMH
  30.     //
  31.     /**
  32.      * @Route("/auto-ecole.html", name="conduite-autoecole")
  33.      */
  34.     public function conduiteActionCondAECEREMH(): Response
  35.     {
  36.         $meta = array(
  37.             'title' => \App\Ressources\metadata::COND_AE_TITLE,
  38.             'description' => \App\Ressources\metadata::COND_AE_DESCRIPTION,
  39.             'keyword' => \App\Ressources\metadata::COND_AE_KEYWORD
  40.         );
  41.         /**
  42.          *
  43.          * API VroomVroom
  44.          *
  45.          */
  46.         /////
  47.         ///
  48.         /// RECUPERATION DES NOTES
  49.         ///
  50.         ///
  51.         $id_CEREMH '5246e3bb24a0390002001104';
  52.         $post = ['X-Auth-Token'=> "d42922e2d4c9bb931a9de4c75aeac9bd"];
  53.         $header = array();
  54.         $header[] = 'X-Auth-Token: 51bf8b3202583f75f1ef0d072b84757f';
  55.         //$header[] = 'X-Auth-Token: 51bf8b3202583f75f1ef0d072b84757f';
  56.         $header[] = 'accept: application/json';
  57.         $ch curl_init();
  58.         curl_setopt$chCURLOPT_CUSTOMREQUEST'GET' );
  59.         curl_setopt($chCURLOPT_HTTPHEADER,$header);
  60.         curl_setopt($chCURLOPT_URL,'https://www.vroomvroom.fr/api/marketplace/v1/schools/5246e3bb24a0390002001104');
  61.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  62.         //curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
  63.         $response curl_exec($ch);
  64.         $result json_decode($response);
  65.         if ($response === false)
  66.         {
  67.             // throw new Exception('Curl error: ' . curl_error($crl));
  68.             var_dump('Curl error: ' curl_error($ch));
  69.         }
  70.         $note $result->avg_ratings_score;
  71.         $accueil $result->avg_reception;
  72.         $information $result->avg_information;
  73.         $pedagogique $result->avg_teaching;
  74.         $disponibilite $result->avg_availability;
  75.         $qualite $result->avg_quality;
  76.         /////
  77.         ///
  78.         /// RECUPERATION DES Avis
  79.         ///
  80.         ///
  81.         $header = array();
  82.         $header[] = 'X-Auth-Token: 51bf8b3202583f75f1ef0d072b84757f';
  83.         //$header[] = 'X-Auth-Token: 51bf8b3202583f75f1ef0d072b84757f';
  84.         $header[] = 'accept: application/json';
  85.         $ch curl_init();
  86.         curl_setopt$chCURLOPT_CUSTOMREQUEST'GET' );
  87.         curl_setopt($chCURLOPT_HTTPHEADER,$header);
  88.         curl_setopt($chCURLOPT_URL,'https://www.vroomvroom.fr/api/marketplace/v1/schools/5246e3bb24a0390002001104/reviews?page=1&limit=10&from_published_at=2019-03-19&to_published_at=2020-04-25&sort_by=published_at&sort_dir=desc');
  89.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  90.         //curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
  91.         $response curl_exec($ch);
  92.         $result json_decode($response);
  93.         curl_close($ch);
  94.         return $this->render('main/Pages/Conduite/conduite_AutoEcole.html.twig', array(
  95.             'note' => $note,
  96.             'accueil' => $accueil,
  97.             'information' => $information,
  98.             'pedagogique' => $pedagogique,
  99.             'disponibilite' => $disponibilite,
  100.             'qualite' => $qualite,
  101.             'data' => $result,
  102.             'meta' => $meta
  103.         ));
  104.     }
  105.     //
  106.     // ESPACE INFORMATION/RESSOURCES
  107.     //
  108.     // Menu gauche dans : conduite_Ressources.html.twig
  109.     //
  110.     //Espace Information Accueil
  111.     /**
  112.      * @Route("/info-conduite.html", name="conduite-inf")
  113.      */
  114.     public function conduiteActionInf(): Response
  115.     {
  116.         $meta = array(
  117.             'title' => \App\Ressources\metadata::COND_INF_TITLE,
  118.             'description' => \App\Ressources\metadata::COND_INF_DESCRIPTION,
  119.             'keyword' => \App\Ressources\metadata::COND_INF_KEYWORD
  120.         );
  121.         return $this->render('main/Pages/Conduite/conduite_inf.html.twig', array(
  122.             'meta' => $meta
  123.         ));
  124.     }
  125.     //DEMARCHES - Permis de conduite et handicap
  126.     /**
  127.      * @Route("/info-demarche-permis-conduire-handicap.html", name="conduite-inf-dem-permishandicap")
  128.      */
  129.     public function conduiteActionCondInfDemPermisHandicap(): Response
  130.     {
  131.         $meta = array(
  132.             'title' => \App\Ressources\metadata::COND_INF_DEM_PC_TITLE,
  133.             'description' => \App\Ressources\metadata::COND_INF_DEM_PC_DESCRIPTION,
  134.             'keyword' => \App\Ressources\metadata::COND_INF_DEM_PC_KEYWORD
  135.         );
  136.         return $this->render('main/Pages/Conduite/conduite_inf_Dem_permis&handicap.html.twig', array(
  137.             'meta' => $meta
  138.         ));
  139.     }
  140.     //REGLEMENTIAIRE - Acces au permis de conduire
  141.     /**
  142.      * @Route("/info-regularisation-permis-conduire.html", name="conduite-inf-reg-permis")
  143.      */
  144.     public function conduiteActionCndInfRegPermis(): Response
  145.     {
  146.         $meta = array(
  147.             'title' => \App\Ressources\metadata::COND_INF_REG_PC_TITLE,
  148.             'description' => \App\Ressources\metadata::COND_INF_REG_PC_DESCRIPTION,
  149.             'keyword' => \App\Ressources\metadata::COND_INF_REG_PC_KEYWORD
  150.         );
  151.         return $this->render('main/Pages/Conduite/conduite_inf_Reg_accessPermis.html.twig', array(
  152.             'meta' => $meta
  153.         ));
  154.     }
  155.     /**
  156.      * @Route("/info-reglementation-adapation-vehicule-adapte.html", name="conduite-inf-reg-adaptation-vehicule")
  157.      */
  158.     public function conduiteActionCndInfRegAdaptationVehicule(): Response
  159.     {
  160.         $meta = array(
  161.             'title' => \App\Ressources\metadata::COND_INF_REG_ADAPT_TITLE,
  162.             'description' => \App\Ressources\metadata::COND_INF_REG_ADAPT_DESCRIPTION,
  163.             'keyword' => \App\Ressources\metadata::COND_INF_REG_ADAPT_KEYWORD
  164.         );
  165.         return $this->render('main/Pages/Conduite/conduite_inf_Reg_adaptation_vehicule.html.twig', array(
  166.             'meta' => $meta
  167.         ));
  168.     }
  169.     /**
  170.      * @Route("/info-reglementation-amenagement-voirie.html", name="conduite-inf-reg-amenagement-voirie")
  171.      */
  172.     public function conduiteActionCndInfRegAmenagementVoirie(): Response
  173.     {
  174.         $meta = array(
  175.             'title' => \App\Ressources\metadata::COND_INF_REG_VOIRIE_TITLE,
  176.             'description' => \App\Ressources\metadata::COND_INF_REG_VOIRIE_DESCRIPTION,
  177.             'keyword' => \App\Ressources\metadata::COND_INF_REG_VOIRIE_KEYWORD
  178.         );
  179.         return $this->render('main/Pages/Conduite/conduite_inf_Reg_amenagement_voirie.html.twig', array(
  180.             'meta' => $meta
  181.         ));
  182.     }
  183.     /**
  184.      * @Route("/info-reglementation-assurance.html", name="conduite-inf-reg-assurance")
  185.      */
  186.     public function conduiteActionCndInfRegAssurance(): Response
  187.     {
  188.         $meta = array(
  189.             'title' => \App\Ressources\metadata::COND_INF_REG_ASS_TITLE,
  190.             'description' => \App\Ressources\metadata::COND_INF_REG_ASS_DESCRIPTION,
  191.             'keyword' => \App\Ressources\metadata::COND_INF_REG_ASS_KEYWORD
  192.         );
  193.         return $this->render('main/Pages/Conduite/conduite_inf_Reg_assurance.html.twig', array(
  194.             'meta' => $meta
  195.         ));
  196.     }
  197.     /**
  198.      * @Route("/info-reglementation-securite.html", name="conduite-inf-reg-securite")
  199.      */
  200.     public function conduiteActionCndInfRegSecurite(): Response
  201.     {
  202.         $meta = array(
  203.             'title' => \App\Ressources\metadata::COND_INF_REG_SEC_TITLE,
  204.             'description' => \App\Ressources\metadata::COND_INF_REG_SEC_DESCRIPTION,
  205.             'keyword' => \App\Ressources\metadata::COND_INF_REG_SEC_KEYWORD
  206.         );
  207.         return $this->render('main/Pages/Conduite/conduite_inf_Reg_securite.html.twig', array(
  208.             'meta' => $meta
  209.         ));
  210.     }
  211.     //Trouver les auto-école adaptées
  212.     /**
  213.      * @Route("/info-autoecole-adaptee.html", name="conduite-inf-ae-adaptee")
  214.      */
  215.     public function conduiteActionCondInfAEAdaptee(): Response
  216.     {
  217.         $meta = array(
  218.             'title' => \App\Ressources\metadata::COND_INF_AEA_TITLE,
  219.             'description' => \App\Ressources\metadata::COND_INF_AEA_DESCRIPTION,
  220.             'keyword' => \App\Ressources\metadata::COND_INF_AEA_KEYWORD
  221.         );
  222.         $tableAE = array();
  223.         if(isset($_POST["depselect"])) {
  224.             $depselect =  $_POST["depselect"];
  225.             $depdata $this->GetDep($depselect);
  226.             $aeDep[] = array();
  227.             foreach($depdata->{'fields'}->{'AutoEcole'} as $idae){
  228.                 $dataAirTAE $this->GetAeData($idae);
  229.                 if ($dataAirTAE->{'fields'}->{'AE_VroomVroom_id'} != 0){
  230.                     $dataVVAE $this->GetVVaeData($dataAirTAE->{'fields'}->{'AE_VroomVroom_id'});
  231.                 }else{
  232.                     $dataVVAE NULL;
  233.                 }
  234.                 $dataAirTAE->{'vv'} = $dataVVAE ;
  235.                 //$aeDep[] = array($dataAirTAE,$dataVVAE);
  236.                 $aeDep[] = $dataAirTAE;
  237.             }
  238.             $tableAE[] = array($depdata,$aeDep);
  239.         }
  240.         $res1 $this->GetDepList();
  241.         return $this->render('main/Pages/Conduite/conduite_inf_AE_adaptee.html.twig', array(
  242.             //'data' => $tableComp,
  243.             'listedep' => $res1->{'records'},
  244.             'tableae' => $tableAE,
  245.             'meta' => $meta
  246.         ));
  247.     }
  248.     function GetDepList(){
  249.         $headerAirT = array();
  250.         $headerAirT[] = 'Authorization: Bearer keyI32yOJYG5jgN46';
  251.         $ch_Air_API curl_init();
  252.         curl_setopt$ch_Air_APICURLOPT_CUSTOMREQUEST'GET' );
  253.         curl_setopt($ch_Air_APICURLOPT_HTTPHEADER,$headerAirT);
  254.         curl_setopt($ch_Air_APICURLOPT_URL,'https://api.airtable.com/v0/app6vWoMXrxSuL52T/Departement?view=Grid%20view');
  255.         curl_setopt($ch_Air_APICURLOPT_RETURNTRANSFERtrue);
  256.         $data json_decode(curl_exec($ch_Air_API));
  257.         curl_close($ch_Air_API);
  258.         return $data ;
  259.     }
  260.     function GetDep($depId){
  261.         $headerAirT = array();
  262.         $headerAirT[] = 'Authorization: Bearer keyI32yOJYG5jgN46';
  263.         $ch_Air_API curl_init();
  264.         curl_setopt$ch_Air_APICURLOPT_CUSTOMREQUEST'GET' );
  265.         curl_setopt($ch_Air_APICURLOPT_HTTPHEADER,$headerAirT);
  266.         curl_setopt($ch_Air_APICURLOPT_URL,'https://api.airtable.com/v0/app6vWoMXrxSuL52T/Departement/' $depId);
  267.         curl_setopt($ch_Air_APICURLOPT_RETURNTRANSFERtrue);
  268.         $data json_decode(curl_exec($ch_Air_API));
  269.         curl_close($ch_Air_API);
  270.         return $data ;
  271.     }
  272.     function GetAeData($idae){
  273.         $headerAirT = array();
  274.         $headerAirT[] = 'Authorization: Bearer keyI32yOJYG5jgN46';
  275.         $ch_Air_API curl_init();
  276.         curl_setopt($ch_Air_APICURLOPT_CUSTOMREQUEST'GET' );
  277.         curl_setopt($ch_Air_APICURLOPT_HTTPHEADER,$headerAirT);
  278.         curl_setopt($ch_Air_APICURLOPT_URL,'https://api.airtable.com/v0/app6vWoMXrxSuL52T/AutoEcole/' $idae);
  279.         curl_setopt($ch_Air_APICURLOPT_RETURNTRANSFERtrue);
  280.         $data json_decode(curl_exec($ch_Air_API));
  281.         curl_close($ch_Air_API);
  282.         return $data;
  283.     }
  284.     function GetVVaeData($idVV){
  285.         $header[] = 'X-Auth-Token: 51bf8b3202583f75f1ef0d072b84757f';
  286.         $header[] = 'accept: application/json';
  287.         $ch curl_init();
  288.         curl_setopt$chCURLOPT_CUSTOMREQUEST'GET' );
  289.         curl_setopt($chCURLOPT_HTTPHEADER,$header);
  290.         curl_setopt($chCURLOPT_URL,'https://vroomvroom.fr/api/marketplace/v1/schools/'.$idVV);
  291.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  292.         $data json_decode(curl_exec($ch));
  293.         curl_close($ch);
  294.         return $data;
  295.     }
  296.     //
  297.     // ESPACE DOCUMENTATION
  298.     //
  299.     /**
  300.      * @Route("/doc.html", name="conduite-doc")
  301.      */
  302.     public function conduiteActionCondDoc(): Response
  303.     {
  304.         $meta = array(
  305.             'title' => \App\Ressources\metadata::COND_DOC_TITLE,
  306.             'description' => \App\Ressources\metadata::COND_DOC_DESCRIPTION,
  307.             'keyword' => \App\Ressources\metadata::COND_DOC_KEYWORD
  308.         );
  309.         return $this->render('main/Pages/Conduite/conduite_doc.html.twig', array(
  310.             'meta' => $meta
  311.         ));
  312.     }
  313.     // Guide Choix TPMR
  314.     /**
  315.      * @Route("/doc-ChoixTPMR.html", name="conduite-doc-choix-tpmr")
  316.      */
  317.     public function conduiteActionCondDocChoixTPMR(): Response
  318.     {
  319.         $meta = array(
  320.             'title' => \App\Ressources\metadata::COND_DOC_TPMR_TITLE,
  321.             'description' => \App\Ressources\metadata::COND_DOC_TPMR_DESCRIPTION,
  322.             'keyword' => \App\Ressources\metadata::COND_DOC_TPMR_KEYWORD
  323.         );
  324.         return $this->render('main/Pages/Conduite/conduite_doc_ChoixTPMR.html.twig', array(
  325.             'meta' => $meta
  326.         ));
  327.     }
  328.     /**
  329.      * @Route("/doc-DownloadguideTPMR.html", name="download_guideTPMR")
  330.      **/
  331.     public function downloadGuideTPMRAction(){
  332.         $response = new BinaryFileResponse('_Assets/Media/CEREMH_guide_TPMR.pdf');
  333.         $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT,'CEREMH_guide_TPMR.pdf');
  334.         return $response;
  335.     }
  336.     // Guide Choix FRE
  337.     /**
  338.      * @Route("/doc-ChoixFRE.html", name="conduite-doc-choix-fre")
  339.      */
  340.     public function conduiteActionCondDocChoixFRE(): Response
  341.     {
  342.         $meta = array(
  343.             'title' => \App\Ressources\metadata::COND_DOC_FRE_TITLE,
  344.             'description' => \App\Ressources\metadata::COND_DOC_FRE_DESCRIPTION,
  345.             'keyword' => \App\Ressources\metadata::COND_DOC_FRE_KEYWORD
  346.         );
  347.         return $this->render('main/Pages/Conduite/conduite_doc_ChoixFRE.html.twig', array(
  348.             'meta' => $meta
  349.         ));
  350.     }
  351.     /**
  352.      * @Route("/doc-DownloadguideFRE.html", name="download_guideFRE")
  353.      **/
  354.     public function downloadGuideFREAction(){
  355.         $response = new BinaryFileResponse('_Assets/Media/CEREMH_guide_FRE.pdf');
  356.         $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT,'CEREMH_guide_FRE.pdf');
  357.         return $response;
  358.     }
  359.     // Guide Choix FRM
  360.     /**
  361.      * @Route("/doc-ChoixFRM.html", name="conduite-doc-choix-frm")
  362.      */
  363.     public function conduiteActionCondDocChoixFRM(): Response
  364.     {
  365.         $meta = array(
  366.             'title' => \App\Ressources\metadata::COND_DOC_FRM_TITLE,
  367.             'description' => \App\Ressources\metadata::COND_DOC_FRM_DESCRIPTION,
  368.             'keyword' => \App\Ressources\metadata::COND_DOC_FRM_KEYWORD
  369.         );
  370.         return $this->render('main/Pages/Conduite/conduite_doc_ChoixFRM.html.twig', array(
  371.             'meta' => $meta
  372.         ));
  373.     }
  374.     /**
  375.      * @Route("/doc-DownloadguideFRM.html", name="download_guideFRM")
  376.      **/
  377.     public function downloadGuideFRMAction(){
  378.         $response = new BinaryFileResponse('_Assets/Media/CEREMH_guide_FRM.pdf');
  379.         $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT,'CEREMH_guide_FRM.pdf');
  380.         return $response;
  381.     }
  382.     /**
  383.      * @Route("/doc-DossierAdminEval.html", name="download_adminEval")
  384.      **/
  385.     public function downloadAdminEval(){
  386.         $response = new BinaryFileResponse('_Assets/Media/CEREMH_Admin_EvalConduite.pdf');
  387.         $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT,'CEREMH_Admin_EvalConduite.pdf');
  388.         return $response;
  389.     }
  390. }