src/Controller/proController.php line 78

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Contracts\HttpClient\HttpClientInterface;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use App\Service\StripeService;
  9. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  10. class proController extends AbstractController
  11. {
  12.     const PARRAIN_CODE_IMPORTED '123I321';
  13.     private $client;
  14.     public function __construct(HttpClientInterface $client)
  15.     {
  16.         $this->client $client;
  17.     }
  18.     
  19.     /**
  20.      * @Route("/proold")
  21.      */
  22.     public function renderAccueilProPage()
  23.     {
  24.         
  25.         $response $this->client->request(
  26.             'GET',
  27.             "{$_ENV['BASE_API']}articles/pro?limit=6"
  28.         );
  29.         $content $response->toArray()["articles"];
  30.         return $this->render('/pro/accueil.html.twig', array(
  31.             "articles" => $content,
  32.         ));
  33.         
  34.     }
  35.      /**
  36.      * @Route("/pro")
  37.      */
  38.     public function renderAccueilProPageNew()
  39.     {
  40.         
  41.         $response $this->client->request(
  42.             'GET',
  43.             "{$_ENV['BASE_API']}articles/pro?limit=6"
  44.         );
  45.         $content $response->toArray()["articles"];
  46.         return $this->render('/pro/accueilNew.html.twig', array(
  47.             "articles" => $content,
  48.         ));
  49.         
  50.     }
  51.     
  52.     /**
  53.      * @Route("/pro/les-avantages")
  54.      */
  55.     public function renderAvantagesProPage()
  56.     {
  57.         return $this->render('/pro/lesAvantages.html.twig', array(
  58.         ));
  59.         
  60.     }
  61.     /**
  62.      * @Route("/pro/qui-sommes-nous")
  63.      */
  64.     public function renderQSNProPage()
  65.     {
  66.         return $this->render('/pro/quiSommesNous.html.twig', array(
  67.         ));
  68.         
  69.     }
  70.     /**
  71.      * @Route("/pro/nos-tarifs")
  72.      */
  73.     public function renderNosTarifsProPage()
  74.     {
  75.         return $this->render('/pro/nos-tarifs.html.twig', array(
  76.         ));
  77.         
  78.     }
  79.     /**
  80.      * @Route("/pro/nos-tarifs-new" , name="app_nos_tarifs_new")
  81.      */
  82.     public function renderNosTarifsNewProPage(SessionInterface $session)
  83.     {
  84.         $session->remove('tarifs');
  85.         return $this->render('/pro/nos-tarifs-new.html.twig', array(
  86.         ));
  87.         
  88.     }
  89.     /**
  90.      * @Route("/cda", name="app_cda")
  91.      */
  92.     public function redirectToCda()
  93.     {
  94.         return $this->redirectToRoute('app_nos_tarifs_new_cda');
  95.     
  96.     }   
  97.     /**
  98.      * @Route("/pro/nos-tarifs-cda", name="app_nos_tarifs_new_cda")
  99.      */
  100.     public function renderNosTarifsCdaProPage(SessionInterface $session)
  101.     {
  102.                 $session->remove('tarifs');
  103.         return $this->render('/pro/nos-tarifs-cda.html.twig', array(
  104.         ));
  105.         
  106.     }   
  107.     /**
  108.      * @Route("/pro/nos-tarifs-atol-audition", name="app_nos_tarifs_new_atol_audition")
  109.      */
  110.     public function renderNosTarifsAtolProPage(SessionInterface $session)
  111.     {
  112.                 $session->remove('tarifs');
  113.         return $this->render('/pro/nos-tarifs-atol.html.twig', array(
  114.         ));
  115.         
  116.     }  
  117.     
  118.     /**
  119.      * @Route("/pro/nos-tarifs-audiolibre", name="app_nos_tarifs_new_audiolibre")
  120.     */
  121.     public function renderNosTarifsAudioLibreProPage(SessionInterface $session)
  122.     {
  123.         $session->remove('tarifs');
  124.         return $this->render('/pro/nos-tarifs-audiolibre.html.twig', array(
  125.         ));
  126.         
  127.     }  
  128.     /**
  129.      * @Route("/pro/inscription",methods={"GET", "POST"})
  130.      */
  131.     public function renderInscriptionProPage(Request $request)
  132.     {
  133.      //  dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
  134.         $response $this->client->request(
  135.             'GET',
  136.             "{$_ENV['BASE_API']}prestations"
  137.         );
  138.         $prestations $response->toArray()["prestations"];
  139.         $response $this->client->request(
  140.             'GET',
  141.             "{$_ENV['BASE_API']}mutuelles"
  142.         );
  143.         $mutuelles $response->toArray()["mutuelles"];
  144.         $response $this->client->request(
  145.             'GET',
  146.             "{$_ENV['BASE_API']}specialites"
  147.         );
  148.         $specialites $response->toArray()["specialites"];
  149.         $response $this->client->request(
  150.             'GET',
  151.             "{$_ENV['BASE_API']}diplomes"
  152.         );
  153.         $diplomes $response->toArray()["diplomes"];
  154.         
  155.         $response $this->client->request(
  156.             'GET',
  157.             "{$_ENV['BASE_API']}stations/city"
  158.         );
  159.         $stations $response->toArray()["stations"];
  160.         // Initialize the variable
  161.         $centreImported null;
  162.         $parrain null;
  163.         // Check if the "parrain" parameter exists in the URL and get the imported
  164.         if ($request->query->has('parrain')) {
  165.             $parrainId $request->query->get('parrain');
  166.             $id substr$parrainId,strlen(self::PARRAIN_CODE_IMPORTED));
  167.             $parrain self::PARRAIN_CODE_IMPORTED;
  168.             $response $this->client->request(
  169.                 'GET',
  170.                 "{$_ENV['BASE_API']}centreImported/".$id
  171.         );
  172.         $centreImported $response->toArray();
  173.         }
  174.         return $this->render('./pro/inscription.html.twig', array(
  175.             "prestations" => $prestations,
  176.             "mutuelles" => $mutuelles,
  177.             "specialites" => $specialites,
  178.             "diplomes" => $diplomes,
  179.             'centreImported' => $centreImported,
  180.             'parrain' => $parrain,
  181.             "stations" => $stations,
  182.         ));
  183.         
  184.     }
  185.     /**
  186.      * @Route("/pro/handle-inscription", methods={"POST"})
  187.      */
  188.     public function handleInscription(Request $requestSessionInterface $session)
  189.     {
  190.         $data json_decode($request->getContent(), true);
  191.         if ($data) {
  192.             $session->set('tarifs'$data);
  193.             
  194.             $redirectUrl $this->generateUrl('app_inscription');
  195.             
  196.             return $this->json(['redirect_url' => $redirectUrl]);
  197.         }
  198.         return $this->json(['error' => 'Invalid data'], 400);
  199.     }
  200.     
  201.     /**
  202.      * @Route("/pro/handle-inscription-atol", methods={"POST"})
  203.      */
  204.     public function handleInscriptionAtol(Request $requestSessionInterface $session)
  205.     {
  206.         $data json_decode($request->getContent(), true);
  207.         if ($data) {
  208.             $session->set('tarifs'$data);
  209.             
  210.             $redirectUrl $this->generateUrl('app_inscription_atol');
  211.             
  212.             return $this->json(['redirect_url' => $redirectUrl]);
  213.         }
  214.         return $this->json(['error' => 'Invalid data'], 400);
  215.     }
  216.     /**
  217.      * @Route("/pro/inscription2",name="app_inscription",methods={"GET", "POST"})
  218.      */
  219.     public function renderInscription2ProPage(Request $requestSessionInterface $session)
  220.     {
  221.         //  dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
  222.         $tarifs $session->get('tarifs'null);
  223.         //dd($tarifs);
  224.         if (empty($tarifs)) {
  225.             return $this->redirectToRoute('app_nos_tarifs_new');
  226.         }
  227.         $response $this->client->request(
  228.             'GET',
  229.             "{$_ENV['BASE_API']}prestations"
  230.         );
  231.         $prestations $response->toArray()["prestations"];
  232.         $response $this->client->request(
  233.             'GET',
  234.             "{$_ENV['BASE_API']}mutuelles"
  235.         );
  236.         $mutuelles $response->toArray()["mutuelles"];
  237.         $response $this->client->request(
  238.             'GET',
  239.             "{$_ENV['BASE_API']}specialites"
  240.         );
  241.         $specialites $response->toArray()["specialites"];
  242.         $response $this->client->request(
  243.             'GET',
  244.             "{$_ENV['BASE_API']}diplomes"
  245.         );
  246.         $diplomes $response->toArray()["diplomes"];
  247.         
  248.         $response $this->client->request(
  249.             'GET',
  250.             "{$_ENV['BASE_API']}stations/city"
  251.         );
  252.         $stations $response->toArray()["stations"];
  253.         // Initialize the variable
  254.         $centreImported null;
  255.         $parrain null;
  256.         // Check if the "parrain" parameter exists in the URL and get the imported
  257.         if ($request->query->has('parrain')) {
  258.             $parrainId $request->query->get('parrain');
  259.             $id substr$parrainId,strlen(self::PARRAIN_CODE_IMPORTED));
  260.             $parrain self::PARRAIN_CODE_IMPORTED;
  261.             $response $this->client->request(
  262.                 'GET',
  263.                 "{$_ENV['BASE_API']}centreImported/".$id
  264.         );
  265.         $centreImported $response->toArray();
  266.         }
  267.         return $this->render('./pro/inscription2.html.twig', array(
  268.             "prestations" => $prestations,
  269.             "mutuelles" => $mutuelles,
  270.             "specialites" => $specialites,
  271.             "diplomes" => $diplomes,
  272.             'centreImported' => $centreImported,
  273.             'parrain' => $parrain,
  274.             "stations" => $stations,
  275.             'tarifs' => $tarifs
  276.         ));
  277.         
  278.     }
  279.     
  280.     /**
  281.      * @Route("/pro/inscription-atol",name="app_inscription_atol",methods={"GET", "POST"})
  282.      */
  283.     public function renderInscriptionAtolProPage(Request $requestSessionInterface $session)
  284.     {
  285.         //  dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
  286.         $tarifs $session->get('tarifs'null);
  287.         //dd($tarifs);
  288.         if (empty($tarifs)) {
  289.             return $this->redirectToRoute('app_nos_tarifs_new');
  290.         }
  291.         $response $this->client->request(
  292.             'GET',
  293.             "{$_ENV['BASE_API']}prestations"
  294.         );
  295.         $prestations $response->toArray()["prestations"];
  296.         $response $this->client->request(
  297.             'GET',
  298.             "{$_ENV['BASE_API']}mutuelles"
  299.         );
  300.         $mutuelles $response->toArray()["mutuelles"];
  301.         $response $this->client->request(
  302.             'GET',
  303.             "{$_ENV['BASE_API']}specialites"
  304.         );
  305.         $specialites $response->toArray()["specialites"];
  306.         $response $this->client->request(
  307.             'GET',
  308.             "{$_ENV['BASE_API']}diplomes"
  309.         );
  310.         $diplomes $response->toArray()["diplomes"];
  311.         
  312.         $response $this->client->request(
  313.             'GET',
  314.             "{$_ENV['BASE_API']}stations/city"
  315.         );
  316.         $stations $response->toArray()["stations"];
  317.         // Initialize the variable
  318.         $centreImported null;
  319.         $parrain null;
  320.         // Check if the "parrain" parameter exists in the URL and get the imported
  321.         if ($request->query->has('parrain')) {
  322.             $parrainId $request->query->get('parrain');
  323.             $id substr$parrainId,strlen(self::PARRAIN_CODE_IMPORTED));
  324.             $parrain self::PARRAIN_CODE_IMPORTED;
  325.             $response $this->client->request(
  326.                 'GET',
  327.                 "{$_ENV['BASE_API']}centreImported/".$id
  328.         );
  329.         $centreImported $response->toArray();
  330.         }
  331.         return $this->render('./pro/inscription-atol.html.twig', array(
  332.             "prestations" => $prestations,
  333.             "mutuelles" => $mutuelles,
  334.             "specialites" => $specialites,
  335.             "diplomes" => $diplomes,
  336.             'centreImported' => $centreImported,
  337.             'parrain' => $parrain,
  338.             "stations" => $stations,
  339.             'tarifs' => $tarifs
  340.         ));
  341.         
  342.     }
  343.      /**
  344.      * @Route("/pro/handle-inscription-cda", methods={"POST"})
  345.      */
  346.     public function handleInscriptionCda(Request $requestSessionInterface $session)
  347.     {
  348.         $data json_decode($request->getContent(), true);
  349.         if ($data) {
  350.             $session->set('tarifs'$data);
  351.             $redirectUrl $this->generateUrl('app_inscription_cda');
  352.             
  353.             return $this->json(['redirect_url' => $redirectUrl]);
  354.         }
  355.         return $this->json(['error' => 'Invalid data'], 400);
  356.     }
  357.     /**
  358.      * @Route("/pro/inscription-cda",name="app_inscription_cda",methods={"GET", "POST"})
  359.      */
  360.     public function renderInscriptionCdaProPage(Request $requestSessionInterface $session)
  361.     {
  362.        
  363.         //  dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
  364.         $tarifs $session->get('tarifs'null);
  365.         //dd($tarifs);
  366.         if (empty($tarifs)) {
  367.             return $this->redirectToRoute('app_nos_tarifs_new_cda');
  368.         }
  369.         
  370.         $response $this->client->request(
  371.             'GET',
  372.             "{$_ENV['BASE_API']}prestations"
  373.         );
  374.         $prestations $response->toArray()["prestations"];
  375.         $response $this->client->request(
  376.             'GET',
  377.             "{$_ENV['BASE_API']}mutuelles"
  378.         );
  379.         $mutuelles $response->toArray()["mutuelles"];
  380.         $response $this->client->request(
  381.             'GET',
  382.             "{$_ENV['BASE_API']}specialites"
  383.         );
  384.         $specialites $response->toArray()["specialites"];
  385.         $response $this->client->request(
  386.             'GET',
  387.             "{$_ENV['BASE_API']}diplomes"
  388.         );
  389.         $diplomes $response->toArray()["diplomes"];
  390.         
  391.         $response $this->client->request(
  392.             'GET',
  393.             "{$_ENV['BASE_API']}stations/city"
  394.         );
  395.         $stations $response->toArray()["stations"];
  396.         // Initialize the variable
  397.         $centreImported null;
  398.         $parrain null;
  399.         // Check if the "parrain" parameter exists in the URL and get the imported
  400.         if ($request->query->has('parrain')) {
  401.             $parrainId $request->query->get('parrain');
  402.             $id substr$parrainId,strlen(self::PARRAIN_CODE_IMPORTED));
  403.             $parrain self::PARRAIN_CODE_IMPORTED;
  404.             $response $this->client->request(
  405.                 'GET',
  406.                 "{$_ENV['BASE_API']}centreImported/".$id
  407.         );
  408.         $centreImported $response->toArray();
  409.         }
  410.         return $this->render('./pro/inscription-cda.html.twig', array(
  411.             "prestations" => $prestations,
  412.             "mutuelles" => $mutuelles,
  413.             "specialites" => $specialites,
  414.             "diplomes" => $diplomes,
  415.             'centreImported' => $centreImported,
  416.             'parrain' => $parrain,
  417.             "stations" => $stations,
  418.             'tarifs' => $tarifs
  419.         ));
  420.         
  421.     }
  422.       /**
  423.      * @Route("/pro/handle-inscription-audiolibre", methods={"POST"})
  424.      */
  425.     public function handleInscriptionAudiolibre(Request $requestSessionInterface $session)
  426.     {
  427.         $data json_decode($request->getContent(), true);
  428.         if ($data) {
  429.             $session->set('tarifs'$data);
  430.             $redirectUrl $this->generateUrl('app_inscription_audiolibre');
  431.             
  432.             return $this->json(['redirect_url' => $redirectUrl]);
  433.         }
  434.         return $this->json(['error' => 'Invalid data'], 400);
  435.     }
  436.      /**
  437.      * @Route("/pro/inscription-audiolibre",name="app_inscription_audiolibre",methods={"GET", "POST"})
  438.      */
  439.     public function renderInscriptionAudioLibreProPage(Request $requestSessionInterface $session)
  440.     {
  441.         //  dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
  442.         $tarifs $session->get('tarifs'null);
  443.         //dd($tarifs);
  444.         if (empty($tarifs)) {
  445.             return $this->redirectToRoute('app_nos_tarifs_new_audiolibre');
  446.         }
  447.         
  448.         $response $this->client->request(
  449.             'GET',
  450.             "{$_ENV['BASE_API']}prestations"
  451.         );
  452.         $prestations $response->toArray()["prestations"];
  453.         $response $this->client->request(
  454.             'GET',
  455.             "{$_ENV['BASE_API']}mutuelles"
  456.         );
  457.         $mutuelles $response->toArray()["mutuelles"];
  458.         $response $this->client->request(
  459.             'GET',
  460.             "{$_ENV['BASE_API']}specialites"
  461.         );
  462.         $specialites $response->toArray()["specialites"];
  463.         $response $this->client->request(
  464.             'GET',
  465.             "{$_ENV['BASE_API']}diplomes"
  466.         );
  467.         $diplomes $response->toArray()["diplomes"];
  468.         
  469.         $response $this->client->request(
  470.             'GET',
  471.             "{$_ENV['BASE_API']}stations/city"
  472.         );
  473.         $stations $response->toArray()["stations"];
  474.         // Initialize the variable
  475.         $centreImported null;
  476.         $parrain null;
  477.         return $this->render('./pro/inscription-audiolibre.html.twig', array(
  478.             "prestations" => $prestations,
  479.             "mutuelles" => $mutuelles,
  480.             "specialites" => $specialites,
  481.             "diplomes" => $diplomes,
  482.             'centreImported' => $centreImported,
  483.             'parrain' => $parrain,
  484.             "stations" => $stations,
  485.             'tarifs' => $tarifs
  486.         ));
  487.         
  488.     }
  489.       /**
  490.      * @Route("/pro/second",methods={"GET", "POST"})
  491.      */
  492.     public function rendersecondInscriptionProPage(StripeService $stripeService)
  493.     {
  494.        
  495.         $response $this->client->request(
  496.             'GET',
  497.             "{$_ENV['BASE_API']}prestations"
  498.         );
  499.         $prestations $response->toArray()["prestations"];
  500.         $response $this->client->request(
  501.             'GET',
  502.             "{$_ENV['BASE_API']}mutuelles"
  503.         );
  504.         $mutuelles $response->toArray()["mutuelles"];
  505.         $response $this->client->request(
  506.             'GET',
  507.             "{$_ENV['BASE_API']}specialites"
  508.         );
  509.         $specialites $response->toArray()["specialites"];
  510.         $response $this->client->request(
  511.             'GET',
  512.             "{$_ENV['BASE_API']}diplomes"
  513.         );
  514.         $diplomes $response->toArray()["diplomes"];
  515.         
  516.         $response $this->client->request(
  517.             'GET',
  518.             "{$_ENV['BASE_API']}stations/city"
  519.         );
  520.         $stations $response->toArray()["stations"];
  521.         
  522.         return $this->render('./pro/secondinscri.html.twig', array(
  523.             "prestations" => $prestations,
  524.             "mutuelles" => $mutuelles,
  525.             "specialites" => $specialites,
  526.             "diplomes" => $diplomes,
  527.             "stations" => $stations,
  528.         ));
  529.         
  530.     }
  531.       /**
  532.      * @Route("/pro/intent/{intent}")
  533.      */
  534.     public function renderStripePage($intent)
  535.     {
  536.         return $this->render('/pro/stripe.html.twig', array(
  537.             'intentSecret' => $intent
  538.         ));
  539.         
  540.     }
  541.        /**
  542.      * @Route("/pro/inscription/termine",name="termination")
  543.      */
  544.     public function renderFinishedPaymentPage()
  545.     {
  546.         return $this->render('/pro/success.html.twig', array(
  547.             //'intentSecret' => $intent
  548.         ));
  549.         
  550.     }
  551.        /**
  552.      * @Route("/pro/addAudio")
  553.      */
  554.     public function renderAddAudioProPage(Request $request)
  555.     {
  556.         $data json_decode($request->getContent(), true);
  557.         $response $this->client->request(
  558.             'GET',
  559.             "{$_ENV['BASE_API']}prestations"
  560.         );
  561.         $prestations $response->toArray()["prestations"];
  562.         $response $this->client->request(
  563.             'GET',
  564.             "{$_ENV['BASE_API']}mutuelles"
  565.         );
  566.         $mutuelles $response->toArray()["mutuelles"];
  567.         $response $this->client->request(
  568.             'GET',
  569.             "{$_ENV['BASE_API']}specialites"
  570.         );
  571.         $specialites $response->toArray()["specialites"];
  572.         $response $this->client->request(
  573.             'GET',
  574.             "{$_ENV['BASE_API']}diplomes"
  575.         );
  576.         $diplomes $response->toArray()["diplomes"];
  577.         
  578.         $response $this->client->request(
  579.             'GET',
  580.             "{$_ENV['BASE_API']}roles"
  581.         );
  582.         $roles $response->toArray()["roles"];
  583.         return $this->render('./pro/addAudio.html.twig', array(
  584.             "nbAudio" => $data['nbAudio'],
  585.             "prestations" => $prestations,
  586.             "mutuelles" => $mutuelles,
  587.             "specialites" => $specialites,
  588.             "roles" => $roles,
  589.             "diplomes" => $diplomes,
  590.         ));
  591.         
  592.     }
  593.     
  594. }
  595. ?>