<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller;
use Symfony\Component\Mailer\MailerInterface;
use Swift_Message;
use Symfony\Component\Mime\Email;
use Unirest;
use Swift_Image;
use Dompdf\Dompdf;
use App\Entity\Ref;
use Dompdf\Options;
use App\Entity\Page;
use App\Entity\User;
use Twig\Environment;
use App\Entity\Panier;
use App\Entity\Sejour;
use App\Entity\Clipart;
use App\Entity\Produit;
use App\Entity\CommandeNumerique;
use App\Entity\Typeref;
use App\Entity\Commande;
use App\Entity\Emailing;
use App\Entity\Typeproduit;
use App\Entity\ParentSejour;
use App\Entity\PanierProduit;
use App\Service\JetonService;
use App\Entity\ComandeProduit;
use App\Entity\SejourAttachment;
use App\Service\PrinterService;
use App\Entity\Likephoto;
use App\Entity\Attachment;
use App\Service\EmailsCmdService;
use App\Entity\TypeProduitConditionnement;
use App\Service\AttachementService;
use App\Service\CarteService;
use App\Service\ComandeService;
use App\Service\EtablissementService;
use App\Service\PayementService;
use App\Service\PhotosFavorisService;
use App\Service\SejourService;
use App\Service\TypeProduiteService;
use App\Service\UserService;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface;
use Qipsius\TCPDFBundle\Controller\TCPDFController;
use SebastianBergmann\Environment\Console;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
class EspaceParentController extends AbstractController
{
private $em;
private $session;
private $templating;
private $mailer;
private $symfonyMailer;
private $EmailServie;
private $urlGenerator;
private $commandeService;
private $printerService;
private $emailsCmdService;
private $userService;
private $typeProduiteService;
private $sejourService;
private $attachementService;
private $etablissementService;
private $payementService;
private $carteService;
private $photosFavorisService;
private $params;
private $tcpdf;
private $logger;
public function __construct(UrlGeneratorInterface $urlGenerator, ManagerRegistry $em, SessionInterface $session, \Swift_Mailer $mailer, MailerInterface $symfonyMailer, Environment $templating, EmailsCmdService $EmailCommandeService, ComandeService $commandeService, UserService $userService, TypeProduiteService $typeProduiteService, SejourService $sejourService, AttachementService $attachementService, EtablissementService $etablissementService, PayementService $payementService, CarteService $carteService, PhotosFavorisService $photosFavorisService, ParameterBagInterface $params, TCPDFController $tcpdf, LoggerInterface $logger, PrinterService $printerService, EmailsCmdService $emailsCmdService)
{
$this->em = $em;
$this->session = $session;
$this->templating = $templating;
$this->mailer = $mailer;
$this->symfonyMailer = $symfonyMailer;
$this->EmailServie = $EmailCommandeService;
$this->urlGenerator = $urlGenerator;
$this->commandeService = $commandeService;
$this->emailsCmdService = $emailsCmdService;
$this->userService = $userService;
$this->typeProduiteService = $typeProduiteService;
$this->sejourService = $sejourService;
$this->attachementService = $attachementService;
$this->etablissementService = $etablissementService;
$this->payementService = $payementService;
$this->carteService = $carteService;
$this->photosFavorisService = $photosFavorisService;
$this->params = $params;
$this->tcpdf = $tcpdf;
$this->logger = $logger;
$this->printerService = $printerService;
}
/**
* @Route("/Parent/CreerAlbumSejourTest", name="CreerAlbumSejourTest")
*/
public function CreerAlbumSejourTest(Request $request)
{
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$idsejour = $request->get("id_du_sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$stat = $request->get('stat');
$version = $request->get('new');
$user = $this->getUser();
$Album = $serviceuser->savealbumAcc($page, $user, $idsejour, $prodid, $stat, $nomprod, $version);
//Envoi des mails aux parents
// Envoi SMS aux parents
// Envoi mail proposition achat groupé au accompagnateur
//YOSRA HERE
$PrentsConnextees = $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' => $idsejour));
dd($PrentsConnextees);
return new response('done');
}
/**
* @Route("/Parent/DirectAchatAlbumm", name="DirectAchatAlbumm")
*/
public function DirectAchatAlbumm(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$versionalbm = $request->get('new');
$user = $this->getUser();
$dateNow = new \Datetime();
$produit = $session->get("produittype");
$produitcondi = $session->get("produit");
$Album = $serviceuser->savealbumParent($page, $user, $sejour, $prodid, $produit, $produitcondi, $nomprod, $versionalbm);
$inser = false;
$produit = $this->em->getRepository(Produit::class)->find($Album->getId());
$em = $this->em;
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect", "typeref" => $typeref));
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($Album);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
$panierProduit->setQuantite(1);
$panierProduit->setPrixTotal($Album->getIdConditionnement()->getMontantTTC());
$this->em->getManager()->persist($panierProduit);
$this->em->getManager()->flush();
return new response('achat direct done');
}
/**
* @Route("/Parent/Achat_direct", name="Achat_direct")
*/
public function Achat_direct()
{
$em = $this->em;
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$typeref = $em->getRepository(Typeref::class)->find(8);
$user = $this->getUser();
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect", "typeref" => $typeref));
$panier = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
return $this->render('Parent/achatdirect.html.twig', ["user" => $user, "sejour" => $sejour, "panier" => $panier]);
}
/**
* @Route("/Parent/AccueilParent", name="AccueilParent")
*/
public function AccueilParent(Request $request, LoggerInterface $loggerInterface): Response
{
$session = $this->session;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$code = $request->get("codeSejour");
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
if (isset($code)) {
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
if ($sejour == null) {
$sejour = $this->em->getRepository(Sejour::class)->USeOldCodes($code);
if ($sejour == null) {
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 1, 'smsnotif' => $user->getSmsnotif()]);
}
} else {
$this->session->set('Sejour', $sejour->getId());
}
}
if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
$code = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($code);
} else {
$code = $request->get("codeSejour");
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
}
if ($sejour == null) {
$sejour = $this->em->getRepository(Sejour::class)->USeOldCodes($code);
}
if ($sejour == null) {
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 1, 'smsnotif' => $user->getSmsnotif()]);
}
$idSejour = $sejour->getId();
$SEjourService = $this->sejourService;
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$this->session->set('Sejour', $idSejour);
$dateCreationArch = clone $sejour->getDateFinCode();
if ($dateCreationArch <= new \DateTime()) {
return $this->render('Parent/SejourDepassee.html.twig');
}
$session->set('pageMenu', 'MonSejour');
$AllAttachements = $SEjourService->getphotosVideosSejour($idSejour, 'watermark', $userId);
$nbImages = count($AllAttachements);
$messages = $SEjourService->getCombinedattachSejour($idSejour, 'message');
$positions = $SEjourService->getsejourposition($idSejour);
$em = $this->em;
$idAcc = $sejour->getIdAcommp();
//VERIFICATION DE L EXISTANCE DE LIVRE OU D ALBUM SEJOUR
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
$label = "Livre_sejour" . $sejour->getCodeSejour();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$livreSej = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
if ($livreSej == null) {
$livreSejour = $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour", 'idsjour' => $sejour, 'labele' => $label, 'version' => "Livre_Admin"]);
}
$parentsejour = $SEjourService->getparentsejour($userId, $idSejour);
if ($parentsejour == NULL) {
$parentsejour = $SEjourService->inserparentsejour($userId, $idSejour);
}
if ($AllAttachements == null && $messages == null) {
$this->session->set('rout', 'rout');
return $this->render('Parent/Aucunphoto.html.twig', [
"sejour" => $sejour,
"parentsejour" => $parentsejour
]);
} else {
$attachementsCount = $AllAttachements['total'];
unset($AllAttachements['total']);
if ($sejour->getPaym() == 0) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
$em = $this->em;
$idAcc = $sejour->getIdAcommp();
$nbmessages = count($messages);
$nblikes = count($listeattachlikephoto);
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'albumAcc' => $albumAcc,
"livreSejour" => $livreSejour,
'listeattach' => $AllAttachements,
'nbmessages' => $nbmessages,
'attachementsCount' => $attachementsCount,
'prod' => $liste,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'nblikes' => $nblikes,
'likes' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
if ($sejour->getPaym() == 1) {
if ($parentsejour->getPayment() == 0) {
$this->session->set('rout', 'rout');
$ses_id = session_id();
return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour, 'images' => $AllAttachements, "session_id" => $ses_id, 'ParentSejour' => $parentsejour]);
}
if ($parentsejour->getPayment() == 1) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'attachementsCount' => $attachementsCount,
'prod' => $liste,
'albumAcc' => $albumAcc,
"livreSejour" => $livreSejour,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
}
}
}
/**
* @Route("/Parent/MessagesVocaux", name="MessagesVocaux")
*/
public function MessagesVocaux_Accueil(Request $request, LoggerInterface $loggerInterface): Response
{
$session = $this->session;
$session->set('pageMenu', 'MessagesVocaux');
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$code = $request->get("codeSejour");
$SEjourService = $this->sejourService;
if (isset($code)) {
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
if ($sejour == null) {
$sejour = $this->em->getRepository(Sejour::class)->USeOldCodes($code);
if ($sejour == null) {
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 1, 'smsnotif' => $user->getSmsnotif()]);
}
} else {
$this->session->set('Sejour', $sejour->getId());
}
}
if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
$code = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($code);
} else {
$code = $request->get("codeSejour");
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
}
if ($sejour == null) {
$sejour = $this->em->getRepository(Sejour::class)->USeOldCodes($code);
}
if ($sejour == null) {
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 1, 'smsnotif' => $user->getSmsnotif()]);
}
$idSejour = $sejour->getId();
$this->session->set('Sejour', $idSejour);
$dateCreationArch = clone $sejour->getDateFinCode();
if ($dateCreationArch <= new \DateTime()) {
return $this->render('Parent/SejourDepassee.html.twig');
}
$AllAttachements = $SEjourService->getCombinedattachSejour($idSejour, 'photoVideo');
$nbImages = count($AllAttachements);
$messages = $SEjourService->getCombinedattachSejour($idSejour, 'message');
$positions = $SEjourService->getsejourposition($idSejour);
$em = $this->em;
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => "1", 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$parentsejour = $SEjourService->getparentsejour($userId, $idSejour);
if ($parentsejour == NULL) {
$parentsejour = $SEjourService->inserparentsejour($userId, $idSejour);
}
if ($AllAttachements == null && $messages == null) {
$this->session->set('rout', 'rout');
return $this->render('Parent/Aucunphoto.html.twig', [
"sejour" => $sejour,
"parentsejour" => $parentsejour
]);
} else {
$attachementsCount = $AllAttachements['total'];
unset($AllAttachements['total']);
if ($sejour->getPaym() == 0) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'albumAcc' => $albumAcc,
'listeattach' => $AllAttachements,
'attachementsCount' => $attachementsCount,
'prod' => $liste,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
if ($sejour->getPaym() == 1) {
if ($parentsejour->getPayment() == 0) {
$this->session->set('rout', 'rout');
$ses_id = session_id();
return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour, 'images' => $AllAttachements, "session_id" => $ses_id, 'ParentSejour' => $parentsejour]);
}
if ($parentsejour->getPayment() == 1) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'attachementsCount' => $attachementsCount,
'prod' => $liste,
'nbImages' => $nbImages,
'albumAcc' => $albumAcc,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
}
}
}
/**
* @Route("/Parent/MesFavoris_Accueil", name="MesFavoris_Accueil")
*/
public function MesFavoris_Accueil(Request $request, LoggerInterface $loggerInterface): Response
{
$session = $this->session;
$session->set('pageMenu', 'MesFavoris');
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$code = $request->get("codeSejour");
$SEjourService = $this->sejourService;
if (isset($code)) {
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
if ($sejour == null) {
$sejour = $this->em->getRepository(Sejour::class)->USeOldCodes($code);
if ($sejour == null) {
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 1, 'smsnotif' => $user->getSmsnotif()]);
}
} else {
$this->session->set('Sejour', $sejour->getId());
}
}
if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
$code = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($code);
} else {
$code = $request->get("codeSejour");
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
}
if ($sejour == null) {
$sejour = $this->em->getRepository(Sejour::class)->USeOldCodes($code);
}
if ($sejour == null) {
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 1, 'smsnotif' => $user->getSmsnotif()]);
}
$idSejour = $sejour->getId();
$this->session->set('Sejour', $idSejour);
$dateCreationArch = clone $sejour->getDateFinCode();
$em = $this->em;
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$livreSej = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
if ($dateCreationArch <= new \DateTime()) {
return $this->render('Parent/SejourDepassee.html.twig');
}
$AllAttachements = $SEjourService->getCombinedattachSejour($idSejour, 'photoVideo');
$nbImages = count($AllAttachements);
$messages = $SEjourService->getCombinedattachSejour($idSejour, 'message');
$positions = $SEjourService->getsejourposition($idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$parentsejour = $SEjourService->getparentsejour($userId, $idSejour);
if ($parentsejour == NULL) {
$parentsejour = $SEjourService->inserparentsejour($userId, $idSejour);
}
if ($AllAttachements == null && $messages == null) {
$this->session->set('rout', 'rout');
return $this->render('Parent/Aucunphoto.html.twig', [
"sejour" => $sejour,
"parentsejour" => $parentsejour
]);
} else {
$attachementsCount = $AllAttachements['total'];
unset($AllAttachements['total']);
if ($sejour->getPaym() == 0) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
$em = $this->em;
$idAcc = $sejour->getIdAcommp();
$label = "Livre_sejour" . $sejour->getCodeSejour();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$livreSej = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
if ($livreSej == null) {
$livreSejour = $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour", 'idsjour' => $sejour, 'labele' => $label, 'version' => "Livre_Admin"]);
}
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
"livreSejour" => $livreSejour,
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'attachementsCount' => $attachementsCount,
'prod' => $liste,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd,
'albumAcc' => $albumAcc,
]);
}
if ($sejour->getPaym() == 1) {
if ($parentsejour->getPayment() == 0) {
$this->session->set('rout', 'rout');
$ses_id = session_id();
return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour, 'images' => $AllAttachements, "session_id" => $ses_id, 'ParentSejour' => $parentsejour]);
}
if ($parentsejour->getPayment() == 1) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'attachementsCount' => $attachementsCount,
'prod' => $liste,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
}
}
}
/**
* @Route("/Parent/DetailsSejour", name="DetailsSejour")
*/
public function ModifierSejour()
{
$SEjourService = $this->sejourService;
$sejour = $SEjourService->getsejour(3);
$listeattach = $SEjourService->getatachmentsejour(3);
$positions = $SEjourService->getsejourposition(3);
$messages = $SEjourService->getsejourmessage(3);
//dd($messages);
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
return $this->render('Parent/DetailsSejour.html.twig', [
'prod' => $liste,
'sejour' => $sejour,
'listeattach' => $listeattach,
'positions' => $positions,
'messages' => $messages,
]);
}
/**
* @Route("/Parent/listefavorie", name="listefavorie")
*/
public function listefavorie()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
dd($listeattachlikephoto);
return ('yoopii');
}
/**
* @Route("/Parent/Store", name="boutique5sur5")
*/
public function boutique5sur5()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $userId */
$userId = $this->getUser();
$userId = $userId->getId();
$session = $this->session;
$session->set('pageMenu', 'boutique5su5');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$nbImages = count($listeattach);
$nbmessages = count($messages);
$produit = $this->typeProduiteService;
$liste = $produit->produitlistTypeConditionnement();
$idAcc = $sejour->getIdAcommp();
$em = $this->em;
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$nbLikes = count($listeattachlikephoto);
// dd($liste);
return $this->render('Parent/boutique_5sur5.html.twig', [
"sejour" => $sejour,
'like' => $listeattachlikephoto,
'produit' => $liste,
'albumAcc' => $albumAcc,
'nbImages' => $nbImages,
'nbmessages' => $nbmessages,
'nbLikes' => $nbLikes
]);
}
/*public function maSelection()
{
$SEjourService = $this->sejourService;
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$produit = $this->typeProduiteService;
$liste = $produit->produitlistTypeConditionnement();
$idAcc = $sejour->getIdAcommp();
$em = $this->em;
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
// dd($liste);
return $this->render('Parent/VoirMaSelection.html.twig', [
"sejour" => $sejour,
'like' => $listeattachlikephoto, 'produit' => $liste, 'albumAcc' => $albumAcc
]);
}*/
/**
* @Route("/Parent/MaSelection", name="maSelection")
*/
public function maSelection()
{
//Yosra
$nbLikes = 0;
$SEjourService = $this->sejourService;
$session = $this->session;
$session->set('pageMenu', 'Meselection');
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$SEjourService = $this->sejourService;
$SEjourService->inserparentsejourPayenet($iduser, $idSejour);
$sejour = $SEjourService->getsejour($idSejour);
$positions = $SEjourService->getsejourposition($idSejour);
//$messages = $SEjourService->getsejourmessage($idSejour);
$messages = $SEjourService->getCombinedattachSejour($idSejour, 'message');
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($iduser, $idSejour);
$nbLikes = count($listeattachlikephoto);
/* $listeattach = $SEjourService->getatachmentsejour($idSejour);
$listeVideo = $SEjourService->getVideosejour($idSejour);
$AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
$AllAttachements = $SEjourService->getCombinedattachSejour($idSejour, 'photoVideo');
$attachementsCount = $AllAttachements['total'];
unset($AllAttachements['total']);
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
"listeattach" => $AllAttachements,
'attachementsCount' => $attachementsCount,
'positions' => $positions,
'messages' => $messages,
'likes' => $listeattachlikephoto,
'like' => $listeattachlikephoto,
'nblikes' => $nbLikes,
'nbImages' => $attachementsCount,
"parentsejour" => $parentsejour,
'prod' => $liste,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
/**
* @Route("/Parent/MesPhotosPerso", name="mesPhotosperso")
*/
public function mesPhotosperso()
{ //Yosra
$SEjourService = $this->sejourService;
$session = $this->session;
$session->set('pageMenu', 'Meselection');
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$SEjourService = $this->sejourService;
$sejour = $SEjourService->getsejour($idSejour);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$listeattachlikephoto = $this->em->getRepository(SejourAttachment::class)->findBy(['idParent' => $iduser, 'statut' => "private", 'idSejour' => $sejour]);
//$listeattach = $SEjourService->getatachmentsejour($idSejour);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$listeVideo = $SEjourService->getVideosejour($idSejour);
$AllAttachements = array_merge_recursive($listeattach, $listeVideo);
$attachementsCount = count($listeattach);
$nbImages = count($listeattachlikephoto);
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
return $this->render('Parent/MesPhotosPerso.html.twig', [
"sejour" => $sejour,
'attachementsCount' => $attachementsCount,
'listeattach' => $AllAttachements,
'positions' => $positions,
'nbImages' => $nbImages,
'messages' => $messages,
'likes' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'prod' => $liste,
'smsnotif' => $parentsejour->getSmsnotif()
]);
}
/**
* @Route("/Parent/achatBoiteVocale", name="achatBoiteVocale")
*/
public function achatBoiteVocale()
{
$this->session->set('rout', 'rout');
$session = $this->session;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$idSejour = $session->get("Sejour");
$ses_id = session_id();
$SEjourService = $this->sejourService;
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$AllAttachements = $SEjourService->getCombinedattachSejour($idSejour, 'photoVideo');
return $this->render('Parent/achatBoiteVocale.html.twig', ["sejour" => $sejour, 'images' => $AllAttachements, "session_id" => $ses_id, 'ParentSejour' => $parentsejour]);
}
/**
* @Route("/Parent/achatsejour", name="achatsejour")
*/
public function achatsejour()
{
$this->session->set('rout', 'rout');
$session = $this->session;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$idSejour = $session->get("Sejour");
$ses_id = session_id();
$SEjourService = $this->sejourService;
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$AllAttachements = $SEjourService->getCombinedattachSejour($idSejour, 'photoVideo');
return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour, 'images' => $AllAttachements, "session_id" => $ses_id, 'ParentSejour' => $parentsejour]);
}
/**
* @Route("/Parent/CodeSejour", name="CodeSejour")
*/
public function CodeSejour()
{
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$this->session->set('rout', 'code');
return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user, "defaultval" => 0, 'smsnotif' => $user->getSmsnotif()]);
}
/** @Route("/Parent/produits", name="produit_parent")
*/
public function produitsparent()
{
$SEjourService = $this->sejourService;
$produitparent = $this->typeProduiteService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$listproduit = $produitparent->produitparent();
return ('yoopii');
}
/**
* @Route("/Parent/AucunePhoto", name="AucunePhoto")
* */
public function premiercnx()
{
$this->session->set('rout', 'rout');
return $this->render('Parent/Aucunphoto.html.twig');
}
/**
* @Route("/Parent/notif", name="notif_parent",methods={"POST","GET"})
*/
public function notif_parent(Request $request)
{
$UserService = $this->userService;
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
// $sejour = $sejourservice->getsejourpourparent($idSejour);
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$sms = $request->get("sms");
$mail = $request->get('mail');
$refaverti = $request->get('refaverti');
//$ville = $request->get("nonnotif");
$parentsejour = $UserService->notifparentsejour($mail, $sms, $idSejour, $iduser, $refaverti);
return new JsonResponse('done');
}
/**
* @Route("/Parent/passerconnxion", name="notif_parenpasserconnxion",methods={"POST","GET"})
*/
public function passerconnxion(Request $request)
{
$UserService = $this->userService;
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
// $sejour = $sejourservice->getsejourpourparent($idSejour);
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$SEjourService = $this->sejourService;
$setparentsejour = $SEjourService->inserparentsejourPayenet($iduser, $idSejour);
$sejour = $SEjourService->getsejour($idSejour);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($iduser, $idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
if (sizeof($sejour->getAttachements()) == 0) {
return new JsonResponse('0');
} else {
return new JsonResponse('1');
}
}
/**
* @Route("/Parent/sejourParent", name="sejourParent_5sur5")
* */
public function sejourParent()
{
$SEjourService = $this->sejourService;
$UserService = $this->userService;
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
// $sejour = $sejourservice->getsejourpourparent($idSejour);
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$SEjourService = $this->sejourService;
$setparentsejour = $SEjourService->inserparentsejourPayenet($iduser, $idSejour);
$sejour = $SEjourService->getsejour($idSejour);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($iduser, $idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbImages = count($listeattach);
$listeVideo = $SEjourService->getVideosejour($idSejour);
$AllAttachements = array_merge_recursive($listeattach, $listeVideo);
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'positions' => $positions,
'nbImages' => $nbImages,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'prod' => $liste,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
/**
* @Route("/Parent/sejourVide", name="sejourvideee")
* */
public function sejourvide()
{
$this->session->set('rout', 'code');
$SEjourService = $this->sejourService;
$UserService = $this->userService;
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
// $sejour = $sejourservice->getsejourpourparent($idSejour);
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$SEjourService = $this->sejourService;
$setparentsejour = $SEjourService->inserparentsejourPayenet($iduser, $idSejour);
$sejour = $SEjourService->getsejour($idSejour);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$parentsejour = $SEjourService->getparentsejour($iduser, $idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($iduser, $idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
return $this->render('Parent/Aucunphoto.html.twig', [
"sejour" => $sejour,
"parentsejour" => $parentsejour
]);
}
/**
* @Route("Parent/EditContenuPage", name="EditContenuPage")
*/
public function EditContenuPageParent()
{
$em = $this->em;
$Albumproduct = $em->getRepository(Produit::class)->findBy(['idConditionnement' => 4]);
foreach ($Albumproduct as $album) {
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $album]);
foreach ($AllPages as $p) {
$arrayexploded = $p->getCouleurbordure();
$arrayexploded1 = str_replace("font-size", "fontSize", $arrayexploded);
$p->setCouleurbordure($arrayexploded1);
$em->getManager()->persist($p);
$em->getManager()->flush();
}
}
return new Response('ok');
}
/**
* @Route("Parent/AjoutAlbum", name="EditionAlbum")
*/
public function EditionAlbumParent()
{
$SEjourService = $this->sejourService;
$em = $this->em;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', 'AlbumSejour');
$idSejour = $session->get("Sejour");
$clipart = null;
$random = true;
$sejour = $SEjourService->getsejourpourparent($idSejour);
$idAcc = $sejour->getIdAcommp();
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$listerandom = $listeattach;
$nbPhoto = count($listeattach);
$AllPagesAcc = null;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc) {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
$allpagesResult = array();
$tabacc = array();
$tabacc1 = array();
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
$rr = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listerandom = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
}
if ($nbLikes != 0) {
$listerandom = $SEjourService->getlikephotosejour($userId, $idSejour);
$arrayRsRandom = $this->random_function($listerandom);
}
if ($nbLikes == 0) {
$arrayRsRandom = $this->random_functionNolikes($listerandom);
}
array_push($tabacc, $arrayRsRandom['idelem']);
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
}
$AllPages = $allpagesResult;
}
$tabacc1 = array_count_values($tabacc);
if ($nbLikes == 0) {
return $this->render('Parent/NewAlbumLikes.html.twig', ["listeattach" => $listeattach, "tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbPhoto]);
}
if ($nbLikes != 0) {
return $this->render('Parent/NewAlbumLikes.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbPhoto]);
}
}
/**
* @Route("Parent/AjoutPochettePhotos_Sejour/{nbr}", name="AjoutPochettePhotos_Sejour")
*/
public function AjoutPochettePhotosParent_Sejour($nbr)
{
$SEjourService = $this->sejourService;
$userId = $this->getUser()->getId();
$user = $this->getUser();
$session = $this->get('session');
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->getDoctrine()->getManager();
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$listerandom = $listeattach;
$AllPagesAcc = null;
// $random = false;
// $Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $userId], ['id' => 'DESC']);
// if ($Albumproduct == null || $Albumproduct == "") {
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' . $nbr]);
$random = true;
// }
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
//$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
//dd($part);
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
// dd($Albumproduct);
if ($albumAcc != null and $albumAcc != "") {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
// dd($albumAcc);
$allpagesResult = array();
$j = 0;
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
// var_dump($arrayexploded);
$rr = "";
$elemPath = "";
$elemId = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
$listerandom = $listeattach;
}
$arrayRsRandom = $this->random_functionPhotoNolIKES($listerandom, $j);
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
if ($j < sizeof($listeattach) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
$AllPages = $allpagesResult;
}
// die();
$nbAttach = count($listeattach);
return $this->render('Parent/PochettePhotos.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'photosSejour' => $listeattach, 'nbAttach' => $nbAttach]);
}
/**
* @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
*/
public function EnregistrerPochettePhoto($nbr)
{
$SEjourService = $this->sejourService;
$user = $this->getUser();
$userId = $this->getUser()->getId();
$session = $this->get('session');
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->getDoctrine()->getManager();
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$listerandom = $listeattachlikephoto;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' . $nbr]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$allpagesResult = array();
$j = 0;
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
// var_dump($arrayexploded);
$rr = "";
$elemPath = "";
$elemId = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
$listerandom = $listeattachlikephoto;
}
$arrayRsRandom = $this->random_functionPhoto($listerandom);
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
if ($j < sizeof($listeattachlikephoto) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
$AllPages = $allpagesResult;
// die();
return new JsonResponse('done');
}
/**
* @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
*/
public function AjoutPochettePhotosParent_Fav($nbr)
{
$SEjourService = $this->sejourService;
$user = $this->getUser();
$userId = $this->getUser()->getId();
$session = $this->get('session');
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->getDoctrine()->getManager();
$listeattachlikephoto = $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId, 'idSejour' => $idSejour]);
foreach ($listeattachlikephoto as $photo) {
$idattach = $photo->getIdSejourAttchment();
$SejattachPhoto = $photo->getIdSejourAttchment();
$urlPhoto = $SejattachPhoto->getIdAttchment()->getPath();
//$urlPhoto = $attachPhoto->getPath();
$new_url = str_replace('upload/', 'upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/', $urlPhoto);
$photosData[] = [
'id' => $photo->getId(),
'url' => $new_url,
'caption' => "",
];
}
$nbLikes = count($listeattachlikephoto);
// Convertir le tableau PHP en JSON
$photosDataJSON = json_encode($photosData);
return $this->render('Parent/PochettePhotosLikes.html.twig', ["nbr" => $nbr, "sejour" => $sejour, "nbLikes" => $nbLikes, 'photosFav' => $photosDataJSON]);
}
/**
* @Route("Parent/AjoutRetroPhotos_Fav/{nbr}", name="AjoutRetroPhotos_Favoris")
*/
public function AjoutRetroPhotosParent_Fav($nbr)
{
$SEjourService = $this->sejourService;
$user = $this->getUser();
$userId = $this->getUser()->getId();
$session = $this->get('session');
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->getDoctrine()->getManager();
$listeattachlikephoto = $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId, 'idSejour' => $idSejour]);
foreach ($listeattachlikephoto as $photo) {
$idattach = $photo->getIdSejourAttchment();
$SejattachPhoto = $photo->getIdSejourAttchment();
$urlPhoto = $SejattachPhoto->getIdAttchment()->getPath();
//$urlPhoto = $attachPhoto->getPath();
$new_url = str_replace('upload/', 'upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/', $urlPhoto);
$photosData[] = [
'id' => $photo->getId(),
'url' => $new_url,
'caption' => "",
];
}
$nbLikes = count($listeattachlikephoto);
// Convertir le tableau PHP en JSON
$photosDataJSON = json_encode($photosData);
return $this->render('Parent/RetroRefonte.html.twig', ["nbr" => $nbr, "sejour" => $sejour, "nbLikes" => $nbLikes, 'photosFav' => $photosDataJSON]);
}
function random_function($listerandom)
{
$elem = array_rand($listerandom);
$photo = $listerandom[$elem];
$idelem = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
$pathelem = $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
return array('pathelem' => $pathelem, 'idelem' => $idelem, 'elem' => $elem);
}
function random_functionNolikes($listerandom)
{
//dd(array_keys($listerandom));
$elem = array_rand($listerandom);
$photo = $listerandom[$elem];
$idelem = $photo["id"];
$pathelem = $photo["path"];
return array('pathelem' => $pathelem, 'idelem' => $idelem, 'elem' => $elem);
}
function random_functionPhoto($listerandom)
{
$elem = array_rand($listerandom);
$photo = $listerandom[$elem];
$idelem = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
$pathelem = $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
return array('pathelem' => $pathelem, 'idelem' => $idelem, 'elem' => $elem);
}
function random_functionPhotosSejour($listerandom, $elem)
{
$elem = array_rand($listerandom);
$photo = $listerandom[$elem];
$idelem = $photo->getId();
$pathelem = $photo->getPath();
return array('pathelem' => $pathelem, 'idelem' => $idelem, 'elem' => $elem);
}
function random_functionPhotoNolIKES($listerandom, $elem)
{
$elem = array_rand($listerandom);
$photo = $listerandom[$elem];
$idelem = $photo['id'];
$pathelem = $photo['path'];
return array('pathelem' => $pathelem, 'idelem' => $idelem, 'elem' => $elem);
}
/**
* @Route("Parent/LivrePhotos", name="LivrePhotos")
*/
public function EditionLivrePhotosParent()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = null;
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listerandom = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$random = true;
$allpagesResult = array();
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$tabacc = array();
$tabacc1 = array();
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
$rr = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listerandom = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
}
if ($nbLikes != 0) {
$listerandom = $SEjourService->getlikephotosejour($userId, $idSejour);
$arrayRsRandom = $this->random_function($listerandom);
}
if ($nbLikes == 0) {
$arrayRsRandom = $this->random_functionNolikes($listerandom);
}
array_push($tabacc, $arrayRsRandom['idelem']);
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
}
$AllPages = $allpagesResult;
$tabacc1 = array_count_values($tabacc);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$nbPhotos = count($listeattach);
$nbLike = count($listeattachlikephoto);
if ($nbLike == 0) {
return $this->render('Parent/NewLivre.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes, 'nbPhotos' => $nbPhotos]);
}
if ($nbLike != 0) {
return $this->render('Parent/NewLivreLikes.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes, 'nbPhotos' => $nbPhotos]);
}
}
/**
* @Route("Parent/AjoutPochettePhotos/{nbr}", name="AjoutPochettePhotos")
*/
public function AjoutPochettePhotosParent($nbr)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
//$listeattach = $SEjourService->getatachmentsejour($idSejour);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$nbPhoto = count($listeattach);
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
$listerandom = array();
$listerandom = $listeattach;
$AllPagesAcc = null;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' . $nbr]);
$random = true;
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
if ($albumAcc != null and $albumAcc != "") {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
$allpagesResult = array();
$j = 0;
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
$rr = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listerandom = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
}
if ($nbLikes != 0) {
$listerandom = $listeattachlikephoto;
$arrayRsRandom = $this->random_functionPhoto($listerandom);
}
if ($nbLikes == 0) {
$arrayRsRandom = $this->random_functionPhotoNolIKES($listerandom, $j);
}
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
if ($j < sizeof($listeattachlikephoto) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
$AllPages = $allpagesResult;
}
return $this->render('Parent/PochettePhotos.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbPhoto' => $nbPhoto, 'Likes' => $nbLikes]);
}
/**
* @Route("Parent/AjoutPhotosRetrosFavoris/{nbr}", name="AjoutPhotosRetros_Favoris")
*/
public function AjoutPhotosRetrosParentFavoris($nbr)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
//$listeattach = $SEjourService->getatachmentsejour($idSejour);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$listerandom = $listeattach;
$AllPagesAcc = null;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' . $nbr]);
$random = true;
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
if ($albumAcc != null and $albumAcc != "") {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
$allpagesResult = array();
$j = 0;
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
$rr = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listerandom = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
}
if ($nbLikes != 0) {
$listerandom = $SEjourService->getlikephotosejour($userId, $idSejour);
$arrayRsRandom = $this->random_functionPhoto($listerandom);
}
if ($nbLikes == 0) {
$arrayRsRandom = $this->random_functionPhotoNolIKES($listerandom, $j);
}
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
if ($j < sizeof($listeattachlikephoto) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
$AllPages = $allpagesResult;
}
return $this->render('Parent/RetroRefonte.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes]);
}
/**
* @Route("Parent/AjoutPhotosRetros/{nbr}", name="AjoutPhotosRetros")
*/
public function AjoutPhotosRetrosParent($nbr)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
//$listeattach = $SEjourService->getatachmentsejour($idSejour);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
if ($nbLikes == 0) {
$listerandom = $listeattach;
}
if ($nbLikes != 0) {
$listerandom = $listeattachlikephoto;
}
$AllPagesAcc = null;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' . $nbr]);
$random = true;
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
if ($albumAcc != null and $albumAcc != "") {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
$allpagesResult = array();
$j = 0;
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
$rr = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if ($nbLikes == 0) {
$arrayRsRandom = $this->random_functionPhotoNolIKES($listerandom, $j);
}
if ($nbLikes != 0) {
$arrayRsRandom = $this->random_functionPhoto($listeattachlikephoto);
}
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
if ($nbLikes == 0) {
if ($j < sizeof($listeattachlikephoto) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
if ($nbLikes != 0) {
if ($j < sizeof($listeattach) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
$AllPages = $allpagesResult;
}
}
if ($nbLikes == 0) {
return $this->render('Parent/PochettePhotosLikes.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattach, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes]);
}
if ($nbLikes != 0) {
return $this->render('Parent/PochettePhotosLikes.html.twig ', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes]);
}
}
/**
* @Route("Parent/CalendrierParent", name="CalendrierParent")
*/
public function CalendrierParent()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$listerandom = $listeattachlikephoto;
$AllPagesAcc = null;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomcalendrier']);
$random = true;
// }
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
//$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
//dd($part);
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
// dd($Albumproduct);
if ($albumAcc != null and $albumAcc != "") {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
// dd($albumAcc);
$allpagesResult = array();
$tabacc = array();
$tabacc1 = array();
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
//dd($arrayexploded);
$rr = "";
$elemPath = "";
$elemId = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
$listerandom = $SEjourService->getlikephotosejour($userId, $idSejour);
}
$arrayRsRandom = $this->random_function($listerandom);
array_push($tabacc, $arrayRsRandom['idelem']);
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
}
$AllPages = $allpagesResult;
}
$tabacc1 = array_count_values($tabacc);
return $this->render('Parent/Calendrier.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random]);
}
/**
* @Route("Parent/ListeSejour", name="ListeSejourParent")
*/
public function ListeSejourParent()
{
return $this->render('Parent/AccueillParent.html.twig', []);
}
/**
* @Route("/parent/couverture", name="choixCouverture")
*/
public function sur5()
{
return $this->render('Parent/couverture.html.twig');
}
/**
* @Route("/", name="footerparent")
*/
public function footerparent(): Response
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
$session = $this->session;
$destination = $session->get("destionation");
$nbvocal = 0;
$nbSlection = 0;
$nbPhoto = 0;
$sejour = null;
$sejourservice = $this->sejourService;
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$albumAcc = null;
$em = $this->em;
if ($idSejour != null) {
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
// Nb favoris
$listeattachlikephoto = $sejourservice->getlikephotosejour($userId, $idSejour);
$nbSlection = count($listeattachlikephoto);
// Nb photos
$listeattach = $sejourservice->getatachmentsejour($idSejour);
$nbPhoto = count($listeattach);
// Nb messages vocaux
$messages = $sejourservice->getsejourmessage($idSejour);
$nbvocal = count($messages);
// Rechercher s'il y'a un album acompagnateur
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
}
return $this->render('Parent/footerParent.html.twig', [
'destionation' => $destination,
'nbvocal' => $nbvocal,
'nbSlection' => $nbSlection,
'nbPhotos' => $nbPhoto,
'albumAcc' => $albumAcc,
]);
}
/**
* @Route("/", name="heedear")
*/
public function headerparenrt(): Response
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
$nblikes = 0;
$nbmesssages = 0;
// dd($liste);
$session = $this->session;
$panierSession = $session->get("Panier");
$destination = $session->get("destionation");
$nbvocal = 0;
$idSejour = $session->get("Sejour");
$sejour = null;
if ($idSejour != null) {
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
}
$Products = $session->get("Panier");
$numSuivi = false;
if ($sejour != null) {
$Products = $session->get("Panier");
if ($Products == Null) {
$Products = [];
}
$UserService = $this->userService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$containsProduitType20 = false;
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$commandes = $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour, "idUser" => $iduser]);
$sejourparent = $this->em->getRepository(ParentSejour::class)->findOneBy(['idSejour' => $idSejour, "idParent" => $iduser]);
$payment = $sejourparent->getPayment();
// Check commands
foreach ($commandes as $commande) {
$commandCondition = $commande->getNumSuivi();
$status = $commande->getStatut()->getId();
if ($commandCondition == 1 && $status == 33) {
$containsProduitType20 = true;
break; // No need to check further if condition is met
}
}
// Check panierSession if the condition is not met in commandes
if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
foreach ($panierSession as $item) {
// Access the details of each item in the Panier
$condition = $item['condition'];
$codesejour = $item['codesejour'];
if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
$containsProduitType20 = true;
break; // No need to check further if condition is met
}
}
}
$sejourservice = $this->sejourService;
$messages = $sejourservice->getsejourmessage($idSejour);
$nbmesssages = count($messages);
$listeattachlikephoto = $sejourservice->getlikephotosejour($iduser, $idSejour);
$nblikes = count($listeattachlikephoto);
$em = $this->em;
$label = "Livre_sejour" . $sejour->getCodeSejour();
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'Album_sejour']);
$livreSej = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'Livre_sejour']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
if ($livreSej == null) {
$livreSejour = $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour", 'idsjour' => $sejour, 'labele' => $label, 'version' => "Livre_Admin"]);
}
$code_sejour = $sejour->getCodeSejour();
return $this->render('Parent/headerParent.html.twig', [
'produit' => $liste,
'sejour' => $sejour,
'livreSejour' => $livreSejour,
'Products' => $Products,
'destionation' => $destination,
'nbvocal' => $nbmesssages,
'albumAcc' => $albumAcc,
'nbLikes' => $nblikes,
'code_sejour' => $code_sejour,
'payment' => $payment
]);
}
if ($sejour == null) {
return $this->render('Parent/headerParent2.html.twig');
}
}
/**
* @Route("/Parent/disablepack", name="disablePack")
*/
public function disableFreepack()
{
//this section is used to disale the freePackOffert
$em = $this->em;
$session = $this->session;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$idSejour = $session->get("Sejour");
$SEjourService = $this->sejourService;
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$panierSession = $session->get("Panier");
$containsProduitType20 = false;
$nbrphoto = count($listeattach);
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$containsProduitType20 = false;
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$commandes = $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour, "idUser" => $iduser]);
// Check commands
foreach ($commandes as $commande) {
$commandCondition = $commande->getNumSuivi();
$status = $commande->getStatut()->getId();
// Check if Num Suivi is set one and if payment is completed
if ($commandCondition == 1 && $status == 33) {
$containsProduitType20 = true;
break; // No need to check further if condition is met
}
}
// Check panierSession if the condition is not met in commandes
if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
foreach ($panierSession as $item) {
// Access the details of each item in the Panier
$condition = $item['condition'];
$codesejour = $item['codesejour'];
if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
$containsProduitType20 = true;
break; // No need to check further if condition is met
}
}
}
return new JsonResponse(['containsProduitType20' => $containsProduitType20, 'idSejour' => $nbrphoto]);
}
/**
* @Route("/Parent/disablepackpanier", name="disablePackpanier")
*/
public function disableFreepackpanier(): JsonResponse
{
//this section is used to disale the + in the panier for the packOffert
$em = $this->em;
$disabledProductIds = [];
$session = $this->session;
$panierSession = $session->get("Panier");
$ids = [];
foreach ($panierSession as $item) {
$ids[] = $item['id'];
}
if ($panierSession) {
foreach ($ids as $id) {
$panierProduits = $em->getRepository(PanierProduit::class)->findBy(['idProduit' => $id]);
foreach ($panierProduits as $panierProduit) {
$produit = $panierProduit->getIdProduit();
$type = $produit->getType();
// Check if the product type is 20 and add to disabledProductIds if true
if ($type && $type->getId() == 20) {
$disabledProductIds[] = $produit->getId();
}
}
}
return new JsonResponse(['disabledProductIds' => $disabledProductIds]);
}
}
/**
* @Route("/", name="heedear2")
*/
public function headerparenrt2(): Response
{
$session = $this->session;
$produit = $this->typeProduiteService;
$nbvocal = 0;
$idSejour = $session->get("Sejour");
$liste = $produit->produitlistType();
$session = $this->session;
$destination = $session->get("destionation");
$Products = $session->get("Panier");
if ($Products == Null) {
$Products = [];
}
return $this->render('Parent/headerParent2.html.twig', [
'produit' => $liste,
'Products' => $Products,
'destionation' => $destination,
'nbvocal' => $nbvocal
]);
}
/**
* @Route("/Parent/ParametresParent", name="ParametresParent")
*/
public function Parametreparent()
{
// $sejourservice = $this->sejourService;
//$sejour = $sejourservice->getparentsejour($id, $this->getUser());
///$session = $this->session;
//$session->set('moncompte', 'parametres');
$user = $this->getUser();
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$ParentSejour = $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour, 'idParent' => $user]);
//ParentSejour
//cablala
//dd($ParentSejour[0]);
//$listeattach = $sejourservice->getatachmentsejour($id);
//$listeattachM = $sejourservice->getsejourmessage($id);
return $this->render('Parent/Parentparametre.html.twig', [
'user' => $user,
'sejour' => $sejour,
'ParentSejour' => $ParentSejour[0],
]);
}
/**
* @Route("/Parent/Accueil5sur5/ajouteradresslirison", name="ajouteradress_livrson",methods={"POST"})
*/
public function ajouteradresslivr(Request $request)
{
$UserService = $this->userService;
//dd($this->getUser()->getId());
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$prenom = $request->get("prenom");
$nom = $request->get("nom");
$organism = $request->get("organism");
$num = $request->get("num");
$rue = $request->get('ruevoi');
$ville = $request->get("villle");
$pays = $request->get("pays");
$codepostal = $request->get("codpostal");
//adress facturation if exsist
$prenomfacturation = $request->get("prenomadressfacturation");
$nomfacturation = $request->get("nomadressfacturation");
$organismfacturation = $request->get("etablismadressfacturation");
$numfacturation = $request->get("numdressfacturation");
$ruefacturation = $request->get('rueadressfacturation');
$villefacturation = $request->get("villefacturation");
$paysfacturation = $request->get("payadressfacturation");
$codepostalfacturation = $request->get("codepostalfacturation");
//modification userPArent
$usernomAcommpa = $request->get("usernom");
$userprenomAcommpa = $request->get("userprenom");
$userfonctionAcommpa = $request->get("userfonction");
$useretablismentAcommpa = $request->get("useretablisment");
$useremailcommpa = $request->get("useremail");
$sejourthem = $request->get("sejourthem");
$adresssejour = $request->get("sejouradresse");
$id = $request->get("id");
$adress = $UserService->setadresslivraison($num, $rue, $ville, $pays, $codepostal, $iduser, $prenom, $nom, $organism, $prenomfacturation, $nomfacturation, $organismfacturation, $numfacturation, $ruefacturation, $villefacturation, $paysfacturation, $codepostalfacturation, $usernomAcommpa, $userprenomAcommpa, $userfonctionAcommpa, $useretablismentAcommpa, $useremailcommpa, $sejourthem, $adresssejour, $id);
return new JsonResponse('done');
}
/**
* @Route("/Accueil5sur5/ajouteradressfacturation", name="ajouteradress_facturation",methods={"POST","GET"})
*/
public function ajouteradressfacturation(Request $request)
{
$UserService = $this->userService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$num = $request->get("num");
$rue = $request->get('rue');
$ville = $request->get("ville");
$pays = $request->get("pays");
$codepostal = $request->get("codepostal");
$adress = $UserService->setadressfacturation($num, $rue, $ville, $pays, $codepostal, $iduser);
return new JsonResponse('done');
}
/**
* @Route("/EntrezCode", name="EntrezCode")
*/
public function EntrezCode(Request $request)
{
$email = $request->get('email');
$password = $request->get('password');
$this->session->set('rout', 'code');
return $this->redirectToRoute('CodeSejour', ['email' => $email, 'password' => $password]);
}
/**
* @Route("/DemandeCode", name="DemandeCode")
*/
public function DemandeCode(Request $request)
{
$nomEnfant = $request->get('nomEnfant');
$prenomEnfant = $request->get('prenomEnfant');
$votreNom = $request->get('votreNom');
$votrePrenom = $request->get('votrePrenom');
$Mail = $request->get('Mail');
$votreLien = $request->get('votreLien');
$du = $request->get('du');
$au = $request->get('au');
$code = $request->get('code');
$ville = $request->get('ville');
$listeSejour = $this->em->getRepository(Sejour::class)->listAcco($du, $au, $code, $ville);
$RefEmail = $this->em->getRepository(Ref::class)->find(23);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
foreach ($listeSejour as $accompagnateur) {
$sendTo = $accompagnateur->getIdAcommp()->getEmail();
$message = (new \Swift_Message('Demande code séjour'))
->setFrom('contact@5sur5sejour.com')
->setTo($sendTo);
//->setBcc("contact@5sur5sejour.com");
$pathImage2 = $Email->getIdImage2()->getPath();
$pathImage1 = $Email->getIdImage1()->getPath();
$image1 = $message->embed(Swift_Image::fromPath("$pathImage1"));
$image2 = $message->embed(Swift_Image::fromPath("$pathImage2"));
$iconphoto = $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_419_pqx0dx._6656d07326a50.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_420_uynuqz._6656d10f4daaf.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_418_wbyysk._6656d16240404.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
$iMagesProduits = $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
$message->setBody(
$this->templating->render(
'emails/ParentDemandeCodeSejour.html.twig',
[
"nomAcco" => $accompagnateur->getIdAcommp()->getNom(),
"prenomAcco" => $accompagnateur->getIdAcommp()->getPrenom(),
"nomEnfant" => $nomEnfant,
"prenomEnfant" => $prenomEnfant,
"votreNom" => $votreNom,
"votrePrenom" => $votrePrenom,
"mail" => $Mail,
"votreLien" => $votreLien,
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"du" => $du,
"au" => $au,
"code" => $code,
"ville" => $ville,
]
),
'text/html'
);
try {
$signMail = $this->getParameter('signMail');
if ($signMail == 'yes') {
$domainName = $this->getParameter('domaine');
$selector = $this->getParameter('selector');
$PrivateKey = file_get_contents($this->getParameter('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
return new JsonResponse(count($listeSejour));
}
/**
* @Route("/Parent/ChoixCouverture", name="ChoixCouvertureParent")
*/
public function Couverture()
{
return $this->render('Parent/ChoixCouverture.html.twig', []);
}
/**
* @Route("/Parent/couvertureAccompagnateur", name="couvertureAccompagnateur")
*/
public function CouvertureAccompagnateur()
{
$user = $this->getUser();
$session = $this->session;
$idSejour = $session->get("Sejour");
$listeproduit = $prod = $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour));
return $this->render('Parent/couvertureAccompagnateur.html.twig', []);
}
/**
* @Route("/Parent/Projet", name="projet-Parent")
*/
public function parentTWo()
{
$this->session->set('rout', 'rout');
/** @var \App\Entity\User $user */
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', 'projets');
$idSejour = $session->get("Sejour");
$listeproduit = $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour, 'iduser' => $user->getId()), ['id' => 'DESC']);
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$parentent_sejour = $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
return $this->render('Parent/ProjetsParent.html.twig', ['sejour' => $sejour, 'parentent_sejour' => $parentent_sejour, 'listeproduit' => $listeproduit]);
}
/**
* @Route("/Parent/MesProjets", name="MesProjets")
*/
public function MesProjets()
{
return $this->render('Parent/MesProjetsSauvegardes.html.twig', []);
}
/**
* @Route("/Parent/allSejourparent", name="SejourParent")
*/
public function SejourAccompagnateur()
{
$sejourservice = $this->sejourService;
$session = $this->session;
$idSejour = $session->get("Sejour");
$session->set('rout', 'rout');
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$listeSejour = $prod = $this->em->getRepository(ParentSejour::class)->findby(array('idParent' => $userId));
return $this->render('Parent/Messejours.html.twig', ['listeSejour' => $listeSejour]);
}
/**
* @Route("/Parent/Commander", name="Commander")
*/
public function Commander()
{
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$user = $this->getUser();
$comande = $session->get("comande");
$panier = $session->get("Panier");
$nbrprodpromo = 0;
$nbralbum = 0;
$nbrlivre = 0;
$nbrphoto12 = 0;
$nbrphoto24 = 0;
$nbrphoto36 = 0;
$nbrcal = 0;
$nbrretro12 = 0;
$nbrretro24 = 0;
$nbrretro36 = 0;
$detailsprod = array();
$prixalbum = 0.0;
$prixphoto12 = 0.0;
$prixphoto24 = 0.0;
$prixphoto36 = 0.0;
$prixcal = 0.0;
$prixalbum = 0.0;
$prixretro12 = 0.0;
$prixretro24 = 0.0;
$prixretro36 = 0.0;
$prodpanierpromo = array();
$promo = array();
foreach ($panier as $key => $p) {
if ($p['condition'] != 11 && $p['condition'] != 6) {
$promo['condition'] = $p['condition'];
$nbrprodpromo = $nbrprodpromo + $p['qte'];
array_push($prodpanierpromo, $promo);
if ($p['condition'] == 4) {
$nbralbum = $nbralbum + $p['qte'];
$prixalbum = $p['mnt'];
} elseif ($p['condition'] == 1) {
$nbrphoto12 = $nbrphoto12 + $p['qte'];
$prixphoto12 = $p['mnt'];
} elseif ($p['condition'] == 2) {
$nbrphoto24 = $nbrphoto24 + $p['qte'];
$prixphoto24 = $p['mnt'];
} elseif ($p['condition'] == 3) {
$nbrphoto36 = $nbrphoto36 + $p['qte'];
$prixphoto36 = $p['mnt'];
} elseif ($p['condition'] == 5) {
$nbrlivre = $nbrlivre + $p['qte'];
$prixlivre = $p['mnt'];
} elseif ($p['condition'] == 7) {
$nbrcal = $nbrcal + $p['qte'];
$prixcal = $p['mnt'];
} elseif ($p['condition'] == 8) {
$nbrretro36 = $nbrretro36 + $p['qte'];
$prixretro36 = $p['mnt'];
} elseif ($p['condition'] == 9) {
$nbrretro12 = $nbrretro12 + $p['qte'];
$prixretro12 = $p['mnt'];
} elseif ($p['condition'] == 10) {
$nbrretro24 = $nbrretro24 + $p['qte'];
$prixretro24 = $p['mnt'];
}
}
}
$detailsprod['album']['qt'] = $nbralbum;
$detailsprod['album']['prix'] = $prixalbum;
$detailsprod['photo12']['qt'] = $nbrphoto12;
$detailsprod['photo12']['prix'] = $prixphoto12;
$detailsprod['photo24']['qt'] = $nbrphoto24;
$detailsprod['photo24']['prix'] = $prixphoto24;
$detailsprod['photo36']['qt'] = $nbrphoto36;
$detailsprod['photo36']['prix'] = $prixphoto36;
$detailsprod['cal']['qt'] = $nbrcal;
$detailsprod['cal']['prix'] = $prixcal;
$detailsprod['livre']['qt'] = $nbrlivre;
$detailsprod['livre']['prix'] = $prixalbum;
$detailsprod['retro12']['qt'] = $nbrretro12;
$detailsprod['retro12']['prix'] = $prixretro12;
$detailsprod['retro24']['qt'] = $nbrretro24;
$detailsprod['retro24']['prix'] = $prixretro24;
$detailsprod['retro36']['qt'] = $nbrretro36;
$detailsprod['retro36']['prix'] = $prixretro36;
$Panier = $session->get("Panier");
return $this->render('Parent/commande.html.twig', ["detailsprod" => $detailsprod, "nbrprodpromo" => $nbrprodpromo, "prodpanierpromo" => $prodpanierpromo, "user" => $user, "sejour" => $sejour, "x" => $panier, 'Panier' => $Panier]);
}
/**
* @Route("/Parent/MonPanier", name="MonPanier")
*/
public function MonPanier()
{
/** @var \App\Entity\User $user */
$user = $this->getUser();
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$listeproduit = $prod = $this->em->getRepository(Produit::class)->findby(array('iduser' => $user->getId()));
$parentent_sejour = $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
$Panier = $session->get("Panier");
//dd($Panier);
$prodpanier = array();
$nbrprodpromo = 0;
$nbralbum = 0;
$nbrlivre = 0;
$nbrphoto12 = 0;
$nbrphoto24 = 0;
$nbrphoto36 = 0;
$nbrcal = 0;
$nbrretro12 = 0;
$nbrretro24 = 0;
$nbrretro36 = 0;
$detailsprod = array();
$prixalbum = 0.0;
$prixphoto12 = 0.0;
$prixphoto24 = 0.0;
$prixphoto36 = 0.0;
$prixcal = 0.0;
$prixalbum = 0.0;
$prixretro12 = 0.0;
$prixretro24 = 0.0;
$prixretro36 = 0.0;
$prodpanierpromo = array();
$promo = array();
foreach ($Panier as $key => $p) {
if ($p['condition'] != null) {
array_push($prodpanier, $p['condition']);
}
if ($p['condition'] != 11 && $p['condition'] != 6) {
$promo['condition'] = $p['condition'];
$nbrprodpromo = $nbrprodpromo + $p['qte'];
array_push($prodpanierpromo, $promo);
if ($p['condition'] == 4) {
$nbralbum = $nbralbum + $p['qte'];
$prixalbum = $p['mnt'];
} elseif ($p['condition'] == 1) {
$nbrphoto12 = $nbrphoto12 + $p['qte'];
$prixphoto12 = $p['mnt'];
} elseif ($p['condition'] == 2) {
$nbrphoto24 = $nbrphoto24 + $p['qte'];
$prixphoto24 = $p['mnt'];
} elseif ($p['condition'] == 3) {
$nbrphoto36 = $nbrphoto36 + $p['qte'];
$prixphoto36 = $p['mnt'];
} elseif ($p['condition'] == 5) {
$nbrlivre = $nbrlivre + $p['qte'];
$prixlivre = $p['mnt'];
} elseif ($p['condition'] == 7) {
$nbrcal = $nbrcal + $p['qte'];
$prixcal = $p['mnt'];
} elseif ($p['condition'] == 8) {
$nbrretro36 = $nbrretro36 + $p['qte'];
$prixretro36 = $p['mnt'];
} elseif ($p['condition'] == 9) {
$nbrretro12 = $nbrretro12 + $p['qte'];
$prixretro12 = $p['mnt'];
} elseif ($p['condition'] == 10) {
$nbrretro24 = $nbrretro24 + $p['qte'];
$prixretro24 = $p['mnt'];
}
}
}
$detailsprod['album']['qt'] = $nbralbum;
$detailsprod['album']['prix'] = $prixalbum;
$detailsprod['photo12']['qt'] = $nbrphoto12;
$detailsprod['photo12']['prix'] = $prixphoto12;
$detailsprod['photo24']['qt'] = $nbrphoto24;
$detailsprod['photo24']['prix'] = $prixphoto24;
$detailsprod['photo36']['qt'] = $nbrphoto36;
$detailsprod['photo36']['prix'] = $prixphoto36;
$detailsprod['cal']['qt'] = $nbrcal;
$detailsprod['cal']['prix'] = $prixcal;
$detailsprod['livre']['qt'] = $nbrlivre;
$detailsprod['livre']['prix'] = $prixalbum;
$detailsprod['retro12']['qt'] = $nbrretro12;
$detailsprod['retro12']['prix'] = $prixretro12;
$detailsprod['retro24']['qt'] = $nbrretro24;
$detailsprod['retro24']['prix'] = $prixretro24;
$detailsprod['retro36']['qt'] = $nbrretro36;
$detailsprod['retro36']['prix'] = $prixretro36;
$produit = $this->typeProduiteService;
$produitlist = $produit->produitlistTypeConditionnement();
//dd( $detailsprod);
$this->session->set('rout', 'rout');
return $this->render('Parent/monpanier.html.twig', ['detailsprod' => $detailsprod, 'nbrprodpromo' => $nbrprodpromo, 'prodpanierpromo' => $prodpanierpromo, 'prodpanier' => $prodpanier, 'parentent_sejour' => $parentent_sejour, 'user' => $user, 'Sejour' => $idSejour, "sejour" => $sejour, 'listeproduit' => $listeproduit, 'Panier' => $Panier, 'produitlist' => $produitlist]);
}
/**
* @Route("/Parent/mail", name="mail")
*/
public function mail()
{
return $this->render('emails/Inscriptionparent.html.twig', []);
}
/**
* @Route("/Parent/AlbummsavealbumParent", name="AlbummsavealbumParent")
*/
public function Albummsavealbum(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$versionalbm = $request->get('new');
$user = $this->getUser();
$produittype = $session->get("produit");
$produit = $session->get("produittype");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$Album = $serviceuser->savealbumParent($page, $user, $sejour, $prodid, $produit, $produittype, $nomprod, $versionalbm);
//dd($etablissementDetail);
$dateNow = new \Datetime();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
return new response();
}
/**
* @Route("/Parent/saveLivrePhotosParent", name="saveLivrePhotosParent")
*/
public function saveLivrePhotos(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$versionalbm = $request->get('new');
$user = $this->getUser();
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$produitcondss = $session->get('produitconditionAlbum');
$Album = $serviceuser->savelivreParent($page, $user, $sejour, $prodid, $produitcondss, $nomprod, $versionalbm);
//dd($etablissementDetail);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
/**
* @Route("/Parent/SavePhotosPochette", name="SavePhotosPochetteParent")
*/
public function SavePhotosPochetteParent(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SavePhotosPochetteParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
//sendmailparent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
/**
* @Route("/Parent/RetrosComandeSaveRetros", name="PochettePhotosComandeSave")
*/
public function PochettePhotosComandeSave(Request $request)
{
$em = $this->em;
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SavePhotosRetrosParents($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
$inser = false;
$Products = $session->get("Panier");
$produit = $em->getRepository(Produit::class)->find($Album->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
//fonction pour pochett photo comande direct au panier
/**
* @Route("/Parent/PochetcomdComandeSave", name="PochettePhotosComandeSave_pochet_panier")
*/
public function PochettePhotosComandeSave_pochet_panier(Request $request)
{
$em = $this->em;
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SavePhotosPochetteParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
$inser = false;
$Products = $session->get("Panier");
$produit = $em->getRepository(Produit::class)->find($Album->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
//Nouvelle fonction ajout pochette
/**
* @Route("/Parent/TestcreateFilePhotosNew", name="TestcreateFilePhotosNew")
*/
function TestcreateFilePhotosNew(Request $request)
{
$prdt = $request->get("produit");
$printerSer = $this->printerService;
$pages = $this->em->getRepository(Page::class)->findBy(array("idproduit" => $prdt));
$this->logger->notice('Generating File for Pack photos');
$name = $printerSer->CreerTcpPhotosPochette_Parent($prdt, 'NumCmd_963', 'Photo', $pages);
dump($name);
die();
return ("ok");
}
//Nouvelle fonction ajout pochette
/**
* @Route("/Parent/AddPochetteAuPanier", name="AddPochetteAuPanier")
*/
public function AddPochetteAuPanier(Request $request)
{
$em = $this->em;
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("photos");
$sejour = $request->get("sejour");
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
//Enregistrement des infos de la pochette dans un produit et les photos dans des pages avec JSON
$Pochette_photos = $serviceuser->photosPochette_Nouvelle($page, $user, $sejour, $nbr);
$produit = $em->getRepository(Produit::class)->find($Pochette_photos->getId());
// $zipFileName = $this->printerService->CreerTcpPhotosPochette_Parent($Pochette_photos->getId(), "9999999", "pochette_photo");
$inser = false;
$Products = $session->get("Panier");
$produit = $em->getRepository(Produit::class)->find($Pochette_photos->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
// Test creation du fichier zip pdf pochette
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
// $this->TestcreateFilePhotosNew($produit);
return new response('done');
}
/**
* @Route("/Parent/AddRetroAuPanier", name="AddRetroAuPanier", methods={"POST"})
*/
public function AddRetroAuPanier(Request $request)
{
$em = $this->em; // or getDoctrine()->getManager()
$session = $this->session;
$user = $this->getUser();
$service = $this->etablissementService; // Same service that had photosPochette_Nouvelle
$photos = $request->get('photos'); // base64 data, widths, heights, etc.
$sejourId = $request->get('sejour');
$nbr = strval($request->get('nbr'));
// 1) Let the service create the new "Retro" product + store pages
// We’ll define photosRetro_Nouvelle similar to photosPochette_Nouvelle
$RetroProduit = $service->photosRetro_Nouvelle($photos, $user, $sejourId, $nbr);
// 2) Same logic to insert that new product in the user’s Panier
// (Essentially the same as your AddPochetteAuPanier code)
$inser = false;
$Products = $session->get("Panier");
if (!$Products) {
$Products = [];
}
// The newly created product
$produit = $em->getRepository(Produit::class)->find($RetroProduit->getId());
// A) Check if a "Panier" with status "creer" for this user exists,
// or create one if needed
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy([
"libiller" => "creer",
"typeref" => $typeref
]);
$panierTrace = $em->getRepository(Panier::class)->findOneBy([
"creerPar" => $user,
"statut" => $statutPanier
]);
if (!$panierTrace) {
$panierTrace = new Panier();
$panierTrace->setDateCreation(new \DateTime());
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
// B) Check if this product already exists in $Products
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] += 1;
$Products[$key]['mnt'] += $produit->getIdConditionnement()->getMontantTTC();
}
}
// C) Check if it also exists in PanierProduit table
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy([
"idProduit" => $produit,
"idPanier" => $panierTrace
]);
if (!$panierProduit) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
// D) Increase quantity & total
$oldQte = $panierProduit->getQuantite();
$panierProduit->setQuantite($oldQte + 1);
$oldTotal = $panierProduit->getPrixTotal();
$panierProduit->setPrixTotal($oldTotal + $produit->getIdConditionnement()->getMontantTTC());
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
// E) If not inserted in $Products above, push new array item
if (!$inser) {
$p = [
"id" => $produit->getId(),
"nom" => $produit->getType()->getLabeletype(),
"ident" => $produit->getLabele(),
"codesejour" => $produit->getIdsjour()->getcodeSejour(),
"mnt" => $produit->getIdConditionnement()->getMontantTTC(),
"path" => $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
"condition" => $produit->getIdConditionnement()->getId(),
"qte" => 1
];
$Products[] = $p;
}
$session->set('Panier', $Products);
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
return new Response('done');
}
/**
* @Route("/Parent/SavePhotosRetros", name="SavePhotosRetrosParent")
*/
public function SavePhotosRetrosParent(Request $request)
{
$em = $this->em;
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$comandePanier = $request->get('comandePanier');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SavePhotosRetrosParents($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
//dd($etablissementDetail);
if ($comandePanier == "comandePanier") {
$inser = false;
$Products = $session->get("Panier");
$produit = $this->em->getRepository(Produit::class)->find($Album->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
}
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
return new response($Album->getId());
}
/**
* @Route("/Parent/SaveCalendrierParent", name="SaveCalendrierParent")
*/
public function SaveCalendrierParent(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SaveCalendrierParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
/**
* @Route("/Parent/SaveCommandeCalendrierParent", name="SaveCommandeCalendrierParent")
*/
public function SaveCommandeCalendrierParent(Request $request)
{
$em = $this->em;
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SaveCalendrierParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
$inser = false;
$Products = $session->get("Panier");
$produit = $em->getRepository(Produit::class)->find($Album->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
/**
* @Route("/Parent/SavePdfParent", name="SavePdfParent")
*/
public function SavePdfParent(Request $request)
{
// $blob = $request->get("blob");
if (!empty($_POST['blob'])) {
$data = $_POST['blob'];
$fname = "test.pdf"; // name the file
$file = fopen("pdf/" . $fname, 'w'); // open the file path
fwrite($file, $data); //save data
fclose($file);
} else {
echo "No Data Sent";
}
return new response('ok');
}
/**
* @Route("/Parent/infosphp", name="infos")
*/
public function infos()
{
echo phpinfo();
}
/**
* @Route("/Parent/RetrosComandeSaveRetros", name="RetrosComandeSaveRetros")
*/
public function RetrosComandeSaveRetros(Request $request)
{
$em = $this->em;
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$Album = $serviceuser->SavePhotosRetrosParents($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod);
$inser = false;
$Products = $session->get("Panier");
$produit = $em->getRepository(Produit::class)->find($Album->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
return new response('done');
}
/**
* @Route("/Parent/nbvisite", name="nbvisite",methods={"POST","GET"})
*/
public function ajouternombrevisite(Request $request)
{
$SejourService = $this->sejourService;
$CarteService = $this->carteService;
$typevisite = $request->get("typevisite");
$idsejour = $request->get("idsejour");
$idattach = $request->get("idattachement");
if ($typevisite == "carte") {
$nbvisite = $CarteService->carteVisite($idsejour);
} else {
$nbvisite = $SejourService->affectationnbvisiteattachement($idsejour, $idattach);
}
return new JsonResponse('done');
}
/**
* @Route("/Parent/ajouterauPanier_Parent", name="Ajouter_MonPanier")
*/
public function Ajouter_MonPanier(Request $request)
{
$inser = false;
$session = $this->session;
$em = $this->em;
$Products = $session->get("Panier");
$id = $request->get("id");
//Touhemi :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
$produit = $this->em->getRepository(Produit::class)->find($id);
if ($Products == null) {
$Products = [];
}
//Touhemi :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
}
}
//Touhemi ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$this->em->getManager()->persist($panierProduit);
$this->em->getManager()->flush();
//fin
if ($inser === false) {
//get nessaisire element
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
return new JsonResponse('done');
}
/**
* @Route("/Parent/Ajouter_Album_Parent", name="Ajouter_Album_Parent_Alb")
*/
public function Ajouter_Album(Request $request)
{
$session = $this->session;
$id = $request->get("id");
$typeProdcondition = $this->em->getRepository(TypeProduitConditionnement::class)->find($id);
$typeprod = $typeProdcondition->getIdTypeProduit()->getId();
$session->set('produit', $id);
$session->set('produitconditionAlbum', $id);
$session->set('produittype', $typeprod);
return new JsonResponse('done');
}
/**
* @Route("/Parent/ComandeParent", name="ComandeParent")
*/
public function comande_Parent(Request $request)
{
$session = $this->session;
// $comande = $request->get("p");
$Panier = $session->get("Panier");
$session->set('comande', $Panier);
return new JsonResponse('done');
}
/**
* @Route("/Parent/Accueil5sur5/adresse_comande", name="adresse_comande",methods={"POST"})
*/
public function adresse_comande(Request $request)
{
$UserService = $this->userService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$idCommande = $request->get("idCommande");
$prenom = $request->get("prenom");
$nom = $request->get("nom");
$organism = $request->get("organism");
$rue = $request->get('ruevoi');
$ville = $request->get("villle");
$pays = $request->get("pays");
$codepostal = $request->get("codpostal");
//adress facturation if exsist
$prenomfacturation = $request->get("prenomadressfacturation");
$nomfacturation = $request->get("nomadressfacturation");
$organismfacturation = $request->get("etablismadressfacturation");
$ruefacturation = $request->get('rueadressfacturation');
$villefacturation = $request->get("villefacturation");
$paysfacturation = $request->get("payadressfacturation");
$codepostalfacturation = $request->get("codepostalfacturation");
//modification userPArent
$em = $this->em;
$adress = $UserService->modifieradress_comande($rue, $ville, $pays, $codepostal, $iduser, $prenom, $nom, $organism, $prenomfacturation, $nomfacturation, $organismfacturation, $ruefacturation, $villefacturation, $paysfacturation, $codepostalfacturation);
$commande = $em->getRepository(Commande::class)->findOneBy(array("id" => $idCommande));
$commande->setAdresslivraison($adress);
$commande->setAddresseLivraison($ville);
$commande->setAdressfactoration($adress);
$em->getManager()->persist($commande);
$em->getManager()->flush();
return new JsonResponse('Adresse Enregitrée');
}
/**
* @Route("/Parent/Accueil5sur5/codesecuriter", name="codesecuriter",methods={"POST"})
*/
public function codesecuriter(Request $request)
{
$UserService = $this->userService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$iduser = $user->getId();
$code1 = $request->get("code1");
$code2 = $request->get("code2");
$code3 = $request->get("code3");
$set1 = $request->get("set");
if ($set1 == 1) {
if ($code1 == "") {
return new Response('erore');
}
$adress = $UserService->codesecuriter($code1, $iduser);
}
if ($set1 == 2) {
if ($code2 == "") {
return new Response('erore');
}
$adress = $UserService->codesecuriter($code2, $iduser);
}
if ($set1 == 3) {
if ($code3 == "") {
return new Response('erore');
}
$adress = $UserService->codesecuriter($code3, $iduser);
}
return new Response('done');
}
/**
* @Route("/Parent/Accueil5sur5/suprimer_Album_panier", name="suprimer_Album_panier",methods={"POST"})
*/
public function suprimer_Album_panier(Request $request)
{
$session = $this->session;
$Products = $session->get("Panier");
$id = $request->get("p");
foreach ($Products as $key => $p) {
if ($p['id'] == $id) {
unset($Products[$key]);
}
}
$session->set('Panier', $Products);
$em = $this->em;
$user = $this->getUser();
$produit = $em->getRepository(Produit::class)->find($id);
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
$em->getManager()->remove($panierProduit);
$em->getManager()->flush();
return new Response('done');
}
/**
* @Route("/Parent/Accueil5sur5/additiondproduit_parent", name="additiondproduit_parent",methods={"POST"})
*/
public function additiondproduit_parent(Request $request)
{
$session = $this->session;
$Products = $session->get("Panier");
$id = $request->get("p");
foreach ($Products as $key => $p) {
if ($p['id'] == $id) {
$qte_dans_panier = $Products[$key]['qte'];
$mnt_dans_panier = $Products[$key]['mnt'] / $qte_dans_panier;
$Products[$key]['qte'] = $p['qte'] + 1;
// $Products[$key]['mnt']=$p['mnt']+$mnt_dans_panier;
}
}
$session->set('Panier', $Products);
//Touhemi addition au panier produit ds bd
$em = $this->em;
$user = $this->getUser();
$produit = $em->getRepository(Produit::class)->find($id);
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit != null) {
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
return new Response('done');
}
/**
* @Route("/Parent/Accueil5sur5/sousstractionproduit_parent", name="sousstractionproduit_parent",methods={"POST"})
*/
public function sousstractionproduit_parent(Request $request)
{
$session = $this->session;
$Products = $session->get("Panier");
$id = $request->get("p");
foreach ($Products as $key => $p) {
if ($p['id'] == $id) {
$qte_dans_panier = $Products[$key]['qte'];
$mnt_dans_panier = $Products[$key]['mnt'] / $qte_dans_panier;
$Products[$key]['qte'] = $p['qte'] - 1;
// $Products[$key]['mnt']=$p['mnt']-$mnt_dans_panier;
$set = $Products[$key];
}
if ($Products[$key]['qte'] == 0) {
unset($Products[$key]);
}
}
$session->set('Panier', $Products);
$em = $this->em;
$user = $this->getUser();
$produit = $em->getRepository(Produit::class)->find($id);
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit != null) {
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte - 1;
if ($newQte > 0) {
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal - $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
if ($newQte == 0) {
$em->getManager()->remove($panierProduit);
$em->getManager()->flush();
}
}
return new Response('done');
}
/**
* @Route("Parent/AjoutAlbum_parent/{idAlbm}", name="EditionAlbumfrompanier")
*/
public function EditionAlbumParent_panier($idAlbm)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = null;
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = 0;
if ($listeattachlikephoto) {
$nbLikes = count($listeattachlikephoto);
}
$AllPages = null;
$Albumproduct = null;
$AllPagesAcc = null;
$random = false;
$Albumproduct = $em->getRepository(Produit::class)->find($idAlbm);
if ($Albumproduct == null || $Albumproduct == "") {
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
$random = true;
}
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = null;
$allpagesResult = array();
$tabacc = array();
$tabacc1 = array();
foreach ($AllPages as $page) {
$pageJ = json_decode($page->getCouleurbordure());
$pageDec = json_decode($pageJ[0]);
$attache = json_decode($pageDec->attache);
foreach ($attache as $att) {
$attachDec = json_decode($att);
if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
$idAttach = json_decode($attachDec->id);
array_push($tabacc, $idAttach);
}
}
}
$tabacc1 = array_count_values($tabacc);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$session->set('produit', $Albumproduct->gettype());
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbphoto = count($listeattach);
if ($Albumproduct->getVersion() === 'new') {
if ($nbLikes != 0) {
return $this->render('Parent/NewAlbumLikes.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbphoto]);
}
return $this->render('Parent/NewAlbumLikes.html.twig', ["listeattach" => $listeattach, "tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbphoto]);
} else {
return $this->render('Parent/NewAlbumLikes.html.twig', ["tabacc" => $tabacc1, "listeattach" => $listeattach, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbphoto]);
}
}
/**
* @Route("/Parent/Accueil5sur5/modifierLabel_produit_parent", name="modifierLabel_produit_parent",methods={"POST"})
*/
public function modifierLabel_produit_parent(Request $request)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$idPrd = $request->get("id");
$description = $request->get("description");
$SEjourService->modif_lbel_Produit($idPrd, $description);
$Products = $session->get("Panier");
if ($Products != null) {
foreach ($Products as $key => $p) {
if ($idPrd == $p['id']) {
$Products[$key]["ident"] = $description;
}
}
}
$session->set('Panier', $Products);
return new Response('done');
}
/**
* @Route("/Parent/checkCodePromoParents", name="checkCodePromoParents")
*/
public function checkCodePromoParents(Request $request)
{
$em = $this->em;
$SejourService = $this->sejourService;
$session = $this->get('session');
$code = $request->get('code');
$idUser = $request->get('idUser');
$user = $em->getRepository(User::class)->findOneBy(['id' => $idUser]);
$CodePromoUtilisse = "";
$totalpanier = $request->get('totalPanier');
$infosPromo = $SejourService->checkCodePromoPrents($code, $user);
$remise = 0;
$pourcentage = 0;
if (isset($infosPromo['remise'])) {
$remise = $infosPromo['remise'];
}
if (isset($infosPromo['pourcentage'])) {
$pourcentage = $infosPromo['pourcentage'];
}
$totalRemise = $totalpanier * $pourcentage;
$totalRemise = ($totalRemise) / 100;
$totalpanierNew = $totalpanier - $totalRemise;
$tvaTotalRemise = ($totalpanierNew * 20) / 100;
$user->setShowdetailsphotos("4");
$em->getManager()->persist($user);
$em->getManager()->flush();
return new JsonResponse(array('message' => $infosPromo['test'], 'pourcentage' => intval($infosPromo['pourcentage']), 'remise' => $remise, 'totalDupanier' => $totalpanierNew, 'totalRemise' => $totalRemise, "tvaTotalRemise" => $tvaTotalRemise, "CodePromoUtilisse" => $CodePromoUtilisse), 200);
}
/**
* @Route("/Parent/Accueil5sur5/ParentcomandeProduit", name="ParentcomandeProduit",methods={"POST"})
*/
public function ParentcomandeProduit(Request $request)
{
$em = $this->em;
$comandeservice = $this->commandeService;
$sejourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$frais = $request->get("fraiEnvoi");
$Products = $session->get("Panier");
$totalepanier = $request->get("totalepanier");
$envoipost = $request->get("envoipost");
$remise = $request->get("remise");
$totalBlackFriday = $request->get("totalBlackFriday");
$session->set('envoipost', $envoipost);
$containsProduitType20 = false;
$comand = $comandeservice->addcomande_parent($Products, $userId, $frais, $totalepanier, $envoipost, $remise, $containsProduitType20);
$codePromo = $request->get('codePromo');
$test = $sejourService->checkCodePromo($codePromo);
if (isset($test['test'])) {
if ($test['test'] == true) {
$promotion = $sejourService->findPromotionByCode($codePromo);
if ($promotion) {
$listeProduitsCommande = $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
$pourcentage = intval($promotion->getPourcentage());
if ($promotion->getNbreApplicable() == 1) {
foreach ($listeProduitsCommande as $cmdProduit) {
$cmdProduit->setPourcentage($pourcentage);
$em->getManager()->persist($cmdProduit);
$em->getManager()->flush();
}
} else {
foreach ($listeProduitsCommande as $cmdProduit) {
$qte = $cmdProduit->getQuantiter();
for ($i = 0; $i < $qte; $i++) {
$ligneCmdProd = new ComandeProduit();
$ligneCmdProd->setQuantiter(1);
$ligneCmdProd->setIdProduit($cmdProduit->getIdProduit());
$ligneCmdProd->setIdComande($cmdProduit->getIdComande());
$ligneCmdProd->setDate($cmdProduit->getDate());
$em->getManager()->persist($ligneCmdProd);
$em->getManager()->remove($cmdProduit);
}
$em->getManager()->flush();
}
$listeProduitsCommande = $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
$qte = 0;
$tabPrices = [];
foreach ($listeProduitsCommande as $cmdProduit) {
$ligne = array('idCmdProduit' => $cmdProduit->getId(), 'price' => $cmdProduit->getIdProduit()->getIdConditionnement()->getMontantTTC());
$qte += $cmdProduit->getQuantiter();
array_push($tabPrices, $ligne);
}
$x = intval($qte / $promotion->getNbreApplicable());
$this->aasort($tabPrices, "price");
$tabPricesPromo = array_slice($tabPrices, -$x, $x, true);
foreach ($tabPricesPromo as $item) {
$cp = $em->getRepository(ComandeProduit::class)->find($item['idCmdProduit']);
$cp->setPourcentage($pourcentage);
$em->getManager()->persist($cp);
$em->getManager()->flush();
}
}
$comand->setIdPromotion($promotion);
}
}
}
$session->set('commandeActual', $comand->getId());
return new Response($comand->getId());
}
function aasort(&$array, $key)
{
$sorter = array();
$ret = array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii] = $va[$key];
}
arsort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii] = $array[$ii];
}
$array = $ret;
}
/**
* @Route("Parent/LivreSejourParent", name="Livre_du_Sejour")
*/
public function LivreSejourParent()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$idSejour = $session->get("Sejour");
$session->set('LivreSejour', 'LivreSejour');
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = null;
$AllPages = null;
$AllPagesAcc = null;
$random = false;
$codeSejour = $sejour->getCodeSejour();
$nomprod = "Livre_Sejour" . $codeSejour;
$sejour = $em->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin', 'labele' => $nomprod, 'idsjour' => $idSejour]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$tabacc = array();
$tabacc1 = array();
foreach ($AllPages as $page) {
$pageJ = json_decode($page->getCouleurbordure());
$pageDec = json_decode($pageJ[0]);
$attache = json_decode($pageDec->attache);
foreach ($attache as $att) {
$attachDec = json_decode($att);
if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
$idAttach = json_decode($attachDec->id);
array_push($tabacc, $idAttach);
}
}
}
$tabacc1 = array_count_values($tabacc);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbPhoto = count($listeattach);
// $session->set('produit', $Albumproduct->gettype());
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
return $this->render('Parent/LivreSejour.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => null, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes, 'nbPhotos' => $nbPhoto]);
}
/**
* @Route("Parent/LivrePhotos_Parent/{idAlbm}", name="Editionlivrefrompanier")
*/
public function EditionLivrePhotosParentparId($idAlbm)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produit = $session->get("produit");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = null;
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
$AllPages = null;
$Albumproduct = null;
$AllPagesAcc = null;
$random = false;
$Albumproduct = $em->getRepository(Produit::class)->find($idAlbm);
if ($Albumproduct == null || $Albumproduct == "") {
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
$random = true;
}
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = null;
$allpagesResult = array();
$tabacc = array();
$tabacc1 = array();
foreach ($AllPages as $page) {
$pageJ = json_decode($page->getCouleurbordure());
$pageDec = json_decode($pageJ[0]);
$attache = json_decode($pageDec->attache);
foreach ($attache as $att) {
$attachDec = json_decode($att);
if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
$idAttach = json_decode($attachDec->id);
array_push($tabacc, $idAttach);
}
}
}
$tabacc1 = array_count_values($tabacc);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbPhoto = count($listeattach);
$session->set('produit', $Albumproduct->gettype());
return $this->render('Parent/NewLivreLikes.html.twig', ["tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'random' => $random, 'listeattach' => $listeattach, 'nbPhotos' => $nbPhoto, 'nbLikes' => $nbLikes]);
}
/**
* @Route("Parent/ModificationPochettePhotos/{nbr}/{id}", name="EditionPochettefrompanier")
*/
public function EditionPochetteParentfrompanier($nbr, $id)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbLikes = count($listeattachlikephoto);
//Stella
$AllPagesAcc = null;
$random = false;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$nomProjet = $Albumproduct->getLabele();
$nbPhoto = count($listeattach);
$nbLikes = count($listeattachlikephoto);
if ($nbLikes < $nbr) {
return $this->render('Parent/PochettePhotosEdit.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $Albumproduct, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'photosSejour' => $listeattach, 'nbLikes' => $nbLikes, 'nbAttach' => $nbPhoto, 'nomProjet' => $nomProjet]);
}
if ($nbLikes >= $nbr) {
return $this->render('Parent/PochettePhotosEditLikes.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $Albumproduct, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'photosSejour' => $listeattach, 'nbLikes' => $nbLikes, 'nbAttach' => $nbPhoto, 'nomProjet' => $nomProjet]);
}
}
/**
* @Route("Parent/ModificationCalendrier/{id}", name="EditionCalendrierParentfrompanier")
*/
public function EditionCalendrierParentfrompanier($id)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$random = false;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
return $this->render('Parent/Calendrier.html.twig', ["nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'random' => $random]);
}
/**
* @Route("Parent/ModificationPhotosRetros/{nbr}/{id}", name="EditionRetrofrompanier")
*/
public function EditionRetroParentfrompanier($nbr, $id)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$listerandom = $listeattachlikephoto;
$nbLikes = count($listeattachlikephoto);
$AllPagesAcc = null;
$random = false;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
//Liste des photos public
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbPhoto = $listeattach;
if ($nbLikes == 0) {
return $this->render('Parent/PhotosRetros.html.twig', ["nbr" => $nbr, " nbPhoto" => $nbPhoto, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattach, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes]);
}
if ($nbLikes != 0) {
return $this->render('Parent/PhotosRetrosLikes.html.twig', ["nbr" => $nbr, " nbPhoto" => $nbPhoto, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach, 'nbLikes' => $nbLikes]);
}
}
//CommanderalbumSejour
/**
* @Route("/Parent/CommanderalbumSejour", name="CommanderalbumSejour")
*/
public function CommanderalbumSejour(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$versionalbm = $request->get('new');
$user = $this->getUser();
$em = $this->em;
// $AlbumSejour = $em->getRepository(Produit::class)->findOneBy(array("id" =>$prodid));
$produit = $session->get("produittype");
$produitcondi = $session->get("produit");
$Album = $serviceuser->saveCopyalbumParent($page, $user, $sejour, $prodid, $produit, $produitcondi, $nomprod, $versionalbm);
$inser = false;
$session = $this->session;
$Products = $session->get("Panier");
$produit = $this->em->getRepository(Produit::class)->find($Album->getId());
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($Album);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
//Touhemi ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $Album->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$this->em->getManager()->persist($panierProduit);
$this->em->getManager()->flush();
//fin
if ($inser === false) {
//get nessaisire element
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendemail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
//dd($etablissementDetail);
return new response('done');
}
/**
* @Route("/Parent/AlbummsavealbumcomandeParent", name="AlbummsavealbumcomandeParent")
*/
public function Albummcomandesavealbum(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$versionalbm = $request->get('new');
$user = $this->getUser();
$produit = $session->get("produittype");
$produitcondi = $session->get("produit");
$Album = $serviceuser->savealbumParent($page, $user, $sejour, $prodid, $produit, $produitcondi, $nomprod, $versionalbm);
$inser = false;
$session = $this->session;
$Products = $session->get("Panier");
$produit = $this->em->getRepository(Produit::class)->find($Album->getId());
$em = $this->em;
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
//Touhemi :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($Album);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
//Touhemi ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $Album->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$this->em->getManager()->persist($panierProduit);
$this->em->getManager()->flush();
//fin
if ($inser === false) {
//get nessaisire element
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendemail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
//dd($etablissementDetail);
return new response('done');
}
/**
* @Route("/Parent/saveLivrePhotosParentPanier", name="saveLivrePhotosParentPanier")
*/
public function saveLivrePhotospuisPanier(Request $request)
{
$em = $this->em;
$session = $this->session;
$produittype = $session->get("produit");
$produit = $session->get("produittype");
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$versionalbm = $request->get('new');
$user = $this->getUser();
$Album = $serviceuser->savelivreParent($page, $user, $sejour, $prodid, $produittype, $nomprod, $versionalbm);
//dd($etablissementDetail);
$inser = false;
$session = $this->session;
$Products = $session->get("Panier");
$produit = $em->getRepository(Produit::class)->find($Album->getId());
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
// $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 02-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
//get nessaisire element
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_patrent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
/**
* @Route("parent/condcnx", name="connexionparentsejour",methods={"POST"})
*/
public function condition(Request $request)
{
$UserService = $this->userService;
$id = $request->get('id');
$ParentSejour = $UserService->conditioncnxparent($id);
return new JsonResponse('done');
}
/**
* @Route("/Parent/MaPropresPhotos", name="MaPropresPhotos")
*/
public function MaPropresPhotos(Request $request)
{
$path = $request->get("path");
$type = $request->get("type");
$sejId = $request->get("id");
$dateSejour = $request->get("date");
$SejourServiceattachh = $this->sejourService;
$Userservicemail = $this->userService;
$sejourfind = $SejourServiceattachh->sejoursansattach($sejId);
//$sendmail = $Userservicemail->sendmailuserforfirstattach($sejId);
$attachementservice = $this->attachementService;
foreach ($path as $key => $path) {
$src = $path['path'];
$attachement = $attachementservice->creationAttachementS($src, $type, $dateSejour);
$sejourservice = $this->sejourService;
$sejAttach = $sejourservice->monpropreattachement($sejId, $attachement, $this->getUser());
if ((array_key_exists("latitude", $path)) && ($path['latitude'] != null)) {
$lat = $path['latitude'];
$lng = $path['longitude'];
$Cartervice = $this->carteService;
$position = $Cartervice->create_newPositionImage($this->getUser(), $lat, $lng);
$Cartervice->affecterPosition($attachement, $position);
$FindSejour = $this->em->getRepository(Sejour::class)->find($sejId);
$FindSejour->setEtatAdresseCarte(true);
$this->em->getManager()->persist($FindSejour);
$this->em->getManager()->flush();
}
//Ajouter les photos aux favoris
$Like = $this->photosFavorisService;
$Like->AddFavoris($this->getUser(), $attachement, $sejId);
}
return new JsonResponse(["id" => $attachement->getId()]);;
}
/**
* @Route("/Parent/Ajouter_photo_sejour", name="pathadddnewphotos")
*/
public function pathaddnewphotos()
{
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$idParent = $session->get("Sejour");
$idSejour = $session->get("Sejour");
$conxparent = $this->sejourService;
$sejour1 = $conxparent->sejourParentcnx($idSejour, $idParent);
//dd($sejour1);
$SEjourService = $this->sejourService;
$sejour = $SEjourService->getsejour($idSejour);
// dd($sejour);
//Liste des photos public
$listeattach = $SEjourService->getatachmentsejour($idSejour);
//Liste des photos privé
// $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
// $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
$listeVideo = $SEjourService->getVideosejour($idSejour);
$AllAttachements = array_merge_recursive($listeattach, $listeVideo);
$nbImages = count($listeattach);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$em = $this->em;
$parentsejour = $SEjourService->getparentsejour($userId, $idSejour);
//dd($parentsejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'nbImages' => $nbImages,
'albumAcc' => $albumAcc,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'prod' => $liste,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
/**
* @Route("/Parent/ajouterauPanier_Parent_coffret", name="comandercoffre")
*/
public function Ajouter_MonPanier_Coffret()
{
$em = $this->em;
$inser = false;
$session = $this->session;
$idSejour = $session->get("Sejour");
$userId = $this->getUser();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userIdCom = $user->getId();
$sejourobj = $this->em->getRepository(Sejour::class)->find($idSejour);
$prodct = $this->em->getRepository(Typeproduit::class)->find(15);
$version = $this->em->getRepository(Produit::class)->SearchVersionproduit($userIdCom);
$Conditionnement = $this->em->getRepository(TypeProduitConditionnement::class)->find(6);
$Products = $session->get("Panier");
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 02-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
$produit = $em->getRepository(Produit::class)->findOneBy(array("type" => $prodct, 'idConditionnement' => $Conditionnement, 'idsjour' => $sejourobj, 'iduser' => $user));
if ($produit == null) {
$produit = new Produit;
$produit->setLabele("Coffret cadeau");
$produit->setIduser($userId);
$produit->setIdsjour($sejourobj);
$produit->setDate(new \DateTime());
$produit->setIdConditionnement($Conditionnement);
$produit->setType($prodct);
$em->getManager()->persist($produit);
$em->getManager()->flush();
}
if ($Products == null) {
$Products = [];
}
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
// $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
//get nessaisire element
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
//sendmailproduct_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$userId = $user->getId();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
$listeproduit = $prod = $this->em->getRepository(Produit::class)->findby(array('iduser' => $userId));
$session->set('Panier', $Products);
$Panier = $session->get("Panier");
$produit = $this->typeProduiteService;
$produitlist = $produit->produitlistTypeConditionnement();
$this->session->set('rout', 'rout');
$parentent_sejour = $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $this->getUser(), "idSejour" => $sejourobj]);
$prodpanier = array();
$nbrprodpromo = 0;
$nbralbum = 0;
$nbrlivre = 0;
$nbrphoto12 = 0;
$nbrphoto24 = 0;
$nbrphoto36 = 0;
$nbrcal = 0;
$nbrretro12 = 0;
$nbrretro24 = 0;
$nbrretro36 = 0;
$detailsprod = array();
$prixalbum = 0.0;
$prixphoto12 = 0.0;
$prixphoto24 = 0.0;
$prixphoto36 = 0.0;
$prixcal = 0.0;
$prixalbum = 0.0;
$prixretro12 = 0.0;
$prixretro24 = 0.0;
$prixretro36 = 0.0;
$prodpanierpromo = array();
$promo = array();
foreach ($Panier as $key => $p) {
if ($p['condition'] != null) {
array_push($prodpanier, $p['condition']);
}
if ($p['condition'] != 11 && $p['condition'] != 6) {
$promo['condition'] = $p['condition'];
$nbrprodpromo = $nbrprodpromo + $p['qte'];
array_push($prodpanierpromo, $promo);
if ($p['condition'] == 4) {
$nbralbum = $nbralbum + $p['qte'];
$prixalbum = $p['mnt'];
} elseif ($p['condition'] == 1) {
$nbrphoto12 = $nbrphoto12 + $p['qte'];
$prixphoto12 = $p['mnt'];
} elseif ($p['condition'] == 2) {
$nbrphoto24 = $nbrphoto24 + $p['qte'];
$prixphoto24 = $p['mnt'];
} elseif ($p['condition'] == 3) {
$nbrphoto36 = $nbrphoto36 + $p['qte'];
$prixphoto36 = $p['mnt'];
} elseif ($p['condition'] == 5) {
$nbrlivre = $nbrlivre + $p['qte'];
$prixlivre = $p['mnt'];
} elseif ($p['condition'] == 7) {
$nbrcal = $nbrcal + $p['qte'];
$prixcal = $p['mnt'];
} elseif ($p['condition'] == 8) {
$nbrretro36 = $nbrretro36 + $p['qte'];
$prixretro36 = $p['mnt'];
} elseif ($p['condition'] == 9) {
$nbrretro12 = $nbrretro12 + $p['qte'];
$prixretro12 = $p['mnt'];
} elseif ($p['condition'] == 10) {
$nbrretro24 = $nbrretro24 + $p['qte'];
$prixretro24 = $p['mnt'];
}
}
}
$detailsprod['album']['qt'] = $nbralbum;
$detailsprod['album']['prix'] = $prixalbum;
$detailsprod['photo12']['qt'] = $nbrphoto12;
$detailsprod['photo12']['prix'] = $prixphoto12;
$detailsprod['photo24']['qt'] = $nbrphoto24;
$detailsprod['photo24']['prix'] = $prixphoto24;
$detailsprod['photo36']['qt'] = $nbrphoto36;
$detailsprod['photo36']['prix'] = $prixphoto36;
$detailsprod['cal']['qt'] = $nbrcal;
$detailsprod['cal']['prix'] = $prixcal;
$detailsprod['livre']['qt'] = $nbrlivre;
$detailsprod['livre']['prix'] = $prixalbum;
$detailsprod['retro12']['qt'] = $nbrretro12;
$detailsprod['retro12']['prix'] = $prixretro12;
$detailsprod['retro24']['qt'] = $nbrretro24;
$detailsprod['retro24']['prix'] = $prixretro24;
$detailsprod['retro36']['qt'] = $nbrretro36;
$detailsprod['retro36']['prix'] = $prixretro36;
return $this->render('Parent/monpanier.html.twig', ['detailsprod' => $detailsprod, 'nbrprodpromo' => $nbrprodpromo, 'prodpanierpromo' => $prodpanierpromo, 'prodpanier' => $prodpanier, "parentent_sejour" => $parentent_sejour, "sejour" => $sejourobj, 'user' => $this->getUser(), 'Sejour' => $idSejour, 'listeproduit' => $listeproduit, 'Panier' => $Panier, 'produitlist' => $produitlist]);
}
/**
* @Route("/Parent/Boite_vocale", name="Boite_vocale")
*/
public function Boite_Vocale()
{
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', 'BoiteVocale');
$idSejour = $session->get("Sejour");
$SEjourService = $this->sejourService;
$sejour = $SEjourService->getsejour($idSejour);
/* $listeattach = $SEjourService->getatachmentsejour($idSejour);
$listeVideo = $SEjourService->getVideosejour($idSejour);
$AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
$AllAttachements = $SEjourService->getCombinedattachSejour($idSejour, 'photoVideo');
$attachementsCount = $AllAttachements['total'];
unset($AllAttachements['total']);
$nbImages = count($AllAttachements);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$parentsejour = $SEjourService->getparentsejour($userId, $idSejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
// test if sejour est vide ou non
if (sizeof($sejour->getAttachements()) == 0) {
$this->session->set('rout', 'rout');
return $this->render('Parent/Aucunphoto.html.twig', [
"sejour" => $sejour,
"parentsejour" => $parentsejour
]);
}
if ($sejour->getPaym() == 1) {
//findlinge
$ParentSejour = $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour, "idParent" => $user]);
if ($ParentSejour->getPayment() == 0) {
$this->session->set('rout', 'rout');
$ses_id = session_id();
return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour, 'images' => $AllAttachements, "session_id" => $ses_id, 'ParentSejour' => $ParentSejour]);
}
if ($ParentSejour->getPayment() == 1) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$em = $this->em;
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$pubProd = $user->getShowpubprod();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'albumAcc' => $albumAcc,
'listeattach' => $AllAttachements,
'prod' => $liste,
'nbImages' => $nbImages,
'attachementsCount' => $attachementsCount,
'positions' => $positions,
'messages' => $messages,
'albumAcc' => $albumAcc,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
}
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
$em = $this->em;
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($albumAcc == null) {
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'albumAcc' => $albumAcc,
'prod' => $liste,
'listeattach' => $AllAttachements,
'nbImages' => $nbImages,
'attachementsCount' => $attachementsCount,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
/**
* @Route("/Parent/Mon_Sejour_parent", name="Mon_Sejour_parent")
*/
public function Mon_Sejour_parent()
{
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
// $idParent=$this->getUser()->getId();
$idSejour = $session->get("Sejour");
$session->set('pageMenu', 'Monsejour');
$conxparent = $this->sejourService;
//$sejour1 = $conxparent->sejourParentcnx($idSejour,$idParent);
//
$SEjourService = $this->sejourService;
$sejour = $SEjourService->getsejour($idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
//Liste des photos privé
// $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
// $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
$listeVideo = $SEjourService->getVideosejour($idSejour);
$AllAttachements = array_merge_recursive($listeattach, $listeVideo);
$nbImages = count($listeattach);
$positions = $SEjourService->getsejourposition($idSejour);
$messages = $SEjourService->getsejourmessage($idSejour);
$parentsejour = $SEjourService->getparentsejour($userId, $idSejour);
//dd($parentsejour);
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
// test if sejour est vide ou non
if (sizeof($sejour->getAttachements()) == 0) {
$this->session->set('rout', 'rout');
return $this->render('Parent/Aucunphoto.html.twig', [
"sejour" => $sejour,
"parentsejour" => $parentsejour
]);
}
if ($sejour->getPaym() == 1) {
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userid = $user->getId();
//findlinge
$ParentSejour = $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour, "idParent" => $userid]);
if ($ParentSejour->getPayment() == 0) {
$this->session->set('rout', 'rout');
$ses_id = session_id();
return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour, 'images' => $listeattach, "session_id" => $ses_id, 'ParentSejour' => $ParentSejour]);
}
if ($ParentSejour->getPayment() == 1) {
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'listeattach' => $AllAttachements,
'prod' => $liste,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif()
]);
}
}
// dd($sejour);
//Liste des photos public
$produits = $this->typeProduiteService;
$liste = $produits->produitlistTypeConditionnement();
$pubProd = $user->getShowpubprod();
return $this->render('Parent/DetailsSejour.html.twig', [
"sejour" => $sejour,
'prod' => $liste,
'listeattach' => $AllAttachements,
'nbImages' => $nbImages,
'positions' => $positions,
'messages' => $messages,
'like' => $listeattachlikephoto,
"parentsejour" => $parentsejour,
'smsnotif' => $parentsejour->getSmsnotif(),
'showpub' => $pubProd
]);
}
/**
* @Route("/Parent/Besoindaide", name="Besoindaide_Parent")
*/
public function Besoindaide(): Response
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
return $this->render('Parent/footer/Besoindaide.html.twig', [
'produit' => $liste,
]);
}
/**
* @Route("/Parent/Besoindaide_5sur5", name="Besoindaide_5sur5")
*/
public function Besoindaide_5sur5(): Response
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = null;
if ($idSejour != null) {
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
}
return $this->render('Parent/footer/5sur5Help.html.twig', [
'produit' => $liste,
'sejour' => $sejour
]);
}
/**
* @Route("/Parent/Mentionlegale", name="Mentionlegale_Parent")
*/
public function MentionlegaleParent()
{
return $this->render('Parent/footer/mentionlegal.html.twig', []);
}
/**
* @Route("/Parent/Conditongeneral", name="Conditongeneral_Parent")
*/
public function ConditongeneralParent()
{
return $this->render('Parent/footer/Condition.html.twig', []);
}
/**
* @Route("/Parent/Politique", name="Politique_Parent")
*/
public function PolitiqueParent()
{
return $this->render('Parent/footer/politique.html.twig', []);
}
/**
* @Route("/Parent/Commande_groupee", name="Commande_groupee")
* */
public function Commande_groupee()
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
return $this->render('Parent/footer/GroupeeCommande.html.twig', [
'showArt' => 'ALL',
'produit' => $liste
]);
}
/**
* @Route("/Parent/partenaires", name="nosPartenaires")
* */
public function nosPartenaires()
{
return $this->render('Parent/footer/Partenaires.html.twig');
}
/**
* @Route("/Parent/produits5sur5", name="produits5sur5")
* */
public function produits5sur5()
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
return $this->render('Parent/produitscinqsurcinq.html.twig', [
'showArt' => 'ALL',
'produit' => $liste
]);
}
/**
* @Route("/Parent/Nous_Connaitre_5sur5", name="NousConnaitre")
* */
public function Nous_Connaitre_5sur5()
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
return $this->render('Parent/footer/5sur5.html.twig', [
'produit' => $liste,
]);
}
/**
* @Route("/Parent/ServiceClient", name="ServiceClient_Parent")
* */
public function ServiceClient()
{
$produit = $this->typeProduiteService;
$liste = $produit->produitlistType();
// dd($liste);
return $this->render('Parent/footer/ServiceClient.html.twig', [
'produit' => $liste,
]);
}
/**
* @Route("/Parent/delateSession_parents", name="delateSession_parent")
* */
public function delateSession_parents()
{
$session = $this->session;
$em = $this->em;
$Products = [];
if ($session->get("paymentmoniteco") == "succses") {
$Products = [];
$session->set('Panier', $Products);
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$payer = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "payer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
if ($panierTrace) {
$panierTrace->setStatut($payer);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
}
$this->session->remove('paymentmoniteco');
$this->session->remove('montanttotalcomande');
$this->session->remove('Panierlength');
$this->session->remove('envoipost');
return new Response('done');
}
/**
* @Route("/Parent/chargement_form_conn_up2pay", name="chargement_form_conn_up2pay")
*/
function chargeFormup2payAction(Request $request)
{
$session = $this->session;
$em = $this->container->get('doctrine')->getManager();
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$user = $user->getId();
$comande = $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour, "idParent" => $user]);
$firstName = $comande->getIdParent()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdParent()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
$addressLine1 = "3 rue de l'église";
$city = "Ostheim";
$postalCode = "68150";
$pbx_site = '6062073'; //variable de test 9999999
$pbx_rang = '001'; //variable de test 95
$pbx_identifiant = '38027616'; //variable de test 123456789
$pbx_cmd = 'REFCN' . $comande->getId();
$pbx_effectue = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$pbx_annule = $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$pbx_refuse = $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
// Paramétrage de l'url de retour back office site (notification de paiement IPN) :
$pbx_repondre_a = "";
//$pbx_repondre_a = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdParent()->getEmail();
$pbx_porteur = $mail; //variable de test test@test.fr
// Paramétrage des données retournées via l'IPN :
$pbx_retour = 'Mt:M;Ref:R;Auto:A;Erreur:E';
// On récupére la date au format ISO-8601 :
$dateTime = date("c");
//$montant = $comande->getMontantrth() . "EUR";
$pbx_total = $comande->getIdSejour()->getPrixcnxparent();
$pbx_total = (int)((string)($pbx_total * 100));
// Suppression des points ou virgules dans le montant
$pbx_total = str_replace(",", "", $pbx_total);
$pbx_total = str_replace(".", "", $pbx_total);
// Nombre de produit envoyé dans PBX_SHOPPINGCART :
$pbx_nb_produit = '1'; //variable de test 5
// Construction de PBX_SHOPPINGCART :
$pbx_shoppingcart = "<?xml version=\"1.0\" encoding=\"utf-8\"?><shoppingcart><total><totalQuantity>" . $pbx_nb_produit . "</totalQuantity></total></shoppingcart>";
// Choix de l'authentification dans PBX_SOUHAITAUTHENT
$pbx_souhaitauthent = '01'; //variable de test authentification 3DS (1 par défaut, 2 pour exemption 3DS)
// Valeurs envoyes dans PBX_BILLING :
$pbx_prenom_fact = $firstName; //variable de test Jean-Marie
$pbx_nom_fact = $lastName; //variable de test Thomson
$pbx_adresse1_fact = $addressLine1; //variable de test 1 rue de Paris
$pbx_adresse2_fact = ''; //variable de test <vide>
$pbx_zipcode_fact = $postalCode; //variable de test 75001
$pbx_city_fact = $city; //variable de test Paris
$pbx_country_fact = '250'; //variable de test 250 (pour la France)
// Construction de PBX_BILLING :
$pbx_billing = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Billing><Address><FirstName>" . $pbx_prenom_fact . "</FirstName>" .
"<LastName>" . $pbx_nom_fact . "</LastName><Address1>" . $pbx_adresse1_fact . "</Address1>" .
"<Address2>" . $pbx_adresse2_fact . "</Address2><ZipCode>" . $pbx_zipcode_fact . "</ZipCode>" .
"<City>" . $pbx_city_fact . "</City><CountryCode>" . $pbx_country_fact . "</CountryCode>" .
"</Address></Billing>";
// Recette (paiements de test) :
//$urletrans ="https://recette-tpeweb.e-transactions.fr/php/";
// Production (paiements réels) :
// URL principale :
$urletrans = "https://tpeweb.e-transactions.fr/php/";
// URL secondaire :
// $urletrans ="https://tpeweb1.e-transactions.fr/php/";
// $hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
$hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
$pbx_prenom_fact = strtoupper($pbx_prenom_fact);
$pbx_nom_fact = strtoupper($pbx_nom_fact);
$pbx_adresse1_fact = strtoupper($pbx_adresse1_fact);
$pbx_adresse2_fact = strtoupper($pbx_adresse2_fact);
$pbx_city_fact = strtoupper($pbx_city_fact);
$pbx_country_fact = strtoupper($pbx_country_fact);
// --------------- TRAITEMENT DES VARIABLES ---------------
// On crée la chaéne a hacher sans URLencodage
$msg = "PBX_SITE=" . $pbx_site .
"&PBX_RANG=" . $pbx_rang .
"&PBX_IDENTIFIANT=" . $pbx_identifiant .
"&PBX_SOURCE=RWD" .
"&PBX_TOTAL=" . $pbx_total .
"&PBX_DEVISE=978" .
"&PBX_CMD=" . $pbx_cmd .
"&PBX_PORTEUR=" . $pbx_porteur .
"&PBX_REPONDRE_A=" . $pbx_repondre_a .
"&PBX_RETOUR=" . $pbx_retour .
"&PBX_EFFECTUE=" . $pbx_effectue .
"&PBX_ANNULE=" . $pbx_annule .
"&PBX_REFUSE=" . $pbx_refuse .
"&PBX_HASH=SHA512" .
"&PBX_TIME=" . $dateTime .
"&PBX_SHOPPINGCART=" . $pbx_shoppingcart .
"&PBX_BILLING=" . $pbx_billing .
"&PBX_SOUHAITAUTHENT=" . $pbx_souhaitauthent;
$binKey = pack("H*", $hmackey);
$hmac = strtoupper(hash_hmac('sha512', $msg, $binKey));
return new JsonResponse(array(
'urletrans' => $urletrans,
'pbx_site' => $pbx_site,
'pbx_rang' => $pbx_rang,
'pbx_identifiant' => $pbx_identifiant,
'pbx_total' => $pbx_total,
'pbx_cmd' => $pbx_cmd,
'pbx_porteur' => $pbx_porteur,
'pbx_repondre_a' => $pbx_repondre_a,
'pbx_retour' => $pbx_retour,
'pbx_effectue' => $pbx_effectue,
'pbx_annule' => $pbx_annule,
'pbx_refuse' => $pbx_refuse,
'dateTime' => $dateTime,
'pbx_shoppingcart' => $pbx_shoppingcart,
'pbx_billing' => $pbx_billing,
'pbx_souhaitauthent' => $pbx_souhaitauthent,
'hmac' => $hmac
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
/**
* @Route("/Parent/chargement_form_connx", name="chargement_form__Connx")
*/
function chargeFormOgoneAction_Connx(Request $request)
{
$session = $this->session;
$em = $this->container->get('doctrine')->getManager();
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$user = $user->getId();
$comande = $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour, "idParent" => $user]);
$firstName = $comande->getIdParent()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdParent()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
$addressLine1 = "3 rue de l'église";
$city = $city = "Ostheim";
$postalCode = "68150";
// $postalCode= trim ($postalCode) ;
$country = "FR";
$contexte = array("billing" => array("firstName" => $firstName, "lastName" => $lastName, "addressLine1" => $addressLine1, "city" => $city, "postalCode" => $postalCode, "country" => $country));
//param de payement
$contexte_commande = base64_encode(json_encode($contexte));
$PayementService = $this->container->get("App\Service\PayementService");
$version = $this->getParameter('version'); //done
$TPE = $this->getParameter('TPE'); //done
$dateTime = $dateNow = new \DateTime();
$date = $dateTime->format("d/m/Y:H:i:s");
//"05/05/2019:11:55:23" ;
$montant = $comande->getIdSejour()->getPrixcnxparent() . "EUR";
$reference = 'REFCN' . $comande->getId();
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$desactivemoyenpaiement = "paypal";
$lgue = "FR"; //done
$societe = "5sur5sejou"; //done
$textelibre = "5sur5sejour"; //
$mail = $this->getUser(); //
$SHAIN = $this->getParameter('shain');
$param = array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'url_retour_ok' => $url_retour_ok,
'url_retour_err' => $url_retour_err,
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => $contexte_commande,
'texte-libre' => $textelibre,
'mail' => $mail,
'desactivemoyenpaiement' => $desactivemoyenpaiement
);
$MAC = $PayementService->monetico_hash_parameters('sha1', $param, $SHAIN);
//utf8_encode
return new JsonResponse(array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'MAC' => $MAC,
'url_retour_ok' => utf8_encode($url_retour_ok),
'url_retour_err' => utf8_encode($url_retour_err),
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => utf8_encode($contexte_commande),
'textelibre' => utf8_encode($textelibre),
'mail' => $mail,
'desactivemoyenpaiement' => $desactivemoyenpaiement
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
/**
* @Route("/Parent/chargement_form_connx_paypal", name="chargement_form__Connx_PayPal")
*/
function chargeFormOgoneAction_Connx_PayPal(Request $request)
{
$session = $this->session;
$em = $this->container->get('doctrine')->getManager();
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$user = $user->getId();
$comande = $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour, "idParent" => $user]);
$firstName = $comande->getIdParent()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdParent()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
$addressLine1 = "3 rue de l'église";
$city = $city = "Ostheim";
$postalCode = "68150";
// $postalCode= trim ($postalCode) ;
$country = "FR";
$contexte = array("billing" => array("firstName" => $firstName, "lastName" => $lastName, "addressLine1" => $addressLine1, "city" => $city, "postalCode" => $postalCode, "country" => $country));
$protocole = "paypal";
//param de payement
$contexte_commande = base64_encode(json_encode($contexte));
$PayementService = $this->container->get("App\Service\PayementService");
$version = $this->getParameter('version'); //done
$TPE = $this->getParameter('TPE'); //done
$dateTime = $dateNow = new \DateTime();
$date = $dateTime->format("d/m/Y:H:i:s");
//"05/05/2019:11:55:23" ;
$montant = $comande->getIdSejour()->getPrixcnxparent() . "EUR";
$reference = 'REFCN' . $comande->getId();
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$lgue = "FR"; //done
$societe = "5sur5sejou"; //done
$textelibre = "5sur5sejour"; //
$mail = $this->getUser(); //
$SHAIN = $this->getParameter('shain');
$param = array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'url_retour_ok' => $url_retour_ok,
'url_retour_err' => $url_retour_err,
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => $contexte_commande,
'texte-libre' => $textelibre,
'mail' => $mail,
'protocole' => $protocole
);
$MAC = $PayementService->monetico_hash_parameters('sha1', $param, $SHAIN);
//utf8_encode
return new JsonResponse(array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'MAC' => $MAC,
'url_retour_ok' => utf8_encode($url_retour_ok),
'url_retour_err' => utf8_encode($url_retour_err),
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => utf8_encode($contexte_commande),
'textelibre' => utf8_encode($textelibre),
'mail' => $mail,
'protocole' => $protocole
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
/**
* @Route("/Parent/SupprimerCommande", name="Supprimer_CommandeParent")
*/
function RemoveCommandeParent(Request $request)
{
$CommandeService = $this->commandeService;
$idCmd = $request->get('id');
$result = $CommandeService->CommandeCloture($idCmd);
return new Response($result);
}
/**
* @Route("/Parent/accept_url_parentcnxx/{id}", name="moneticoAcceptUrl_parentcnxx")
*/
function moneticoAcceptUrl_parent($id)
{
$em = $this->container->get('doctrine')->getManager();
$comande = $this->em->getRepository(ParentSejour::class)->find($id);
if ($comande->getPayment() != 1) {
$typ = $this->em->getRepository(Typeproduit::class)->find(1);
$condit = $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
$produit = new Produit();
$produit->setIdConditionnement($condit);
$produit->setType($typ);
$produit->setDate(new \DateTime());
$produit->setLabele("Connexion");
$produit->setIduser($this->getUser());
$sats = $this->em->getRepository(Ref::class)->find(33);
//$ComandeService = $this->container->get("App\Service\ComandeService");
$ComandeService = $this->commandeService;
$comande->setPayment(1);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$produit->setIdsjour($comande->getIdSejour());
$this->em->getManager()->persist($produit);
$this->em->getManager()->flush();
$bytes = random_int(1000, 9999);
$pass = bin2hex($bytes);
//generate Num facture
$dateSJoue = new \Datetime();
$annes = $dateSJoue->format('y');
$moi = $dateSJoue->format('m');
$val = $this->em->getRepository(Commande::class)->serachNombreFacture();
$val = $val + 1;
$valx = sprintf('%04d', $val);
$valx1 = "20" . $annes . $moi . $valx;
$cmdpaym = new Commande();
$cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
$cmdpaym->setNumComande($pass);
$cmdpaym->getIdSejour($pass);
$cmdpaym->setNumfacture($valx1);
$cmdpaym->setDateCreateCommande(new \DateTime());
$cmdpaym->setDateFacture(new \DateTime());
$cmdpaym->setStatut($sats);
$cmdpaym->setIdSejour($comande->getIdSejour());
$cmdpaym->setIdUser($this->getUser());
$this->em->getManager()->persist($cmdpaym);
$this->em->getManager()->flush();
$cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0', 6) . $cmdpaym->getId());
$this->em->getManager()->persist($cmdpaym);
$this->em->getManager()->flush();
$cpmd = new ComandeProduit();
$cpmd->setIdComande($cmdpaym);
$cpmd->setIdProduit($produit);
$cpmd->setQuantiter(1);
$cpmd->setDate(new \DateTime());
//stille reversment par prod
$this->em->getManager()->persist($cpmd);
$this->em->getManager()->flush();
$pdfOptions = new Options();
$pdfOptions->set('isRemoteEnabled', TRUE);
$pdfOptions->set('defaultFont', 'Arial');
// Instantiate Dompdf with our options
$dompdf = new Dompdf($pdfOptions);
$dompdf->set_option('isRemoteEnabled', TRUE);
// Retrieve the HTML generated in our twig file
$html = $this->renderView('Admin/pdfFactureparent.html.twig', [
"Commande" => $cmdpaym,
]);
// Load HTML to Dompdf
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Store PDF Binary Data
$output = $dompdf->output();
// In this case, we want to write the file in the public directory
$publicDirectory = $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
// e.g /var/www/project/public/mypdf.pdf
$pdfFilepath = $publicDirectory . "Facture" . $cmdpaym->getId() . '-' . $cmdpaym->getNumComande() . ".pdf";
// Write file to the desired path
file_put_contents($pdfFilepath, $output);
}
$jetonService = new JetonService($this->em);
if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
$jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
}
$session = $this->session;
$session->set('paymentmoniteco', 'succses');
$resulat = $session->get("paymentmoniteco");
//dd($montanttotalcomande);
return $this->redirectToRoute('AccueilParent');
}
/**
* @Route("/Parent/accept_url_parentcnxxVirgo/{id}", name="moneticoAcceptUrl_parentcnxxVirgo")
*/
function moneticoAcceptUrl_parentVirgo($id)
{
$em = $this->container->get('doctrine')->getManager();
$comande = $this->em->getRepository(ParentSejour::class)->find($id);
if ($comande->getPayment() != 1) {
$typ = $this->em->getRepository(Typeproduit::class)->find(1);
$condit = $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
$produit = new Produit();
$produit->setIdConditionnement($condit);
$produit->setType($typ);
$produit->setLabele("Connexion");
$produit->setIduser($this->getUser());
$produit->setDate(new \DateTime());
$sats = $this->em->getRepository(Ref::class)->find(33);
$ComandeService = $this->container->get("App\Service\ComandeService");
$comande->setPayment(1);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$produit->setIdsjour($comande->getIdSejour());
$this->em->getManager()->persist($produit);
$this->em->getManager()->flush();
$bytes = random_int(1000, 9999);
$pass = bin2hex($bytes);
//generate Num facture
$dateSJoue = new \Datetime();
$annes = $dateSJoue->format('y');
$moi = $dateSJoue->format('m');
$val = $this->em->getRepository(Commande::class)->serachNombreFacture();
$val = $val + 1;
$valx = sprintf('%04d', $val);
$valx1 = "20" . $annes . $moi . $valx;
$cmdpaym = new Commande();
$cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
$cmdpaym->setNumComande($pass);
$cmdpaym->getIdSejour($pass);
$cmdpaym->setNumfacture($valx1);
$cmdpaym->setDateFacture(new \DateTime());
$cmdpaym->setDateCreateCommande(new \DateTime());
$cmdpaym->setStatut($sats);
$cmdpaym->setPaymentType("Mobile");
$cmdpaym->setIdSejour($comande->getIdSejour());
$cmdpaym->setIdUser($this->getUser());
$this->em->getManager()->persist($cmdpaym);
$this->em->getManager()->flush();
$cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0', 6) . $cmdpaym->getId());
$this->em->getManager()->persist($cmdpaym);
$this->em->getManager()->flush();
$cpmd = new ComandeProduit();
$cpmd->setIdComande($cmdpaym);
$cpmd->setIdProduit($produit);
$cpmd->setQuantiter(1);
$cpmd->setDate(new \DateTime());
//stille reversment par prod
$this->em->getManager()->persist($cpmd);
$this->em->getManager()->flush();
$pdfOptions = new Options();
$pdfOptions->set('isRemoteEnabled', TRUE);
$pdfOptions->set('defaultFont', 'Arial');
// Instantiate Dompdf with our options
$dompdf = new Dompdf($pdfOptions);
$dompdf->set_option('isRemoteEnabled', TRUE);
// Retrieve the HTML generated in our twig file
$html = $this->renderView('Admin/pdfFactureparent.html.twig', [
"Commande" => $cmdpaym,
]);
// Load HTML to Dompdf
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Store PDF Binary Data
$output = $dompdf->output();
// In this case, we want to write the file in the public directory
$publicDirectory = $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
// e.g /var/www/project/public/mypdf.pdf
$pdfFilepath = $publicDirectory . "Facture" . $cmdpaym->getId() . '-' . $cmdpaym->getNumComande() . ".pdf";
// Write file to the desired path
file_put_contents($pdfFilepath, $output);
}
$jetonService = new JetonService($this->em);
if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
$jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
}
$session = $this->session;
$session->set('paymentmoniteco', 'succses');
$resulat = $session->get("paymentmoniteco");
//dd($montanttotalcomande);
return $this->redirectToRoute('AccueilParent');
}
/**
* @Route("/error_url_parentcnxx/{id}", name="moneticoExceptionUrl_parentcnxx")
*/
function moneticoExceptionUrl_parentcnxx($id)
{
$em = $this->container->get('doctrine')->getManager();
$comande = $this->em->getRepository(ParentSejour::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'echec');
$comande->setPayment(0);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$resulat = $session->get("paymentmoniteco");
//dd($montanttotalcomande);
return $this->redirectToRoute('AccueilParent');
}
/**
* @Route("/Parent/SuiviCommande", name="SuiviCommande")
* */
public function SuiviCommande()
{
// dd($liste);
$user = $this->getUser();
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$ParentSejour = $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour, 'idParent' => $user]);
//ParentSejour
//cablala
//dd($ParentSejour[0]);
//$listeattach = $sejourservice->getatachmentsejour($id);
//$listeattachM = $sejourservice->getsejourmessage($id);
return $this->render('Parent/suivicommande.html.twig', [
'user' => $user,
'sejour' => $sejour,
'ParentSejour' => $ParentSejour[0],
]);
}
/**
* @Route("/Parent/SuiviCommandeparent", name="SuiviCommandeparent")
* */
public function SuiviCommandeparent()
{
// dd($liste);
$user = $this->getUser();
//dd($user);
$cmdservice = $this->commandeService;
$session = $this->session;
$idSejour = $session->get("Sejour");
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$listeCmd = $cmdservice->listerCommandeParent($user);
return $this->render('Parent/suivicommande.html.twig', [
'user' => $user,
'sejour' => $sejour,
'listeCmd' => $listeCmd
]);
}
private function envoieMailPackNumerique($nameZip,$email,$commande)
{
// Utiliser directement le numéro de commande comme identifiant de téléchargement
$downloadLink = $nameZip ;
$this->emailsCmdService->MailPackPhotosNumerique(
$email,
$downloadLink,
$commande->getId(),
);
// Marquer comme envoyé
$commande->setEnvoi(1);
$this->em->getManager()->persist($commande);
$this->em->getManager()->flush();
$this->logger->info("Email sent for order: ");
return true;
}
/**
* @Route("/Parent/telechargerPack/{idCommande}", name="telechargerPack")
*/
public function TelechagerPackNumerique($idCommande): Response
{
$this->logger->info("Tentative de téléchargement du pack pour la commande numérique ID: {$idCommande}");
// Récupérer la commande numérique
$commandeNumerique = $this->em->getRepository(CommandeNumerique::class)->find($idCommande);
// Vérifier si la commande existe
if (!$commandeNumerique) {
$this->logger->error("Commande numérique introuvable - ID: {$idCommande}");
return new JsonResponse(["message" => "Commande introuvable"], 404);
}
// Récupérer les informations associées
$commande = $commandeNumerique->getIdCommande();
$idcommande = $commande->getId();
$user = $commande->getIdUser();
$iduser = $user->getId();
$sejour = $commande->getIdSejour();
$this->logger->info("Commande numérique {$commandeNumerique->getId()} trouvée, commande parent ID: {$idcommande}, utilisateur: {$user->getEmail()},ETAT: {$commandeNumerique->getEtat()}");
$idCmdNumerique = $commandeNumerique->getId();
// Vérifier si le lien de téléchargement existe
$refcmdnum = $commandeNumerique->getLinkdownload();
$this->logger->info("Lien de téléchargement: {$refcmdnum}");
if (!$refcmdnum) {
// Envoyer un email d'alerte à l'administrateur
$email = (new Email())
->from('noreply@5sur5sejour.com')
->to('yousra.tlich@gmail.com')
->subject('ALERTE - Lien de téléchargement corrompu')
->text(
"Le lien de téléchargement est corrompu pour la commande suivante:\n" .
"ID Commande Numérique: " . $idCmdNumerique . "\n" .
"ID Commande: " . $idcommande . "\n" .
"Utilisateur: " . $user->getEmail() . "\n" .
"Séjour: " . $sejour->getLibelleSejour() . "\n" .
"Date: " . (new \DateTime())->format('Y-m-d H:i:s')
);
$this->symfonyMailer->send($email);
$this->logger->error("Lien de téléchargement corrompu pour la commande numérique {$idCommande}");
return new JsonResponse(["message" => "Lien de téléchargement non disponible"], 404);
}
$this->logger->info("Lien de téléchargement trouvé pour la commande numérique {$idCommande}: {$refcmdnum}");
// Vérifier que l'utilisateur et le séjour existent
if (!$user || !$sejour) {
$this->logger->error("Utilisateur ou séjour manquant pour la commande numérique {$idCommande}");
return new JsonResponse(['message' => 'Lien invalide - utilisateur ou séjour manquant'], 400);
}
// Vérifier l'état de la commande
if ($commandeNumerique->getEtat() === 1) {
// Construire le chemin du fichier
$filePath = $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' . $refcmdnum . '.zip';
// Vérifier si le fichier existe
if (file_exists($filePath)) {
$this->logger->info("Fichier trouvé, téléchargement démarré pour la commande numérique {$idCmdNumerique}");
return $this->file($filePath, $refcmdnum . '.zip', ResponseHeaderBag::DISPOSITION_ATTACHMENT);
} else {
// Envoyer un email d'alerte pour fichier manquant
$email = (new Email())
->from('noreply@5sur5sejour.com')
->to('yousra.tlich@gmail.com')
->subject('ALERTE - Fichier ZIP manquant')
->text(
"Le fichier ZIP est manquant pour la commande suivante:\n" .
"ID Commande Numérique: " . $idCommande . "\n" .
"ID Commande: " . $idcommande . "\n" .
"Lien de téléchargement: " . $refcmdnum . "\n" .
"Chemin attendu: " . $filePath . "\n" .
"Date: " . (new \DateTime())->format('Y-m-d H:i:s')
);
$this->symfonyMailer->send($email);
$this->logger->error("Fichier ZIP manquant pour la commande numérique {$idCommande} - chemin: {$filePath}");
return new JsonResponse(['message' => 'Fichier non trouvé'], 404);
}
}
elseif ($commandeNumerique->getEtat() == 2) {
$this->logger->warning("Tentative de téléchargement d'une commande déjà livrée - ID: {$idCommande}");
return new JsonResponse(['message' => 'Commande déjà livrée'], 400);
} else {
$this->logger->warning("État de commande invalide pour la commande numérique {$idCmdNumerique} - état: {$commandeNumerique->getEtat()}");
return new JsonResponse(['message' => 'Commande invalide'], 400);
}
}
/**
* @Route("/Parent/disableTelecharge/{idCommande}" , name="disableTelecharge" )
*/
public function disableTelecharge($idCommande)
{
$commandenumerique = $this->em->getRepository(CommandeNumerique::class)->findOneBy(['id' => $idCommande]);
$commandenumerique->setEtat(2);
$commandenumerique->setDateTelechargement(new \DateTime());
$this->em->getManager()->persist($commandenumerique);
$this->em->getManager()->flush();
return "ok";
}
/**
* @Route("/Accompagnateur/pdffacturetest/{id}", name="pdffacturetest")
*/
public function pdffactureAccomptest($id)
{
$em = $this->em;
$cmd = $em->getRepository(Commande::class)->find($id);
return $this->render('Parent/pdfFactureParent.html.twig', [
"comande" => $cmd,
]);
}
/**
* @Route("/Parent/pdffacture/{id}", name="pdffacture")
*/
public function pdffacture($id)
{
$user = $this->getUser();
$cmd = $this->em->getRepository(Commande::class)->find($id);
// $result= $this->EmailServie->MailCommandeSuivieParent($user->getEmail(),$cmd );
// Configure Dompdf according to your needs
$pdfOptions = new Options();
$pdfOptions->set('isRemoteEnabled', TRUE);
$pdfOptions->set('defaultFont', 'Arial');
// Instantiate Dompdf with our options
$dompdf = new Dompdf($pdfOptions);
$dompdf->set_option('isRemoteEnabled', TRUE);
// Retrieve the HTML generated in our twig file
$html = $this->renderView('Parent/pdfFactureParent.html.twig', [
"comande" => $cmd,
]);
// Load HTML to Dompdf
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser (force download)
$dompdf->stream("facture.pdf", [
"Attachment" => true
]);
return new Response('yoopi');
}
/**
* @Route("/Parent/testPDF/{idPrdt}", name="TcPdf")
*/
public function TcPdf($idPrdt)
{
ini_set("max_execution_time", -1);
$pageLayout = array(21, 15);
$pdf = $this->get("white_october.tcpdf")->create('L', 'CM', $pageLayout, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 009');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// $pdf->AddPage();
$pdf->setJPEGQuality(100);
$horizontal_alignments = array('L', 'C', 'R');
$vertical_alignments = array('T', 'M', 'B');
//var_dump($pdf->getPageWidth());
//var_dump($pdf->getPageHeight());die();
$em = $this->em;
$Album = $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
//dd($AllPages);
// $fP=[];
// array_push($fP,$AllPages[0]);
//dd($AllPages);
foreach ($AllPages as $p) {
$pdf->AddPage();
$pdf->setJPEGQuality(100);
$contenu = json_decode(json_decode($p->getCouleurbordure())[0]);
$nbatach = $contenu->nbrAttc;
$nbatach = intval(str_replace('"', '', $nbatach));
$color = $contenu->color;
// $color="rgb(255,255,255)";
$color = str_replace('"rgb(', '', $color);
$color = str_replace(')"', '', $color);
$color = explode(",", $color);
$colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
$tabtxt = json_decode($contenu->txt);
$tabphoto = json_decode($contenu->attache);
//
//dd($tabtxt);
// dd($tabtxt);
//dd($tabphoto);
$tabClips = json_decode($contenu->clips);
// dd($tabClips);
$x = 0.6;
$y = 0.8;
$w = 19.8;
$h = 13.4;
// get the current page break margin
$bMargin = $pdf->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $pdf->getAutoPageBreak();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// test all combinations of alignments
$fitbox = $horizontal_alignments[1] . ' ';
$fitbox[1] = $vertical_alignments[1];
$pdf->Rect(0, 0, 21, 15, 'F', array(), $colorp);
// sizeof($tabphoto)
for ($i = 0; $i < sizeof($tabphoto); $i++) {
$photo = json_decode($tabphoto[$i]);
//les coordonnées de l'image réel:
$hght = $photo->height;
$top = $photo->top;
$left = $photo->left;
$width = $photo->width;
$ordre = $photo->ordre;
$zoom = $photo->zoom;
$path = $photo->path;
$hght = floatval(str_replace('cm', '', $hght));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$width = floatval(str_replace('cm', '', $width));
//les coordonnées dropzone:
$heightOriginal = $photo->height;
$widthOriginal = $photo->width;
$top = $photo->top;
$left = $photo->left;
$heightOriginal = floatval(str_replace('cm', '', $heightOriginal));
$widthOriginal = floatval(str_replace('cm', '', $widthOriginal));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$heightOriginal = $heightOriginal * 37.7952755906;
$widthOriginal = $widthOriginal * 37.7952755906;
$topOriginal = $top * 37.7952755906;
$leftOriginal = $left * 37.7952755906;
$heightCrop = $photo->heightCrop;
$topCrop = $photo->topCrop;
$leftCrop = $photo->leftCrop;
$widthCrop = $photo->widthCrop;
$path = $photo->path;
$heightCrop = floatval(str_replace('cm', '', $heightCrop));
$topCrop = floatval(str_replace('cm', '', $topCrop));
$leftCrop = floatval(str_replace('cm', '', $leftCrop));
$widthCrop = floatval(str_replace('cm', '', $widthCrop));
$widthCropPX = $widthCrop * 37.7952755906;
$heightCropPX = $heightCrop * 37.7952755906;
$topCropPX = $topCrop * 37.7952755906;
$leftCropPX = $leftCrop * 37.7952755906;
// var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
// var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
// var_dump("//00");
// var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
// var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
//Calculer position des images selon nombres images par page:
$positionX = 0;
$positionY = 0;
$widthImg = 0;
$heightImg = 0;
if ($nbatach == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 18;
$heightImg = 12;
} elseif ($nbatach == 2) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 12;
}
if ($ordre == 2) {
$positionX = 10.8;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 12;
}
} elseif ($nbatach == 3) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 12;
}
if ($ordre == 2) {
$positionX = 10.8;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 5.7;
}
if ($ordre == 3) {
$positionX = 10.8;
$positionY = 7.8;
$widthImg = 8.7;
$heightImg = 5.7;
}
} elseif ($nbatach == 4) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 5.7;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 7.8;
$widthImg = 8.7;
$heightImg = 5.7;
}
if ($ordre == 3) {
$positionX = 10.8;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 5.7;
}
if ($ordre == 4) {
$positionX = 10.8;
$positionY = 7.8;
$widthImg = 8.7;
$heightImg = 5.7;
}
} elseif ($nbatach == 5) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 18;
$heightImg = 8;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 10.1;
$widthImg = 4.05;
$heightImg = 3.4;
}
if ($ordre == 3) {
$positionX = 6.15;
$positionY = 10.1;
$widthImg = 4.05;
$heightImg = 3.4;
}
if ($ordre == 4) {
$positionX = 10.8;
$positionY = 10.1;
$widthImg = 4.05;
$heightImg = 3.4;
}
if ($ordre == 5) {
$positionX = 15.45;
$positionY = 10.1;
$widthImg = 4.05;
$heightImg = 3.4;
}
} elseif ($nbatach == 6) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 5.53;
$heightImg = 3.6;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 5.7;
$widthImg = 5.53;
$heightImg = 3.6;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 9.9;
$widthImg = 5.53;
$heightImg = 3.6;
}
if ($ordre == 4) {
$positionX = 7.63;
$positionY = 1.5;
$widthImg = 5.53;
$heightImg = 3.6;
}
if ($ordre == 5) {
$positionX = 7.63;
$positionY = 5.7;
$widthImg = 5.53;
$heightImg = 3.6;
}
if ($ordre == 6) {
$positionX = 7.63;
$positionY = 9.9;
$widthImg = 5.53;
$heightImg = 3.6;
}
} elseif ($nbatach == 12) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 5.7;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 9.9;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 4) {
$positionX = 6.15;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 5) {
$positionX = 6.15;
$positionY = 5.7;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 6) {
$positionX = 6.15;
$positionY = 9.9;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 7) {
$positionX = 10.8;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 8) {
$positionX = 10.8;
$positionY = 5.7;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 9) {
$positionX = 10.8;
$positionY = 9.9;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 10) {
$positionX = 15.45;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 11) {
$positionX = 15.45;
$positionY = 5.7;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 12) {
$positionX = 15.45;
$positionY = 9.9;
$widthImg = 4.05;
$heightImg = 3.6;
}
}
//Recarder l'image :
// $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
// $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
$pathArray = explode("/", $path);
$idsArray = explode(".", $pathArray[sizeof($pathArray) - 1]);
$idImage = "";
foreach ($idsArray as $key => $elem) {
if ($key != (sizeof($idsArray) - 1)) {
$idImage = $idImage . $elem;
}
}
// $cloudinaryWidht=$widthOriginal;
// $cloudinaryHeight=$widthOriginal;
$idImage = 'newprod/' . $idImage;
//var_dump($idImage);
Unirest\Request::auth('263346742199243', 'jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
$headers = array('Accept' => 'application/json');
$data = array("public_ids" => array($idImage));
$body = Unirest\Request\Body::form($data);
Unirest\Request::verifyPeer(false);
$url = 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' . $idImage;
// $resultMetadata= \Cloudinary::Api.resources_by_ids([$idImage]);
// var_dump($url);
//https://media.5sur5sejour.com/api/upload/a_exif/original/
$resultMetadata = Unirest\Request::post($url, $headers, $body);
if (isset(json_decode($resultMetadata->raw_body)->width)) {
$cloudinaryWidht = json_decode($resultMetadata->raw_body)->width;
$cloudinaryHeight = json_decode($resultMetadata->raw_body)->height;
} else {
$cloudinaryWidht = $widthOriginal;
$cloudinaryHeight = $heightOriginal;
}
$ratiohight = $cloudinaryWidht / $widthOriginal;
$ratioHight = $cloudinaryHeight / $heightOriginal;
//$cloudinaryHeight=$cloudinaryHeight*$zoom;
//$cloudinaryWidht=$cloudinaryWidht*$zoom;
var_dump($cloudinaryWidht);
var_dump($cloudinaryHeight);
var_dump($ratioHight);
var_dump($zoom);
var_dump($leftOriginal);
var_dump('x_' . round(abs($leftOriginal / $zoom) * $ratioHight));
var_dump('y_' . round(abs($topOriginal / $zoom) * $ratiohight));
var_dump('w_' . round(($widthCropPX / $zoom) * $ratioHight));
var_dump('h_' . round(($heightCropPX / $zoom) * $ratiohight));
//var_dump($path);i
$path = str_replace('upload/', 'upload/w_' . round($cloudinaryWidht) . ',h_' . round($cloudinaryHeight) . ',c_scale/x_' . round(abs($leftOriginal / $zoom) * $ratioHight) . ',y_' . round(abs($topOriginal / $zoom) * $ratiohight) . ',w_' . round(($widthCropPX / $zoom) * $ratioHight) . ',h_' . round(($heightCropPX / $zoom) * $ratiohight) . ',c_crop/', $path);
//var_dump($path);i
// $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
//var_dump($path);
$path = str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,", '', $path);
// var_dump("//00");
// var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
// var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
// var_dump("//00");
// var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
// var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
var_dump($zoom);
var_dump($path);
// $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
$pdf->Image($path, $positionX, $positionY, $widthImg, $heightImg, 'JPG', '', '', false, 1000, '', false, false, 0, false, false, false);
// $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
//
}
// $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3, 2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
for ($i = 0; $i < sizeof($tabtxt); $i++) {
$txt = json_decode($tabtxt[$i]);
$fontSize = floatval(str_replace('px', '', $txt->fontSize)) * 0.75;
//$txt->rotation
$check = explode(',', $txt->fontFamily);
if (sizeof($check) > 1) {
//default
if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
$finalFont = "helvetica";
$weight = '';
}
//classique
if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
$finalFont = "times";
$weight = '';
}
//creative
if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
$finalFont = "helveticaB";
$weight = '';
}
// manuscrite
if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
$finalFont = "Courier";
$weight = '';
}
//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
} else {
//baton
if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
$finalFont = "helveticaB";
$weight = 'B';
}
}
$pdf->SetFont($finalFont, $weight, $fontSize);
$leftTxt = $txt->left;
$topTxt = $txt->top;
$heightClips = $txt->height;
$widthClips = $txt->width;
$heightTxt = floatval(str_replace('cm', '', $heightClips));
$topTxt = floatval(str_replace('cm', '', $topTxt));
$leftTxt = floatval(str_replace('cm', '', $leftTxt));
$widthTxt = floatval(str_replace('cm', '', $widthClips));
$pdf->SetXY($leftTxt, $topTxt, true);
// var_dump($leftTxt);
// var_dump($topTxt);
// var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
// var_dump("text");
$pdf->StartTransform();
var_dump($txt->rotation);
var_dump(str_replace('rad', '', $txt->rotation));
var_dump(floatval(str_replace('rad', '', $txt->rotation)) * 57.2958);
$pdf->Rotate((floatval(str_replace('rad', '', $txt->rotation)) * 57.2958) * -1, $leftTxt + ($widthTxt / 2), $topTxt + ($heightTxt / 2));
// $pdf->Rotate(45);
// $pdf->Text($leftTxt, $topTxt, $txt->contenu);
//$pdf->SetTextColor(200);
//$pdf->Text($leftTxt, $topTxt, $txt->contenu);
// $pdf->MultiCell($leftTxt, $topTxt, $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
$pdf->Write(str_replace('cm', '', $txt->height), trim($txt->contenu));
// $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
$pdf->StopTransform();
}
//Positionner text
// $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
//Positionner clipart
// dd($tabClips);
for ($i = 0; $i < sizeof($tabClips); $i++) {
$Clips = json_decode($tabClips[$i]);
$heightClips = $Clips->height;
$topClips = $Clips->top;
$leftClips = $Clips->left;
$widthClips = $Clips->width;
$path = $Clips->path;
$pathClips = str_replace('"', '', $path);
$heightClips = floatval(str_replace('cm', '', $heightClips));
$topClips = floatval(str_replace('cm', '', $topClips));
$leftClips = floatval(str_replace('cm', '', $leftClips));
$widthClips = floatval(str_replace('cm', '', $widthClips));
$heightClipsPX = round($heightClips * 37.7952755906);
$widthClipsPX = round($widthClips * 37.7952755906);
//// $positionXclips = $positionX + $leftClips;
//// $positionYclips = $positionY + $topClips;
//
//$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
//https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
// https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
var_dump($pathClips);
$pdf->StartTransform();
$pdf->Rotate((floatval(str_replace('rad', '', $Clips->rotation)) * 57.2958) * -1, $leftClips + ($widthClips / 2), $topClips + ($heightClips / 2));
$pdf->Image($this->newPAthCLipart($pathClips, $heightClipsPX, $widthClipsPX), $leftClips, $topClips, $widthClips, $heightClips, '', '', '', false, 300);
$pdf->StopTransform();
}
}
// echo '</pre>';
//return new response("yezi");
$projectRoot = $this->getParameter('kernel.project_dir');
$pdf->Output($projectRoot . '/public/pdfDocs/example_' . $idPrdt . '.pdf', 'F');
return new response("yezi");
//return $pdf->Output('example_009.pdf', 'I');
}
/**
* @Route("/Parent/testPDFphoto/{idPrdt}", name="TcPdfphoto")
*/
public function TcPdfPhoto($idPrdt)
{
ini_set("max_execution_time", -1);
$pageLayout = array(15, 10);
$pdf = $this->get("white_october.tcpdf")->create('L', 'CM', $pageLayout, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 009');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// $pdf->AddPage();
$pdf->setJPEGQuality(100);
$horizontal_alignments = array('L', 'C', 'R');
$vertical_alignments = array('T', 'M', 'B');
//var_dump($pdf->getPageWidth());
//var_dump($pdf->getPageHeight());die();
$em = $this->em;
$Album = $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
//dd($AllPages);
// $fP=[];
// array_push($fP,$AllPages[0]);
//dd($AllPages);
foreach ($AllPages as $p) {
$pdf->AddPage();
$pdf->setJPEGQuality(100);
$contenu = json_decode(json_decode($p->getCouleurbordure())[0]);
$nbatach = $contenu->nbrAttc;
$nbatach = intval(str_replace('"', '', $nbatach));
$color = $contenu->color;
// $color="rgb(255,255,255)";
$tabphoto = json_decode($contenu->attache);
//
//dd($tabtxt);
// dd($tabtxt);
//dd($tabphoto);
// dd($tabClips);
// get the current page break margin
$bMargin = $pdf->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $pdf->getAutoPageBreak();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// test all combinations of alignments
$fitbox = $horizontal_alignments[1] . ' ';
$fitbox[1] = $vertical_alignments[1];
// sizeof($tabphoto)
for ($i = 0; $i < sizeof($tabphoto); $i++) {
$photo = json_decode($tabphoto[$i]);
//les coordonnées de l'image réel:
$hght = $photo->height;
$top = $photo->top;
$left = $photo->left;
$width = $photo->width;
$ordre = $photo->ordre;
$zoom = $photo->zoom;
$path = $photo->path;
$hght = floatval(str_replace('cm', '', $hght));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$width = floatval(str_replace('cm', '', $width));
//les coordonnées dropzone:
$heightOriginal = $photo->height;
$widthOriginal = $photo->width;
$top = $photo->top;
$left = $photo->left;
$heightOriginal = floatval(str_replace('cm', '', $heightOriginal));
$widthOriginal = floatval(str_replace('cm', '', $widthOriginal));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$heightOriginal = $heightOriginal * 37.7952755906;
$widthOriginal = $widthOriginal * 37.7952755906;
$topOriginal = $top * 37.7952755906;
$leftOriginal = $left * 37.7952755906;
$heightCrop = $photo->heightCrop;
$topCrop = $photo->topCrop;
$leftCrop = $photo->leftCrop;
$widthCrop = $photo->widthCrop;
$path = $photo->path;
$heightCrop = floatval(str_replace('cm', '', $heightCrop));
$topCrop = floatval(str_replace('cm', '', $topCrop));
$leftCrop = floatval(str_replace('cm', '', $leftCrop));
$widthCrop = floatval(str_replace('cm', '', $widthCrop));
$widthCropPX = $widthCrop * 37.7952755906;
$heightCropPX = $heightCrop * 37.7952755906;
$topCropPX = $topCrop * 37.7952755906;
$leftCropPX = $leftCrop * 37.7952755906;
// var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
// var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
// var_dump("//00");
// var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
// var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
//Calculer position des images selon nombres images par page:
$positionX = 0;
$positionY = 0;
$widthImg = 0;
$heightImg = 0;
if ($nbatach == 1) {
$positionX = 0.3;
$positionY = 0.3;
$widthImg = 14.4;
$heightImg = 9.4;
}
//Recarder l'image :
// $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
// $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
$pathArray = explode("/", $path);
$idsArray = explode(".", $pathArray[sizeof($pathArray) - 1]);
$idImage = "";
foreach ($idsArray as $key => $elem) {
if ($key != (sizeof($idsArray) - 1)) {
$idImage = $idImage . $elem;
}
}
// $cloudinaryWidht=$widthOriginal;
// $cloudinaryHeight=$widthOriginal;
$idImage = 'newprod/' . $idImage;
//var_dump($idImage);
Unirest\Request::auth('263346742199243', 'jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
$headers = array('Accept' => 'application/json');
$data = array("public_ids" => array($idImage));
$body = Unirest\Request\Body::form($data);
Unirest\Request::verifyPeer(false);
$url = 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' . $idImage;
// $resultMetadata= \Cloudinary::Api.resources_by_ids([$idImage]);
// var_dump($url);
$resultMetadata = Unirest\Request::post($url, $headers, $body);
if (isset(json_decode($resultMetadata->raw_body)->width)) {
$cloudinaryWidht = json_decode($resultMetadata->raw_body)->width;
$cloudinaryHeight = json_decode($resultMetadata->raw_body)->height;
} else {
$cloudinaryWidht = $widthOriginal;
$cloudinaryHeight = $heightOriginal;
}
$ratiohight = $cloudinaryWidht / $widthOriginal;
$ratioHight = $cloudinaryHeight / $heightOriginal;
//$cloudinaryHeight=$cloudinaryHeight*$zoom;
//$cloudinaryWidht=$cloudinaryWidht*$zoom;
$zoom = 1;
var_dump($cloudinaryWidht);
var_dump($cloudinaryHeight);
var_dump($ratioHight);
var_dump($zoom);
var_dump($leftOriginal);
var_dump('x_' . round(abs($leftOriginal / $zoom) * $ratioHight));
var_dump('y_' . round(abs($topOriginal / $zoom) * $ratiohight));
var_dump('w_' . round(($widthCropPX / $zoom) * $ratioHight));
var_dump('h_' . round(($heightCropPX / $zoom) * $ratiohight));
//var_dump($path);i
$path = str_replace('upload/', 'upload/w_' . round($cloudinaryWidht) . ',h_' . round($cloudinaryHeight) . ',c_scale/x_' . round(abs($leftOriginal / $zoom) * $ratioHight) . ',y_' . round(abs($topOriginal / $zoom) * $ratiohight) . ',w_' . round(($widthCropPX / $zoom) * $ratioHight) . ',h_' . round(($heightCropPX / $zoom) * $ratiohight) . ',c_crop/', $path);
//var_dump($path);i
// $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
//var_dump($path);
$path = str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,", '', $path);
// var_dump("//00");
// var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
// var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
// var_dump("//00");
// var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
// var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
var_dump($zoom);
var_dump($path);
// $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
$pdf->Image($path, $positionX, $positionY, $widthImg, $heightImg, 'JPG', '', '', false, 1000, '', false, false, 0, false, false, false);
// $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
//
}
// $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3, 2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
//Positionner text
// $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
//Positionner clipart
// dd($tabClips);
}
// echo '</pre>';
//return new response("yezi");
$projectRoot = $this->getParameter('kernel.project_dir');
$pdf->Output($projectRoot . '/public/pdfDocs/example_' . $idPrdt . '.pdf', 'F');
return new response("yezi");
//return $pdf->Output('example_009.pdf', 'I');
}
/**
* @Route("/Parent/testPDFphotoR/{idPrdt}", name="TcPdfphotoR")
*/
public function TcPdfPhotoR($idPrdt)
{
ini_set("max_execution_time", -1);
$pageLayout = array(9, 10);
$pdf = $this->get("white_october.tcpdf")->create('P', 'CM', $pageLayout, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 009');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// $pdf->AddPage();
$pdf->setJPEGQuality(100);
$horizontal_alignments = array('L', 'C', 'R');
$vertical_alignments = array('T', 'M', 'B');
//var_dump($pdf->getPageWidth());
//var_dump($pdf->getPageHeight());die();
$em = $this->em;
$Album = $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
//dd($AllPages);
// $fP=[];
// array_push($fP,$AllPages[0]);
//dd($AllPages);
foreach ($AllPages as $p) {
$pdf->AddPage();
$pdf->setJPEGQuality(100);
$contenu = json_decode(json_decode($p->getCouleurbordure())[0]);
$nbatach = $contenu->nbrAttc;
$nbatach = intval(str_replace('"', '', $nbatach));
$color = $contenu->color;
// $color="rgb(255,255,255)";
$tabphoto = json_decode($contenu->attache);
//
//dd($tabtxt);
// dd($tabtxt);
//dd($tabphoto);
// dd($tabClips);
// get the current page break margin
$bMargin = $pdf->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $pdf->getAutoPageBreak();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// test all combinations of alignments
$fitbox = $horizontal_alignments[1] . ' ';
$fitbox[1] = $vertical_alignments[1];
// sizeof($tabphoto)
for ($i = 0; $i < sizeof($tabphoto); $i++) {
$photo = json_decode($tabphoto[$i]);
//les coordonnées de l'image réel:
$hght = $photo->height;
$top = $photo->top;
$left = $photo->left;
$width = $photo->width;
$ordre = $photo->ordre;
$zoom = $photo->zoom;
$path = $photo->path;
$hght = floatval(str_replace('cm', '', $hght));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$width = floatval(str_replace('cm', '', $width));
//les coordonnées dropzone:
$heightOriginal = $photo->height;
$widthOriginal = $photo->width;
$top = $photo->top;
$left = $photo->left;
$heightOriginal = floatval(str_replace('cm', '', $heightOriginal));
$widthOriginal = floatval(str_replace('cm', '', $widthOriginal));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$heightOriginal = $heightOriginal * 37.7952755906;
$widthOriginal = $widthOriginal * 37.7952755906;
$topOriginal = $top * 37.7952755906;
$leftOriginal = $left * 37.7952755906;
$heightCrop = $photo->heightCrop;
$topCrop = $photo->topCrop;
$leftCrop = $photo->leftCrop;
$widthCrop = $photo->widthCrop;
$path = $photo->path;
$heightCrop = floatval(str_replace('cm', '', $heightCrop));
$topCrop = floatval(str_replace('cm', '', $topCrop));
$leftCrop = floatval(str_replace('cm', '', $leftCrop));
$widthCrop = floatval(str_replace('cm', '', $widthCrop));
$widthCropPX = $widthCrop * 37.7952755906;
$heightCropPX = $heightCrop * 37.7952755906;
$topCropPX = $topCrop * 37.7952755906;
$leftCropPX = $leftCrop * 37.7952755906;
// var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
// var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
// var_dump("//00");
// var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
// var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
//Calculer position des images selon nombres images par page:
$positionX = 0;
$positionY = 0;
$widthImg = 0;
$heightImg = 0;
$positionX = 0.55;
$positionY = 0.5;
$widthImg = 7.9;
$heightImg = 6.9;
//Recarder l'image :
// $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
// $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
$pathArray = explode("/", $path);
$idsArray = explode(".", $pathArray[sizeof($pathArray) - 1]);
$idImage = "";
foreach ($idsArray as $key => $elem) {
if ($key != (sizeof($idsArray) - 1)) {
$idImage = $idImage . $elem;
}
}
// $cloudinaryWidht=$widthOriginal;
// $cloudinaryHeight=$widthOriginal;
$idImage = 'newprod/' . $idImage;
//var_dump($idImage);
Unirest\Request::auth('263346742199243', 'jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
$headers = array('Accept' => 'application/json');
$data = array("public_ids" => array($idImage));
$body = Unirest\Request\Body::form($data);
Unirest\Request::verifyPeer(false);
$url = 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' . $idImage;
// $resultMetadata= \Cloudinary::Api.resources_by_ids([$idImage]);
// var_dump($url);
$resultMetadata = Unirest\Request::post($url, $headers, $body);
if (isset(json_decode($resultMetadata->raw_body)->width)) {
$cloudinaryWidht = json_decode($resultMetadata->raw_body)->width;
$cloudinaryHeight = json_decode($resultMetadata->raw_body)->height;
} else {
$cloudinaryWidht = $widthOriginal;
$cloudinaryHeight = $heightOriginal;
}
$ratiohight = $cloudinaryWidht / $widthOriginal;
$ratioHight = $cloudinaryHeight / $heightOriginal;
//$cloudinaryHeight=$cloudinaryHeight*$zoom;
//$cloudinaryWidht=$cloudinaryWidht*$zoom;
$zoom = 1;
var_dump($cloudinaryWidht);
var_dump($cloudinaryHeight);
var_dump($ratioHight);
var_dump($zoom);
var_dump($leftOriginal);
var_dump('x_' . round(abs($leftOriginal / $zoom) * $ratioHight));
var_dump('y_' . round(abs($topOriginal / $zoom) * $ratiohight));
var_dump('w_' . round(($widthCropPX / $zoom) * $ratioHight));
var_dump('h_' . round(($heightCropPX / $zoom) * $ratiohight));
//var_dump($path);i
$path = str_replace('upload/', 'upload/w_' . round($cloudinaryWidht) . ',h_' . round($cloudinaryHeight) . ',c_scale/x_' . round(abs($leftOriginal / $zoom) * $ratioHight) . ',y_' . round(abs($topOriginal / $zoom) * $ratiohight) . ',w_' . round(($widthCropPX / $zoom) * $ratioHight) . ',h_' . round(($heightCropPX / $zoom) * $ratiohight) . ',c_crop/', $path);
//var_dump($path);i
// $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
//var_dump($path);
$path = str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,", '', $path);
// var_dump("//00");
// var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
// var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
// var_dump("//00");
// var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
// var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
var_dump($zoom);
var_dump($path);
// $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
$pdf->Image($path, $positionX, $positionY, $widthImg, $heightImg, 'JPG', '', '', false, 1000, '', false, false, 0, false, false, false);
// $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
//
}
// $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3, 2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
//Positionner text
// $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
//Positionner clipart
// dd($tabClips);
}
// echo '</pre>';
//return new response("yezi");
$projectRoot = $this->getParameter('kernel.project_dir');
$pdf->Output($projectRoot . '/public/pdfDocs/example_' . $idPrdt . '.pdf', 'F');
return new response("yezi");
//return $pdf->Output('example_009.pdf', 'I');
}
/**
* @Route("/Parent/testPDFCal/{idPrdt}", name="TcPdfCal")
*/
public function TcPdfCalendrier($idPrdt)
{
ini_set("max_execution_time", -1);
$pageLayout = array(21, 15);
$pdf = $this->get("white_october.tcpdf")->create('L', 'CM', $pageLayout, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 009');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// $pdf->AddPage();
$pdf->setJPEGQuality(100);
$horizontal_alignments = array('L', 'C', 'R');
$vertical_alignments = array('T', 'M', 'B');
//var_dump($pdf->getPageWidth());
//var_dump($pdf->getPageHeight());die();
$em = $this->em;
$Album = $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
//dd($AllPages);
// $fP=[];
// array_push($fP,$AllPages[0]);
//dd($AllPages);
foreach ($AllPages as $key => $p) {
$pdf->AddPage();
$pdf->setJPEGQuality(100);
$contenu = json_decode(json_decode($p->getCouleurbordure())[0]);
$nbatachS = $contenu->nbrAttc;
$nbatach = intval(str_replace('"', '', $nbatachS));
if (strpos($nbatachS, "H")) {
$nbatach = $nbatach . 'H';
}
$tabtxt = json_decode($contenu->txt);
$tabphoto = json_decode($contenu->attache);
//
//dd($tabtxt);
// dd($tabtxt);
//dd($tabphoto);
$tabClips = json_decode($contenu->clips);
// dd($tabClips);
$x = 0.6;
$y = 0.8;
$w = 19.8;
$h = 13.4;
// get the current page break margin
$bMargin = $pdf->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $pdf->getAutoPageBreak();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// test all combinations of alignments
$fitbox = $horizontal_alignments[1] . ' ';
$fitbox[1] = $vertical_alignments[1];
// sizeof($tabphoto)
for ($i = 0; $i < sizeof($tabphoto); $i++) {
$photo = json_decode($tabphoto[$i]);
//les coordonnées de l'image réel:
$hght = $photo->height;
$top = $photo->top;
$left = $photo->left;
$width = $photo->width;
$ordre = $photo->ordre;
$zoom = $photo->zoom;
$path = $photo->path;
$hght = floatval(str_replace('cm', '', $hght));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$width = floatval(str_replace('cm', '', $width));
//les coordonnées dropzone:
$heightOriginal = $photo->height;
$widthOriginal = $photo->width;
$top = $photo->top;
$left = $photo->left;
$heightOriginal = floatval(str_replace('cm', '', $heightOriginal));
$widthOriginal = floatval(str_replace('cm', '', $widthOriginal));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$heightOriginal = $heightOriginal * 37.7952755906;
$widthOriginal = $widthOriginal * 37.7952755906;
$topOriginal = $top * 37.7952755906;
$leftOriginal = $left * 37.7952755906;
$heightCrop = $photo->heightCrop;
$topCrop = $photo->topCrop;
$leftCrop = $photo->leftCrop;
$widthCrop = $photo->widthCrop;
$path = $photo->path;
$heightCrop = floatval(str_replace('cm', '', $heightCrop));
$topCrop = floatval(str_replace('cm', '', $topCrop));
$leftCrop = floatval(str_replace('cm', '', $leftCrop));
$widthCrop = floatval(str_replace('cm', '', $widthCrop));
$widthCropPX = $widthCrop * 37.7952755906;
$heightCropPX = $heightCrop * 37.7952755906;
$topCropPX = $topCrop * 37.7952755906;
$leftCropPX = $leftCrop * 37.7952755906;
// var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
// var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
// var_dump("//00");
// var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
// var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
//Calculer position des images selon nombres images par page:
$positionX = 0;
$positionY = 0;
$widthImg = 0;
$heightImg = 0;
var_dump('nbr_attach ' . $nbatach);
if ($nbatach == 1) {
if ($key == 0) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 18;
$heightImg = 10;
} else {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 12;
}
} elseif (($nbatach == 2) && ($nbatach == '2V')) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 12;
}
if ($ordre == 2) {
$positionX = 6.15;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 12;
}
} elseif ($nbatach == '2H') {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 5.7;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 7.8;
$widthImg = 8.7;
$heightImg = 5.7;
}
} elseif (($nbatach == 3) && ($nbatach == "3V")) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 12;
}
if ($ordre == 2) {
$positionX = 6.15;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 5.7;
}
if ($ordre == 3) {
$positionX = 6.15;
$positionY = 7.8;
$widthImg = 4.05;
$heightImg = 5.7;
}
} elseif ($nbatach == '3H') {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 5.7;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 7.8;
$widthImg = 4.05;
$heightImg = 5.7;
}
if ($ordre == 3) {
$positionX = 6.15;
$positionY = 7.8;
$widthImg = 4.05;
$heightImg = 5.7;
}
} elseif ($nbatach == 4) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 5.7;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 7.8;
$widthImg = 4.05;
$heightImg = 5.7;
}
if ($ordre == 3) {
$positionX = 6.15;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 5.7;
}
if ($ordre == 4) {
$positionX = 6.15;
$positionY = 7.8;
$widthImg = 4.05;
$heightImg = 5.7;
}
}
//nop
elseif ($nbatach == 5) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 18;
$heightImg = 8;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 3;
}
if ($ordre == 3) {
$positionX = 6.25;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 3;
}
if ($ordre == 4) {
$positionX = 11;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 3;
}
if ($ordre == 5) {
$positionX = 15.75;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 3;
}
} elseif ($nbatach == 6) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 5.7;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 9.9;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 4) {
$positionX = 6.15;
$positionY = 1.5;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 5) {
$positionX = 6.15;
$positionY = 5.7;
$widthImg = 4.05;
$heightImg = 3.6;
}
if ($ordre == 6) {
$positionX = 6.15;
$positionY = 9.9;
$widthImg = 4.05;
$heightImg = 3.6;
}
}
//nop
elseif ($nbatach == 12) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 4) {
$positionX = 6.25;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 5) {
$positionX = 6.25;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 6) {
$positionX = 6.25;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 7) {
$positionX = 11;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 8) {
$positionX = 11;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 9) {
$positionX = 11;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 10) {
$positionX = 15.75;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 11) {
$positionX = 15.75;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 12) {
$positionX = 15.75;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
} elseif ($nbatach == 15) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 4.2;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 6.54;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 4) {
$positionX = 1.5;
$positionY = 9.06;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 5) {
$positionX = 1.5;
$positionY = 11.58;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 6) {
$positionX = 4.6;
$positionY = 1.5;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 7) {
$positionX = 4.6;
$positionY = 4.2;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 8) {
$positionX = 4.6;
$positionY = 6.54;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 9) {
$positionX = 4.6;
$positionY = 9.06;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 10) {
$positionX = 4.6;
$positionY = 11.58;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 11) {
$positionX = 7.7;
$positionY = 1.5;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 12) {
$positionX = 7.7;
$positionY = 4.2;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 13) {
$positionX = 7.7;
$positionY = 6.54;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 14) {
$positionX = 7.7;
$positionY = 9.06;
$widthImg = 2.5;
$heightImg = 1.92;
}
if ($ordre == 15) {
$positionX = 7.7;
$positionY = 11.58;
$widthImg = 2.5;
$heightImg = 1.92;
}
}
if (($i == sizeof($tabphoto) - 1) && ($key != 0)) {
$path = 'https://demo.appsfactor.fr/' . $path;
$positionX = 10.8;
$positionY = 1.5;
$widthImg = 8.7;
$heightImg = 12;
$pdf->Image($path, $positionX, $positionY, $widthImg, $heightImg, 'JPG', '', '', false, 1000, '', false, false, 0, false, false, false);
} else {
//Recarder l'image :
// $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
// $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
$pathArray = explode("/", $path);
$idsArray = explode(".", $pathArray[sizeof($pathArray) - 1]);
$idImage = "";
foreach ($idsArray as $key2 => $elem) {
if ($key2 != (sizeof($idsArray) - 1)) {
$idImage = $idImage . $elem;
}
}
// $cloudinaryWidht=$widthOriginal;
// $cloudinaryHeight=$widthOriginal;
$idImage = 'newprod/' . $idImage;
//var_dump($idImage);
Unirest\Request::auth('263346742199243', 'jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
$headers = array('Accept' => 'application/json');
$data = array("public_ids" => array($idImage));
$body = Unirest\Request\Body::form($data);
Unirest\Request::verifyPeer(false);
$url = 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' . $idImage;
// $resultMetadata= \Cloudinary::Api.resources_by_ids([$idImage]);
// var_dump($url);
$resultMetadata = Unirest\Request::post($url, $headers, $body);
var_dump($resultMetadata);
if (isset(json_decode($resultMetadata->raw_body)->width)) {
$cloudinaryWidht = json_decode($resultMetadata->raw_body)->width;
$cloudinaryHeight = json_decode($resultMetadata->raw_body)->height;
} else {
$cloudinaryWidht = $widthOriginal;
$cloudinaryHeight = $heightOriginal;
}
$ratiohight = $cloudinaryWidht / $widthOriginal;
$ratioHight = $cloudinaryHeight / $heightOriginal;
//$cloudinaryHeight=$cloudinaryHeight*$zoom;
//$cloudinaryWidht=$cloudinaryWidht*$zoom;
var_dump($cloudinaryWidht);
var_dump($cloudinaryHeight);
var_dump($ratioHight);
var_dump($zoom);
$zoom = 1;
var_dump($leftOriginal);
var_dump('x_' . round(abs($leftOriginal / $zoom) * $ratioHight));
var_dump('y_' . round(abs($topOriginal / $zoom) * $ratiohight));
var_dump('w_' . round(($widthCropPX / $zoom) * $ratioHight));
var_dump('h_' . round(($heightCropPX / $zoom) * $ratiohight));
//var_dump($path);i
$path = str_replace('upload/', 'upload/w_' . round($cloudinaryWidht) . ',h_' . round($cloudinaryHeight) . ',c_scale/x_' . round(abs($leftOriginal / $zoom) * $ratioHight) . ',y_' . round(abs($topOriginal / $zoom) * $ratiohight) . ',w_' . round(($widthCropPX / $zoom) * $ratioHight) . ',h_' . round(($heightCropPX / $zoom) * $ratiohight) . ',c_crop/', $path);
//var_dump($path);i
// $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
//var_dump($path);
$path = str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,", '', $path);
// var_dump("//00");
// var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
// var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
// var_dump("//00");
// var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
// var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
var_dump($zoom);
var_dump($path);
// $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
$pdf->Image($path, $positionX, $positionY, $widthImg, $heightImg, 'JPG', '', '', false, 1000, '', false, false, 0, false, false, false);
// $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
//
}
}
// $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3, 2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
for ($i = 0; $i < sizeof($tabtxt); $i++) {
$txt = json_decode($tabtxt[$i]);
$fontSize = floatval(str_replace('px', '', $txt->fontSize)) * 0.75;
//$txt->rotation
$check = explode(',', $txt->fontFamily);
if (sizeof($check) > 1) {
//default
if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
$finalFont = "helvetica";
$weight = '';
}
//classique
if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
$finalFont = "times";
$weight = '';
}
//creative
if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
$finalFont = "helveticaB";
$weight = '';
}
// manuscrite
if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
$finalFont = "Courier";
$weight = '';
}
//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
} else {
//baton
if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
$finalFont = "helveticaB";
$weight = 'B';
}
}
$pdf->SetFont($finalFont, $weight, $fontSize);
$leftTxt = $txt->left;
$topTxt = $txt->top;
$heightClips = $txt->height;
$widthClips = $txt->width;
$heightTxt = floatval(str_replace('cm', '', $heightClips));
$topTxt = floatval(str_replace('cm', '', $topTxt));
$leftTxt = floatval(str_replace('cm', '', $leftTxt));
$widthTxt = floatval(str_replace('cm', '', $widthClips));
if ($key == 0) {
$heightTxt = 2;
$widthTxt = 7;
$leftTxt = (21) - ($widthTxt / 2);
$topTxt = 11.8;
$pdf->SetXY(0, $topTxt, true);
$pdf->Cell(21, 0, trim($txt->contenu), 0, 0, 'C', 0, '', 0);
} else {
$heightTxt = 2;
$widthTxt = 7;
$leftTxt = (21) - ($widthTxt / 2);
$topTxt = 11.8;
$pdf->SetXY(13.6, 12.4, true);
$pdf->Cell(6, 0, trim($txt->contenu), 0, 0, 'L', 0, '', 0);
}
// var_dump($leftTxt);
// var_dump($topTxt);
// var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
// var_dump("text");
//$pdf->StartTransform();
//$txt->rotation=0;
//var_dump($txt->rotation);
//var_dump(str_replace('rad','',$txt->rotation));
//var_dump(floatval(str_replace('rad','',$txt->rotation))*57.2958);
// $pdf->Rotate((floatval(str_replace('rad','',$txt->rotation))*57.2958)*-1,$leftTxt+($widthTxt/2),$topTxt+($heightTxt/2));
// $pdf->Rotate(45);
// $pdf->Text($leftTxt, $topTxt, $txt->contenu);
//$pdf->SetTextColor(200);
//$pdf->Text($leftTxt, $topTxt, $txt->contenu);
// $pdf->MultiCell($leftTxt, $topTxt, $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
// $pdf->Write(str_replace('cm','',$txt->height),trim($txt->contenu));
// $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
//$pdf->StopTransform();
}
//Positionner text
// $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
//Positionner clipart
// dd($tabClips);
for ($i = 0; $i < sizeof($tabClips); $i++) {
$Clips = json_decode($tabClips[$i]);
$heightClips = $Clips->height;
$topClips = $Clips->top;
$leftClips = $Clips->left;
$widthClips = $Clips->width;
$path = $Clips->path;
$pathClips = str_replace('"', '', $path);
$heightClips = floatval(str_replace('cm', '', $heightClips));
$topClips = floatval(str_replace('cm', '', $topClips));
$leftClips = floatval(str_replace('cm', '', $leftClips));
$widthClips = floatval(str_replace('cm', '', $widthClips));
$heightClipsPX = round($heightClips * 37.7952755906);
$widthClipsPX = round($widthClips * 37.7952755906);
//// $positionXclips = $positionX + $leftClips;
//// $positionYclips = $positionY + $topClips;
//
//$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
//https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
// https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
var_dump($pathClips);
$pdf->StartTransform();
$pdf->Rotate((floatval(str_replace('rad', '', $Clips->rotation)) * 57.2958) * -1, $leftClips + ($widthClips / 2), $topClips + ($heightClips / 2));
$pdf->Image($this->newPAthCLipart($pathClips, $heightClipsPX, $widthClipsPX), $leftClips, $topClips, $widthClips, $heightClips, '', '', '', false, 300);
$pdf->StopTransform();
}
}
// echo '</pre>';
//return new response("yezi");
$projectRoot = $this->getParameter('kernel.project_dir');
$pdf->Output($projectRoot . '/public/pdfDocs/example_' . $idPrdt . '.pdf', 'F');
return new response("yezi");
//return $pdf->Output('example_009.pdf', 'I');
}
function newPAthCLipart($url, $heigh, $width)
{
$allImage = [
'Eclaire.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143379/newprod/clipart/Eclaire_pr0ecu.png',
'ARcenciel.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143391/newprod/clipart/ARcenciel_grkyap.png',
'Drapeaux.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143377/newprod/clipart/Drapeaux_zqo8v3.png',
'Annif.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143391/newprod/clipart/Annif_ihvyoo.png',
'Basquettes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143377/newprod/clipart/Basquettes_znjd41.png',
'Foot.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143382/newprod/clipart/Foot_az6bct.png',
'Hello.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143383/newprod/clipart/Hello_njqifl.png',
'Love.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143386/newprod/clipart/Love_q39usk.png',
'LICORNE.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143385/newprod/clipart/LICORNE_hpomru.png',
'Noeud.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143388/newprod/clipart/Noeud_mw5a4j.png',
'Etoilerose.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143380/newprod/clipart/Etoilerose_ewrzff.png',
'Ete4.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143379/newprod/clipart/Ete4_pdxadk.png',
'Ete6.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143380/newprod/clipart/Ete6_a3xgpd.png',
'Ete9.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143380/newprod/clipart/Ete9_s4vllm.png',
'Hiver1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143384/newprod/clipart/Hiver1_fekrjz.png',
'Hiver2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143384/newprod/clipart/Hiver2_e9iygg.png',
'Noel2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143387/newprod/clipart/Noel2_eqvdzr.png',
'Hiver.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143383/newprod/clipart/Hiver_et04e1.png',
'Sapin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143390/newprod/clipart/Sapin_qjkxz6.png',
'Chaussetet.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143377/newprod/clipart/Chaussetet_xfpt6t.png',
'Cloches.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143377/newprod/clipart/Cloches_x2v3eo.png',
'Like.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143387/newprod/clipart/Like_ynxb2u.png',
'coeurlike.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143379/newprod/clipart/coeurlike_ferv9y.png',
'Fetedesmeres.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' . $width . '/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.png',
'Fetedesperes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' . $width . '/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.png',
'OOPS.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143389/newprod/clipart/OOPS_gj9p1c.png',
'OOPS_1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143389/newprod/clipart/OOPS_1_r9a7l6.png',
'WoW.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143393/newprod/clipart/WoW_ljlqjm.png',
'Nuage.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143387/newprod/clipart/Nuage_fgomd0.png',
'Pingouin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143389/newprod/clipart/Pingouin_ogxb6e.png',
'Renard.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143378/newprod/clipart/Chouette_mc1ik2.png',
'Chouette.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' . $width . '/v1589143390/newprod/clipart/Renard_mlhrxt.png'
];
//http://127.0.0.1:8000/images/ClipArt_SVG/LICORNE.svg
$arryUrls = explode('/', $url);
return ($allImage[$arryUrls[sizeof($arryUrls) - 1]]);
}
/**
* @Route("/Parent/TcPdfCalcul/{idPrdt}", name="TcPdfCalc")
*/
public function TcPdfCalcule($idPrdt)
{
echo '<pre>';
ini_set("max_execution_time", -1);
$pageLayout = array(21, 15);
$pdf = $this->get("white_october.tcpdf")->create('L', 'CM', $pageLayout, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 009');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// $pdf->AddPage();
$pdf->setJPEGQuality(100);
$horizontal_alignments = array('L', 'C', 'R');
$vertical_alignments = array('T', 'M', 'B');
//var_dump($pdf->getPageWidth());
//var_dump($pdf->getPageHeight());die();
$em = $this->em;
$Album = $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
//dd($AllPages);
// $fP=[];
// array_push($fP,$AllPages[0]);
//dd($AllPages);
foreach ($AllPages as $p) {
$pdf->AddPage();
$pdf->setJPEGQuality(100);
$contenu = json_decode(json_decode($p->getCouleurbordure())[0]);
$nbatach = $contenu->nbrAttc;
$nbatach = intval(str_replace('"', '', $nbatach));
$color = $contenu->color;
// $color="rgb(255,255,255)";
$color = str_replace('"rgb(', '', $color);
$color = str_replace(')"', '', $color);
$color = explode(",", $color);
$colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
$tabtxt = json_decode($contenu->txt);
$tabphoto = json_decode($contenu->attache);
//
//dd($tabtxt);
// dd($tabtxt);
//dd($tabphoto);
$tabClips = json_decode($contenu->clips);
// dd($tabClips);
$x = 0.6;
$y = 0.8;
$w = 19.8;
$h = 13.4;
// get the current page break margin
$bMargin = $pdf->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $pdf->getAutoPageBreak();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// test all combinations of alignments
$fitbox = $horizontal_alignments[1] . ' ';
$fitbox[1] = $vertical_alignments[1];
$pdf->Rect(0, 0, 21, 15, 'F', array(), $colorp);
// sizeof($tabphoto)
for ($i = 0; $i < sizeof($tabphoto); $i++) {
$photo = json_decode($tabphoto[$i]);
//les coordonnées de l'image réel:
$hght = $photo->height;
$top = $photo->top;
$left = $photo->left;
$width = $photo->width;
$ordre = $photo->ordre;
$zoom = $photo->zoom;
$path = $photo->path;
$hght = floatval(str_replace('cm', '', $hght));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$width = floatval(str_replace('cm', '', $width));
//les coordonnées dropzone:
$heightOriginal = $photo->height;
$widthOriginal = $photo->width;
$top = $photo->top;
$left = $photo->left;
$heightOriginal = floatval(str_replace('cm', '', $heightOriginal));
$widthOriginal = floatval(str_replace('cm', '', $widthOriginal));
$top = floatval(str_replace('cm', '', $top));
$left = floatval(str_replace('cm', '', $left));
$heightOriginal = $heightOriginal * 37.7952755906;
$widthOriginal = $widthOriginal * 37.7952755906;
$topOriginal = $top * 37.7952755906;
$leftOriginal = $left * 37.7952755906;
$heightCrop = $photo->heightCrop;
$topCrop = $photo->topCrop;
$leftCrop = $photo->leftCrop;
$widthCrop = $photo->widthCrop;
$path = $photo->path;
$heightCrop = floatval(str_replace('cm', '', $heightCrop));
$topCrop = floatval(str_replace('cm', '', $topCrop));
$leftCrop = floatval(str_replace('cm', '', $leftCrop));
$widthCrop = floatval(str_replace('cm', '', $widthCrop));
$widthCropPX = $widthCrop * 37.7952755906;
$heightCropPX = $heightCrop * 37.7952755906;
$topCropPX = $topCrop * 37.7952755906;
$leftCropPX = $leftCrop * 37.7952755906;
var_dump("original widh: " . $widthCrop . " " . "original height : " . $heightCrop);
var_dump("original left: " . $topCrop . " " . "original top : " . $leftCrop);
var_dump("//00");
var_dump("multip 37 widh: " . $widthCropPX . " " . "multip 37 height : " . $heightCropPX);
var_dump("multip 37 top: " . $topOriginal . " " . "multip 37 left : " . $leftOriginal);
//Calculer position des images selon nombres images par page:
$positionX = 0;
$positionY = 0;
$widthImg = 0;
$heightImg = 0;
if ($nbatach == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 18;
$heightImg = 12;
} elseif ($nbatach == 2) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.5;
$heightImg = 12;
}
if ($ordre == 2) {
$positionX = 11;
$positionY = 1.5;
$widthImg = 8.5;
$heightImg = 12;
}
} elseif ($nbatach == 3) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.5;
$heightImg = 12;
}
if ($ordre == 2) {
$positionX = 11;
$positionY = 1.5;
$widthImg = 8.5;
$heightImg = 5.5;
}
if ($ordre == 3) {
$positionX = 11;
$positionY = 8;
$widthImg = 8.5;
$heightImg = 5.5;
}
} elseif ($nbatach == 4) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 8.5;
$heightImg = 5.5;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 8;
$widthImg = 8.5;
$heightImg = 5.5;
}
if ($ordre == 3) {
$positionX = 11;
$positionY = 1.5;
$widthImg = 8.5;
$heightImg = 5.5;
}
if ($ordre == 4) {
$positionX = 11;
$positionY = 8;
$widthImg = 8.5;
$heightImg = 5.5;
}
} elseif ($nbatach == 5) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 18;
$heightImg = 8;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 4;
}
if ($ordre == 3) {
$positionX = 6.25;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 4;
}
if ($ordre == 4) {
$positionX = 11;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 4;
}
if ($ordre == 5) {
$positionX = 15.75;
$positionY = 10.5;
$widthImg = 3.75;
$heightImg = 4;
}
} elseif ($nbatach == 6) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 5.33;
$heightImg = 3.33;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 5.83;
$widthImg == 5.33;
$heightImg = 3.33;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 10.16;
$widthImg = 5.33;
$heightImg = 3.33;
}
if ($ordre == 4) {
$positionX = 7.83;
$positionY = 1.5;
$widthImg == 5.33;
$heightImg = 3.33;
}
if ($ordre == 5) {
$positionX = 7.83;
$positionY = 5.83;
$widthImg == 5.33;
$heightImg = 3.33;
}
if ($ordre == 6) {
$positionX = 7.83;
$positionY = 10.16;
$widthImg == 5.33;
$heightImg = 3.33;
}
} elseif ($nbatach == 12) {
if ($ordre == 1) {
$positionX = 1.5;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 2) {
$positionX = 1.5;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 3) {
$positionX = 1.5;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 4) {
$positionX = 6.25;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 5) {
$positionX = 6.25;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 6) {
$positionX = 6.25;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 7) {
$positionX = 11;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 8) {
$positionX = 11;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 9) {
$positionX = 11;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 10) {
$positionX = 15.75;
$positionY = 1.5;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 11) {
$positionX = 15.75;
$positionY = 5.83;
$widthImg = 3.75;
$heightImg = 3.33;
}
if ($ordre == 12) {
$positionX = 15.75;
$positionY = 10.16;
$widthImg = 3.75;
$heightImg = 3.33;
}
}
//Recarder l'image :
// $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
// $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
$path = str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,", '', $path);
//var_dump($api);
$pathArray = explode("/", $path);
$idsArray = explode(".", $pathArray[sizeof($pathArray) - 1]);
$idImage = "";
foreach ($idsArray as $key2 => $elem) {
if ($key2 != (sizeof($idsArray) - 1)) {
$idImage = $idImage . $elem;
}
}
$idImage = 'newprod/' . $idImage;
var_dump($idImage);
Unirest\Request::auth('263346742199243', 'jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
$headers = array('Accept' => 'application/json');
$data = array("public_ids" => array($idImage));
$body = Unirest\Request\Body::form($data);
Unirest\Request::verifyPeer(false);
$url = 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' . $idImage;
// $resultMetadata= \Cloudinary::Api.resources_by_ids([$idImage]);
var_dump($url);
$resultMetadata = Unirest\Request::post($url, $headers, $body);
var_dump($resultMetadata->raw_body);
if (isset(json_decode($resultMetadata->raw_body)->width)) {
$cloudinaryWidht = json_decode($resultMetadata->raw_body)->width;
$cloudinaryHeight = json_decode($resultMetadata->raw_body)->height;
} else {
$cloudinaryWidht = $widthOriginal;
$cloudinaryHeight = $heightOriginal;
}
$ratiohight = $cloudinaryWidht / $widthOriginal;
$ratioHight = $cloudinaryHeight / $heightOriginal;
$path = str_replace('upload/', 'upload/w_' . round($cloudinaryWidht) . ',h_' . round($cloudinaryHeight) . '/x_' . round(abs($leftOriginal * $ratioHight) / $zoom) . ',y_' . round(abs($topOriginal * $ratiohight) / $zoom) . ',w_' . round(($widthCropPX * $ratioHight) / $zoom) . ',h_' . round(($heightCropPX * $ratiohight) / $zoom) . ',c_crop/', $path);
//var_dump($path);i
var_dump("//00");
var_dump("avant 1.4 widh: " . round($widthCropPX) . " " . "avant 1.4 height : " . round($heightCropPX));
var_dump("avant 1.4 top: " . round(abs($top * 37.7952755906)) . " avant 1.4 final left : " . round(abs($left * 37.7952755906)));
var_dump("//00");
var_dump("final widh: " . round($widthCropPX * 1.4) . " " . "final height : " . round($heightCropPX * 1.4));
var_dump("final top: " . round(abs($top * 37.7952755906 * 1.4)) . " " . "final left : " . round(abs($left * 37.7952755906 * 1.4)));
var_dump("//00");
var_dump($path);
// $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
$pdf->Image($path, $positionX, $positionY, $widthImg, $heightImg, 'JPG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
// $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
//
$pdf->SetY(-6);
// Set font
$pdf->SetFont('helvetica', 'I', 8);
// Page number
$pdf->Cell(0, 10, 'Page ' . $pdf->getAliasNumPage() . '/' . $pdf->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
$pdf->SetFont('helvetica', 'B', 8);
$pdf->SetXY(1, 1);
}
// $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3, 2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
for ($i = 0; $i < sizeof($tabtxt); $i++) {
$txt = json_decode($tabtxt[$i]);
$pdf->SetFont('helvetica', 'B', $txt->fontSize);
$leftTxt = $txt->left;
$topTxt = $txt->top;
// $heightClips = floatval(str_replace('cm', '', $heightClips));
$topTxt = floatval(str_replace('cm', '', $topTxt));
$leftTxt = floatval(str_replace('cm', '', $leftTxt));
// $widthClips = floatval(str_replace('cm', '', $widthClips));
$pdf->SetXY($leftTxt - 1.2, $topTxt - 1);
$pdf->Write(0, $txt->contenu, '', 0, 'L', true, 0, false, false, 0);
}
//Positionner text
// $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
//Positionner clipart
// dd($tabClips);
// for($i=0;$i <sizeof($tabClips);$i++) {
// $Clips = json_decode($tabClips[$i]);
// $heightClips = $Clips->height;
// $topClips = $Clips->top;
// $leftClips = $Clips->left;
// $widthClips = $Clips->width;
// $path = $Clips->path;
// $pathClips = str_replace('http://127.0.0.1:8000/', 'https://demo.appsfactor.fr/', $path);
//
// $heightClips = floatval(str_replace('cm', '', $heightClips));
// $topClips = floatval(str_replace('cm', '', $topClips));
// $leftClips = floatval(str_replace('cm', '', $leftClips));
// $widthClips = floatval(str_replace('cm', '', $widthClips));
//
//// $positionXclips = $positionX + $leftClips;
//// $positionYclips = $positionY + $topClips;
//
// $pdf->ImageSVG("images/ClipArt_SVG/Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
//
//// $pdf->Image($path,$leftClips, $topClips, $widthClips, $heightClips, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
//
// }
}
echo '</pre>';
return new response("yezi");
// return $pdf->Output('example_009.pdf', 'I');
}
/**
* @Route("/Parent/suprimerproduitAcompa", name="suprimerproduitAcompa_parent")
*/
public function suprimerproduitAcompa(Request $request)
{
$em = $this->em;
$user = $this->getUser();
$p = $request->get("p");
$Album = $em->getRepository(Produit::class)->find($p);
$Album->setDelated(1);
$em->getManager()->persist($Album);
$em->getManager()->flush();
return new Response('yoopi');
}
/**
* @Route("/Parent/saveDiaporamaParent", name="saveDiaporamaParent")
*/
public function saveDiaporamaParent()
{
$session = $this->session;
$idSejour = $session->get("Sejour");
/** @var \App\Entity\User $userId */
$userId = $this->getUser();
$sejourobj = $this->em->getRepository(Sejour::class)->find($idSejour);
$prodct = $this->em->getRepository(Typeproduit::class)->find(19);
$produit = $this->em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $userId->getId()]);
if ($produit !== null && $produit !== "") {
$produit->setLabele("Diaporama");
$produit->setIduser($userId);
$produit->setIdsjour($sejourobj);
$produit->setType($prodct);
} else {
$produit = new Produit;
$produit->setLabele("Diaporama");
$produit->setIduser($userId);
$produit->setIdsjour($sejourobj);
$produit->setType($prodct);
$produit->setDate(new \DateTime());
}
$this->em->getManager()->persist($produit);
$this->em->getManager()->flush();
return new Response('disporama saved');
}
/**
* @Route("/Parent/appActiveAcompt/{id}", name="appActiveAcompt")
*/
public function ActiveAcounnt($id)
{
$user = $this->em->getRepository(User::class)->find($id);
$user->setActivatemail(1);
$this->em->getManager()->persist($user);
$this->em->getManager()->flush();
$encript = hash("sha256", $user->getUsername() . $user->getId());
$url_newPass = $this->get('router')->generate('sauthentifierAuto', array("token" => str_replace(".", "", $user->getEmail()), 'idUser' => $user->getId(), 'userHash' => $encript), UrlGeneratorInterface::ABSOLUTE_URL);
return $this->redirect($url_newPass);
// return $this->redirectToRoute('sauthentifierAuto', array("token" => str_replace(".", "", $user->getEmail()),'idUser'=>$user->getId(), 'userHash' => $encript), UrlGeneratorInterface::ABSOLUTE_URL);
}
/**
* @Route("/Parent/Album_du_Sejour", name="Album_du_Sejour")
*/
function ActiverSessionAlbum()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$AllPages = null;
$random = false;
$idAcc = $sejour->getIdAcommp();
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'Album_sejour']);
if ($Albumproduct == null) {
$Albumproduct = $this->em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
if ($Albumproduct != null and $Albumproduct != "") {
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
}
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$session->set('produit', $Albumproduct->gettype());
return $this->render('Parent/AlbumSejour.html.twig', ["nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'cliparts' => null, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => null, 'AllPagesAcc' => null, 'random' => $random, 'nbLikes' => $nbLikes]);
}
/**
* @Route("/Parent/Editer_Album_du_Sejour", name="Editer_Album_du_Sejour")
*/
function EditerSessionAlbum()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
$AllPages = null;
$random = false;
$idAcc = $sejour->getIdAcommp();
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'Album_sejour']);
if ($Albumproduct == null) {
$Albumproduct = $this->em->getRepository(Produit::class)->findOneBy(['iduser' => 1, 'statut' => "Album_sejour", 'idsjour' => $sejour]);
}
if ($Albumproduct != null and $Albumproduct != "") {
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
}
$allpagesResult = array();
$tabacc = array();
$tabacc1 = array();
foreach ($AllPages as $page) {
$pageJ = json_decode($page->getCouleurbordure());
$pageDec = json_decode($pageJ[0]);
$attache = json_decode($pageDec->attache);
if (isset($attache[0])) {
$attachDec = json_decode($attache[0]);
}
//var_dump($attachDec);
//var_dump(json_decode($attachDec->id));
if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
$idAttach = json_decode($attachDec->id);
array_push($tabacc, $idAttach);
}
}
$tabacc1 = array_count_values($tabacc);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$session->set('produit', $Albumproduct->gettype());
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbPhoto = count($listeattach);
return $this->render('Parent/NewAlbumLikes.html.twig', ["listeattach" => $listeattach, "tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => null, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => null, 'AllPagesAcc' => null, 'random' => $random, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbPhoto]);
}
/**
* @Route("/Parent/Editer_Livre_du_Sejour", name="Editer_Livre_du_Sejour")
*/
function EditerSessionLivre()
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$nbLikes = count($listeattachlikephoto);
$AllPages = null;
$random = false;
$idAcc = $sejour->getIdAcommp();
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
if ($Albumproduct == null) {
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin', 'idsjour' => $idSejour]);
}
if ($Albumproduct == null) {
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
}
if ($Albumproduct != null and $Albumproduct != "") {
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
}
$allpagesResult = array();
$tabacc = array();
$tabacc1 = array();
foreach ($AllPages as $page) {
$pageJ = json_decode($page->getCouleurbordure());
$pageDec = json_decode($pageJ[0]);
$attache = json_decode($pageDec->attache);
if (isset($attache[0])) {
$attachDec = json_decode($attache[0]);
}
//var_dump($attachDec);
//var_dump(json_decode($attachDec->id));
if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
$idAttach = json_decode($attachDec->id);
array_push($tabacc, $idAttach);
}
}
$tabacc1 = array_count_values($tabacc);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$session->set('produit', $Albumproduct->gettype());
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbPhoto = count($listeattach);
return $this->render('Parent/NewLivreLikes.html.twig', ["listeattach" => $listeattach, "tabacc" => $tabacc1, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => null, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => null, 'AllPagesAcc' => null, 'random' => $random, 'nbLikes' => $nbLikes, 'nbPhoto' => $nbPhoto]);
}
/**
* @Route("/Parent/DesactiverSessionAlbum", name="DesactiverSessionAlbum")
*/
function DesactiverSessionAlbum()
{
$session = $this->session;
$session->remove('sessionalbm');
return new Response('session removed');
}
/**
* @Route("/Parent/Mon_Compte_Activer", name="Mon_Compte_Activer")
*/
public function Mon_Compte_Activer(Request $request)
{
$em = $this->em;
return $this->render('Parent/activeMoncompte.html.twig');
}
/**
* @Route("/Parent/swuitchSejour/{id}", name="swuitchSejour")
*/
public function swuitchSejour($id)
{
$em = $this->em;
$sejourobj = $this->em->getRepository(Sejour::class)->find($id);
$this->session->set('Sejour', $sejourobj->getId());
return $this->redirectToRoute('AccueilParent');
}
/**
* @Route("/migrationCloudinary", name="migrationCloudinary")
*/
public function cloudinaryMigration()
{
$em = $this->em;
// $path="https://res.cloudinary.com/apss-factory/image/upload/a_exif/v1588979564/newprod/JUEGOS-EN-LA-PLAYA5_dnvgj8.jpg";
$attachement = [
'Eclaire.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Eclaire_pr0ecu.svg',
'ARcenciel.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/ARcenciel_grkyap.svg',
'Drapeaux.svg' => 'https://res.cloudinary.com/apss-factory/image/uploadv/1589143377/newprod/clipart/Drapeaux_zqo8v3.svg',
'Annif.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/Annif_ihvyoo.svg',
'Basquettes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Basquettes_znjd41.svg',
'Foot.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143382/newprod/clipart/Foot_az6bct.svg',
'Hello.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hello_njqifl.svg',
'Love.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143386/newprod/clipart/Love_q39usk.svg',
'LICORNE.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143385/newprod/clipart/LICORNE_hpomru.svg',
'Noeud.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143388/newprod/clipart/Noeud_mw5a4j.svg',
'Etoilerose.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Etoilerose_ewrzff.svg',
'Ete4.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Ete4_pdxadk.svg',
'Ete6.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete6_a3xgpd.svg',
'Ete9.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete9_s4vllm.svg',
'Hiver1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver1_fekrjz.svg',
'Hiver2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver2_e9iygg.svg',
'Noel2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Noel2_eqvdzr.svg',
'Hiver.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hiver_et04e1.svg',
'Sapin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Sapin_qjkxz6.svg',
'Chaussetet.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Chaussetet_xfpt6t.svg',
'Cloches.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Cloches_x2v3eo.svg',
'Like.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Like_ynxb2u.svg',
'coeurlike.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/coeurlike_ferv9y.svg',
'Fetedesmeres.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.svg',
'Fetedesperes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.svg',
'OOPS.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_gj9p1c.svg',
'OOPS_1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_1_r9a7l6.svg',
'WoW.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143393/newprod/clipart/WoW_ljlqjm.svg',
'Nuage.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Nuage_fgomd0.svg',
'Pingouin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/Pingouin_ogxb6e.svg',
'Renard.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143378/newprod/clipart/Chouette_mc1ik2.svg',
'Chouette.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Renard_mlhrxt.svg'
];
foreach ($attachement as $at) {
$exif = false;
$path = $at;
$pathArray = explode("/", $path);
$idsArray = explode(".", $pathArray[sizeof($pathArray) - 1]);
$idImage = "";
foreach ($idsArray as $key2 => $elem) {
if ($key2 != (sizeof($idsArray) - 1)) {
$idImage = $idImage . $elem;
}
}
$idImage = 'clipart/' . $idImage;
\Cloudinary::config(array(
"cloud_name" => "af5sur5sejour",
"api_key" => "263346742199243",
"api_secret" => "jYw-jg0FOJGv89-o5Wo0Fa3rQWU",
"secure" => true
));
Unirest\Request::auth('263346742199243', 'jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
Unirest\Request::verifyPeer(false);
$url = 'https://api.cloudinary.com/v1_1/af5sur5sejour/image/upload';
$headers = array('Accept' => 'application/json');
$data = array("file" => $path, "public_id" => $idImage, "upload_preset" => 'ml_default');
$body = Unirest\Request\Body::form($data);
$resultMetadata = Unirest\Request::post($url, $headers, $body);
var_dump($resultMetadata);
if (isset(json_decode($resultMetadata->raw_body)->secure_url)) {
var_dump(json_decode($resultMetadata->raw_body)->secure_url);
}
}
$em->getManager()->flush();
return new response("done");
}
/**
* @Route("/Parent/virgoPAss", name="virgopass")
*/
public function virgopass()
{
return $this->render('Parent/virgo.html.twig');
}
/**
* @Route("/Parent/interfaceUpdatePassorwdParent", name="interfaceUpdatePassorwdParent")
*/
public function interfaceUpdatePassorwdParent(Request $request)
{
$user = $this->getUser();
return $this->render('Parent/interfaceUpdatePassorwdParent.html.twig', ["userToSetPassword" => $user]);
}
/**
* @Route("/Parent/updatePassorwdParent", name="updatePassorwd_parent")
*/
public function updatePassorwdParent(Request $request)
{
$em = $this->em;
$serviceuser = $this->userService;
$id = $request->get("userID");
$password = $request->get("password");
$result = $serviceuser->ModifierPwdParent($id, $password);
return new Response('pwd modifié');
}
/**
* @Route("/Parent/sauthentifierAuto/{token}/{idUser}/{userHash}",name="sauthentifierAuto")
*/
function sauthentifierAuto($token, $idUser, $userHash)
{
$parent = $this->em->getRepository(User::class)->find($idUser);
if ((hash("sha256", $parent->getUsername() . $parent->getId()) == $userHash)) {
$providerKey = 'main_Parent'; // your firewall name
$token = new UsernamePasswordToken($parent, null, $providerKey, $parent->getRoles());
$this->container->get('security.token_storage')->setToken($token);
return $this->redirectToRoute("CodeSejour");
} else {
return $this->redirectToRoute("app_back_Parent");
}
}
/**
* @Route("/loginAutotoAlbumAcco/{token}/{idUser}/{userHash}/{albumAcco}",name="loginAutotoAlbumAcco")
*/
function loginAutotoAlbumAcco($token, $idUser, $userHash, $albumAcco)
{
$parent = $this->em->getRepository(User::class)->find($idUser);
if ((hash("sha256", $parent->getUsername() . $parent->getId()) == $userHash)) {
// return $this->render('security/DemandePasswordParentv.html.twig', ["userToSetPassword" => $use
//dd('im herge');
$providerKey = 'main_Parent'; // your firewall name
$token = new UsernamePasswordToken($parent, null, $providerKey, $parent->getRoles());
//dd($token);
$this->container->get('security.token_storage')->setToken($token);
$session = $this->session;
$produit = $this->em->getRepository(Produit::class)->find($albumAcco);
// dd($produit->getIdsjour()->getId());
$session->set("Sejour", $produit->getIdsjour()->getId());
return $this->redirectToRoute("ActiverSessionAlbum");
} else {
return $this->redirectToRoute("app_back_Parent");
}
}
/**
* @Route("/Parent/respondNotifSms",name="respondNotifSms")
*/
function respondNotifSms(Request $request)
{
$resp = $request->get("resp");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$user->setSmsnotif($resp);
$this->em->getManager()->persist($user);
$parentsejour = $this->em->getRepository(ParentSejour::class)->findBy(['idParent' => $user]);
foreach ($parentsejour as $sejr) {
$sejr->setSmsnotif($resp);
if (strpos($sejr->getIdSejour()->getCodeSejour(), "EF") !== false) {
$sejr->setSmsnotif(0);
}
$this->em->getManager()->persist($sejr);
}
$this->em->getManager()->flush();
return new Response('smsnotifmodifié');
}
/**
* @Route("/Parent/CheckRandomNotice",name="CheckRandomNotice")
*/
function CheckRandomNotice(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setRandomnotice($val);
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/CheckalbumNotif",name="CheckalbumNotif")
*/
function CheckalbumNotif(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setShowdetailsalbum($val);
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/ChecklivreNotif",name="ChecklivreNotif")
*/
function ChecklivreNotif(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setShowdetailslivre($val);
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/CheckphotosNotif",name="CheckphotosNotif")
*/
function CheckphotosNotif(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setShowdetailsphotos($val);
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/CheckcalNotif",name="CheckcalNotif")
*/
function CheckcalNotif(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setShowdetailscal($val);
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/CheckretrosNotif",name="CheckretrosNotif")
*/
function CheckretrosNotif(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setShowdetailsretros($val);
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/hidePubProd",name="hidePubProd")
*/
function hidePubProd(Request $request)
{
$val = $request->get("val");
/** @var \App\Entity\User $user */
$user = $this->getUser();
$parent = $this->em->getRepository(User::class)->find($user->getId());
$parent->setShowpubprod('false');
$this->em->getManager()->persist($parent);
$this->em->getManager()->flush();
return new Response('ok');
}
/**
* @Route("/Parent/PackPhotosNumerique_Modifier/{nbr}/{id}", name="PackPhotosNumerique_Modifier")
*/
public function PackPhotosNumerique_Modifier($nbr, $id)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
$listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
$listeattach = $SEjourService->getatachmentsejour($idSejour);
$nbLikes = count($listeattachlikephoto);
//Stella
$AllPagesAcc = null;
$random = false;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
$nbPhoto = count($listeattach);
// die();
if ($nbLikes == 0) {
return $this->render('Parent/PackPhotosNumerique.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattach, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random]);
}
if ($nbLikes != 0) {
return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattachlikephoto, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random]);
}
}
/**
* @Route("Parent/PackPhotosNumerique_Favoris/{nbr}", name="PackPhotosNumerique_Favoris")
*/
public function PackPhotosNumerique_Favoris($nbr)
{
$SEjourService = $this->sejourService;
$user = $this->getUser();
$userId = $this->getUser()->getId();
$session = $this->get('session');
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->getDoctrine()->getManager();
$listeattachlikephoto = $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId, 'idSejour' => $idSejour]);
foreach ($listeattachlikephoto as $photo) {
$idattach = $photo->getIdSejourAttchment();
$SejattachPhoto = $photo->getIdSejourAttchment();
$urlPhoto = $SejattachPhoto->getIdAttchment()->getPath();
//$urlPhoto = $attachPhoto->getPath();
$new_url = str_replace('upload/', 'upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/', $urlPhoto);
$photosData[] = [
'id' => $photo->getId(),
'url' => $new_url,
'caption' => "",
];
}
$nbLikes = count($listeattachlikephoto);
// Convertir le tableau PHP en JSON
$photosDataJSON = json_encode($photosData);
return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
"nbr" => $nbr,
"sejour" => $sejour,
"nbLikes" => $nbLikes,
'photosFav' => $photosDataJSON
]);
}
/**
* @Route("Parent/PackPhotosNumerique_Offert/{nbr}", name="PackPhotosNumerique_Offert")
*/
public function PackPhotosNumerique_Offert($nbr)
{
$SEjourService = $this->sejourService;
$user = $this->getUser();
$userId = $this->getUser()->getId();
$session = $this->get('session');
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$produitcondition = $session->get("produit");
$produit = $session->get("produittype");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->getDoctrine()->getManager();
$listeattachlikephoto = $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId, 'idSejour' => $idSejour]);
foreach ($listeattachlikephoto as $photo) {
$idattach = $photo->getIdSejourAttchment();
$SejattachPhoto = $photo->getIdSejourAttchment();
$urlPhoto = $SejattachPhoto->getIdAttchment()->getPath();
//$urlPhoto = $attachPhoto->getPath();
$new_url = str_replace('upload/', 'upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/', $urlPhoto);
$photosData[] = [
'id' => $photo->getId(),
'url' => $new_url,
'caption' => "",
];
}
$nbLikes = count($listeattachlikephoto);
// Convertir le tableau PHP en JSON
$photosDataJSON = json_encode($photosData);
return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
"nbr" => $nbr,
"sejour" => $sejour,
"nbLikes" => $nbLikes,
'photosFav' => $photosDataJSON
]);
}
/**
* @Route("Parent/AjoutPackPhotosNum/{nbr}", name="AjoutPackPhotosNum")
*/
public function AjoutPackPhotosNumParent($nbr)
{
$SEjourService = $this->sejourService;
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userId = $user->getId();
$user = $this->getUser();
$session = $this->session;
$session->set('pageMenu', '');
$idSejour = $session->get("Sejour");
$sejour = $SEjourService->getsejourpourparent($idSejour);
$em = $this->em;
$clipart = $em->getRepository(Clipart::class)->findAll();
// $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listeattach = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
$listerandom = $listeattach;
$AllPagesAcc = null;
$Albumproduct = $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPackPhotosNum' . $nbr]);
$random = true;
$AllPages = $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
$idAcc = $sejour->getIdAcommp();
$albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
$part = $sejour->getIdPartenaire();
$nompart = $part->getUsername();
$logopart = $part->getLogourl();
if ($albumAcc != null and $albumAcc != "") {
$AllPagesAcc = $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
}
$allpagesResult = array();
$j = 0;
if ($random == true) {
foreach ($AllPages as $p) {
$arrayexploded = preg_split('[randomid|randompath]', $p->getCouleurbordure());
$rr = "";
for ($i = 0; $i < sizeof($arrayexploded); $i = $i + 2) {
if ($i + 1 < sizeof($arrayexploded)) {
if (sizeof($listerandom) == 0) {
//$listerandom = $SEjourService->getatachmentsejour($idSejour);
$listerandom = $SEjourService->getCombinedattachSejour($idSejour, 'photo');
}
$arrayRsRandom = $this->random_functionNolikes($listerandom);
$rr = $rr . $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i + 1] . $arrayRsRandom['pathelem'];
unset($listerandom[$arrayRsRandom['elem']]);
} else {
$rr = $rr . $arrayexploded[$i];
}
$listerandom = $listerandom;
}
$resultFinal = $rr;
$p->setCouleurbordure($resultFinal);
array_push($allpagesResult, $p);
if ($j < sizeof($listeattach) - 1) {
$j = $j + 1;
} else {
$j = 0;
}
}
$AllPages = $allpagesResult;
}
return $this->render('Parent/PackPhotosNumerique.html.twig', ["nbr" => $nbr, "nompart" => $nompart, "logopart" => $logopart, "sejour" => $sejour, 'like' => $listeattach, 'cliparts' => $clipart, 'Album' => $Albumproduct, 'AllPages' => $AllPages, 'albumAcc' => $albumAcc, 'AllPagesAcc' => $AllPagesAcc, 'random' => $random, 'listeattach' => $listeattach]);
}
/**
* @Route("/Parent/SavePackPhotosNumerique", name="SavePackPhotosNumeriqueParent")
*/
public function SavePackPhotosNumeriqueParent(Request $request)
{
$session = $this->session;
$serviceuser = $this->etablissementService;
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
// $Album = $serviceuser->SavePhotosPochetteParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr,$nomprod);
$refPackNum = null;
if ($sejour) {
$refPackNum = $this->generateRefPackPhotosNum($sejour, $user);
}
$Album = $serviceuser->SavePackPhotosNumerique($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod, $refPackNum);
//sendmailparent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
//$this->EmailServie->MailRelancePanier($userEmail);
return new response('done');
}
/**
* @Route("/Parent/CommandeDirecteAddPackNumeriqueAuPanier", name="CommandeDirecteAddPackNumeriqueAuPanier")
*/
public function CommandeDirecteAddPackNumeriqueAuPanier(Request $request)
{
$em = $this->em->getManager();
$session = $this->session;
$this->logger->info('Début CommandeDirecteAddPackNumeriqueAuPanier');
$serviceuser = $this->etablissementService;
$photos = $request->get("photos");
$sejour = $request->get("sejour");
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$nomprod = "Pack Photos Numerique - " . $nbr;
// Créer le produit pack photos
$packPhotos = $serviceuser->SavePackPhotosNumerique($photos, $user, $sejour, $nbr, $nomprod);
$product = $em->getRepository(Produit::class)->find($packPhotos->getId());
// Récupérer ou créer le panier
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer", "typeref" => $typeref]);
$panierTrace = $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user, "statut" => $statutPanier]);
if ($panierTrace === null) {
$panierTrace = new Panier();
$panierTrace->setDateCreation(new \DateTime());
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->persist($panierTrace);
$em->flush();
}
$this->logger->info('Panier récupéré', ['panier_id' => $panierTrace ? $panierTrace->getId() : 'null']);
// Récupérer les produits du panier en session
$Products = $session->get("Panier", []);
$inser = false;
// Vérifier si le panier est vide (pas de produits en session)
if(count($Products) == 0) {
// Créer directement une commande et une commande numérique
$commande = new Commande();
$commande->setDateCreation(new \DateTime());
$commande->setCreerPar($user);
$commande->setStatut($statutPanier);
$commande->setTyperef($typeref);
$commande->setMontantTTC($product->getIdConditionnement()->getMontantTTC());
$commande->setIdsjour($sejour);
$commande->setIdpanier($panierTrace->getId());
$commande->setNumComande($this->generateUniqueOrderNumber());
$em->persist($commande);
$em->flush();
$commandeNumerique = new CommandeNumerique();
$commandeNumerique->setDateCreation(new \DateTime());
$commandeNumerique->setCreerPar($user);
$commandeNumerique->setIdCommande($commande);
$commandeNumerique->setStatut($statutPanier);
$commandeNumerique->setLinkdownload($product->getId());
$commandeNumerique->setEtat(0); // État en attente de paiement
$em->persist($commandeNumerique);
$em->flush();
// Ajouter le produit au panier en session pour le paiement
$p = [
"id" => $product->getId(),
"nom" => $product->getType()->getLabeletype(),
"ident" => $product->getLabele(),
"codesejour" => $product->getIdsjour()->getcodeSejour(),
"mnt" => $product->getIdConditionnement()->getMontantTTC(),
"path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
"condition" => $product->getIdConditionnement()->getId(),
"qte" => 1
];
array_push($Products, $p);
$session->set('Panier', $Products);
// Ajouter le produit au panier en base de données
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($product);
$panierProduit->setIdPanier($panierTrace);
$panierProduit->setQuantite(1);
$panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
$em->persist($panierProduit);
$em->flush();
// Rediriger vers la page de paiement
return $this->redirectToRoute('paiement_commande_directe', [
'id' => $commande->getId()
]);
} else {
// Il y a déjà des produits dans le panier
// Ajouter le produit au panier existant
// Vérifier si le produit existe déjà dans le panier en session
foreach ($Products as $key => $p) {
if ($p['id'] === $product->getId()) {
$inser = true;
$Products[$key]['qte'] += 1;
$Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
}
}
// Vérifier si le produit existe dans PanierProduit en base de données
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product, "idPanier" => $panierTrace]);
if ($panierProduit === null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($product);
$panierProduit->setIdPanier($panierTrace);
$panierProduit->setQuantite(1);
$panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
$em->persist($panierProduit);
$em->flush();
} else {
// Mettre à jour la quantité et le prix total
$panierProduit->setQuantite($panierProduit->getQuantite() + 1);
$panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
$em->persist($panierProduit);
$em->flush();
}
// Si le produit n'est pas déjà dans le panier en session, l'ajouter
if (!$inser) {
$p = [
"id" => $product->getId(),
"nom" => $product->getType()->getLabeletype(),
"ident" => $product->getLabele(),
"codesejour" => $product->getIdsjour()->getcodeSejour(),
"mnt" => $product->getIdConditionnement()->getMontantTTC(),
"path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
"condition" => $product->getIdConditionnement()->getId(),
"qte" => 1
];
array_push($Products, $p);
}
// Mettre à jour le panier en session
$session->set('Panier', $Products);
// Ajouter un message flash pour informer l'utilisateur
$this->addFlash('success', 'Le pack photos a été ajouté à votre panier.');
// Rediriger vers le panier
$this->logger->info('Redirection vers le panier');
return new Response('done');
}
}
/**
* Génère un numéro de commande unique
*/
private function generateUniqueOrderNumber()
{
// Générer un numéro de commande basé sur la date et un nombre aléatoire
return date('YmdHis') . rand(1000, 9999);
}
/**
* @Route("/Parent/confirmation-pack-photos/{id}", name="confirmation_pack_photos")
*/
public function confirmationPackPhotos($id): Response
{
$commandeNumerique = $this->em->getRepository(CommandeNumerique::class)->find($id);
if (!$commandeNumerique) {
throw $this->createNotFoundException('Commande numérique introuvable');
}
$commande = $commandeNumerique->getIdCommande();
$user = $commande->getCreerPar();
$sejour = $commande->getIdsjour();
return $this->render('Parent/confirmation_pack_photos.html.twig', [
'commandeNumerique' => $commandeNumerique,
'commande' => $commande,
'user' => $user,
'sejour' => $sejour,
'downloadUrl' => $this->generateUrl('telechargerPack', ['idCommande' => $commandeNumerique->getId()])
]);
}
/**
* @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panier", name="SavePackPhotosNumeriqueComandeSave_panier")
*/
public function AddPackNumeriqueAuPanier(Request $request)
{
$em = $this->em->getManager();
$session = $this->session;
$serviceuser = $this->etablissementService;
$photos = $request->get("photos");
$sejour = $request->get("sejour");
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$nomprod = "Pack Photos Numerique - " . $nbr;
//test de la fonction envoieMailPackNumerique
$packPhotos = $serviceuser->SavePackPhotosNumerique($photos, $user, $sejour, $nbr, $nomprod);
$product = $em->getRepository(Produit::class)->find($packPhotos->getId());
// --- Test pour envoyer le mail pak numerique ---//
// $this->emailsCmdService->envoieMailPackNumerique($packPhotos->getId());
// $this->printerService->PackPhotosNumerique($packPhotos->getId(),20);
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer", "typeref" => $typeref]);
$panierTrace = $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user, "statut" => $statutPanier]);
if ($panierTrace === null) {
$panierTrace = new Panier();
$panierTrace->setDateCreation(new \DateTime());
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->persist($panierTrace);
$em->flush();
}
// Add product to cart session
$Products = $session->get("Panier", []);
$inser = false;
foreach ($Products as $key => $p) {
if ($p['id'] === $product->getId()) {
$inser = true;
$Products[$key]['qte'] += 1;
$Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
}
}
// Check if product exists in PanierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product, "idPanier" => $panierTrace]);
if ($panierProduit === null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($product);
$panierProduit->setIdPanier($panierTrace);
$panierProduit->setQuantite(1);
$panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
$em->persist($panierProduit);
$em->flush();
} else {
// Update existing product quantity and total price
$panierProduit->setQuantite($panierProduit->getQuantite() + 1);
$panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
$em->persist($panierProduit);
$em->flush();
}
if (!$inser) {
$p = [
"id" => $product->getId(),
"nom" => $product->getType()->getLabeletype(),
"ident" => $product->getLabele(),
"codesejour" => $product->getIdsjour()->getcodeSejour(),
"mnt" => $product->getIdConditionnement()->getMontantTTC(),
"path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
"condition" => $product->getIdConditionnement()->getId(),
"qte" => 1
];
array_push($Products, $p);
}
$session->set('Panier', $Products);
// Send reminder email
/** @var \App\Entity\User $user */
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
return new Response('done');
}
/* public function SavePackPhotosNumeriqueComandeSave_panier(PrinterService $PrinterService, Request $request)
{
$em = $this->em;
var_dump("Debut Creation du pack numerique ");
$session = $this->session;
$serviceuser = $this->etablissementService;
$attachements = $request->get('attachements');
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
var_dump($prodid);
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
if ($sejour !== null) {
$refPackNum = $this->generateRefPackPhotosNum($sejour, $user);
$Album = $serviceuser->SavePackPhotosNumerique($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod, $refPackNum);
$produit = $em->getRepository(Produit::class)->find($Album->getId());
$serviceuser->commandepackphotoNum($attachements, $sejour, $user, $Album);
// $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
$inser = false;
$Products = $session->get("Panier");
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
if ($Products != null) {
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_parent
$dateNow = new \Datetime();
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
}
return new response('done');
}
*/
/**
* @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panierfree", name="SavePackPhotosNumeriqueComandeSave_panierfree")
*/
public function SavePackPhotosNumeriqueComandeSave_panierfree(PrinterService $PrinterService, Request $request)
{
$em = $this->em;
var_dump("Debut Creation du pack numerique ");
$session = $this->session;
$serviceuser = $this->etablissementService;
$attachements = $request->get('attachements');
$page = $request->get("pages");
$sejour = $request->get("sejour");
$prodid = $request->get('idProd');
var_dump($prodid);
$nomprod = $request->get('nomprod');
$nbr = $request->get('nbr');
$user = $this->getUser();
$nbr = strval($nbr);
$produittype = $session->get("produit");
$produit = $session->get("produittype");
if ($sejour !== null) {
$refPackNum = $this->generateRefPackPhotosNum($sejour, $user);
$Album = $serviceuser->SavePackPhotosNumeriquefree($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod, $refPackNum);
$produit = $em->getRepository(Produit::class)->find($Album->getId());
$serviceuser->commandepackphotoNum($attachements, $sejour, $user, $Album);
// $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
$inser = false;
$Products = $session->get("Panier");
//Touhemi 03-07-2020 :Rechercher si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
$user = $this->getUser();
$typeref = $em->getRepository(Typeref::class)->find(8);
$statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
$panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
//fin
if ($panierTrace == null) {
$panierTrace = new Panier();
$dateNow = new \Datetime();
$panierTrace->setDateCreation($dateNow);
$panierTrace->setCreerPar($user);
$panierTrace->setStatut($statutPanier);
$em->getManager()->persist($panierTrace);
$em->getManager()->flush();
}
//Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on écrit un produit
if ($Products == null) {
$Products = [];
}
if ($Products != null) {
foreach ($Products as $key => $p) {
if ($p['id'] == $produit->getId()) {
$inser = true;
$Products[$key]['qte'] = $p['qte'] + 1;
$Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
}
}
}
//Touhemi 03-07-2020 :Rechercher si le produti existe déja ds panierProduit
$panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
if ($panierProduit == null) {
$panierProduit = new PanierProduit();
$panierProduit->setIdProduit($produit);
$panierProduit->setIdPanier($panierTrace);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
}
//fin
// Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
$oldQte = $panierProduit->getQuantite();
$newQte = $oldQte + 1;
$panierProduit->setQuantite($newQte);
$oldTotal = $panierProduit->getPrixTotal();
$newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
$panierProduit->setPrixTotal($newTotal);
$em->getManager()->persist($panierProduit);
$em->getManager()->flush();
//fin
if ($inser === false) {
$p = [];
$p["id"] = $produit->getId();
$p["nom"] = $produit->getType()->getLabeletype();
$p["ident"] = $produit->getLabele();
$p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
$p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
$p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
$p["condition"] = $produit->getIdConditionnement()->getId();
$p["qte"] = 1;
array_push($Products, $p);
}
$session->set('Panier', $Products);
//sendmail_parent
$dateNow = new \Datetime();
/** @var \App\Entity\User $user */
$user = $this->getUser();
$userEmail = $user->getEmail();
$this->EmailServie->SaveMailRelancePanier($userEmail);
// $this->EmailServie->MailRelancePanier($userEmail);
}
return new response('done');
}
function generateRefPackPhotosNum($idsejour, $user)
{
//photonum_code_sejour_idparent_random;
$em = $this->em;
$date = new \Datetime();
$Milliseconde = $date->format('dmYhis');
$sejour = $this->em->getRepository(Sejour::class)->find($idsejour);
$ref = "photonum_" . $sejour->getCodeSejour() . "_" . $user->getId() . "_" . $Milliseconde;
return $ref;
}
/**
* @Route("/downloadpackphotonum/{refcmdnum}", name="downloadpackphotonum",methods={"GET"})
*/
public function downloadpackphotonumAction($refcmdnum)
{
$tab = explode("_", $refcmdnum);
if (sizeof($tab) == 4) {
$codesejour = $tab[1];
$iduser = $tab[2];
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(array('codeSejour' => $codesejour));
$user = $this->em->getRepository(User::class)->find(intval($iduser));
if ($user && $sejour) {
$commandenumerique = $this->em->getRepository(CommandeNumerique::class)->findOneBy(array('linkdownload' => $refcmdnum));
if ($commandenumerique) {
if ($commandenumerique->getEtat() === 1) {
$commandenumerique->setEtat(2);
$commandenumerique->setDateTelechargement(new \DateTime());
$this->em->getManager()->persist($commandenumerique);
$this->em->getManager()->flush();
$response = new BinaryFileResponse($this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' . $refcmdnum . '/' . $refcmdnum . '.zip');
$response->headers->set('Content-Type', "application/zip");
// Set content disposition inline of the file
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
$refcmdnum . '.zip'
);
return $response;
} elseif ($commandenumerique->getEtat() == 2) {
return new JsonResponse(array('message' => 'commande déjà livrée'), 400);
} else {
return new JsonResponse(array('message' => 'commande invalide'), 400);
}
} else {
return new JsonResponse(array('message' => 'commande introuvable'), 400);
}
}
} else {
return new JsonResponse(array('message' => 'lien invalide'), 400);
}
}
/**
* @Route("/Parent/showpub" , name="showpub")
*/
public function showpub()
{
/** @var User $user */
$user = $this->getUser();
if (!$user) {
return new JsonResponse(['status' => 'error', 'message' => 'User not found'], 400);
}
// Set showpubprod to true
$user->setShowpubprod(1);
// Save the changes to the database
$this->em->getManager()->persist($user);
$this->em->getManager()->flush();
// Return a success response
return new JsonResponse(['status' => 'success']);
}
/**
* @Route("/Parent/Mentionslegales", name="mentionlegale")
*/
public function Mentionslegales()
{
return $this->render('Parent/footer/mentionlegal.html.twig', []);
}
/**
* @Route("/Parent/Conditongeneral", name="Conditongeneral")
*/
public function Conditongeneral()
{
return $this->render('Parent/footer/Condition.html.twig', []);
}
}