<?php
namespace App\Controller\Admin;
use App\Entity\AppCarteMenuItem;
use App\Entity\AppDeviceToken;
use App\Entity\AppEmail;
use App\Entity\AppGallery;
use App\Entity\AppGroup;
use App\Entity\Configurations;
use App\Entity\CrossApp;
use App\H3\TTControllerTrait;
use App\Repository\AdvertisersRepository;
use App\Repository\AppCarteMenuItemRepository;
use App\Repository\AppCarteMenuRepository;
use App\Repository\AppCarteMenuTypeRepository;
use App\Repository\AppDeviceTokenRepository;
use App\Repository\AppEventRepository;
use App\Repository\AppGalleryRepository;
use App\Repository\AppGroupRepository;
use App\Repository\AppSlidesRepository;
use App\Repository\ConfigurationsRepository;
use App\Repository\CrossAppRepository;
use App\Repository\DancePlaningRepository;
use App\Repository\DanceTypeRepository;
use App\Repository\NotificationPushRepository;
use App\Repository\PagesCarousselRepository;
use App\Repository\PagesRepository;
use App\Services\GoogleReviews;
use App\Services\NotificationPhoto;
use App\Services\Tools;
use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use ImalH\PDFLib\PDFLib;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class PublicController extends AbstractDashboardController
{
use TTControllerTrait;
private static $__forms = [
"questions" => [
"I" => [
"heading_label" => "VOTRE ACCUEIL AU SEIN DE L’ETABLISSEMENT",
"forms" => [
[
"label" => "La signalisation de l'établissement à l’extérieur",
"question_number" => 1,
"custom_response" => false
],[
"label" => "Les facilités pour le stationnement",
"question_number" => 2,
"custom_response" => false
],[
"label" => "La signalisation interne des services",
"question_number" => 3,
"custom_response" => false
],[
"label" => "L'accueil au niveau des admissions",
"question_number" => 4,
"custom_response" => false
],[
"label" => "L'accueil dans les services de soins",
"question_number" => 5,
"custom_response" => false
],[
"label" => "L'accueil au bloc opératoire",
"question_number" => 6,
"custom_response" => false
],
]
],
"II" => [
"heading_label" => "LES DELAIS D'ATTENTE",
"forms" => [
[
"label" => "Lors de l'admission (entrée...)",
"question_number" => 7,
"custom_response" => false
],[
"label" => "Lors de la sortie (sortie...)",
"question_number" => 8,
"custom_response" => false
],[
"label" => "Aux urgences",
"question_number" => 9,
"custom_response" => false
],[
"label" => "Dans le service d'hospitalisation",
"question_number" => 10,
"custom_response" => false
],[
"label" => "Au bloc opératoire",
"question_number" => 11,
"custom_response" => false
],[
"label" => "A la radiologie",
"question_number" => 12,
"custom_response" => false
],
]
],
"III" => [
"heading_label" => "VOTRE PRISE EN CHARGE DANS LE SERVICE",
"forms" => [
[
"label" => "L'identification du personnel",
"question_number" => 13,
"custom_response" => false
],[
"label" => "La disponibilité des médecins, infirmières, sages-femmes et autres agents ",
"question_number" => 14,
"custom_response" => false
],[
"label" => "L'amabilité du personnel",
"question_number" => 15,
"custom_response" => false
],[
"label" => "La prise en charge de la douleur ",
"question_number" => 16,
"custom_response" => false
],[
"label" => "L’efficacité du traitement anti-douleur",
"question_number" => 17,
"custom_response" => false
],[
"label" => "La qualité des soins médicaux",
"question_number" => 18,
"custom_response" => false
],[
"label" => "La qualité des soins paramédicaux et sociaux (infirmière, aide-soignant, psychologue, kiné, assistante sociale, diététicienne...)",
"question_number" => 19,
"custom_response" => false
],[
"label" => "La qualité du transport interne (transport par les brancardiers)",
"question_number" => 20,
"custom_response" => false
],[
"label" => "Avez-vous eu un report d’hospitalisation ou de passage au bloc",
"question_number" => 21,
"custom_response" => [
'Oui' => 'Oui',
'Non' => 'Non'
]
],[
"label" => "La qualité des réponses à vos attentes et préoccupations au service maternité",
"question_number" => 22,
"custom_response" => false
],[
"label" => "La qualité de l’accompagnement à la parentalité (allaitement, soin du cordon, toilette)",
"question_number" => 23,
"custom_response" => false
],
]
],
"IV" => [
"heading_label" => "VOTRE APPRECIATION SUR L'HEBERGEMENT",
"forms" => [
'La chambre' => [
[
"label" => "Le confort de la chambre (toilette, douche literie...)",
"question_number" => 24,
"custom_response" => false
],[
"label" => "Le calme de la chambre et du service",
"question_number" => 25,
"custom_response" => false
],[
"label" => "La propreté de la chambre",
"question_number" => 26,
"custom_response" => false
],[
"label" => "Le fonctionnement des équipements notamment de sécurité (appel malade…)",
"question_number" => 27,
"custom_response" => false
],[
"label" => "Le respect de votre intimité",
"question_number" => 28,
"custom_response" => false
],
]
,'Les repas' => [
[
"label" => "La qualité des repas",
"question_number" => 29,
"custom_response" => false
],[
"label" => "La quantité des plats servis",
"question_number" => 30,
"custom_response" => false
],[
"label" => "La variété des repas",
"question_number" => 31,
"custom_response" => false
],[
"label" => "La température des repas",
"question_number" => 32,
"custom_response" => false
],[
"label" => "Les horaires des repas",
"question_number" => 33,
"custom_response" => false
],[
"label" => "Le respect du régime alimentaire",
"question_number" => 34,
"custom_response" => false
],
]
,'Les services' => [
[
"label" => "Le téléphone et la TV",
"question_number" => 35,
"custom_response" => false
],[
"label" => "Le service du courrier",
"question_number" => 36,
"custom_response" => false
],[
"label" => "Le culte",
"question_number" => 37,
"custom_response" => false
],[
"label" => "La Wifi (accès internet)",
"question_number" => 38,
"custom_response" => false
],[
"label" => "L’espace de lecture",
"question_number" => 39,
"custom_response" => false
]
]
]
],
"V" => [
"heading_label" => "VOTRE INFORMATION PENDANT VOTRE SEJOUR",
"forms" => [
[
"label" => "Livret d'accueil remis à votre arrivée",
"question_number" => 40,
"custom_response" => [
'Oui' => 'Oui',
'Non' => 'Non'
]
],[
"label" => "Informations données par le médecin (traitement, opération...)",
"question_number" => 41,
"custom_response" => false
],[
"label" => "Informations sur les bénéfices/risques liés à votre traitement ou intervention",
"question_number" => 42,
"custom_response" => false
],[
"label" => "Informations données par les paramédicaux sur les soins",
"question_number" => 43,
"custom_response" => false
],[
"label" => "Informations données à votre famille ou la personne de confiance",
"question_number" => 44,
"custom_response" => false
],[
"label" => "Informations sur la possibilité de faire une plainte ou une lettre de satisfaction",
"question_number" => 45,
"custom_response" => false
]
]
],
"VI" => [
"heading_label" => "VOTRE SORTIE",
"forms" => [
[
"label" => "Sur le plan médical (information sur votre traitement, vos prochains rendez-vous...)",
"question_number" => 46,
"custom_response" => false
],[
"label" => "Sur le plan administratif (bulletin de sortie, formalités permettant la prise en charge financière de votre séjour, récupération de vos dépôts et valeurs...)",
"question_number" => 47,
"custom_response" => false
],[
"label" => "Formalités de sortie sur le plan médical",
"question_number" => 48,
"custom_response" => false
],[
"label" => "Formalités de sortie sur le plan administratif",
"question_number" => 49,
"custom_response" => false
],
]
],
"VII" => [
"heading_label" => "VOTRE OPINION GENERALE",
"forms" => [
[
"label" => "Votre opinion générale",
"question_number" => 50,
"custom_response" => false
],
]
],
],
"responses" => [
"Très satisfait(e)" => "Très satisfait(e)",
"Satisfait(e)" => "Satisfait(e)",
"Pas du tout satisfait(e)" => "Pas du tout satisfait(e)",
"Non concerné(e)" => "Non concerné(e)"
]
];
/**
* @Route("/post/send/device/notification", name="route_send_device_notification", methods={"POST"})
*/
public function send_device_notification(Request $request, CrossAppRepository $crossAppRepository, EntityManagerInterface $entityManager, AppDeviceTokenRepository $appDeviceTokenRepository){
$package = $request->get('pkg');
if ( null != $package ){
$app = $crossAppRepository->findOneBy(['app_package_name' => $package]);
$token = $request->get('token');
$check = $appDeviceTokenRepository->findOneBy(['app'=>$app, 'token'=>$token]);
if ( null == $check ){
$entity = (new AppDeviceToken())->setApp($app);
$entity->setToken($request->get('token'));
if (null != $request->get("platform")){
$entity->setPlatform($request->get("platform"));
}
$entityManager->persist($entity);
$entityManager->flush();
} else {
if (null != $request->get("platform") and null == $check->getPlatform()){
$check->setPlatform( $request->get("platform") );
$entityManager->persist($check);
$entityManager->flush();
}
}
if (null != $request->get("v")){
$app->setAppVersion($request->get("v"));
$entityManager->persist($app);
$entityManager->flush();
}
}
$out = new \stdClass();
$out->success = true;
return new JsonResponse($out);
}
/**
* @Route("/send/email", name="route_send_email", methods={"POST"})
*/
public function send_mail(Request $request, CrossAppRepository $crossAppRepository, EntityManagerInterface $entityManager){
$out = new \stdClass();
$out->success = false;
/** @var CrossApp|null $app */
$app = $crossAppRepository->findOneBy(['app_package_name' => $request->get('pkg')]);
if ( null != $app ){
// $to = "rivomanana.dev@gmail.com";
$to = $app->getContactCoords()[0]->getEmail();
if ( null != $to ){
$headers = "Return-Path: Yziapp <webmaster@appadmin.yziapp.com>\r\n";
$headers .= "From: Yziapp <webmaster@appadmin.yziapp.com>\r\n";
$headers .= "Organization: Yziprod\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n" ;
$start_hospi = \DateTime::createFromFormat("Y-m-d", $_POST['start_hospi']);
$end_hospi = \DateTime::createFromFormat("Y-m-d", $_POST['end_hospi']);
$_POST['start_hospi'] = $start_hospi->format('d/m/Y');
$_POST['end_hospi'] = $end_hospi->format('d/m/Y');
$send = mail($to, 'Questionnaire de satisfaction App', $this->get('twig')->render('admin/mail.chu.html.twig', [
'post' => $_POST,
'forms' => self::$__forms
]), $headers);
$out->success = $send;
$app_email = (new AppEmail())
->setApp($app)
->setEmail('place.holder.email@contet.com')
->setMessage(json_encode($_POST))
->setCreatedAt(new \DateTime());
$entityManager->persist($app_email);
$entityManager->flush();
}
}
return new JsonResponse($out);
}
/**
* @Route("/get/data", name="route_get_data")
*/
public function get_data(
Request $request,
AppCarteMenuItemRepository $appCarteMenuItemRepository,
PagesRepository $pagesRepository,
PagesCarousselRepository $pagesCarousselRepository,
AppGroupRepository $appGroupRepository,
CrossAppRepository $crossAppRepository,
ConfigurationsRepository $configurationsRepository,
HttpClientInterface $httpClient,
AppCarteMenuTypeRepository $appCarteMenuTypeRepository,
NotificationPhoto $notificationPhoto,
AppCarteMenuRepository $appCarteMenuRepository,
AppSlidesRepository $slidesRepository,
AppGalleryRepository $appGalleryRepository,
DanceTypeRepository $danceTypeRepository,
DancePlaningRepository $dancePlaningRepository,
NotificationPushRepository $notificationPushRepository,
AdvertisersRepository $advertisersRepository,
AppEventRepository $appEventRepository
){
$out = new \stdClass();
$out->data = new \stdClass();
$out->data->success = false;
/** @var CrossApp|null $app */
$app = $crossAppRepository->findOneBy(['app_package_name' => $request->get('pkg')]);
if ( null != $app ){
$out->data->success = true;
$out->data->sitename = $app->getName();
$out->data->logo = $app->getLogo() ? $this->generateUrl('route_get_app_logo', [
'encoded_file_name' => base64_encode($app->getLogo())
], UrlGeneratorInterface::ABSOLUTE_URL) : "";
/** planing */
$dance_type = $app->getDanceTypes();
if ( null != $dance_type ){
$days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"];
$out->data->planing_crc = [];
foreach ( $dance_type as $item ){
if ( $item->getStatus() ){
$out->data->planing_crc[$item->getName()] = [];
foreach( $days as $day ){
$planing_day = $dancePlaningRepository->createQueryBuilder('d')
->select('d.content')
->andWhere('d.type = :type')
->andWhere('d.day = :day')
->setParameters(['day'=>$day, 'type'=>$item])
->getQuery()->getResult();
if ( is_array($planing_day) and sizeof($planing_day) )
$out->data->planing_crc[$item->getName()][$day] = $planing_day;
}
}
}
ksort($out->data->planing_crc);
}
/** fb */
$fb = $app->getAppFbs();
if ( null != $fb ){
$out->data->facebook = new \stdClass();
foreach ( $fb as $fb_item ){
switch ( $fb_item->getType() ){
case 'primary':
$out->data->facebook->appId = $fb_item->getFbAppId();
$out->data->facebook->pageUrl = $fb_item->getPageUrl();
$out->data->facebook->photo_360 = $fb_item->getUrlPhoto360();
$out->data->facebook->info = $fb_item->getInfo();
$out->data->facebook->elfsight_instagram = $fb_item->getInstagramElfsight();
break;
case 'secondary':
$out->data->facebook->secondary = [
'appId' => $fb_item->getFbAppId(),
'pageUrl'=> $fb_item->getPageUrl(),
'photo_360'=> $fb_item->getUrlPhoto360(),
'elfsight_instagram' => $fb_item->getInstagramElfsight(),
'info' => $fb_item->getInfo()
];
break;
default:
$out->data->facebook->appId = "";
$out->data->facebook->pageUrl = "";
$out->data->facebook->photo_360 = "";
$out->data->facebook->info = "";
$out->data->facebook->elfsight_instagram = "";
}
}
}
/** about */
$about = $app->getAppAbouts();
if ( null != $about ){
$out->data->about = new \stdClass();
foreach ( $about as $about_item ){
switch ( $about_item->getType() ){
case 'primary':
$out->data->about->image = $about_item->getPhoto() ? $this->generateUrl( 'route_get_photo_about', [
'encoded_file_name' => base64_encode($about_item->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL) : "" ;
$out->data->about->title = $about_item->getTitle();
$out->data->about->content = $about_item->getContent();
break;
case 'secondary':
$out->data->about->secondary = [
'image' => $about_item->getPhoto() ? $this->generateUrl( 'route_get_photo_about', [
'encoded_file_name' => base64_encode($about_item->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL) : "",
'title'=> $about_item->getTitle(),
'content'=> $about_item->getContent()
];
break;
default:
$out->data->about->image = "";
$out->data->about->title = "";
$out->data->about->content = "";
}
}
}
/** carte-menus */
//$carteMenus = $app->getAppCarteMenus();
$carteMenus = $appCarteMenuRepository->findBy(["app" => $app], ["id" => "DESC"]);
if ( null != $carteMenus ){
usort($carteMenus, function ($start, $end){
$start_ordering = null == $start->getOrdering() ? 90000 : $start->getOrdering();
$end_ordering = null == $end->getOrdering() ? 90000 : $end->getOrdering();
return $start_ordering < $end_ordering ? -1 : 1;
});
$out->data->carte_menus = new \stdClass();
$out->data->carte_menus->cardsData = [];
$option_menu_multi = [];
foreach ($this->getParameter('carte_multiple') as $package_name => $props){
$item_type = [];
foreach ($props as $k=>$v){
foreach ($v as $_v)
$item_type[$_v] = $_v;
}
$option_menu_multi[array_keys($props)[0]] = $item_type;
}
/*foreach ( $carteMenus as $carteMenu ){
if ( isset($option_menu_multi[$app->getAppPackageName()]) ){
$out->data->carte_menus->cardsData->{$carteMenu->getType()} = [];
}
}*/
$hack_separator = '~';
foreach ( $carteMenus as $carteMenu ){
/*if ( $carteMenu->getId() != 55 )
continue;*/
if ( true == $carteMenu->getStatus() ){
$item = new \stdClass();
$item->label = $carteMenu->getTitle();
$item->__id = $carteMenu->getId();
$item->photo = "https://appadmin.yziapp.com/" . 'images/cross.app.carte.menu.image/' . $carteMenu->getPhoto();
$item->content =new \stdClass();
$item->content->items = [];
$item->content->has_categories = false;
if ( null != $carteMenu->getAppCarteMenuItems() ){
$cartes_menus = $appCarteMenuItemRepository->findBy(['carte'=>$carteMenu], ['ordering' => "ASC"]);
usort($cartes_menus, function ($start, $end){
$start_ordering = null == $start->getOrdering() ? 90000 : $start->getOrdering();
$end_ordering = null == $end->getOrdering() ? 90000 : $end->getOrdering();
return $start_ordering < $end_ordering ? -1 : 1;
});
$categorized = [];
$temp_categorized = [];
$uncategorized = [];
foreach ($cartes_menus as $appCarteMenuItem){
if ( true == $appCarteMenuItem->getStatus() ){
if ( null == $appCarteMenuItem->getType() ){
$uncategorized[] = $appCarteMenuItem;
} else {
$ordering__ = null != $appCarteMenuItem->getType()->getOrdering() ? (int)$appCarteMenuItem->getType()->getOrdering() : 90000;
$temp_categorized[$appCarteMenuItem->getType()->getName().$hack_separator.$ordering__.$hack_separator.(int)$appCarteMenuItem->getType()->getId()][] = $appCarteMenuItem;
}
}
}
if ( sizeof($temp_categorized) ){
$item->content->has_categories = true;
$temp_srt = [];
foreach ( $temp_categorized as $__k => $i_c ){
list($name, $ordering, $id) = explode($hack_separator, $__k);
$temp_srt[$id] = (int)$ordering;
}
asort($temp_srt);
foreach ( $temp_srt as $id_type => $ordering ){
$type = $appCarteMenuTypeRepository->find($id_type);
$ordering__ = null == $type->getOrdering() ? 90000 : (int)$type->getOrdering();
if ( $type ){
$key = $type->getName() . $hack_separator . $ordering__. $hack_separator . $type->getId();
$categorized[$type->getName()] = $temp_categorized[$key];
}
}
}
/** if without category */
if ( sizeof( $uncategorized ) ){
if ( false == $item->content->has_categories ){
/** @var AppCarteMenuItem $menuItem */
foreach ( $uncategorized as $menuItem ){
$item->content->items[] = [
"photo" => $this->generateUrl('route_get_photo_carte_menu', ['encoded_file_name' => base64_encode($menuItem->getPhoto())], UrlGeneratorInterface::ABSOLUTE_URL),
"title" => $menuItem->getName(),
"brand" => null == $menuItem->getAppCarteMenuBrand() ? "" : $menuItem->getAppCarteMenuBrand()->getName(),
"description" => nl2br($menuItem->getDescription()),
"price" => number_format($menuItem->getPrice(), 2, ',', ' ')
];
}
} else {
$items_u = [
"category" => "",
"catgory_items" => []
];
/** @var AppCarteMenuItem $menuItem */
foreach ( $uncategorized as $menuItem ){
if ( true == $menuItem->getStatus() ){
$items_u["catgory_items"][] = [
"photo" => $this->generateUrl('route_get_photo_carte_menu', ['encoded_file_name' => base64_encode($menuItem->getPhoto())], UrlGeneratorInterface::ABSOLUTE_URL),
"title" => $menuItem->getName(),
"brand" => null == $menuItem->getAppCarteMenuBrand() ? "" : $menuItem->getAppCarteMenuBrand()->getName(),
"description" => $menuItem->getDescription(),
"price" => number_format($menuItem->getPrice(), 2, ',', ' ')
];
}
}
$item->content->items[] = $items_u;
}
}
/** if categorized */
if ( sizeof( $categorized ) ){
/** @var AppCarteMenuItem[] $menuItems */
foreach ( $categorized as $category_name => $menuItems ){
$items = [
"category" => $category_name,
"catgory_items" => []
];
foreach ( $menuItems as $menuItem ){
if ( true == $menuItem->getStatus() ){
$items["catgory_items"][] = [
"photo" => $this->generateUrl('route_get_photo_carte_menu', ['encoded_file_name' => base64_encode($menuItem->getPhoto())], UrlGeneratorInterface::ABSOLUTE_URL),
"title" => $menuItem->getName(),
"brand" => null == $menuItem->getAppCarteMenuBrand() ? "" : $menuItem->getAppCarteMenuBrand()->getName(),
"description" => $menuItem->getDescription(),
"price" => number_format($menuItem->getPrice(), 2, ',', ' ')
];
}
}
$item->content->items[] = $items;
}
}
}
if ( isset($option_menu_multi[$app->getAppPackageName()]) ){
$out->data->carte_menus->cardsData[$carteMenu->getType()][] = $item;
} else
$out->data->carte_menus->cardsData[] = $item;
}
}
}
/** map_api_key */
$map_api_key = $app->getMapApiKey();
$out->data->map_api_key = $map_api_key;
/** itineraire */
$itineraire = $app->getAppItineraires();
if ( null != $itineraire ){
foreach ( $app->getAppItineraires() as $item_itineraire ){
switch ( $item_itineraire->getType() ){
case 'primary':
$out->data->itineraire = [
"center" => ["lat" => $item_itineraire->getCenterLat(), "long" => $item_itineraire->getCenterLong()],
"addr" => $item_itineraire->getMapAddress(),
"iframe" => $item_itineraire->getLinkIframe()
];
break;
case 'secondary':
$out->data->itineraire['secondary'] = [
"center" => ["lat" => $item_itineraire->getCenterLat(), "long" => $item_itineraire->getCenterLong()],
"addr" => $item_itineraire->getMapAddress(),
"iframe" => $item_itineraire->getLinkIframe()
];
break;
default:
$out->data->itineraire = [
"center" => ["lat" => null, "long" => null],
"addr" => null
];
}
}
/*$out->data->itineraire = [
"center" => [
'lat' => null != $itineraire[0] ? $itineraire[0]->getCenterLat() : "",
'long' => null != $itineraire[0] ? $itineraire[0]->getCenterLong() : ""
],
"addr" => null != $itineraire[0] ? $itineraire[0]->getMapAddress() : ""
];*/
} else
$out->data->itineraire = [];
/** contact */
$contact = $app->getContactCoords();
if ( null != $contact ){
foreach ( $contact as $contact_item ){
switch ( $contact_item->getType() ){
case 'primary':
$out->data->contact = [
"contact_photo" => $contact_item->getPhoto() ? $this->generateUrl('route_get_get_photo_contact', [
'encoded_file_name' => base64_encode($contact_item->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL) : "",
"contact_data" => [
"coords" => [
"phone" => $contact_item->getPhone(),
"phone_secondary" => $contact_item->getPhoneHome(),
"adress" => $contact_item->getAddress(),
"info" => nl2br($contact_item->getInfo()),
"email" => $contact_item->getEmail()
]
]
];
if ( Tools::isTwoShop($this->get('parameter_bag'), $app->getAppPackageName()) ){
$out->data->contact['bb_photo_contact'] = $contact_item->getBbPhotoContact() ? $this->generateUrl('route_get_get_photo_contact', [
'encoded_file_name' => base64_encode($contact_item->getBbPhotoContact())
], UrlGeneratorInterface::ABSOLUTE_URL) : "";
}
break;
case 'secondary':
if ( null != $contact_item->getPhone()
or null != $contact_item->getAddress()
or null != $contact_item->getInfo()
or null != $contact_item->getEmail()
) {
$out->data->contact['secondary'] = [
"contact_photo" => $contact_item->getPhoto() ? $this->generateUrl('route_get_get_photo_contact', [
'encoded_file_name' => base64_encode($contact_item->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL) : "",
"contact_data" => [
"coords" => [
"phone" => $contact_item->getPhone(),
"adress" => $contact_item->getAddress(),
"phone_secondary" => $contact_item->getPhoneHome(),
"info" => $contact_item->getInfo(),
"email" => $contact_item->getEmail()
]
]
];
}
break;
default:
$out->data->contact = [
"contact_photo" => "",
"contact_data" => [
"coords" => [
"phone" => "",
"adress" => "",
"info" => "",
"email" => ""
]
]
];
}
}
} else
$out->data->contact = [];
/** gallery_photos */
//$galleries = $app->getAppGalleries();
$galleries = $appGalleryRepository->getGallery( $app );
if ( null != $galleries ){
usort($galleries, function (AppGallery $start, AppGallery $end){
$start_ordering = null == $start->getOrdering() ? 90000 : $start->getOrdering();
$end_ordering = null == $end->getOrdering() ? 90000 : $end->getOrdering();
return $start_ordering < $end_ordering ? -1 : 1;
});
foreach ( $galleries as $gallery ){
$photo = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.gallery/' . $gallery->getPhoto();
if ( file_exists($photo) ){
list($width, $height, $type, $attr) = getimagesize($photo);
//$divisor = \gmp_intval( \gmp_gcd( $width, $height ) );
$out->data->gallery_photos[] = [
"src" => $this->generateUrl('route_get_photo_gallery', [
'encoded_file_name' => base64_encode($gallery->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL),
"width" => $width/*/$divisor*/,
"group" => $gallery->getAppGroup(),
"height" => $height/*/$divisor*/
];
}
}
} else
$out->data->gallery_photos = [];
/** events */
// $events = $app->getAppEvents();
$events = $appEventRepository->findBy(['app'=>$app], ['date' => 'ASC']);
if ( null != $events ){
$event_lists = [];
foreach ($events as $event){
if ( true == $event->getStatus() /*$event->getDate() >= new \DateTime()*/ ){
$event_lists[] = [
"photo" => $event->getPhoto() ? $this->generateUrl('route_get_photo_event', [
'encoded_file_name' => base64_encode($event->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL) : null,
"content" => $event->getContent(),
"date" => $event->getDate()->format("d-m-Y H:i"),
];
}
}
$out->data->events = $event_lists;
} else
$out->data->events = [];
/** formations */
$formations = $app->getFormations();
if ( null != $formations ){
foreach ($formations as $formation){
$photo = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.formations/' . $formation->getPhoto();
list($width, $height, $type, $attr) = getimagesize($photo);
//$divisor = \gmp_intval( \gmp_gcd( $width, $height ) );
$out->data->formations[] = [
"photo" => $this->generateUrl('route_get_photo_formation', [
'encoded_file_name' => base64_encode($formation->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL),
"width" => $width/*/$divisor*/,
"name" => $formation->getName(),
"description" => $formation->getDescription(),
"category" => $formation->getCategory(),
"height" => $height/*/$divisor*/
];
}
} else
$out->data->formations = [];
/** slides */
//$slides = $app->getAppSlides();
$slides = $slidesRepository->findBy(['app'=>$app,'status'=>true], ['ordering'=>'ASC']);
if ( null != $slides ){
usort($slides, function ($start, $end){
$start_ordering = null == $start->getOrdering() ? 90000 : $start->getOrdering();
$end_ordering = null == $end->getOrdering() ? 90000 : $end->getOrdering();
return $start_ordering < $end_ordering ? -1 : 1;
});
foreach ( $slides as $slide ){
$out->data->slides[] = [
$this->generateUrl('route_get_photo_slides', [
'encoded_file_name' => base64_encode($slide->getPhoto())
], UrlGeneratorInterface::ABSOLUTE_URL)
];
}
} else
$out->data->slides = [];
/** shop_url */
$out->data->shop_url = $app->getShopUrl();
$out->data->secondary_shop_url = $app->getShopSecondaryUrl();
$out->data->rdv_url = $app->getRdvUrl();
$out->data->secondary_rdv_url = $app->getRdvSecondaryUrl();
/** notifications */
//$notifications = $app->getNotificationPushes();
$notifications = $notificationPushRepository->findBy(['app' => $app], ['created_at' => 'DESC']);
if ( null != $notifications and sizeof($notifications) ){
foreach ( $notifications as $notification ){
$photo_file = $notification->getPhoto();
$extension = pathinfo( $photo_file, PATHINFO_EXTENSION );
$is_video = in_array( $extension, ['mp4', 'webm', 'ogg', 'mov', 'avi', 'mkv'] );
if ( in_array( $extension, ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'svg', 'webp'] ) ){
$photo = $notificationPhoto->getPhoto($notification->getPhoto());
} else {
$photo = $notificationPhoto->getPhoto($notification->getPhotoVideo());
}
$out->data->notifications[] = [
"id" => $notification->getId(),
"title" => $notification->getTitle(),
"body" => $notification->getDescription(),
"seen" => $notification->getSeen(),
"photo" => $photo,
"is_video" => $is_video,
"video_file" => $notificationPhoto->getPhoto( $notification->getPhoto() ),
"date" => $notification->getCreatedAt()->format("d/m/Y")
];
}
} else
$out->data->notifications = [];
/** ratings */
$gr = new GoogleReviews($app->getGooglePlaceId(), (null != $app->getMapApiKey() ? $app->getMapApiKey() : 'AIzaSyALsd4b_E60Ki2_dT7i8aTerg6ZalCjyOE'), $httpClient);
$out->data->ratings = $gr->getReviews();
$out->data->ratings_secondary = (new GoogleReviews($app->getPlaceIdSecondary(), (null != $app->getMapApiKey() ? $app->getMapApiKey() : 'AIzaSyALsd4b_E60Ki2_dT7i8aTerg6ZalCjyOE'), $httpClient))
->getReviews();
/** yziapp */
/** @var Configurations|null $title_about */
$title_about = $configurationsRepository->findOneBy(['config_key' => 'about_title']);
/** @var Configurations|null $title_about */
$content_about = $configurationsRepository->findOneBy(['config_key' => 'about_content']);
$out->data->yziapp = [
"title" => null != $title_about ? $title_about->getConfigValue() : '-',
"content" => null != $content_about ? $content_about->getConfigValue() : '-'
];
/** uber */
$out->data->uber_url = $app->getUberUrl();
/** rvd on/off */
$out->data->use_booking = null == $app->getUseBooking() ? true : !$app->getUseBooking();
/** inwood */
/*$out->data->_360_inwood = "com.yziapp.seco.bois" == $app->getAppPackageName() ?
(null != $configurationsRepository->findOneBy(['config_key' => 'urlPhoto360_secondary_'.$app->getAppPackageName()])
? $configurationsRepository->findOneBy(['config_key' => 'urlPhoto360_secondary_'.$app->getAppPackageName()])->getConfigValue() : null )
: null;*/
/** group */
if ( isset($this->getParameter('app_with_group')[$app->getAppPackageName()]) ){
$out->data->group = [];
foreach ( $this->getParameter('app_with_group')[$app->getAppPackageName()] as $k => $v ){
$fields = [
'title', 'content', 'place-id', 'facebook', 'logo', 'shop_url', 'email', 'adress', 'phone', 'mobile_phone', 'horaire',
'lat', 'lng', 'map_adress', 'iframe_map', 'photo_360'
];
foreach ( $fields as $field ){
$check = $appGroupRepository->findOneBy(['name'=>$k, 'field' => md5($app->getId()).'-'.$field]);
if ( "logo" == $field ){
$out->data->group[$k][$field] = (null != $check and $check instanceof AppGroup and null != $check->getValue()) ? 'https://appadmin.yziapp.com/images/app.logo.group/'.$check->getValue() : '';
} else if ("place-id" == $field){
$out->data->group[$k][$field] = null != $check ? $check->getValue() : '';
$google_review = new GoogleReviews((null != $check ? $check->getValue() : ''), (null != $app->getMapApiKey() ? $app->getMapApiKey() : 'AIzaSyALsd4b_E60Ki2_dT7i8aTerg6ZalCjyOE'), $httpClient);
$out->data->group[$k]['ratings'] = $google_review->getReviews();
} else
$out->data->group[$k][$field] = null != $check ? $check->getValue() : '';
}
$out->data->group[$k]['group_name'] = $v;
}
}
/** question_responses */
if ( in_array($app->getAppPackageName(), array_keys($this->getParameter('with_qr'))) ){
$out->data->qr = [];
foreach ( $app->getQuestionResponses() as $questionResponse ){
$out->data->qr[] = [
'title' => $questionResponse->getQuestion(),
'content' => $questionResponse->getResponse()
];
}
}
/** annonceurs */
$out->data->advertiser = [];
foreach ( $advertisersRepository->findBy(['app' => $app]) as $advertiser ){
$item = [
'name' => $advertiser->getName(),
'link' => $advertiser->getLink(),
'photo' => $request->getSchemeAndHttpHost() . '/public/images/chu.advertiser/' . $advertiser->getPhoto(),
'display_in_home' => $advertiser->getShowInIndex(),
'description' => $advertiser->getDescription(),
'chu' => json_decode($advertiser->getChu(), true)
];
$out->data->advertiser[] = $item;
}
/** page galleries */
if ( in_array($app->getAppPackageName(), $this->getParameter('with_pages')) ){
$out->data->pages = [];
foreach ( $pagesRepository->findBy(['cross_app' => $app]) as $page ){
if ( $page->getWithBuilder() ){
$file = $request->getSchemeAndHttpHost() . '/public/html-iframe/page-'.$app->getId().'-'.$page->getId().'.html?_='.md5(time());
$content = '<iframe frameborder="0" height="900px" scrolling="yes" src="'.$file.'" width="100%"></iframe>';
} else
$content = $page->getContent();
$item = [];
$item['title'] = $page->getTitle();
$item['id'] = $page->getId();
$item['description'] = $page->getDescription();
$item['facebook_link'] = $page->getFacebookPageUrl();
$item['chu_address'] = $page->getChuAddress();
$item['coordonnes'] = $page->getCoordonnes();
$item['map'] = [
'lat' => $page->getLatitude(),
'lng' => $page->getLongitude(),
'latlong' => $page->getLatLng(),
'adress' => $page->getAddress()
];
$item['phone'] = $page->getPhone();
$item['type'] = $page->getType();
$item['website'] = $page->getWebsite();
$item['email'] = $page->getEmail();
$item['file'] = (null != $page->getAttachment() or "" != $page->getAttachment()) ? $this->generateUrl('route_get_page_file', ['encoded_file_name' => base64_encode($page->getAttachment())], UrlGeneratorInterface::ABSOLUTE_URL) : "";
//$item['file'] = null != $page->getAttachment() ? $request->getSchemeAndHttpHost() . '/public/files/page.attachment/' . $page->getAttachment() : "";
$item['content'] = $content;
$item['galleries'] = [];
foreach ( $pagesCarousselRepository->findBy(['page' => $page], ['ordering' => 'ASC']) as $pagesCaroussel ){
$item['galleries'][] = [
'photo' => $this->generateUrl('route_get_pages_n_slides', ['encoded_file_name' => base64_encode($pagesCaroussel->getPhoto())], UrlGeneratorInterface::ABSOLUTE_URL),
'link' => $pagesCaroussel->getLink()
];
}
$out->data->pages[$page->getSlug()] = $item;
}
}
if ( "com.yziapp.vahiana.spa" == $app->getAppPackageName() ){
$out->data->disable_booking_android = false;
}
if ( "com.yziapp.chu.martinique" == $app->getAppPackageName() ){
$out->data->questions_forms = self::$__forms;
}
$out->data->hash = md5(json_encode($out));
}
$response = new Response(json_encode($out));
$response->setStatusCode(200);
$response->headers->set('Content-Type', 'application/json; charset=UTF-8');
$response->headers->set('Access-Control-Allow-Origin', '*');
$response->headers->set('Access-Control-Allow-Methods', 'OPTIONS,GET,POST,PUT,DELETE');
$response->headers->set('Access-Control-Max-Age', 3600);
$response->headers->set('Access-Control-Allow-Headers', "Content-Type, x-xsrf-token");
$response->headers->set('Access-Control-Allow-Headers', "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
return $response;
}
/**
* @Route("/get/menus/uber-eats", methods={"GET"})
*/
public function uber_eats_menu(){
$client = HttpClient::create();
$bearerToken = 'IA.VUNmGAAAAAAAEgASAAAABwAIAAwAAAAAAAAAEgAAAAAAAAGwAAAAFAAAAAAADgAQAAQAAAAIAAwAAAAOAAAAhAAAABwAAAAEAAAAEAAAABc_Q4ZlmVpCladCj_JnpBxfAAAAv8MaCyQHNMXKrC3-dTkHmvAWjTrlNZ0N7Dp6EIlZwlDfmvq8eYITT6bPDxZAsQ4ukLPcPf-cIcqvrXTnioauDfc63UE8FKSHiZ7tTxpGWZXltFRv9sbs4Rbb7brvt7oADAAAACRClmLOFkFhdLSInCQAAABiMGQ4NTgwMy0zOGEwLTQyYjMtODA2ZS03YTRjZjhlMTk2ZWU';
$out = new \stdClass();
$out->success = false;
$apiUrl = 'https://api.uber.com/v2/eats/stores/99bba954-b618-4b2d-853f-93e7b7d5b0b9/menus';
try {
// Faire la requête GET avec les headers
$response = $client->request('GET', $apiUrl, [
'headers' => [
'Authorization' => 'Bearer ' . $bearerToken,
'Accept' => 'application/json', // Optionnel selon l'API
],
]);
// Récupérer le statut de la réponse
$statusCode = $response->getStatusCode();
// Récupérer le contenu en JSON (si l'API retourne du JSON)
$content = $response->toArray();
// ou en string si ce n'est pas du JSON : $content = $response->getContent();
$out->data = $content;
$out->success = true;
} catch (\Exception $e) {
// Gérer les erreurs
$out->message = $e->getMessage();
}
return new JsonResponse( $out );
}
/**
* @Route("/get/cs/log", methods={"GET"})
*/
public function display_log(){
$file = $this->getParameter('kernel.project_dir') . '/log.json';
if ( !file_exists( $file ) )
file_put_contents($file, json_encode([]));
$content = json_decode(file_get_contents($file),true);
$response = new Response(implode("\n",$content), 200);
$response->headers->set('Content-Type', 'text/plain');
return $response;
}
/**
* @Route("/put/cs/log", methods={"POST"})
*/
public function custom_log(Request $request){
$log = $request->get('log');
$file = $this->getParameter('kernel.project_dir') . '/log.json';
if ( !file_exists( $file ) )
file_put_contents($file, json_encode([]));
$content = json_decode(file_get_contents($file),true);
$content[] = (new \DateTime('now'))->format('d-m-Y H:i:s') . ' ---->> ' . $log;
file_put_contents($file, json_encode($content));
return new JsonResponse([]);
}
/**
* @Route("/get/page/photo/{encoded_file_name}", name="route_get_pages_n_slides")
*/
public function get_pages_slides($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/page_caroussel/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/slide/photo/{encoded_file_name}", name="route_get_photo_slides")
*/
public function get_photo_slides($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.slide/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/page/file/{encoded_file_name}", name="route_get_page_file")
*/
public function get_page_file_attachment($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/files/page.attachment/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir), 204, [
'Access-Control-Allow-Origin' => '*',
//'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers' => 'DNT, X-User-Token, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type',
'Access-Control-Max-Age' => 1728000,
'Content-Type' => mime_content_type($dir),
]);
$response->setStatusCode(200);
// ->headers->set('Content-Type', mime_content_type($dir));
return $response;
}
/**
* @Route("/get/gallery/photo/{encoded_file_name}", name="route_get_photo_gallery")
*/
public function get_photo_gallery($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.gallery/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/formation/photo/{encoded_file_name}", name="route_get_photo_formation")
*/
public function get_photo_formation($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.formations/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/events/photo/{encoded_file_name}", name="route_get_photo_event")
*/
public function get_photo_event($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.events/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/contact/photo/{encoded_file_name}", name="route_get_get_photo_contact")
*/
public function get_photo_contact($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.coords/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/carte/photo/{encoded_file_name}", name="route_get_photo_carte_menu", defaults={"encoded_file_name"=""})
*/
public function get_photo_carte_menu(?string $encoded_file_name = ""){
$dir = "" != $encoded_file_name ? $this->getParameter('kernel.project_dir') . '/public/images/cross.app.carte.menu.item/'. base64_decode( $encoded_file_name )
: $this->getParameter('kernel.project_dir') . '/public/images/e.png';
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/about/photo/{encoded_file_name}", name="route_get_photo_about")
*/
public function get_photo_about($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/cross.app.about/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
/**
* @Route("/get/logo/{encoded_file_name}", name="route_get_app_logo")
*/
public function get_app_logo($encoded_file_name){
$dir = $this->getParameter('kernel.project_dir') . '/public/images/app.logo/'. base64_decode( $encoded_file_name );
if ( !file_exists( $dir ) )
throw new AccessDeniedException('file not found');
$response = new Response(file_get_contents($dir));
$response->setStatusCode(200)
->headers->set('Content-Type', 'image/'.pathinfo($dir, PATHINFO_EXTENSION));
return $response;
}
}