<?php
namespace App\Controller;
use App\Entity\CenterZipcode;
use App\Entity\Centers;
use App\Entity\Cities;
use App\Entity\Doctors;
use App\Entity\EventsCategory;
use App\Entity\Geocode;
use App\Entity\Hospitals;
use App\Entity\Image;
use App\Entity\Lookup;
use App\Entity\Maps;
use App\Entity\ServiceDoctors;
use App\Entity\Services;
use App\Entity\Zipcode;
use App\Repository\DoctorsRepository;
use App\Repository\ServicesRepository;
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 ServiceorlController extends AbstractController
{
/**
* @Route("/service-hospitalier-orl/{id}", name="redirect_id_hopital", requirements={"id"="\d+"})
*/
public function redirectIdOnly($id)
{
$hopital = $this->getDoctrine()->getRepository(Hospitals::class)->find($id);
if ($hopital && ($hopital->getLocalisation()->getCountry() == "FRANCE" || $hopital->getLocalisation()->getCountry() == "")) {
$url = $this->router->generate(
'page_service_hospitalier',
array('ville' => $this->slugify->slugify($hopital->getLocalisation()->getCity()), 'zipcode' => $hopital->getLocalisation()->getZipcode(), 'nomhopital' => $this->slugify->slugify($hopital->getCorporateName()), 'idhopital' => $id)
);
} else {
$url = $this->router->generate(
'liste_service'
);
}
return $this->redirect($url, 301);
}
/**
* @Route("/service-hospitalier-orl/page/{page}", name="redirect_page_service")
*/
public function redirectPage($page = null)
{
if ($page) {
$url = $this->router->generate(
'liste_service'
);
}
return $this->redirect($url, 301);
}
/**
* @Route("/service-hospitalier-orl", name="liste_service")
*/
public function renderDefault(): Response
{
$this->setTemplateParameters(array('title_seo' => 'Services ORL'));
$this->setInternalLinkage('serviceListe');
return $this->renderTemplate('pages/annuaire_search_ORLServices.twig');
}
/**
* @Route("/service-hospitalier-orl-{zipcode}-{ville}.html", name="results_service_audio_by_city", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/service-hospitalier-orl-{zipcode}-{ville}/filtre-resultats/implantcochleaire-{implant}.html", name="results_service_by_city_filter_implant", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/service-hospitalier-orl-{zipcode}-{ville}/filtre-resultats/centre-pour-laryngectomise-{laryng}.html", name="results_service_by_city_filter_laryng", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
* @Route("/service-hospitalier-orl-{departementCode}-{departementTexte}.html", name="results_service_by_departement", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/service-hospitalier-orl-{departementCode}-{departementTexte}/filtre-resultats/implantcochleaire-{implant}.html", name="results_service_by_departement_filter_implant", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
* @Route("/service-hospitalier-orl-{departementCode}-{departementTexte}/filtre-resultats/centre-pour-laryngectomise-{laryng}.html", name="results_service_by_departement_filter_laryng", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
*
*/
public function renderList($zipcode = null, $ville = null, $departementCode = null, $departementTexte = null, $implant = null, $laryng = null, Request $request, PaginatorInterface $paginator): Response
{
$result = [];
$searchtype = [];
$search_by = null;
$hospitals = array();
$hospitals_filtered = array();
$service_title_seo = $service_description_seo = null;
if ($zipcode) {
/************* Description seo ****************/
$description_seo = "Services ORL à " . $this->dataProvider->wordUpperCaseFirstLetter($ville) . " (" . $zipcode . ") : Trouvez un service ORL 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)->findByZipCodeAndCityLike($zipcode, $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)->findOneBy(['zipcode' => $zipcode]);
}
if (!$localisation) {
throw new NotFoundHttpException();
}
if ($ville != $this->slugify->slugify($localisation->getCity())) {
return $this->redirectProvider->redirect301('results_service_audio_by_city', array('ville' => $this->slugify->slugify($localisation->getCity()), 'zipcode' => $zipcode));
}
$departementTexte = "";
$cities = $localisation->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
if (!empty($localisation->getCities())) {
$departementTexte = $localisation->getCities()->getDeptTxt();
$depcode = $localisation->getCities()->getDeptcode();
} else {
$dep = $localisation->getDepartment();
$departementTexte = substr($dep, 7);
$depcode = substr($dep, 0, 2);
}
// PREFOOTER
$searchtype['departementCode'] = $depcode;
$searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
$searchtype['zipcode'] = $zipcode;
$searchtype['ville'] = $ville;
// BREADCRUMB
$this->breadDatas['type'] = 'city';
$this->breadDatas['final'] = $localisation->getCity() . " (" . $zipcode . ")";
$this->breadDatas['final_url'] = $this->router->generate(
'results_service_audio_by_city',
array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville))
);
$this->breadDatas['departementTxt'] = $departementTexte;
$this->breadDatas['departementCode'] = $depcode;
$hospitals = $this->getDoctrine()->getRepository(Hospitals::class)->findByLocalisationId($localisation->getId());
$total_results = count($hospitals);
$limit = 30 - $total_results;
if ($total_results < 30) {
$hospitals_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) {
$hospitals_proximite = $this->getDoctrine()->getRepository(Hospitals::class)->findByLocalisationId($city[0]->getId());
foreach ($hospitals_proximite as $hospital_proximite) {
if (!in_array($hospital_proximite, $hospitals) && $total_results < 30) {
$hospital_proximite->zip_pro = $zip_pro->getZipcode();
$hospital_proximite->zip_pro = $zip_pro->getCity();
array_push($hospitals, $hospital_proximite);
$total_results = count($hospitals);
$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 = "Hôpitaux à " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . $arrondissement . " (" . $zipcode . ") - Services ORL";
// Description seo //
if ($localisation) {
$service_title_seo = $localisation->getServicesTitleSeo();
$service_description_seo = html_entity_decode(strip_tags($localisation->getServicesDescriptionSeo()), ENT_QUOTES);
}
$canonical_url = $this->router->generate('results_service_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
//$searchtype['exceptZipCode'] = $zipcode;
$this->setTemplateParameters(array('zipcode' => $zipcode));
$this->setTemplateParameters(array('ville' => $ville));
} elseif ($departementCode) {
/************* Description seo ****************/
$description_seo = "Services ORL " . $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ") : Trouvez un service ORL proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
$search_by = 'depcode';
$localisation = $this->getDoctrine()->getRepository(Cities::class)->findOneBy(array('deptCode' => $departementCode));
$ville = $localisation->getVille();
$zipcode = $localisation->getZipCode();
$depcode = $localisation->getDeptcode();
$checkDept = $this->slugify->slugify($localisation->getDeptTxt());
if ($checkDept != $departementTexte && ($departementTexte != 'lyon' && $departementTexte != 'paris' && $departementTexte != 'marseille')) {
return $this->redirectProvider->redirect301('results_service_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $checkDept));
}
//$departementTexte = $localisation->getDeptTxt();
$hospitals = array();
// PREFOOTER
$searchtype['departementCode'] = $departementCode;
$searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
// BREADCRUMB
$this->breadDatas['type'] = 'dept';
$this->breadDatas['final'] = $localisation->getDeptTxt() . " (" . $departementCode . ")";
$this->breadDatas['final_url'] = $this->router->generate(
'results_service_by_departement',
array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte))
);
$title_seo = "Hôpitaux " . $this->dataProvider->wordUpperCaseFirstLetter($localisation->getDeptTxt()) . " (" . $departementCode . ") - Service ORL";
// TOUTES LES VILLES DU DEPARTEMENT
if ($departementTexte == 'lyon' || $departementTexte == 'paris' || $departementTexte == 'marseille') {
$this->breadDatas['type'] = 'city';
$title_seo = "Hôpitaux à " . $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" . $departementCode . ") - Service ORL";
$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) {
$hospitalsincity = $this->getDoctrine()->getRepository(Hospitals::class)->findByLocalisationId($city->getId());
foreach ($hospitalsincity as $hospitalincity) {
if (!in_array($hospitalincity, $hospitals)) {
$hospitalincity->zip_pro = $city->getZipcode();
$hospitalincity->city_pro = $city->getCity();
array_push($hospitals, $hospitalincity);
}
}
}
$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])) {
$service_title_seo = $maps[0]->getServicesTitleSeo();
$service_description_seo = html_entity_decode(strip_tags($maps[0]->getServicesDescriptionSeo()), ENT_QUOTES);
}
$canonical_url = $this->router->generate('results_service_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
}
// Récupération des filtres implants
$implant_filters = $this->FiltersProvider->getServiceImplantFilters($hospitals, $datasFilters);
// Récupération des filtres Laryngtomisé
$laryng_filters = $this->FiltersProvider->getServiceLaryngFilters($hospitals, $datasFilters);
$filtered = false;
// SI filtre par implant
if ($implant) {
foreach ($hospitals as $hospital) {
$services = $this->getDoctrine()->getRepository(Services::class)->findBy(['hospital' => $hospital->getId()]);
foreach ($services as $service) {
if (($service->getCochlearImplant() && $implant == "oui") || (!$service->getCochlearImplant() && $implant == "non")) {
if (!in_array($hospital, $hospitals_filtered)) {
$hospitals_filtered[] = $hospital;
}
}
}
}
$filtered = true;
}
// SI filtre par laryng
if ($laryng) {
foreach ($hospitals as $hospital) {
if (($hospital->getCenterForLaryngectomy() && $laryng == "oui") || (!$hospital->getCenterForLaryngectomy() && $laryng == "non")) {
$hospitals_filtered[] = $hospital;
}
}
$filtered = true;
}
if ($filtered) {
$result = $this->cardProvider->getHospitalCards($hospitals_filtered);
} else {
$result = $this->cardProvider->getHospitalCards($hospitals);
}
$results_paginated = $paginator->paginate(
$result,
$request->query->getInt('page', 1),
30
);
$map = array();
foreach ($results_paginated as $result_paginated) {
if ($marker = $this->geoProvider->getHospitalCoords($result_paginated['hospital'], $result_paginated['img_src'], 'ServiceOrl')) {
$map['markers'][] = $marker;
}
}
if ($search_by == 'zipcode') :
$location['text'] = $ville;
$location['code'] = $zipcode;
else :
$location['text'] = $departementTexte;
$location['code'] = $depcode;
endif;
$this->setTemplateParameters(array(
'searchresult' => array(
'services' => $results_paginated,
'location' => $location,
),
'filter' => array(
'implant' => $implant_filters,
'laryng' => $laryng_filters,
)
));
// Breadcrumb //
$this->breadDatas['departementTexte'] = $departementTexte;
$this->breadDatas['departementCode'] = $depcode;
$this->setBreadcrumb('services', 'list');
$deptForPreFooter = ($departementTexte == "paris" || $ville == "paris" || $departementTexte == "marseille" || $ville == "marseille" || $departementTexte == "lyon" || $ville == "lyon") ? "à " . $departementTexte : "en " . $departementTexte;
$this->setTemplateParameters(array('dept' => $deptForPreFooter));
$this->setTitleSearch();
$this->setTemplateParameters(array('map' => $map));
$this->setInternalLinkage('serviceListe', $searchtype);
$this->setTemplateParameters(array('title_seo' => ($title_seo) ?? 'Service ORL'));
$this->setTemplateParameters(array('description_seo' => $description_seo));
$this->setTemplateParameters(array('canonical_url' => $canonical_url));
$this->setTemplateParameters(array('seo_text' => array('title' => $service_title_seo, 'text' => $service_description_seo)));
$this->setPrevNextRel(count($result), $request->query->getInt('page'), $request->getSchemeAndHttpHost() . $request->getPathInfo());
return $this->renderTemplate('pages/annuaire_searchResults_ORLServices.twig');
}
/**
* @Route("/service-hospitalier-orl/{ville}-{zipcode}/{nomhopital}-{idhopital}/{nomservice}-{idservice}.html", name="page_service_hospitalier_avec_service", requirements={"zipcode"="\d{5}", "ville"="[a-zA-Z0-9\-_\/]+", "nomhopital"="[a-zA-Z0-9\-_\/]+", "nomservice"="[a-zA-Z0-9\-_\/]+"})
* @Route("/service-hospitalier-orl/{ville}-{zipcode}/{nomhopital}-{idhopital}.html", name="page_service_hospitalier", requirements={"ville"="[a-zA-Z0-9\-_\/]+", "nomhopital"="[a-zA-Z0-9\-_\/]+"})
*
*/
public function renderPage(
$ville,
$zipcode,
$idhopital,
$nomhopital = null,
$nomservice = null,
$idservice = null,
ServicesRepository $servicesRepository
) {
$lat = "";
$lng = "";
$nom_service = "";
$hospital = $this->getDoctrine()->getRepository(Hospitals::class)->find($idhopital);
if (!$hospital) {
return $this->redirectProvider->redirect301('results_service_audio_by_city', array(
'zipcode' => $zipcode,
'ville' => $ville
));
}
if ($hospital) {
// Si aucun service passé en paramètre, alors dans ce cas on récupère le premier service lié dans la BD
if (!$idservice) {
$service = $this->getDoctrine()->getRepository(Services::class)->findOneBy(['hospital' => $idhopital]);
if ($service) {
return $this->redirectProvider->redirect301('page_service_hospitalier_avec_service', array('ville' => $ville, 'zipcode' => $zipcode, 'nomhopital' => $nomhopital, 'idhopital' => $idhopital, 'nomservice' => $this->slugify->slugify($service->getName()), 'idservice' => $service->getId()));
} else {
return $this->redirectProvider->redirect301('results_service_audio_by_city', array(
'zipcode' => $zipcode,
'ville' => $ville
));
}
} else {
$service = $this->getDoctrine()->getRepository(Services::class)->find($idservice);
if (!$service) {
return $this->redirectProvider->redirect301('page_service_hospitalier', array('ville' => $ville, 'zipcode' => $zipcode, 'nomhopital' => $nomhopital, 'idhopital' => $idhopital));
}
}
$slugCheck = $this->slugify->slugify($hospital->getCorporateName());
if ($slugCheck != $nomhopital) {
return $this->redirectProvider->redirect301('page_service_hospitalier_avec_service', array('ville' => $ville, 'zipcode' => $zipcode, 'nomhopital' => $slugCheck, 'idhopital' => $idhopital, 'nomservice' => $nomservice, 'idservice' => $idservice));
}
$slugCheckService = $this->slugify->slugify($service->getName());
if ($slugCheckService != $nomservice) {
return $this->redirectProvider->redirect301('page_service_hospitalier_avec_service', array('ville' => $ville, 'zipcode' => $zipcode, 'nomhopital' => $nomhopital, 'idhopital' => $idhopital, 'nomservice' => $slugCheckService, 'idservice' => $idservice));
}
$localisation = null;
if ($hospital->getLocalisation()) {
$localisation = $hospital->getLocalisation();
}
if (!$localisation) {
$localisation = $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array('zipcode' => $zipcode));
}
if (!$localisation) {
throw new NotFoundHttpException();
}
if ($zipcode != $localisation->getZipcode() || $ville != $this->slugify->slugify($localisation->getCity())) {
preg_match('/^[0-9]{5}/', $localisation->getZipcode(), $matches);
if ($matches) {
return $this->redirectProvider->redirect301('page_service_hospitalier_avec_service', array(
'ville' => $this->slugify->slugify($localisation->getCity()),
'zipcode' => $localisation->getZipcode(),
'nomhopital' => $nomhopital,
'idhopital' => $idhopital,
'nomservice' => $nomservice,
'idservice' => $idservice
));
}
}
//Geolocalisation
$cities = $localisation->getCities();
if (!$cities) {
$cities = $this->geoProvider->addCities($ville, $zipcode, $localisation);
}
if ($geocode = $this->getDoctrine()->getRepository(Geocode::class)->findOneBy(['class' => 'Hospitals', 'id' => $idhopital])) {
$lat = $geocode->getLat();
$lng = $geocode->getLng();
} else {
$lat = $localisation->getCities()->getLat();
$lng = $localisation->getCities()->getLng();
}
if (!empty($localisation->getCities())) {
$departementTexte = $localisation->getCities()->getDeptTxt();
$depcode = $localisation->getCities()->getDeptcode();
} else {
$dep = $localisation->getDepartment();
$departementTexte = substr($dep, 7);
$depcode = substr($dep, 0, 2);
}
$ville = $localisation->getCity();
$localisationId = $localisation->getId();
if (!empty($localisation->getCities())) {
$departementTexte = $localisation->getCities()->getDeptTxt();
$depcode = $localisation->getCities()->getDeptcode();
} else {
$dep = $localisation->getDepartment();
$departementTexte = substr($dep, 7);
$depcode = substr($dep, 0, 2);
}
$slugHopital = $this->slugify->slugify($hospital->getCorporateName());
// Logo //
$logoPersonne = $this->dataProvider->getAvatar('ServiceOrl');
if ($logoId = $this->getDoctrine()->getRepository(Image::class)->findOneBy(['class' => 'Hospitals', 'entityId' => $idhopital, 'cover' => 1])) {
$file = $this->bo_url . "images/" . $logoId->getId() . "-medium.jpg";
$logoPersonne = $file;
}
// Website
$website = $hospital->getWebsite() ?? '';
// On récupère les autres service liés
$otherServices = $servicesRepository->findBy(['hospital' => $hospital]);
$buttons = [];
$relatedServices = [];
$i = 1;
$idsServices = array();
foreach ($otherServices as $otherService) {
$idsServices[] = $otherService->getId();
$current = ($otherService->getId() == $idservice) ? true : false;
$serviceLink = $this->generateUrl('page_service_hospitalier_avec_service', [
'ville' => $this->slugify->slugify($hospital->getLocalisation()->getCity()),
'zipcode' => $hospital->getLocalisation()->getZipcode(),
'nomhopital' => $this->slugify->slugify($hospital->getCorporateName()),
'idhopital' => $hospital->getId(),
'nomservice' => $this->slugify->slugify($otherService->getName()),
'idservice' => $otherService->getId()
]);
if ($otherService->getName() && $ville && $zipcode) {
array_push($buttons, array(
"title" => "Service ORL " . $i,
"url" => $serviceLink,
"current" => $current,
));
$i++;
}
if ($current) continue;
$coords = array(
"items" => array(
"address" => $hospital->getAddress() . " \n" . $hospital->getAdditionalAddress(),
"zip" => $hospital->getLocalisation()->getZipcode(),
"city" => $hospital->getLocalisation()->getCity(),
"bp" => $hospital->getPoBox(),
"zipcedex" => $hospital->getCedex(),
"citycedex" => $hospital->getCityCedex()
),
"coordTitle" => $otherService->getName(),
'link' => $serviceLink,
);
for ($k = 1; $k <= 3; $k++) {
$tel = $service->{'getTitle' . $k}();
if (!empty($tel)) $tel .= "\n";
$tel .= $service->{'getDescription' . $k}();
$coords['items']['tel' . $k] = $tel;
}
$relatedServices[] = $coords;
}
if (!in_array($idservice, $idsServices)) {
return $this->redirectProvider->redirect301('page_service_hospitalier', array('ville' => $this->slugify->slugify($ville), 'zipcode' => $zipcode, 'nomhopital' => $nomhopital, 'idhopital' => $idhopital));
}
// LES MÉDECINS ORL RATTACHÉS AU SERVICE //
$teamDesordre = [];
$team = [];
$doctors = $this->getDoctrine()->getRepository(ServiceDoctors::class)->findBy(['service' => $idservice]);
foreach ($doctors as $doctor) {
//$doctor = $doctor->getDoctor();
$rolePerson = null;
if ($lookup = $this->getDoctrine()->getRepository(Lookup::class)->findOneBy(['code' => $doctor->getStatusGrade(), 'type' => 'StatusGrade'])) {
$rolePerson = $lookup->getName();
$rolePos = $lookup->getPosition();
} else {
$rolePos = 99999;
}
if ($doctor->getSpecialty()) {
$rolePerson .= " (" . $doctor->getSpecialty() . ")";
}
$doctor = $this->getDoctrine()->getRepository(Doctors::class)->findOneBy(['id' => $doctor->getDoctor(), 'visible' => 1]);
// Logo //
if ($doctor) {
// Logo //
$logo = $this->dataProvider->getAvatar('Docteur', $doctor->getTitle());
if ($logoId = $this->getDoctrine()->getRepository(Image::class)->findOneBy(['class' => 'Doctors', 'entityId' => $doctor->getId(), 'cover' => 1])) {
$file = $this->bo_url . "images/" . $logoId->getId() . "-medium.jpg";
$logo = $file;
}
// Diplômes //
$diplomas = [];
$diplomes = $this->getDoctrine()->getRepository(Doctors::class)->getDoctorDegrees($doctor->getId());
foreach ($diplomes as $diplome) {
$diplomas[] = $diplome->getName();
}
array_push($teamDesordre, array(
"lastName" => $doctor->getName(),
"name" => $doctor->getTitle() . ' ' . $doctor->getFirstName() . ' ' . $doctor->getName(),
"image" => $logo,
"job" => $this->dataProvider->getDoctorSpecialities($doctor->getId()),
"diploma" => $diplomas,
"rolePerson" => $rolePerson,
"rolePos" => $rolePos,
"link" => $this->router->generate(
'page_single_medecin_with_service',
array(
'ville' => $this->slugify->slugify($ville),
'zipcode' => $zipcode,
'nomMedecin' => $this->slugify->slugify($doctor->getFirstName() . '-' . $doctor->getName()),
'idMedecin' => $doctor->getId(),
'idService' => $idservice
)
)
));
}
}
// TRI PAR POSITION
$pos = array_column($teamDesordre, 'rolePos');
$name = array_column($teamDesordre, 'lastName');
array_multisort($pos, SORT_ASC, $name, SORT_ASC, $teamDesordre);
foreach ($teamDesordre as $r) {
$team[] = $r;
}
// LES CENTRES D'AUDIOPROTHÈSE À PROXIMITÉ DU SERVICE //
$centre_proximite = [];
if ($lat && $lng) {
$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 (count($centre_proximite) < 6) {
$limit = 6 - count($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);
}
}
}
$centersLiesTab = $this->cardProvider->getCenterCards($centre_proximite, null, true);
}
// PROCHAINS ÉVENEMENTS DU SERVICES ORL //
$events = [];
$evenements = $this->getDoctrine()->getRepository(Services::class)->getEvents($idservice);
$events = $this->cardProvider->getEventsCards($evenements);
// Coordonnées du service //
$coords = [];
if ($service) {
$nom_service = $service->getName();
$coords = array(
"items" => array(
"address" => $hospital->getAddress() . " \n" . $hospital->getAdditionalAddress(),
"zip" => $hospital->getLocalisation()->getZipcode(),
"city" => $hospital->getLocalisation()->getCity(),
"bp" => $hospital->getPoBox(),
"zipcedex" => $hospital->getCedex(),
"citycedex" => $hospital->getCityCedex()
),
"coordTitle" => $nom_service,
);
for ($i = 1; $i <= 3; $i++) {
$tel = $service->{'getTitle' . $i}();
if (!empty($tel)) $tel .= "\n";
$tel .= $service->{'getDescription' . $i}();
$coords['items']['tel' . $i] = $tel;
}
}
$header = array(
"image" => $logoPersonne,
"name" => $hospital->getCorporateName(),
"name2" => $hospital->getCorporateName2(),
"websites" => [["link" => $website]],
);
$this->setTemplateParameters(array(
'page_orl_service' => array(
'header' => $header,
'nom_service' => $nom_service,
'team' => $team,
'centers' => $centersLiesTab,
'events' => $events,
'city' => $ville,
'coords' => $coords,
'relatedServices' => $relatedServices,
),
'search' => ['filter' => $buttons],
'title' => $hospital->getCorporateName()
));
$map['markers'][] = array(
"lat" => $lat,
"lon" => $lng,
"premium" => true,
"src" => "url(" . $logoPersonne . ")"
);
/************** Title & Description seo *****************/
$title_seo = $hospital->getCorporateName() . ' à ' . $this->dataProvider->wordUpperCaseFirstLetter($ville) . ' (' . $zipcode . ') - Service ' . $nom_service;
if ($hospital->getCorporateName2()) {
$title_seo .= ' - ' . $hospital->getCorporateName2();
}
$description_seo = "Prenez rendez-vous avec le service " . $nom_service . " " . $hospital->getCorporateName() . " à " . $this->dataProvider->wordUpperCaseFirstLetter($ville) . " (" . $zipcode . "). Consultez ses coordonnées et son adresse sur l'Annuaire de l'Audition.";
// Breadcrumb //
$this->breadDatas['departementTexte'] = $departementTexte;
$this->breadDatas['departementCode'] = $depcode;
$this->breadDatas['ville'] = $ville;
$this->breadDatas['zipcode'] = $zipcode;
$this->breadDatas['final'] = $hospital->getCorporateName();
$this->setBreadcrumb('services', 'single');
$searchtype['lat'] = $lat;
$searchtype['lng'] = $lng;
$searchtype['currentCityId'] = $localisation->getCities()->getId();
$this->setInternalLinkage('servicePage', $searchtype);
$this->setTemplateParameters(array('map' => $map));
$this->setTemplateParameters(array('title_seo' => $title_seo));
$this->setTemplateParameters(array('description_seo' => $description_seo));
$this->setTemplateParameters(array('dataLayerCenters' => $centersLiesTab, 'creative' => 'services-orl'));
if ($idservice) {
$this->setTemplateParameters(array('idService' => $idservice));
// on cherche le cache des parkings
if (file_exists('overpass/parkings/service/service-' . intval($idservice) . '.json')) {
$data = json_decode(file_get_contents('overpass/parkings/service/service-' . intval($idservice) . '.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/service/service-' . intval($idservice) . '.json')) {
$data = json_decode(file_get_contents('overpass/buses/service/service-' . intval($idservice) . '.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/service/service-' . intval($idservice) . '.json')) {
$data = json_decode(file_get_contents('overpass/subways/service/service-' . intval($idservice) . '.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 métros/trains
if (file_exists('overpass/trams/service/service-' . intval($idservice) . '.json')) {
$data = json_decode(file_get_contents('overpass/trams/service/service-' . intval($idservice) . '.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 = [];
if ($service) {
$hospital = $service->getHospital();
if ($hospital) {
//dd($service);
$address = $hospital->getAddress();
$localisation = $hospital->getLocalisation();
if ($localisation) {
$address .= " " . $localisation->getZipcode() . " " . $localisation->getcity();
$faqs[] = [
"question" => "Quelle est l'adresse du service " . $service->getName() . " - " . $hospital->getCorporateName() . " ?",
"response" => "L'adresse du service " . $service->getName() . " - " . $hospital->getCorporateName() . " est " . $address
];
}
$response_phone = "";
$response_phone1 = "";
$response_phone2 = "";
if ($service->getDescription1()) $response_phone1 .= $service->getDescription1();
if ($service->getTitle1()) $response_phone1 = $service->getTitle1() . " - " . $response_phone1;
if ($service->getDescription2()) $response_phone2 .= $service->getDescription2();
if ($service->getTitle2()) $response_phone2 = $service->getTitle2() . " - " . $response_phone2;
$response_phone .= $response_phone1 ? "<li>" . $response_phone1 . "</li>" : "";
$response_phone .= $response_phone2 ? "<li>" . $response_phone2 . "</li>" : "";
$faqs[] = [
"question" => "Comment contacter le service " . $service->getName() . " - " . $hospital->getCorporateName() . " ?",
"response" => "Le service " . $service->getName() . " - " . $hospital->getCorporateName() . " peut être contacté par téléphone au :<ul>" . $response_phone . "</ul>"
];
}
if ($team) {
$response_txt = "";
foreach ($team as $doctor) {
$response_txt .= "<li>" . $doctor['name'] . " (" . $doctor['rolePerson'] . ")</li>";
}
$faqs[] = [
"question" => "Quels médecins ORL exercent dans le service " . $service->getName() . " - " . $hospital->getCorporateName() . " ?",
"response" => "Les médecins ORL suivants sont rattachés au service " . $service->getName() . " - " . $hospital->getCorporateName() . " : <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 service " . $service->getName() . " - " . $hospital->getCorporateName() . " par les transports en commun ?",
"response" => "Le service " . $service->getName() . " - " . $hospital->getCorporateName() . " est situé à proximité des arrêts suivants :<ul>" . $response_txt . "</ul>"
];
}
$this->setTemplateParameters(array('faqs' => $faqs));
}
}
return $this->renderTemplate('pages/annuaire_page_ORLServices.twig');
}
}
}