<?php
namespace App\Controller;
use App\Entity\CenterZipcode;
use App\Entity\Centers;
use App\Entity\Cities;
use App\Entity\Geocode;
use App\Entity\Image;
use App\Entity\Maps;
use App\Entity\PracticeSpeechTherapists;
use App\Entity\Practices;
use App\Entity\ServiceSpeechTherapists;
use App\Entity\Services;
use App\Entity\SpeechTherapist;
use App\Entity\Zipcode;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
class OrthoController extends AbstractController
{
/**
* @Route("/orthophoniste/{id}", name="redirect_id_ortho", requirements={"id"="\d+"})
*/
public function redirectIdOnly($id)
{
$ortho = $this->getDoctrine()->getRepository(SpeechTherapist::class)->find($id);
if ($ortho) {
$slug = $this->slugify->slugify($ortho->getFirstName() . '-' . $ortho->getName());
$url = $this->router->generate(
'page_single_ortho_alone',
array('nomortho' => $slug, 'idortho' => $id)
);
} else {
$url = $this->router->generate(
'liste_ortho'
);
}
return $this->redirect($url, 301);
}
/**
* @Route("/orthophoniste/page/{page}", name="redirect_page_ortho")
*/
public function redirectPage($page = null)
{
if ($page) {
$url = $this->router->generate(
'liste_ortho'
);
}
return $this->redirect($url, 301);
}
/**
* @Route("/orthophoniste", name="liste_ortho")
*/
public function renderDefault(): Response
{
$this->setTemplateParameters(array('title_seo' => "Orthophonistes : Trouvez un orthophoniste près de chez vous"));
$data = $this->JsonProvider->getJson('seo_text_orthos');
$this->setTemplateParameters(array('seo_text' => json_decode($data)));
$this->setInternalLinkage('orthoListe');
return $this->renderTemplate('pages/annuaire_search_Orthophonists.twig');
}
/**
* @Route("/orthophoniste-{zipcode}-{ville}.html", name="results_ortho_audio_by_city", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/orthophoniste-{zipcode}-{ville}/filtre-resultats/exercice-{exercice}.html", name="results_ortho_by_city_filter_exercice", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/orthophoniste-{zipcode}-{ville}/filtre-resultats/{specialisation}.html", name="results_ortho_by_city_filter_specialisation", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/orthophoniste-{departementCode}-{departementTexte}.html", name="results_ortho_by_departement", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/orthophoniste-{departementCode}-{departementTexte}/filtre-resultats/exercice-{exercice}.html", name="results_ortho_by_departement_filter_exercice", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/orthophoniste-{departementCode}-{departementTexte}/filtre-resultats/{specialisation}.html", name="results_ortho_by_departement_filter_specialisation", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
*
*/
public function renderList($zipcode = null, $ville = null, $departementCode = null, $departementTexte = null, $exercice = null, $specialisation = null, Request $request, PaginatorInterface $paginator): Response
{
$result = [];
$searchtype = [];
$orthos = [];
$orthos_filtered = [];
$lat = $lng = $canonical_url = null;
$ortho_title_seo = $ortho_description_seo = null;
if ($zipcode) {
/*************** Description seo *******************/
$description_seo = "Orthophoniste à " . $this->dataProvider->wordUpperCaseFirstLetter($ville) . " (" . $zipcode . ") : Trouvez un orthophoniste proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
$search_by = 'zipcode';
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
'zipcode' => $zipcode,
'city' => strtoupper($ville)
));
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
'zipcode' => $zipcode,
'city' => strtoupper(str_replace('-', ' ', $ville))
));
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findByZipCodeAndCityLike($zipcode, $ville);
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['zipcode' => $zipcode]);
}
if (!$localisation) {
throw new NotFoundHttpException();
}
$departementTexte = "";
if ($ville != $this->slugify->slugify($localisation->getCity())) {
return $this->redirectProvider->redirect301('results_ortho_audio_by_city', array('ville' => $this->slugify->slugify($localisation->getCity()), 'zipcode' => $zipcode));
}
$cities = $localisation->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
if (!empty($localisation->getCities())) {
$departementTexte = $localisation->getCities()->getDeptTxt();
$depcode = $localisation->getCities()->getDeptcode();
$lat = $localisation->getCities()->getLat();
$lng = $localisation->getCities()->getLng();
} else {
$dep = $localisation->getDepartment();
$departementTexte = substr($dep, 7);
$depcode = substr($dep, 0, 2);
}
//PREFOOTER
$searchtype['departementCode'] = $depcode;
$searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
$searchtype['ville'] = strtolower($ville);
$searchtype['zipcode'] = $zipcode;
// BREADCRUMB
$this->breadDatas['type'] = 'city';
$this->breadDatas['final'] = $localisation->getCity() . " (" . $zipcode . ")";
$search_location = $ville;
$this->breadDatas['final_url'] = $this->router->generate(
'results_ortho_audio_by_city',
array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville))
);
$this->breadDatas['departementTxt'] = $departementTexte;
$this->breadDatas['departementCode'] = $depcode;
// Recherche des Orthophonistes par zipcode
$orthos = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findByLocalisationId($localisation->getId());
foreach ($orthos as $ortho) {
$ortho->zip = $zipcode;
$ortho->city = $ville;
}
$total_results = count($orthos);
$limit = 30 - $total_results;
if ($total_results < 30) {
$orthos_proximite = [];
// ------- Récupération coordonnées de la ville courante
$lat = $localisation->getCities()->getLat();
$lng = $localisation->getCities()->getLng();
$idLoc = $localisation->getCities()->getId();
$cities_proximite = $this->getDoctrine()->getRepository(Zipcode::class)->findCitiesByProximite($lat, $lng, $idLoc);
foreach ($cities_proximite as $city) {
if ($zip_pro = $this->getDoctrine()->getRepository(Zipcode::class)->find($city[0]->getId())) {
$zip_pro_id = $zip_pro->getId();
if ($total_results < 30) {
$orthos_proximite = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findByLocalisationId($city[0]->getId());
foreach ($orthos_proximite as $ortho_proximite) {
if (!in_array($ortho_proximite, $orthos) && $total_results < 30) {
$ortho_proximite->zip = $zip_pro->getZipcode();
$ortho_proximite->city = $zip_pro->getCity();
array_push($orthos, $ortho_proximite);
$total_results = count($orthos);
$limit = 30 - $total_results;
}
}
}
}
}
}
$datasFilters = array('ville' => $ville, 'zipcode' => $zipcode);
$arrondissement = false;
if ($ville == "paris" || $ville == "marseille" || $ville == "lyon") {
$arrondissement = " " . $this->dataProvider->getArrondissement($zipcode);
if ($ville != "paris")
$this->breadDatas['villeArrondissement'] = $ville;
}
$title_seo = "Orthophonistes à " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . $arrondissement . " (" . $zipcode . ")";
// Description seo //
if ($localisation) {
$ortho_title_seo = $localisation->getSpeechtherapistsTitleSeo();
$ortho_description_seo = html_entity_decode(strip_tags($localisation->getSpeechtherapistsDescriptionSeo()), ENT_QUOTES);
}
$canonical_url = $this->router->generate('results_ortho_audio_by_city', array(
'zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)
));
//$searchtype['exceptZipCode'] = $zipcode;
$this->setTemplateParameters(array('zipcode' => $zipcode));
$this->setTemplateParameters(array('ville' => $ville));
$centers_url = $this->router->generate('results_centres_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
$medecin_url = $this->router->generate('results_medecin_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
//$audio_url = $this->router->generate('results_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
} elseif ($departementCode) {
$depcode = $departementCode;
/************ Description seo **************/
$description_seo = "Orthophoniste " . $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ") : Trouvez un orthophoniste proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
// PREFOOTER
$searchtype['departementCode'] = $departementCode;
$searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
$localisation = $this->getDoctrine()->getRepository(Cities::class)->findOneBy(array('deptCode' => $departementCode));
$ville = $localisation->getVille();
$zipcode = $localisation->getZipCode();
//$departementTexte = $localisation->getDeptTxt();
$localisation = $this->getDoctrine()->getRepository(Cities::class)->findOneBy(array('deptCode' => $departementCode));
$checkDept = $this->slugify->slugify($localisation->getDeptTxt());
if ($checkDept != $departementTexte && ($departementTexte != 'lyon' && $departementTexte != 'paris' && $departementTexte != 'marseille')) {
return $this->redirectProvider->redirect301('results_ortho_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $checkDept));
}
$ville = $localisation->getVille();
$zipcode = $localisation->getZipCode();
// DEPARTEMENT ET COORDONNEES
$localisationId = $localisation->getId();
$lat = $localisation->getLat();
$lng = $localisation->getLng();
// BREADCRUMB
$this->breadDatas['type'] = 'dept';
$this->breadDatas['final'] = $localisation->getDeptTxt() . " (" . $departementCode . ")";
$this->breadDatas['final_url'] = $this->router->generate(
'results_ortho_by_departement',
array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte))
);
$search_location = $departementTexte;
$title_seo = "Orthophonistes " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getDeptTxt()) . " (" . $departementCode . ")";
// Recherche des Orthophonistes par departement
// TOUTES LES VILLES DU DEPARTEMENT
if ($departementTexte == 'lyon' || $departementTexte == 'paris' || $departementTexte == 'marseille') {
$this->breadDatas['type'] = 'city';
$title_seo = "Orthophonistes à " . $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ")";
$this->breadDatas['final'] = $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ")";
$citiesInDept = $this->getDoctrine()->getRepository(Zipcode::class)->findBy(['city' => $departementTexte]);
// BREADCRUMB SPECIFIQUE
switch ($departementTexte) {
case 'paris':
$this->breadDatas['departementTxt'] = 'Paris';
$this->breadDatas['departementCode'] = 75;
break;
case 'lyon':
$this->breadDatas['departementTxt'] = 'Rhône';
$this->breadDatas['departementCode'] = 69;
break;
case 'marseille':
$this->breadDatas['departementTxt'] = 'Bouches-du-Rhône';
$this->breadDatas['departementCode'] = 13;
break;
}
} else {
$citiesInDept = $this->getDoctrine()->getRepository(Zipcode::class)->findCitiesInDept($departementCode);
}
// TOUS LES DOCTEURS DE TOUTES LES VILLES
foreach ($citiesInDept as $city) {
$orthosincity = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findByLocalisationId($city->getId());
foreach ($orthosincity as $orthoincity) {
if (!in_array($orthoincity, $orthos)) {
$orthoincity->zip = $city->getZipcode();
$orthoincity->city = $city->getCity();
array_push($orthos, $orthoincity);
}
}
}
$datasFilters = array('departementCode' => $departementCode, 'departementTexte' => $departementTexte);
// Description seo //
//---- On cherche l'objet Map ayant le nom qui commence par depcode %
$maps = $this->getDoctrine()->getRepository(Maps::class)->findOneMapByDepCode($departementCode);
if ($maps && isset($maps[0])) {
$ortho_title_seo = $maps[0]->getSpeechtherapistsTitleSeo();
$ortho_description_seo = html_entity_decode(strip_tags($maps[0]->getSpeechtherapistsDescriptionSeo()), ENT_QUOTES);
}
$canonical_url = $this->router->generate('results_ortho_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $departementTexte));
$centers_url = $this->router->generate('results_centres_audio_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
$medecin_url = $this->router->generate('results_medecin_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
//$audio_url = $this->router->generate('results_audio_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
}
// Récupération des filtres exercices
$exercice_filters = $this->FiltersProvider->getOrthoExerciceFilters($orthos, $datasFilters);
// Récupération des filtres spécialisation
$specialisation_filters = $this->FiltersProvider->getOrthoSpecialisationFilters($orthos, $datasFilters);
$filtered = false;
// SI filtre par exercice
if ($exercice) {
foreach ($orthos as $ortho) {
if ($exercice == 'liberal') {
$cabinetF = $this->getDoctrine()->getRepository(PracticeSpeechTherapists::class)->findOneBy(['speechTherapists' => $ortho->getId()]);
if ($cabinetF)
$orthos_filtered[] = $ortho;
} else if ($exercice == 'hospitalier') {
$serviceF = $this->getDoctrine()->getRepository(ServiceSpeechTherapists::class)->findOneBy(['speechTherapistsId' => $ortho->getId()]);
if ($serviceF)
$orthos_filtered[] = $ortho;
}
}
$filtered = true;
}
if ($specialisation) {
foreach ($orthos as $ortho) {
$spesOrtho = $this->getSpecialisation($ortho);
foreach ($spesOrtho as $speOrtho) {
if ($this->slugify->slugify($speOrtho) == $specialisation) {
if (!in_array($ortho, $orthos_filtered)) {
$orthos_filtered[] = $ortho;
}
}
}
}
$filtered = true;
}
if ($filtered) {
$result = $this->cardProvider->getOrthoCards($orthos_filtered, true);
} else {
$result = $this->cardProvider->getOrthoCards($orthos, true);
}
$results_paginated = $paginator->paginate(
$result,
$request->query->getInt('page', 1),
30
);
$map = array();
foreach ($results_paginated as $result_paginated) {
if (array_key_exists('hospital', $result_paginated)) {
if ($marker = $this->geoProvider->getHospitalCoords($result_paginated['hospital'], $result_paginated['image'], 'Ortho', $result_paginated['ortho']->getTitle())) {
$map['markers'][] = $marker;
}
} else if (array_key_exists('practice', $result_paginated)) {
if ($marker = $this->geoProvider->getPracticeCoords($result_paginated['practice'], $result_paginated['image'], 'Ortho', $result_paginated['ortho']->getTitle())) {
$map['markers'][] = $marker;
}
}
}
$this->setTemplateParameters(array(
'searchresult' => array('orthophonists' => $results_paginated),
'filter' => array(
'exercice' => $exercice_filters,
'specialisation' => $specialisation_filters,
)
));
//$this->setTemplateParameters(array('search_location' => $search_location));
$deptForPreFooter = ($departementTexte == "paris" || $departementTexte == "marseille" || $departementTexte == "lyon") ? "à " . $departementTexte : "en " . $departementTexte;
/*$this->breadDatas['ville'] = $ville;
$this->breadDatas['zipcode'] = $zipcode;*/
$this->setBreadcrumb('orthophonistes', 'list');
// Maillage
$searchtype['lng'] = $lng;
$searchtype['lat'] = $lat;
$searchtype['localisationId'] = $localisation->getId();
$this->setInternalLinkage('orthoListe', $searchtype);
$this->setTemplateParameters(array('dept' => $deptForPreFooter));
$this->setTemplateParameters(array('map' => $map));
$this->setTemplateParameters(array('title_seo' => ($title_seo) ?? "Orthophonistes"));
$this->setTemplateParameters(array('description_seo' => $description_seo));
$this->setTemplateParameters(array('canonical_url' => $canonical_url));
$this->setTemplateParameters(array('seo_text' => array('title' => $ortho_title_seo, 'text' => $ortho_description_seo)));
$this->setPrevNextRel(count($result), $request->query->getInt('page'), $request->getSchemeAndHttpHost() . $request->getPathInfo());
$this->setTitleSearch();
$this->setTemplateParameters(array(
'centers_url' => $centers_url,
//'audio_url' =>$audio_url,
'medecin_url' => $medecin_url
));
return $this->renderTemplate('pages/annuaire_searchResults_Orthophonists.twig');
}
/**
* @Route("/orthophoniste/{ville}-{zipcode}/{nomortho}-{idortho}-practice-{idPractice}.html", name="page_orthophoniste_with_practice", requirements={"zipcode"="\d{5}", "nomortho"="[a-zA-Z0-9\-_\/]+", "ville"="[a-zA-Z0-9\-_\/]+", "idPractice"="[0-9]+"})
* @Route("/orthophoniste/{ville}-{zipcode}/{nomortho}-{idortho}-service-{idService}.html", name="page_orthophoniste_with_service", requirements={"zipcode"="\d{5}", "nomortho"="[a-zA-Z0-9\-_\/]+", "ville"="[a-zA-Z0-9\-_\/]+", "idPractice"="[0-9]+"})
* @Route("/orthophoniste/{ville}-{zipcode}/{nomortho}-{idortho}.html", name="page_orthophoniste", requirements={"zipcode"="\d{5}", "nomortho"="[a-zA-Z0-9\-_\/]+", "ville"="[a-zA-Z0-9\-_\/]+"})
* * @Route("/orthophoniste/{nomortho}-{idortho}.html", name="page_single_ortho_alone", requirements={"nomortho"="[a-zA-Z0-9\-_\/]+", "idortho"="[0-9]+"})
*
*/
public function renderPage($zipcode = null, $ville = null, $nomortho, $idortho, $idPractice = null, $idService = null, Request $request): Response
{
$team = [];
$page_provider = [];
$ortho = $this->getDoctrine()->getRepository(SpeechTherapist::class)->find($idortho);
if (!$ortho) {
if ($zipcode) {
return $this->redirectProvider->redirect301('results_ortho_audio_by_city', array('zipcode' => $zipcode, 'ville' => $ville));
} else {
return $this->redirectProvider->redirect301('liste_ortho');
}
}
$slugOrtho = $this->slugify->slugify($ortho->getFirstName() . '-' . $ortho->getName());
if ($slugOrtho != $nomortho) {
if ($idPractice) {
return $this->redirectProvider->redirect301('page_orthophoniste_with_practice', array('zipcode' => $zipcode, 'ville' => $ville, 'nomortho' => $slugOrtho, 'idortho' => $idortho, 'idPractice' => $idPractice));
} else if ($idService) {
return $this->redirectProvider->redirect301('page_orthophoniste_with_service', array('zipcode' => $zipcode, 'ville' => $ville, 'nomortho' => $slugOrtho, 'idortho' => $idortho, 'idService' => $idService));
} else {
return $this->redirectProvider->redirect301('page_single_ortho_alone', array('nomortho' => $slugOrtho, 'idortho' => $idortho));
}
}
$alone = false;
if (!$idPractice && !$idService) {
$alone = true;
}
// Centres à proximités du cabinet //
// On teste s'il y a un cabinet en paramètre, sinon on récupère le premier cabinet dans la requête.
$centre_proximite = [];
$cabinet = $service = null;
if ($idPractice) {
$cabinet = $this->getDoctrine()->getRepository(Practices::class)->find($idPractice);
if (!$cabinet) {
return $this->redirectProvider->redirect301('page_single_ortho_alone', array('nomortho' => $slugOrtho, 'idortho' => $idortho));
}
} else if ($idService) {
$service = $this->getDoctrine()->getRepository(Services::class)->find($idService);
if (!$service) {
return $this->redirectProvider->redirect301('page_single_ortho_alone', array('nomortho' => $slugOrtho, 'idortho' => $idortho));
}
}
/*else {
// On récupère le premier Cabinet dans le requête pour s'enservir de ces adresses etc...
$cabinet = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findPracticeByOrthoID($idortho, null, 1);
$cabinet = ($cabinet)? $cabinet[0] : NULL;
}*/
// Les autres cabinets
$buttons = [];
$practices = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findPracticeByOrthoID($idortho);
$i = 1;
$idspractices = array();
foreach ($practices as $practice) {
$zipcodeCheck = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['id' => $practice->getLocalisation()->getId()]);
if ($zipcodeCheck) {
if ($alone) {
$url = $this->router->generate(
'page_orthophoniste_with_practice',
array(
'zipcode' => trim($practice->getLocalisation()->getZipcode()),
'nomortho' => $slugOrtho,
'idortho' => $idortho,
'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
'idPractice' => $practice->getId()
)
);
return $this->redirect($url, 301);
}
$current = ($practice->getId() == $idPractice) ? true : false;
$idspractices[] = $practice->getId();
array_push($buttons, array(
"title" => "Cabinet " . $i,
"url" => "/orthophoniste/" . $this->slugify->slugify($practice->getLocalisation()->getCity()) . "-" . trim($practice->getLocalisation()->getZipcode()) . "/" . $slugOrtho . '-' . $idortho . "-practice-" . $practice->getId() . ".html",
"current" => $current,
));
$i++;
if ($current) {
if ($zipcode != trim($practice->getLocalisation()->getZipcode())) {
return $this->redirectProvider->redirect301(
'page_orthophoniste_with_practice',
array(
'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
'zipcode' => trim($practice->getLocalisation()->getZipcode()),
'nomortho' => $nomortho,
'idortho' => $idortho,
'idPractice' => $idPractice
)
);
}
// Infos Cabinet
$adresse = $cabinet->getAddress() . " \n";
if ($cabinet->getAdditionalAddress()) {
$adresse .= $cabinet->getAdditionalAddress() . " \n";
}
$adresse .= $cabinet->getLocalisation()->getZipcode() . ' ' . $cabinet->getLocalisation()->getCity() . " \n";
if ($cabinet->getPoBox()) {
$adresse .= $cabinet->getPoBox() . " \n";
}
if ($cabinet->getZipCedex()) {
$adresse .= $cabinet->getZipCedex() . " ";
}
if ($cabinet->getCityCedex()) {
$adresse .= $cabinet->getCityCedex();
}
$cabinet_ortho = $this->getDoctrine()->getRepository(PracticeSpeechTherapists::class)->findOneBy(['speechTherapists' => $ortho->getId(), 'practiceId' => $idPractice]);
$tel1 = ($cabinet_ortho && $cabinet_ortho->getPhone()) ? $cabinet_ortho->getPhone() : $cabinet->getPhone();
$page_provider = array(
"coords" => array(
"items" => array(
"tel1" => $tel1,
"address" => $cabinet->getAddress() . " \n" . $cabinet->getAdditionalAddress(),
"zip" => trim($cabinet->getLocalisation()->getZipcode()),
"city" => $cabinet->getLocalisation()->getCity(),
"bp" => $cabinet->getPoBox(),
"zipcedex" => $cabinet->getZipCedex(),
"citycedex" => $cabinet->getCityCedex()
),
"coordTitle" => $practice->getName()
)
);
}
}
}
if ($idPractice && !in_array($idPractice, $idspractices)) {
$zipcodeCheckCurrent = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['id' => $idPractice]);
if (!$zipcodeCheckCurrent) {
return $this->redirectProvider->redirect301('page_single_ortho_alone', array('nomortho' => $slugOrtho, 'idortho' => $idortho));
}
}
// Les autres services
$services = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findServiceByOrthoID($idortho);
$idsservices = array();
$j = 1;
foreach ($services as $serv) {
if ($alone) {
$url = $this->router->generate(
'page_orthophoniste_with_service',
array(
'zipcode' => rtrim($serv->getHospital()->getLocalisation()->getZipcode()),
'nomortho' => $slugOrtho,
'idortho' => $idortho,
'ville' => $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()),
'idService' => $serv->getId()
)
);
return $this->redirect($url, 301);
}
$idservice = $serv->getId();
$idsservices[] = $idservice;
$current = ($idservice == $idService) ? true : false;
array_push($buttons, array(
"title" => "Service ORL " . $j,
"url" => "/orthophoniste/" . $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()) . "-" . trim($serv->getHospital()->getLocalisation()->getZipcode()) . "/" . $slugOrtho . '-' . $idortho . "-service-" . $idservice . ".html",
"current" => $current,
));
$j++;
if ($current) {
if ($zipcode != trim($serv->getHospital()->getLocalisation()->getZipcode())) {
return $this->redirectProvider->redirect301(
'page_orthophoniste_with_service',
array(
'ville' => $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()),
'zipcode' => rtrim($serv->getHospital()->getLocalisation()->getZipcode()),
'nomortho' => $nomortho,
'idortho' => $idortho,
'idService' => $idService
)
);
}
$page_provider = array(
"coords" => array(
"items" => array(
"address" => $serv->getHospital()->getAddress() . " \n" . $serv->getHospital()->getAdditionalAddress(),
"zip" => $serv->getHospital()->getLocalisation()->getZipcode(),
"city" => $serv->getHospital()->getLocalisation()->getCity(),
"bp" => $serv->getHospital()->getPoBox(),
"zipcedex" => $serv->getHospital()->getCedex(),
"citycedex" => $serv->getHospital()->getCityCedex()
),
"coordTitle" => $serv->getHospital()->getCorporateName(),
'subtitleORLService' => $serv->getName(),
'link' => $url = $this->router->generate(
'page_service_hospitalier_avec_service',
array(
'ville' => $ville,
'zipcode' => $zipcode,
'nomhopital' => $this->slugify->slugify($serv->getHospital()->getCorporateName()),
'idhopital' => $serv->getHospital()->getId(),
'nomservice' => $this->slugify->slugify($serv->getName()),
'idservice' => $serv->getId(),
)
)
)
);
for ($i = 1; $i <= 3; $i++) {
$tel = $serv->{'getTitle' . $i}();
if (!empty($tel))
$tel .= "\n";
$tel .= $serv->{'getDescription' . $i}();
$page_provider['coords']['items']['tel' . $i] = $tel;
}
}
}
if ($idService && !in_array($idService, $idsservices)) {
return $this->redirectProvider->redirect301('page_single_ortho_alone', array('nomortho' => $slugOrtho, 'idortho' => $idortho));
}
// Logo //
$logo = $this->dataProvider->getAvatar('Ortho', $ortho->getTitle());
if ($logoId = $this->getDoctrine()->getRepository(Image::class)->findOneBy(['class' => 'SpeechTherapist', 'entityId' => $idortho, 'cover' => 1])) {
$file = $this->bo_url . "images/" . $logoId->getId() . "-medium.jpg";
if (@fopen($file, "r")) {
$logo = $file;
}
}
if (!$alone) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findByZipCodeAndCityLike($zipcode, $ville);
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['zipcode' => $zipcode]);
}
if ($zipcode != trim($localisation->getZipcode()) || $ville != $this->slugify->slugify($localisation->getCity())) {
return $this->redirectProvider->redirect301('page_single_ortho_alone', array('nomortho' => $nomortho, 'idortho' => $idortho));
}
if (!$localisation) {
throw new NotFoundHttpException();
}
$cities = $localisation->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
$slugVille = $this->slugify->slugify($localisation->getCity());
if ($cabinet || $service) {
$object = ($cabinet) ? $cabinet : $service;
$idObject = $object->getId();
// Coordonnées de localisation
if ($service)
$geocode = $this->dataProvider->getGeoCode($service->getHospital());
else
$geocode = $this->dataProvider->getGeoCode($object);
$lat = $geocode['lat'];
$lng = $geocode['lng'];
$idLoc = $geocode['idLoc'];
$centersCity = $this->getDoctrine()->getRepository(Centers::class)->findBy([
'localisation' => $localisation->getId(),
'advertiser' => 1,
'visible' => 1
]);
shuffle($centersCity);
foreach ($centersCity as $c) {
array_push($centre_proximite, $c);
}
$centersRelated = $this->getDoctrine()->getRepository(CenterZipcode::class)->findBy(['zipcodeId' => $localisation->getId()]);
shuffle($centersRelated);
foreach ($centersRelated as $c) {
$cr = $this->getDoctrine()->getRepository(Centers::class)->findOneBy([
'id' => $c->getCenterId(),
'advertiser' => 1,
'visible' => 1
]);
if ($cr) {
array_push($centre_proximite, $cr);
}
}
if (sizeof($centre_proximite) < 6) {
$limit = 6 - sizeof($centre_proximite);
$proximites = $this->getDoctrine()->getRepository(Centers::class)->findCentersByProximiteCity(array('lat' => $lat, 'lng' => $lng), $localisation->getId(), $limit);
shuffle($proximites);
foreach ($proximites as $proximite) {
$centerPro = $this->getDoctrine()->getRepository(Centers::class)->findOneBy([
'id' => $proximite[0]->getId(),
'visible' => 1
]);
if ($centerPro && !in_array($centerPro, $centre_proximite)) {
array_push($centre_proximite, $centerPro);
}
}
}
/*$centersRelated = $this->getDoctrine()->getRepository(CenterZipcode::class)->findBy(['zipcodeId'=>$localisation->getId()]);
foreach($centersRelated as $centerRelated) {
$cr = $this->getDoctrine()->getRepository(Centers::class)->findOneBy(['id'=>$centerRelated->getCenterId(), 'advertiser'=>1]);
if($cr) {
array_push($centre_proximite, $cr);
}
if (sizeof($centre_proximite) >= 6) break;
}
if (sizeof($centre_proximite) < 6) {
$centersCity = $this->getDoctrine()->getRepository(Centers::class)->findBy(['localisation'=>$localisation->getId(), 'advertiser'=>1]);
foreach ($centersCity as $c) {
array_push($centre_proximite, $c);
if (sizeof($centre_proximite) >= 6) break;
}
}
if (sizeof($centre_proximite) < 6) {
$proximites = $this->getDoctrine()->getRepository(Geocode::class)->findEntitiesByProximite('Centers', array('lat'=>$lat, 'lng'=>$lng), 100);
foreach($proximites as $proximite) {
$centerPro = $this->getDoctrine()->getRepository(Centers::class)->findOneBy(['id'=>$proximite[0]->getId(), 'advertiser'=>1]);
if($centerPro && !in_array($centerPro, $centre_proximite)) {
array_push($centre_proximite, $centerPro);
if (sizeof($centre_proximite) >= 6) break;
}
}
}
shuffle($centre_proximite);*/
$centre_proximite = $this->cardProvider->getCenterCards($centre_proximite);
$team = null;
// On cherche les autres Orthophonistes du même cabinet //
if ($cabinet)
$otherOrthos = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findByPractice($cabinet->getId(), $idortho);
elseif ($service)
$otherOrthos = $this->getDoctrine()->getRepository(SpeechTherapist::class)->findByService($service->getId(), $idortho);
if ($otherOrthos) {
foreach ($otherOrthos as $otherOrtho) {
$otherOrtho->zip = $zipcode;
$otherOrtho->city = $ville;
$otherOrtho->specialisation = $this->getSpecialisation($otherOrtho);
}
$team = $this->cardProvider->getOrthoCards($otherOrthos, false);
}
}
$searchtype['lat'] = $lat;
$searchtype['lng'] = $lng;
$searchtype['currentCityId'] = $idLoc;
$this->setInternalLinkage('orthoPage', $searchtype);
$this->setTemplateParameters(array('city' => ($localisation) ? $localisation->getCity() : null));
$dep = $localisation->getDepartment();
$departementTxt = $localisation->getCities()->getDeptTxt();
$departementCode = $localisation->getCities()->getDeptCode();
$map['markers'][] = array(
"lat" => $lat,
"lon" => $lng,
"premium" => true,
"src" => "url(" . $logo . ")"
);
$this->breadDatas['ville'] = $localisation->getCity();
$this->breadDatas['zipcode'] = $localisation->getZipcode();
$this->breadDatas['departementTxt'] = $departementTxt;
$this->breadDatas['departementCode'] = $departementCode;
$this->setTemplateParameters(array('map' => $map));
} else {
$this->setInternalLinkage('orthoListe');
}
// Header //
$header = array(
"image" => $logo,
"name" => $ortho->getFirstName(),
"surname" => $ortho->getName(),
"job" => "Orthophoniste",
);
// Spécialisation //
$specialization = $this->getSpecialisation($ortho);
$centers_url = $this->router->generate('results_centres_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
//$audio_url = $this->router->generate('results_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
$medecin_url = $this->router->generate('results_medecin_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
$this->setTemplateParameters(array(
"page_orthophonist" => array(
"header" => $header,
"centers" => $centre_proximite,
"team" => $team,
"specialization" => $specialization,
"lieuType" => ($service) ? 'service ORL' : 'cabinet',
),
'search' => array(
'filter' => $buttons,
),
"page_provider" => $page_provider,
));
// Breadcrumb
$this->breadDatas['final'] = $ortho->getFirstName() . ' ' . $ortho->getName();
$title_seo = $ortho->getFirstName() . ' ' . $ortho->getName() . ' - Orthophoniste';
if ($ville) {
$title_seo .= ' à ' . $this->dataProvider->wordUpperCaseFirstLetter($ville) . ' (' . $zipcode . ')';
}
/************* Description seo ****************/
$description_seo = "Prenez rendez-vous avec " . $ortho->getFirstName() . " " . $ortho->getName() . ", orthophoniste à " . $this->dataProvider->wordUpperCaseFirstLetter($ville) . " (" . $zipcode . "). Consultez ses coordonnées et son adresse sur l'Annuaire de l'Audition.";
$this->setTemplateParameters(array('title_seo' => $title_seo));
$this->setTemplateParameters(array('description_seo' => $description_seo));
$this->setBreadcrumb('orthophonistes', 'single');
$this->setTemplateParameters(array('dataLayerCenters' => $centre_proximite, 'creative' => 'fiche-orthophoniste'));
$this->setTemplateParameters(array(
'centers_url' => $centers_url,
//'audio_url' =>$audio_url,
'medecin_url' => $medecin_url
));
if ($idPractice) $this->setTemplateParameters(array('idPractice' => $idPractice));
if ($idService) $this->setTemplateParameters(array('idService' => $idService));
if ($idPractice || $idService) {
$id_entity = $idPractice ?? $idService;
$entity = $idPractice ? 'practice' : 'service';
// on cherche le cache des parkings
if (file_exists('overpass/parkings/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/parkings/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
$parkings = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "parkings",
'parkings' => (array)$data
));
$this->setTemplateParameters(array('parkings' => $parkings));
}
$transport_communs = [];
// on cherche le cache des bus
if (file_exists('overpass/buses/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/buses/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
if ($data) {
$transport_communs['buses'] = $data;
}
$buses = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "transport",
'subtype' => "buses",
'buses' => (array)$data
));
$this->setTemplateParameters(array('buses' => $buses));
}
// on cherche le cache des métros/trains
if (file_exists('overpass/subways/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/subways/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
if ($data) {
$transport_communs['subways'] = $data;
}
$subways = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "transport",
'subtype' => "subways",
'subways' => (array)$data
));
$this->setTemplateParameters(array('subways' => $subways));
}
// on cherche le cache des trams.
if (file_exists('overpass/trams/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json')) {
$data = json_decode(file_get_contents('overpass/trams/' . $entity . '/' . $entity . '-' . intval($id_entity) . '.json'));
if ($data) {
$transport_communs['trams'] = $data;
}
$trams = $this->renderView('modules/map/nearby.html.twig', array(
'type' => "transport",
'subtype' => "trams",
'trams' => (array)$data
));
$this->setTemplateParameters(array('trams' => $trams));
}
}
// FAQ //
$faqs = [];
$nomortho = $ortho->getTitle() . ' ' . $ortho->getFirstName() . ' ' . $ortho->getName();
$entity = $cabinet;
if (!$cabinet && $service && $service->getHospital()) $entity = $service->getHospital();
if ($entity) {
$address = $entity->getAddress();
if ($entity->getLocalisation() && $entity->getLocalisation()->getId()) {
$address .= " " . $entity->getLocalisation()->getZipcode() . " " . $entity->getLocalisation()->getCity();
}
$faqs[] = [
"question" => "Quelle est l'adresse" . ($ortho->getTitle() == "Mme" ? " de " : " du ") . $nomortho . " ?",
"response" => "L'adresse" . ($ortho->getTitle() == "Mme" ? " de " : " du ") . $nomortho . " est " . $address
];
$phone = $entity->getPhone();
if ($phone) {
$faqs[] = [
"question" => "Comment contacter " . $nomortho . " ?",
"response" => "Il est possible de contacter " . $nomortho . " par téléphone au " . $phone . "."
];
}
}
//$placename = $cabinet ? $entity->getName() : $entity->getCorporateName();
$placeType = $cabinet ? "cabinet" : "service";
if ($otherOrthos) {
$suffix = sizeof($otherOrthos) > 1 ? "s" : "";
$suffix_ENT = sizeof($otherOrthos) > 1 ? "nt" : "";
$placeAddress = " " . $entity->getAddress();
if ($entity->getLocalisation() && $entity->getLocalisation()->getId()) {
$placeAddress .= " " . $entity->getLocalisation()->getZipcode() . " " . $entity->getLocalisation()->getCity();
}
$response_txt = "";
foreach ($otherOrthos as $doc) {
$response_txt .= "<li>" . $doc->getTitle() . " " . $doc->getFirstName() . " " . $doc->getName() . "</li>";
}
$faqs[] = [
"question" => "Quels sont les autres orthophonistes du " . $placeType . ($ortho->getTitle() == "Mme" ? " de " : " du ") . $nomortho . " ?",
"response" => sizeof($otherOrthos) . " autre" . $suffix . " orthophoniste" . $suffix . " exerce" . $suffix_ENT . " également dans le " . $placeType . ($ortho->getTitle() == "Mme" ? " de " : " du ") . $nomortho . " :<ul>" . $response_txt . "</ul>"
];
}
if ($transport_communs) {
$response_txt = "<ul>";
foreach ($transport_communs as $type => $tc) {
$type = $type == 'buses' ? 'Bus - ' : ($type == 'subways' ? 'Métro - ' : 'Tram - ');
foreach ($tc as $value) {
$response_txt .= "<li>" . $type . $value->name . "</li>";
}
}
$response_txt .= "</ul>";
$faqs[] = [
"question" => "Comment accéder au " . $placeType . ($ortho->getTitle() == "Mme" ? " de " : " du ") . $nomortho . " par les transports en commun ?",
"response" => "Le " . $placeType . ($ortho->getTitle() == "Mme" ? " de " : " du ") . $nomortho . " est situé à proximité des arrêts suivants :<ul>" . $response_txt . "</ul>"
];
}
$this->setTemplateParameters(array('faqs' => $faqs));
return $this->renderTemplate('pages/annuaire_page_Orthophonist.twig');
}
public function getSpecialisation(SpeechTherapist $ortho)
{
$result = [];
$specialites = array(
'Aphasie', 'Articulation', 'Apprentissage de la voix', 'Apprentissage de la voix oesophagienne', 'Autisme', 'Bégaiement', 'Déglutition primaire', 'Démutisation', 'Division palatine', 'Dysarthrie',
'Dyscalculie', 'Dyslexie', 'Dysorthographie', 'Dysphagie', 'Dysphasie', 'Laryngectomie', 'Lecture labiale', 'Prise en charge maladie neuro-végétatives', 'Rééducation tubaire', 'Surdité', 'Trisomie', 'Trouble de la parole et du langage', 'Trouble de la voix', 'Trouble neuro-visuels', 'Rééducation à domicile', 'Rééducation langues étrangères'
);
for ($i = 0; $i <= 25; $i++) {
if ($ortho->{'getAdvertisers' . $i}() == 1) {
if ($i == 25 && !empty($ortho->getAdvertisers25Text()))
$result[] = $specialites[$i] . " (" . $ortho->getAdvertisers25Text() . ")";
else {
$result[] = $specialites[$i];
}
}
}
if (!empty($ortho->getSpecialtyIfAdvertisers()))
$result[] = $ortho->getSpecialtyIfAdvertisers();
return $result;
}
}