<?php
namespace App\Controller;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Service\StripeService;
class proController extends AbstractController
{
const PARRAIN_CODE_IMPORTED = '123I321';
private $client;
public function __construct(HttpClientInterface $client)
{
$this->client = $client;
}
/**
* @Route("/pro")
*/
public function renderAccueilProPage()
{
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}articles/pro?limit=6"
);
$content = $response->toArray()["articles"];
return $this->render('/pro/accueil.html.twig', array(
"articles" => $content,
));
}
/**
* @Route("/pro/les-avantages")
*/
public function renderAvantagesProPage()
{
return $this->render('/pro/lesAvantages.html.twig', array(
));
}
/**
* @Route("/pro/qui-sommes-nous")
*/
public function renderQSNProPage()
{
return $this->render('/pro/quiSommesNous.html.twig', array(
));
}
/**
* @Route("/pro/nos-tarifs")
*/
public function renderNosTarifsProPage()
{
return $this->render('/pro/nos-tarifs.html.twig', array(
));
}
/**
* @Route("/pro/inscription",methods={"GET", "POST"})
*/
public function renderInscriptionProPage(Request $request)
{
// dd(strtotime(date('H:i:s Y-m-d', strtotime('+1 month'))));
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}prestations"
);
$prestations = $response->toArray()["prestations"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}mutuelles"
);
$mutuelles = $response->toArray()["mutuelles"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}specialites"
);
$specialites = $response->toArray()["specialites"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}diplomes"
);
$diplomes = $response->toArray()["diplomes"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}stations/city"
);
$stations = $response->toArray()["stations"];
// Initialize the variable
$centreImported = null;
$parrain = null;
// Check if the "parrain" parameter exists in the URL and get the imported
if ($request->query->has('parrain')) {
$parrainId = $request->query->get('parrain');
$id = substr( $parrainId,strlen(self::PARRAIN_CODE_IMPORTED));
$parrain = self::PARRAIN_CODE_IMPORTED;
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}centreImported/".$id
);
$centreImported = $response->toArray();
}
return $this->render('./pro/inscription.html.twig', array(
"prestations" => $prestations,
"mutuelles" => $mutuelles,
"specialites" => $specialites,
"diplomes" => $diplomes,
'centreImported' => $centreImported,
'parrain' => $parrain,
"stations" => $stations,
));
}
/**
* @Route("/pro/second",methods={"GET", "POST"})
*/
public function rendersecondInscriptionProPage(StripeService $stripeService)
{
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}prestations"
);
$prestations = $response->toArray()["prestations"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}mutuelles"
);
$mutuelles = $response->toArray()["mutuelles"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}specialites"
);
$specialites = $response->toArray()["specialites"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}diplomes"
);
$diplomes = $response->toArray()["diplomes"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}stations/city"
);
$stations = $response->toArray()["stations"];
return $this->render('./pro/secondinscri.html.twig', array(
"prestations" => $prestations,
"mutuelles" => $mutuelles,
"specialites" => $specialites,
"diplomes" => $diplomes,
"stations" => $stations,
));
}
/**
* @Route("/pro/intent/{intent}")
*/
public function renderStripePage($intent)
{
return $this->render('/pro/stripe.html.twig', array(
'intentSecret' => $intent
));
}
/**
* @Route("/pro/inscription/termine",name="termination")
*/
public function renderFinishedPaymentPage()
{
return $this->render('/pro/success.html.twig', array(
//'intentSecret' => $intent
));
}
/**
* @Route("/pro/addAudio")
*/
public function renderAddAudioProPage(Request $request)
{
$data = json_decode($request->getContent(), true);
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}prestations"
);
$prestations = $response->toArray()["prestations"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}mutuelles"
);
$mutuelles = $response->toArray()["mutuelles"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}specialites"
);
$specialites = $response->toArray()["specialites"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}diplomes"
);
$diplomes = $response->toArray()["diplomes"];
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}roles"
);
$roles = $response->toArray()["roles"];
return $this->render('./pro/addAudio.html.twig', array(
"nbAudio" => $data['nbAudio'],
"prestations" => $prestations,
"mutuelles" => $mutuelles,
"specialites" => $specialites,
"roles" => $roles,
"diplomes" => $diplomes,
));
}
}
?>