<?php
namespace App\Service;
/**
* Created by PhpStorm.
* desc: Service Sejout ;
*
*/
use App\Entity\Emailing;
use App\Entity\SejourAttachment;
use App\Service\EmailsCmdService;
use Swift_Image;
use Twig\Environment;
use App\Entity\Sejour;
use App\Entity\Produit;
use App\Entity\Attachment;
use App\Entity\Commande;
use App\Entity\PromoParents;
use App\Entity\PromoSejour;
use App\Entity\ComandeProduit;
use App\Entity\ParentSejour;
use App\Entity\Ref;
use App\Entity\Position;
use App\Entity\Likephoto;
use App\Entity\User;
use App\Entity\Etablisment;
use App\Entity\Jourdescripdate;
use App\Entity\LogPromotions;
use App\Entity\PanierProduit;
use App\Entity\Promotions;
use Swift_Attachment;
use setasign\Fpdi\Fpdi;
use setasign\Fpdi\PdfReader;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use \DatePeriod;
use \DateInterval;
use DateTime;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use App\Repository\AttachmentRepository;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class SejourService
{
private $em;
private $mailer;
private $templating;
private $projectDir;
private $params;
private $client;
private $emailsCmdService;
private $sejourAttachmentRepository;
private $mailerInterface;
public function __construct(ManagerRegistry $em, \Swift_Mailer $mailer, Environment $templating, KernelInterface $kernel, ParameterBagInterface $params, HttpClientInterface $client, AttachmentRepository $sejourAttachmentRepository, EmailsCmdService $emailsCmdService, \Swift_Mailer $mailerInterface)
{
$this->em = $em;
$this->mailer = $mailer;
$this->templating = $templating;
$this->projectDir = $kernel->getProjectDir();
$this->params = $params;
$this->client = $client;
$this->sejourAttachmentRepository = $sejourAttachmentRepository;
$this->emailsCmdService = $emailsCmdService;
$this->mailerInterface = $mailerInterface;
}
function CreationNouveauSejour($themSejour, $adressSejour, $codePostal, $dateDebut, $FinSejour, $AgeDugroupe, $type, $userid, $NbEnfant, $connpay, $pays, $ville, $prixcnxparent = null, $prixcnxpartenaire = null, $reversecnxpart = null, $reverseventepart = null)
{
$sejour = new Sejour();
$sejour->setCodeSejour($this->GenrateCodeSejour($type, $connpay));
$sejour->setDateCreationCode(new \DateTime());
$sejour->setThemSejour($themSejour);
$sejour->setAdresseSejour($adressSejour);
if ($codePostal == "") {
$codePostal = 0;
}
$sejour->setCodePostal($codePostal);
$dateDebutFormat = date_create_from_format('Y-m-d', $dateDebut);
$sejour->setDateDebutSejour($dateDebutFormat);
$FinSejourSejour = date_create_from_format('Y-m-d', $FinSejour);
$sejour->setDateFinSejour($FinSejourSejour);
$FinSejourSejour->modify('+2 month');
$sejour->setDateFinCode($FinSejourSejour);
$Statut = $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => "Crée"));
$sejour->setStatut($Statut);
$AgeDugroupeRef = $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => $AgeDugroupe));
$sejour->setAgeGroup($AgeDugroupeRef);
$sejour->setNbenfan($NbEnfant);
$sejour->setNbenfantencours($NbEnfant);
$sejour->setPays($pays);
$sejour->setVille($ville);
$sejour->setPrixcnxparent($prixcnxparent);
$sejour->setPrixcnxpartenaire($prixcnxpartenaire);
$sejour->setReversecnxpart($reversecnxpart);
$sejour->setReverseventepart($reverseventepart);
//setif sejour gratuie ou non
$sejour->setPaym($connpay);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
return $sejour;
}
function CreationNouveauSejourParAccompagnateur($themSejour, $adressSejour, $dateDebut, $FinSejour, $AgeDugroupe, $type, $NbEnfant, $connpay, $pays, $ville, $prixcnxparent, $prixcnxpartenaire, $reversecnxpart, $reverseventepart)
{
$sejour = new Sejour();
$sejour->setCodeSejour($this->GenrateCodeSejour($type, $connpay));
$sejour->setDateCreationCode(new \DateTime());
$sejour->setThemSejour($themSejour);
$sejour->setAdresseSejour($adressSejour);
$dateDebutFormat = date_create_from_format('Y-m-d', $dateDebut);
$sejour->setDateDebutSejour($dateDebutFormat);
$FinSejourSejour = date_create_from_format('Y-m-d', $FinSejour);
$dateFinCode = new \DateTime($FinSejour);
$dateFinCode->modify('+2 month');
$sejour->setDateFinCode($dateFinCode);
$sejour->setDateFinSejour($FinSejourSejour);
$Statut = $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => "Crée"));
$sejour->setStatut($Statut);
$AgeDugroupeRef = $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => $AgeDugroupe));
$sejour->setAgeGroup($AgeDugroupeRef);
$sejour->setNbenfan($NbEnfant);
$sejour->setNbenfantencours($NbEnfant);
$sejour->setPays($pays);
$sejour->setVille($ville);
$sejour->setPrixcnxparent($prixcnxparent);
$sejour->setPrixcnxpartenaire($prixcnxpartenaire);
$sejour->setReversecnxpart($reversecnxpart);
$sejour->setReverseventepart($reverseventepart);
//set if sejour gratuie ou non
$sejour->setPaym($connpay);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
return $sejour;
}
function EnvoyerEmailCodeSejour($idSejour, $TypeSejour)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(28);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sendTo = $Sejour->getIdEtablisment()->getEmail();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->setBody(
$this->templating->render(
'emails/SendCode.html.twig',
[
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"destinataire" => $Sejour->getIdEtablisment()->getNometab()
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$done = $this->mailer->send($message);
//var_dump($done);
// var_dump("send it ");
} catch (\Swift_SwiftException $ex) {
//var_dump( $ex->getMessage());
}
}
function EnvoyerEmailCodeSejourAccompagnateur($idSejour)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($Sejour) {
//dd($sejour);
$pdf1 = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf1->setSourceFile($pdfFilepath1);
$pageId = $pdf1->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf1->addPage();
$pdf1->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$MotPass = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$MotPass = $Sejour->getIdAcommp()->getPasswordNonCripted();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage($i + 1);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 268, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 268, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 268, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 268, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(80, 279, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(48, 258, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(89, 258, $DateFin->format('d/m/Y'));
}
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent G 5sur5séjour " . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
}
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$sendTo = $Sejour->getIdAcommp()->getReponseemail();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
}
$message->setBody(
$this->templating->render(
'emails/SendCode.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
"identifiant" => $Sejour->getCodeSejour(),
'roles' => $Sejour->getIdAcommp()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
}
function EnvoyerEmailNewAcco($emailsend, $accompagnateur, $idSejour, $passAcommpa)
{
$RefEmail = $this->em->getRepository(Ref::class)->find(16);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$sendTo = $accompagnateur->getEmail();
$message = (new \Swift_Message('Bienvenue à 5sur5 séjour '))
->setFrom('contact@5sur5sejour.com')
->setTo($emailsend);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->setBody(
$this->templating->render(
'emails/DemandeCreationAcc.html.twig',
[
"Nomdestinataire" => $accompagnateur->getNom(),
"Predestinataire" => $accompagnateur->getPrenom(),
"code" => $Sejour->getCodeSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"identifiant" => $sendTo,
"roles" => $accompagnateur->getRoles(),
'accompagnateur' => $accompagnateur,
"passAcommpa" => $passAcommpa,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function EnvoyerEmailNewPartenaire($partenaire)
{
$logo = '';
$nom = '';
if ($partenaire->hasRole('ROLE_PARTENAIRE')) {
$logo = $partenaire->getLogourl();
$nom = $partenaire->getNometablisment();
}
$RefEmail = $this->em->getRepository(Ref::class)->find(17);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail));
$sendTo = $partenaire->getEmail();
$message = (new \Swift_Message('Nouveau partenaire'))
->setFrom('partenariat-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"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$icon2 = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$icon3 = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$message->setBody(
$this->templating->render(
'emails/NewPartenaireEmail.html.twig',
[
"Nomdestinataire" => $partenaire->getNom(),
"Predestinataire" => $partenaire->getPrenom(),
"password" => $partenaire->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"icon2" => $icon2,
"icon3" => $icon3,
"iconfooter" => $iconfooter,
"iconmsg" => $iconmsg,
"idPartenaire" => $partenaire->getId(),
"identifiant" => $sendTo,
"password" => $partenaire->getPasswordNonCripted(),
'logo' => $logo,
'nom' => $nom,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function affecterEtablissement($sejour, $etablissement)
{
$sejour->setIdEtablisment($etablissement);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
}
function affecterAccompaniateur($sejour, $accomp)
{
$sejour->setIdAcommp($accomp);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
}
function affecterPartenaire($sejour, $etabUser)
{
$sejour->setIdPartenaire($etabUser);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
}
function affecteretablisment($sejour, $Etablisment)
{
$sejour->setIdEtablisment($Etablisment);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
}
function GenrateCodeSejour($type, $connpay)
{
$Typeabr = "IN";
$pay = "";
if ($type == "ECOLES/AUTRES") {
$Typeabr = "E";
} elseif ($type == "PARTENAIRES/VOYAGISTES") {
$Typeabr = "P";
} elseif ($type == "CSE") {
$Typeabr = "C";
}
if ($connpay == 0) {
$pay = "F";
}
if ($connpay == 1) {
$pay = "P";
}
$date = new \Datetime();
$Milliseconde = $date->format('u');
$code = $Typeabr . $pay . $Milliseconde;
return $code;
}
function index($dateTimeDebut, $dateTimeFin)
{
if ($dateTimeDebut == null) {
$Sejours = $this->em->getRepository(Sejour::class)->searshAllSejour();
// dd(count($Sejours));
} else {
$Sejours = $this->em->getRepository(Sejour::class)->searshDate($dateTimeDebut, $dateTimeFin);
}
return $Sejours;
}
function getsejour($id)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($id);
return $Sejour;
}
function getsejourByAcc($id, $user)
{
$Sejour = $this->em->getRepository(Sejour::class)->findOneBy(array("id" => $id, "idAcommp" => $user));
return $Sejour;
}
function getsejourByItab($idEtablisment)
{
$Sejour = $this->em->getRepository(Sejour::class)->findBy(array("idEtablisment" => $idEtablisment));
return $Sejour;
}
function getNbreconnxparsejour($id)
{
$Sejourfind = $this->em->getRepository(Sejour::class)->find($id);
if ((substr($Sejourfind->getCodeSejour(), 1, 1) == 'P')) {
$Sejour = $this->em->getRepository(ParentSejour::class)->findby(['idSejour' => $id, 'payment' => 1]);
} elseif ((substr($Sejourfind->getCodeSejour(), 1, 1) == 'F')) {
$Sejour = $this->em->getRepository(ParentSejour::class)->findby(['idSejour' => $id]);
}
$NB = sizeof($Sejour);
return $NB;
}
//a terminier le nombre enfant par sejour
function Nbpersonnecnnx($id)
{
$Nbpconnx = $this->em->getRepository(ComandeProduit::class)->searshNbpersoneparNbcnnx($id);
return $Nbpconnx;
}
function Nbpersonnesejour($id)
{
$Nbpersone = $this->em->getRepository(ParentSejour::class)->searshNbperpersonneSjour($id);
return $Nbpersone;
}
function nombreenfantparsejour($id)
{
$Nbenfant = $this->em->getRepository(sejour::class)->searshNbperson($id);
return $Nbenfant;
}
function Nbpecnnxsejourtype($type, $date = null)
{
if ($date == null) {
$Nbcnxnxpartype = $this->em->getRepository(ParentSejour::class)->searshNBcnnxParSejour($type);
} else {
$Nbcnxnxpartype = $this->em->getRepository(ParentSejour::class)->searshNBcnnxParSejourByDate($type, $date);
}
return $Nbcnxnxpartype;
}
function Nbcommandepartypesejour($type, $date = null)
{
if ($date == null) {
$Nbdemandpartype = $this->em->getRepository(ParentSejour::class)->searshNBcommandeParSejour($type);
} else {
$Nbdemandpartype = $this->em->getRepository(ParentSejour::class)->searshNBcommandeParSejourByDate($type, $date);
}
return $Nbdemandpartype;
}
function Moyenpainierpartypesejour($type, $dateTimeDebut, $dateTimeFin)
{
if ($dateTimeDebut == null || $dateTimeFin == null) {
$panier = $this->em->getRepository(Produit::class)->searshPanierMoyen($type);
} else {
$panier = $this->em->getRepository(Produit::class)->searshPanierMoyenByDate($type, $dateTimeDebut, $dateTimeFin);
}
return $panier;
}
public function typeproduitsevice($id)
{
$prod = $this->em->getRepository(Produit::class)->findby(array('idsjour' => $id));
return $prod;
}
public function getatachmentsejour($id): array
{
$liste = $this->em->getRepository(Attachment::class)->searshSejourAtachment($id);
return $liste;
}
/**
* Gets the list of attachements based on the sejour id and attachement type
* @param string $id The sejour id
* @param string $type The attachement type
* @return array The list of photos avec pagination
*/
public function getCombinedattachSejourPaginee(string $id, string $type = 'photo')
{
$liste = [];
$results = $this->em->getRepository(SejourAttachment::class)->getSejourAttachByPhotoPagination($id, $type);
return $results;
}
/**
* Gets the list of attachements based on the sejour id and attachement type
* @param string $id The sejour id
* @param string $type The attachement type
* @return array The list of attachements
*/
/**
* Gets the list of attachements based on the sejour id, attachement type, and user id.
*
* @param string $id The sejour id
* @param string $type The attachement type ('photo', 'photoVideo', 'message')
* @param int|null $userId The user id (optional, for checking favorites)
* @return array The list of attachements
*/
public function getCombinedattachSejour_REVISION(string $id, string $type = 'photo', ?int $userId = null): array
{
// Récupérer les attachements pour le type 'photoVideo'
if ($type === 'photoVideo') {
$groupedAttachments = [];
$results = $this->em->getRepository(SejourAttachment::class)->getSejourAttachById($id, $type);
$attachCount = count($results);
// Récupérer les favoris de l'utilisateur pour ces attachements
// Ajouter un champ 'isFavorite' à chaque photo
//$favorites = $this->em->getRepository(Likephoto::class)->searshlikephotousersejour($userId, $id);
foreach ($results as $result) {
$attachmentId = $result->getIdAttchment()->getId();
$date = $result->getDateDepotAttachement()->format('Y-m-d');
$preListe = [
'date_depot_attachement' => $result->getDateDepotAttachement(),
'path' => $result->getIdAttchment()->getPath(),
'id_attchment' => $attachmentId,
'idposition' => $result->getIdAttchment()->getIdposition(),
'libiller' => $result->getIdAttchment()->getIdref()->getLibiller(),
'descreption' => $result->getIdAttchment()->getDescreption(),
'is_favorite' => "",
];
// Grouper par date
if (!isset($groupedAttachments[$date])) {
$groupedAttachments[$date] = [];
}
$groupedAttachments[$date][] = $preListe;
}
// Définir toujours 'total'
$groupedAttachments['total'] = $attachCount;
// Trier par date décroissante
uksort($groupedAttachments, fn($a, $b) => strtotime($b) - strtotime($a));
return $groupedAttachments;
}
// Pour les types 'photo' et 'message'
$liste = [];
$results = $type === 'photo' ?
$this->em->getRepository(SejourAttachment::class)->getSejourAttachByPhoto($id, $type) :
$this->em->getRepository(SejourAttachment::class)->getSejourAttachByMessage($id, $type);
// Récupérer les favoris de l'utilisateur
$favorites = $this->getUserFavorites($userId, array_map(fn($r) => $r->getIdAttchment()->getId(), $results));
foreach ($results as $result) {
$attachmentId = $result->getIdAttchment()->getId();
$preListe = [
'id' => $attachmentId,
'date_depot_attachement' => $result->getDateDepotAttachement(),
'path' => $result->getIdAttchment()->getPath(),
'libiller' => $type,
'descreption' => $type === 'message' ? $result->getIdAttchment()->getDescreption() : null,
'is_favorite' => in_array($attachmentId, $favorites)
];
$liste[] = $preListe;
}
return ['total' => count($liste), 'attachments' => $liste];
}
/**
* Gets the list of attachements based on the sejour id, attachement type, and user id.
*
* @param string $id The sejour id
* @param string $type The attachement type ('watermark', 'original', '900')
* @param int|null $userId The user id (optional, for checking favorites)
* @return array The list of attachements
*/
public function getphotosVideosSejour(string $id, string $type, int $userId): array
{
$groupedAttachments = [];
$sejour = $this->em->getRepository(Sejour::class)->findOneBy(['id' => $id]);
$dateDebut = $sejour->getDateDebutSejour()->format('Y-m-d');
$dateFin = $sejour->getDateFinSejour()->format('Y-m-d');
// Récupérer les messages audio
$messages = $this->em->getRepository(SejourAttachment::class)->getSejourAttachByMessage($id, "message");
// Récupérer les photos/vidéos
$results = $this->em->getRepository(SejourAttachment::class)->getSejourAttachById($id, "photoVideo");
$attachCount = count($results);
// Récupérer les favoris de l'utilisateur
$favorites = $this->getlikephotosejour($userId, $id);
$favoritePhotoIds = array_map(function ($fav) {
return $fav->getIdSejourAttchment()->getIdAttchment()->getId();
}, $favorites);
// Fusionner les messages audio avec les photos/vidéos
foreach (array_merge($messages, $results) as $result) {
$attachmentId = $result->getIdAttchment()->getId();
$date = $result->getDateDepotAttachement()->format('Y-m-d');
$attchmentType = $result->getIdAttchment()->getIdref()->getLibiller();
$path = $result->getIdAttchment()->getPath();
if ($type == 'watermark' && $attchmentType == 'photo') {
$path = preg_replace(
'/upload/',
'upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled',
$result->getIdAttchment()->getPath()
);
} elseif ($type == 'original') {
$path = $result->getIdAttchment()->getPath();
}
$preListe = [
'date_depot_attachement' => $result->getDateDepotAttachement(),
'path' => $path,
'id_attchment' => $attachmentId,
'idposition' => $result->getIdAttchment()->getIdposition(),
'libiller' => $result->getIdAttchment()->getIdref()->getLibiller(),
'descreption' => $result->getIdAttchment()->getDescreption(),
'is_favorite' => in_array($attachmentId, $favoritePhotoIds),
];
// Initialiser le groupe de la date si nécessaire
if (!isset($groupedAttachments[$date])) {
$groupedAttachments[$date] = [
'attachments' => [],
'countPhotos' => 0,
'countAudio' => 0,
'countVideos' => 0,
'isFirstDay' => ($date === $dateDebut) ? "yes" : "no",
'isLastDay' => ($date === $dateFin) ? "yes" : "no",
];
}
$groupedAttachments[$date]['attachments'][] = $preListe;
// Incrémenter les compteurs en fonction du type d'attachement
$attachmentType = $result->getIdAttchment()->getIdref()->getLibiller();
if ($attachmentType === 'photo') {
$groupedAttachments[$date]['countPhotos']++;
} elseif ($attachmentType === 'video') {
$groupedAttachments[$date]['countVideos']++;
} elseif ($attachmentType === 'message') {
$groupedAttachments[$date]['countAudio']++;
}
}
// Trier les jours par date
uksort($groupedAttachments, function ($a, $b) {
return strtotime($a) - strtotime($b); // Ascendant (pour descendant : strtotime($b) - strtotime($a))
});
// Ajouter le total des attachements
$groupedAttachments['total'] = $attachCount;
return $groupedAttachments;
}
/**
* Récupérer les favoris pour un utilisateur donné.
*
* @param int|null $userId
* @param array $attachmentIds
* @return array
*/
private function getUserFavorites(?int $userId, array $attachmentIds): array
{
if (is_null($userId) || empty($attachmentIds)) {
return [];
}
$qb = $this->em->createQueryBuilder()
->select('l.idSejourAttchment')
->from(Likephoto::class, 'l')
->where('l.idUser = :userId')
->andWhere('l.idSejourAttchment IN (:attachmentIds)')
->setParameter('userId', $userId)
->setParameter('attachmentIds', $attachmentIds);
$results = $qb->getQuery()->getResult();
return array_map(fn($r) => $r['idSejourAttchment'], $results);
}
/**
* Gets the list of attachments based on the sejour id and attachment type
* @param string $id The sejour id
* @param string $type The attachment type
* @return array The list of attachments
*/ /**
* Gets the list of attachements based on the sejour id and attachement type
* @param string $id The sejour id
* @param string $type The attachement type
* @return array The list of attachements
*/
public function getCombinedattachSejour(string $id, string $type = 'photo'): array
{
if ($type == 'photoVideo') {
$groupedAttachments = [];
$results = $this->em->getRepository(SejourAttachment::class)->getSejourAttachById($id, $type);
$attachCount = count($results);
foreach ($results as $result) {
$date = $result->getDateDepotAttachement()->format('Y-m-d');
$preListe = [
'date_depot_attachement' => $result->getDateDepotAttachement(),
'path' => $result->getIdAttchment()->getPath(),
'id_attchment' => $result->getIdAttchment()->getId(),
'idposition' => $result->getIdAttchment()->getIdposition(),
'libiller' => $result->getIdAttchment()->getIdref()->getLibiller(),
'descreption' => $result->getIdAttchment()->getDescreption()
];
// Group attachments by date
if (!isset($groupedAttachments[$date])) {
$groupedAttachments[$date] = [];
}
$groupedAttachments[$date][] = $preListe;
}
uksort($groupedAttachments, function ($a, $b) {
return strtotime($b) - strtotime($a);
});
if ($attachCount > 0) {
$groupedAttachments['total'] = $attachCount;
}
return $groupedAttachments;
}
if ($type == 'photo') {
$liste = [];
$results = $this->em->getRepository(SejourAttachment::class)->getSejourAttachByPhoto($id, $type);
foreach ($results as $result) {
$preListe = [
'id' => $result->getIdAttchment()->getId(),
'date_depot_attachement' => $result->getDateDepotAttachement(),
'path' => $result->getIdAttchment()->getPath()
];
$liste[] = $preListe;
}
return $liste;
}
if ($type == 'message') {
$liste = [];
$results = $this->em->getRepository(SejourAttachment::class)->getSejourAttachByMessage($id, $type);
foreach ($results as $result) {
$preListe = [
'date_depot_attachement' => $result->getDateDepotAttachement(),
'path' => $result->getIdAttchment()->getPath(),
'id_attchment' => $result->getIdAttchment()->getId(),
'idposition' => $result->getIdAttchment()->getIdposition(),
'libiller' => $result->getIdAttchment()->getIdref()->getLibiller(),
'descreption' => $result->getIdAttchment()->getDescreption()
];
$liste[] = $preListe;
}
return $liste;
}
}
public function getatachmentsejourparent($id, $idParent)
{
//$liste = $this->em->getRepository(SejourAttachment::class)->findBy(array('idSejour' => $id,'idParent'=>$idParent,'statut'=>"private"));
$liste = $this->em->getRepository(Attachment::class)->searshSejourAtachmentEpaceParent($id, $idParent);
return $liste;
}
public function getVideosejour($id)
{
$liste = $this->em->getRepository(Attachment::class)->searshSejourVideo($id);
return $liste;
}
public function getsejourposition($id)
{
$liste = $this->em->getRepository(Position::class)->searshSejourPosition($id);
return $liste;
}
public function getTotalParent($id)
{
$liste = $this->em->getRepository(ParentSejour::class)->searshNbperpersonneSjour($id);
return $liste;
}
public function getTotalLikesSejour($id)
{
$liste = $this->em->getRepository(Likephoto::class)->getTotalLikes($id);
return $liste;
}
public function countPhotos(int $sejourId): int
{
$result = $this->sejourAttachmentRepository->CountsearshSejourAtachment($sejourId);
return isset($result[0]['COUNT(*)']) ? (int) $result[0]['COUNT(*)'] : 0;
}
public function countVideos(int $sejourId): int
{
$result = $this->sejourAttachmentRepository->CountsearshSejourVideo($sejourId);
return isset($result[0]['COUNT(*)']) ? (int) $result[0]['COUNT(*)'] : 0;
}
public function countMessages(int $sejourId): int
{
$result = $this->sejourAttachmentRepository->CountsearshSejourMessage($sejourId);
return isset($result[0]['COUNT(*)']) ? (int) $result[0]['COUNT(*)'] : 0;
}
/**
* Return all counts as an associative array.
*/
public function countAll(int $sejourId): array
{
return [
'photos' => $this->countPhotos($sejourId),
'videos' => $this->countVideos($sejourId),
'messages' => $this->countMessages($sejourId),
];
}
public function getsejourmessage($id)
{
$listeaudio = $this->em->getRepository(Attachment::class)->searshSejourMessage($id);
return $listeaudio;
}
function NBpersonnayaoncomande($id)
{
$Nbpconnx = $this->em->getRepository(ComandeProduit::class)->searshNbpersoneayontcomande($id);
return $Nbpconnx;
}
function montantttc($id)
{
$somme = $this->em->getRepository(Commande::class)->searshMttc($id);
return $somme;
}
function affectationAttachement($idSejou, $attachement)
{
$sejour = $this->em->getRepository(Sejour::class)->find($idSejou);
$sejAattch = new SejourAttachment();
$sejAattch->setIdSejour($sejour);
$sejAattch->setIdAttchment($attachement);
$sejAattch->setDateDepotAttachement($attachement->getDate());
$sejAattch->setStatut("public");
$this->em->getManager()->persist($sejAattch);
$this->em->getManager()->flush();
return $sejAattch;
}
function monpropreattachement($idSejou, $attachement, $user)
{
$sejour = $this->em->getRepository(Sejour::class)->find($idSejou);
$sejAattch = new SejourAttachment();
$sejAattch->setIdSejour($sejour);
$sejAattch->setIdAttchment($attachement);
$sejAattch->setDateDepotAttachement($attachement->getDate());
$sejAattch->setIdParent($user);
$sejAattch->setStatut("private");
$this->em->getManager()->persist($sejAattch);
$this->em->getManager()->flush();
return $sejAattch;
}
function affectationnbvisiteattachement($idSejou, $idattachement)
{
$nbs = 0;
$sejour = $this->em->getRepository(Sejour::class)->find($idSejou);
$attachement = $this->em->getRepository(Attachment::class)->find($idattachement);
$sejAattch = $this->em->getRepository(SejourAttachment::class)->findOneBy(array('idAttchment' => $attachement, 'idSejour' => $sejour));
if ($sejAattch->getNbpartenaireattch() === null) {
$nbs = 0;
} else {
$nbs = $sejAattch->getNbpartenaireattch();
}
$sejAattch->setNbpartenaireattch($nbs + 1);
$this->em->getManager()->persist($sejAattch);
$this->em->getManager()->flush();
return $sejAattch;
}
function EnvoyerEmailNewAccoNewSejour($emailacc, $accompagnateur, $idSejour, $passAcommpa)
{
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$sendTo = $accompagnateur->getEmail();
$message = (new \Swift_Message('Bienvenue à 5sur5 séjour '))
->setFrom('contact@5sur5sejour.com')
->setTo($emailacc);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->setBody(
$this->templating->render(
'emails/DemandeCreationAcc.html.twig',
[
"Nomdestinataire" => $accompagnateur->getNom(),
"Predestinataire" => $accompagnateur->getPrenom(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'roles' => $accompagnateur->getRoles(),
"identifiant" => $Sejour->getCodeSejour(),
'accompagnateur' => $accompagnateur,
"passAcommpa" => $passAcommpa,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
// authentification parent
function getsejourpourparent($id)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($id);
return $Sejour;
}
function getparentsejour($userId, $idSejour)
{
$Sejour = $this->em->getRepository(ParentSejour::class)->findOneBy(array('idParent' => $userId, 'idSejour' => $idSejour));
return $Sejour;
}
function getlikephotosejour($userId, $idSejour)
{
$liste = $this->em->getRepository(Likephoto::class)->searshlikephotousersejour($userId, $idSejour);
return $liste;
}
function getTotallikesphotosejour($photoId, $idSejour)
{
$liste = $this->em->getRepository(Likephoto::class)->getTotalLikesForPhoto($photoId, $idSejour);
return $liste;
}
function getToutesLesphotoSejour($userId, $idSejour)
{
$liste = $this->em->getRepository(Likephoto::class)->searshlikephotousersejour($userId, $idSejour);
return $liste;
}
function inserparentsejour($userId, $idSejour)
{
$user = $this->em->getRepository(User::class)->find($userId);
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$notifsms = $user->getSmsnotif();
$notifmail = $user->getMailnotif();
$ParentSejour = new ParentSejour();
if ($sejour->getNbenfan() == null || $sejour->getNbenfan() == 0 || $sejour->getNbenfan() == NULL) {
$ParentSejour->setFlagPrix(1);
} else {
if ((sizeof($sejour->getParentSejour()) < $sejour->getNbenfan()) && ((substr($sejour->getCodeSejour(), 1, 1) == 'F'))) {
$ParentSejour->setFlagPrix(1);
} elseif (substr($sejour->getCodeSejour(), 1, 1) == 'F') {
$ParentSejour->setFlagPrix(0);
}
}
$ParentSejour->setIdSejour($sejour);
$ParentSejour->setIdParent($user);
$ParentSejour->setSmsnotif($notifsms);
if (strpos($sejour->getCodeSejour(), "EF") !== false) {
$ParentSejour->setSmsnotif(0);
}
$ParentSejour->setMailnotif($notifmail);
$ParentSejour->setDateCreation(new \DateTime());
$ParentSejour->setPayment(0);
$this->em->getManager()->persist($ParentSejour);
$this->em->getManager()->flush();
return $ParentSejour;
}
function inserparentsejourPayenet($userId, $idSejour)
{
$parntsejour = $this->em->getRepository(ParentSejour::class)->findOneBy(array('idParent' => $userId, 'idSejour' => $idSejour));
if ($parntsejour == NULL) {
}
$parntsejour->setPayment(1);
$this->em->getManager()->persist($parntsejour);
$this->em->getManager()->flush();
return $parntsejour;
}
function sejoursansattach($sejId)
{
$sejour = $this->em->getRepository(Sejour::class)->find($sejId);
return $sejour;
}
function EnvoyerEmailCodeSejourAccompagnateurviapartenaireenmasse($emailAcommpa, $idSejour, $TypeSejour, $passAcommpa)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(29);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sendTo = $emailAcommpa;
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->setBody(
$this->templating->render(
'emails/Demandecreationacompaviapartenaire.html.twig',
[
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'passAcommpa' => $passAcommpa,
"destinataire" => $Sejour->getIdAcommp()->getUsername()
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function EnvoyerEmailSejourAccompa($emailAcommpa, $idSejour, $TypeSejour, $passAcommpa)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(29);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sendTo = $emailAcommpa;
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->setBody(
$this->templating->render(
// Firas : completer Twig
'emails/EnvoyerEmailSejourAccompa.html.twig',
[
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'passAcommpa' => $passAcommpa,
"destinataire" => $Sejour->getIdAcommp()->getUsername()
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function EnvoyerEmailSejourPartnaire($partnaire, $etab2, $err, $ok, $nomfilevalid, $nomfileinvalid)
{
$logo = '';
$nom = '';
if ($partnaire->hasRole('ROLE_PARTENAIRE')) {
$logo = $partnaire->getLogourl();
$nom = $partnaire->getNometablisment();
}
$RefEmail = $this->em->getRepository(Ref::class)->find(29);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sendTo = $partnaire->getEmail();
$message = (new \Swift_Message('Vos codes séjour 5sur5Séjour'))
->setFrom('partenariat-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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($ok > 1) {
$message->attach(Swift_Attachment::fromPath($this->projectDir . '/public/message//' . $nomfilevalid)->setFilename('Recap_Excel_' . $etab2->getNometab() . '.xlsx'));
}
if ($err > 1) {
$message->attach(Swift_Attachment::fromPath($this->projectDir . '/public/message//' . $nomfileinvalid)->setFilename('Liste_Sejour_Invalide_' . $etab2->getNometab() . '.xlsx'));
}
$message->setBody(
$this->templating->render(
// Firas : completer Twig
'emails/EnvoyerEmailSejourPartnaire.html.twig',
[
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function modif_lbel_Produit($id, $lbel)
{
$Album = $this->em->getRepository(Produit::class)->find($id);
$Album->setLabele($lbel);
$this->em->getManager()->persist($Album);
$this->em->getManager()->flush();
}
function AugmenterNombreVu($array)
{
$sejourPartenaire = $array[0]->getIdSejour()->getIdPartenaire();
$etablism = $this->em->getRepository(Etablisment::class)->findby(['user' => $sejourPartenaire]);
$type = $etablism[0]->getTypeetablisment();
foreach ($array as $e) {
if ($type == "ECOLES/AUTRES") {
if ($e->getNbecoleattch() == NULL) {
$e->setNbecoleattch(1);
$this->em->getManager()->persist($e);
$this->em->getManager()->flush();
} else {
$e->setNbecoleattch($e->getNbecoleattch() + 1);
$this->em->getManager()->persist($e);
$this->em->getManager()->flush();
}
}
if ($type == "CSE") {
if ($e->getNbconsomateurattch() == NULL) {
$e->setNbconsomateurattch(1);
$this->em->getManager()->persist($e);
$this->em->getManager()->flush();
} else {
$e->setNbconsomateurattch($e->getNbconsomateurattch() + 1);
$this->em->getManager()->persist($e);
$this->em->getManager()->flush();
}
}
if ($type == "PARTENAIRES/VOYAGISTES") {
if ($e->getNbpartenaireattch() == NULL) {
$e->setNbpartenaireattch(1);
$this->em->getManager()->persist($e);
$this->em->getManager()->flush();
} else {
$e->setNbpartenaireattch($e->getNbpartenaireattch() + 1);
$this->em->getManager()->persist($e);
$this->em->getManager()->flush();
}
}
}
}
function Nbrephotosejour($id)
{
$nombre = $this->em->getRepository(SejourAttachment::class)->SearchNombrephotoonsejour($id);
return $nombre;
}
function NombreMessageSejour($id)
{
$nombre = $this->em->getRepository(SejourAttachment::class)->NombreMessageSejour($id);
return $nombre;
}
function Nbpersone_commandepartypesejour($type, $dateTimeDebut, $dateTimeFin)
{
if ($dateTimeDebut == null || $dateTimeFin == null) {
$Nbcnxnxpartype = $this->em->getRepository(ComandeProduit::class)->Nbpersone_commandepartypesejoursansdate($type);
} else {
$Nbcnxnxpartype = $this->em->getRepository(ComandeProduit::class)->Nbpersone_commandepartypesejourAvecdate($type, $dateTimeDebut, $dateTimeFin);
}
return $Nbcnxnxpartype;
}
function NombreConnexionParSejour($Sejours)
{
$NbParent = $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' => $Sejours));
return $NbParent;
}
function rechercheLesCommandesParSejour($Sejours)
{
$Commandes = $this->em->getRepository(Commande::class)->findBy(array('idSejour' => $Sejours));
return $Commandes;
}
function sejourParentcnx($idSejour, $idParent)
{
$Sejour = $this->em->getRepository(ParentSejour::class)->findOneBy(array("idSejour" => $idSejour, "idParent" => $idParent));
return $Sejour;
}
function EnvoyerEmailCodeSejourToPartenaireAndAcco($idSejour)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($sejour) {
// Génération des PDFs
$pdf1 = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf1->setSourceFile($pdfFilepath1);
// Pour chaque page du PDF source
for ($i = 1; $i <= $pageCount; $i++) {
$pageId = $pdf1->importPage($i, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf1->addPage();
$pdf1->useImportedPage($pageId);
// Ajouter le contenu uniquement sur la première page
if ($i === 1) {
$pdf1->SetFont('Helvetica', '', 12);
$pdf1->SetTextColor(0, 0, 0);
// Position pour le code séjour
$pdf1->SetXY(50, 100);
$pdf1->Write(0, "Code séjour : " . $sejour->getCodeSejour());
// Position pour le mot de passe
$pdf1->SetXY(50, 120);
$pdf1->Write(0, "Mot de passe : " . $sejour->getIdAcommp()->getPasswordNonCripted());
// Informations du séjour
$pdf1->SetXY(50, 140);
$pdf1->Write(0, "Dates : du " . $sejour->getDateDebutSejour()->format('d/m/Y') . " au " . $sejour->getDateFinSejour()->format('d/m/Y'));
$pdf1->SetXY(50, 160);
$pdf1->Write(0, "Thème : " . $sejour->getThemSejour());
$pdf1->SetXY(50, 180);
$pdf1->Write(0, "Lieu : " . $sejour->getAdresseSejour());
$pdf1->SetXY(50, 200);
$pdf1->Write(0, "Ville : " . $sejour->getVille());
$pdf1->SetXY(50, 220);
$pdf1->Write(0, "Pays : " . $sejour->getPays());
}
}
$pdfFilepath1Output = $publicDirectory . "Mode d'emploi 5sur5sejour" . $sejour->getId() . ".pdf";
$pdf1->Output($pdfFilepath1Output, "F");
// Génération du deuxième PDF
$pdf = new Fpdi();
$paym = $sejour->getPaym();
if ($paym == 1) {
$pdfFilepathSource = $publicDirectory . "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
} else {
$pdfFilepathSource = $publicDirectory . "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
}
$pageCount = $pdf->setSourceFile($pdfFilepathSource);
// Pour chaque page du PDF source
for ($i = 1; $i <= $pageCount; $i++) {
$pageId = $pdf->importPage($i, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId);
// Ajouter le contenu uniquement sur la première page
if ($i === 1) {
$pdf->SetFont('Helvetica', '', 12);
$pdf->SetTextColor(0, 0, 0);
// Position pour le code séjour
$pdf->SetXY(50, 100);
$pdf->Write(0, "Code séjour : " . $sejour->getCodeSejour());
// Informations du séjour
$pdf->SetXY(50, 120);
$pdf->Write(0, "Dates : du " . $sejour->getDateDebutSejour()->format('d/m/Y') . " au " . $sejour->getDateFinSejour()->format('d/m/Y'));
$pdf->SetXY(50, 140);
$pdf->Write(0, "Thème : " . $sejour->getThemSejour());
$pdf->SetXY(50, 160);
$pdf->Write(0, "Lieu : " . $sejour->getAdresseSejour());
$pdf->SetXY(50, 180);
$pdf->Write(0, "Ville : " . $sejour->getVille());
$pdf->SetXY(50, 200);
$pdf->Write(0, "Pays : " . $sejour->getPays());
}
}
if ($paym == 1) {
$pdfFilepathOutput = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $sejour->getId() . ".pdf";
} else {
$pdfFilepathOutput = $publicDirectory . "Mode d'emploi parent G 5sur5séjour " . $sejour->getId() . ".pdf";
}
$pdf->Output($pdfFilepathOutput, "F");
// Envoi des emails avec EmailsCmdService
if ($sejour->getIdEtablisment()) {
// Déterminer l'email du partenaire
if (!is_null($sejour->getIdEtablisment()->getEmail())) {
$emailPartenaire = $sejour->getIdEtablisment()->getEmail();
} else {
$emailPartenaire = $sejour->getIdPartenaire()->getEmail();
}
// Récupérer le logo et le nom
$logo = $sejour->getIdEtablisment()->getLogo();
$nom = $sejour->getIdEtablisment()->getNometab();
// Préparer les données pour le template
$extraDataPartenaire = [
"Password" => $sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $sejour->getCodeSejour(),
"dateCreation" => $sejour->getDateCreationCode(),
"dateFinCode" => $sejour->getDateFinCode(),
"lieu" => $sejour->getAdresseSejour(),
"identifiant" => $sejour->getCodeSejour(),
"theme" => $sejour->getThemSejour(),
"ville" => $sejour->getVille(),
"pays" => $sejour->getPays(),
"dateDebut" => $sejour->getDateDebutSejour(),
"dateFin" => $sejour->getDateFinSejour(),
"motPass" => $sejour->getIdAcommp()->getPasswordNonCripted(),
'roles' => $sejour->getIdEtablisment()->getUser()->getRoles(),
'fichiers' => [
$pdfFilepathOutput,
$pdfFilepath1Output
]
];
// Envoyer l'email au partenaire
$this->emailsCmdService->sendMail(
$emailPartenaire,
'🔐 Code séjour + mot de passe – Connectez-vous à votre espace 5sur5séjour',
'EnvoiCodeSejourUniquementToAccoAndPartenaire',
$extraDataPartenaire,
['bcc' => 'contact@5sur5sejour.com']
);
// Envoyer l'email à l'accompagnateur si différent du partenaire
if ($emailPartenaire != $sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $sejour->getIdAcommp()->getReponseemail();
// Préparer les données pour l'accompagnateur
$extraDataAcco = [
"Password" => $sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $sejour->getCodeSejour(),
"dateCreation" => $sejour->getDateCreationCode(),
"dateFinCode" => $sejour->getDateFinCode(),
"lieu" => $sejour->getAdresseSejour(),
'theme' => $sejour->getThemSejour(),
'ville' => $sejour->getVille(),
'pays' => $sejour->getPays(),
'dateDebut' => $sejour->getDateDebutSejour(),
'dateFin' => $sejour->getDateFinSejour(),
"identifiant" => $sejour->getCodeSejour(),
"motPass" => $sejour->getIdAcommp()->getPasswordNonCripted(),
'logo' => $logo,
'nom' => $nom,
'image1' => $image1,
'image2' => $image2,
'iconphoto' => $iconphoto,
'iconfooter' => $iconfooter,
'iconmsg' => $iconmsg,
'roles' => $sejour->getIdAcommp()->getRoles(),
'fichiers' => [
$pdfFilepathOutput,
$pdfFilepath1Output
]
];
// Envoyer l'email à l'accompagnateur
$this->emailsCmdService->sendMail(
$emailAcco,
'🔐 Code séjour + mot de passe – Connectez-vous à votre espace 5sur5séjour',
'EnvoiCodeSejourUniquementToAccoAndPartenaire',
$extraDataAcco
);
}
}
}
return true;
}
function EnvoyerEmailOKActivation_CompteAcc($idSejour)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($sejour) {
// Génération des PDFs
$pdf1 = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf1->setSourceFile($pdfFilepath1);
// Pour chaque page du PDF source
for ($i = 1; $i <= $pageCount; $i++) {
$pageId = $pdf1->importPage($i, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf1->addPage();
$pdf1->useImportedPage($pageId);
// Ajouter le contenu uniquement sur la première page
if ($i === 1) {
$pdf1->SetFont('Helvetica', '', 12);
$pdf1->SetTextColor(0, 0, 0);
// Position pour le code séjour
$pdf1->SetXY(50, 100);
$pdf1->Write(0, "Code séjour : " . $sejour->getCodeSejour());
// Position pour le mot de passe
$pdf1->SetXY(50, 120);
$pdf1->Write(0, "Mot de passe : " . $sejour->getIdAcommp()->getPasswordNonCripted());
// Informations du séjour
$pdf1->SetXY(50, 140);
$pdf1->Write(0, "Dates : du " . $sejour->getDateDebutSejour()->format('d/m/Y') . " au " . $sejour->getDateFinSejour()->format('d/m/Y'));
$pdf1->SetXY(50, 160);
$pdf1->Write(0, "Thème : " . $sejour->getThemSejour());
$pdf1->SetXY(50, 180);
$pdf1->Write(0, "Lieu : " . $sejour->getAdresseSejour());
$pdf1->SetXY(50, 200);
$pdf1->Write(0, "Ville : " . $sejour->getVille());
$pdf1->SetXY(50, 220);
$pdf1->Write(0, "Pays : " . $sejour->getPays());
}
}
$pdfFilepath1Output = $publicDirectory . "Mode d'emploi 5sur5sejour" . $sejour->getId() . ".pdf";
$pdf1->Output($pdfFilepath1Output, "F");
// Génération du deuxième PDF
$pdf = new Fpdi();
$paym = $sejour->getPaym();
if ($paym == 1) {
$pdfFilepathSource = $publicDirectory . "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
} else {
$pdfFilepathSource = $publicDirectory . "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
}
$pageCount = $pdf->setSourceFile($pdfFilepathSource);
// Pour chaque page du PDF source
for ($i = 1; $i <= $pageCount; $i++) {
$pageId = $pdf->importPage($i, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId);
// Ajouter le contenu uniquement sur la première page
if ($i === 1) {
$pdf->SetFont('Helvetica', '', 12);
$pdf->SetTextColor(0, 0, 0);
// Position pour le code séjour
$pdf->SetXY(50, 100);
$pdf->Write(0, "Code séjour : " . $sejour->getCodeSejour());
// Informations du séjour
$pdf->SetXY(50, 120);
$pdf->Write(0, "Dates : du " . $sejour->getDateDebutSejour()->format('d/m/Y') . " au " . $sejour->getDateFinSejour()->format('d/m/Y'));
$pdf->SetXY(50, 140);
$pdf->Write(0, "Thème : " . $sejour->getThemSejour());
$pdf->SetXY(50, 160);
$pdf->Write(0, "Lieu : " . $sejour->getAdresseSejour());
$pdf->SetXY(50, 180);
$pdf->Write(0, "Ville : " . $sejour->getVille());
$pdf->SetXY(50, 200);
$pdf->Write(0, "Pays : " . $sejour->getPays());
}
}
if ($paym == 1) {
$pdfFilepathOutput = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $sejour->getId() . ".pdf";
} else {
$pdfFilepathOutput = $publicDirectory . "Mode d'emploi parent G 5sur5séjour " . $sejour->getId() . ".pdf";
}
$pdf->Output($pdfFilepathOutput, "F");
$loginUrl = "5sur5sejour.com";
$accomp = $this->em->getRepository(User::class)->find($sejour->getIdAcommp());
if ($accomp != null) {
$loginUrl = $this->emailsCmdService->requestLoginLink($accomp);
}
// Récupérer le logo et le nom
$logo = $sejour->getIdEtablisment()->getLogo();
$nom = $sejour->getIdEtablisment()->getNometab();
// Préparer les données pour le template
$extraDataEmail = [
"Password" => $sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $sejour->getCodeSejour(),
"dateCreation" => $sejour->getDateCreationCode(),
"dateFinCode" => $sejour->getDateFinCode(),
"lieu" => $sejour->getAdresseSejour(),
"identifiant" => $sejour->getCodeSejour(),
"theme" => $sejour->getThemSejour(),
"ville" => $sejour->getVille(),
"pays" => $sejour->getPays(),
"dateDebut" => $sejour->getDateDebutSejour(),
"dateFin" => $sejour->getDateFinSejour(),
"motPass" => $sejour->getIdAcommp()->getPasswordNonCripted(),
"codeSejour" => $sejour->getCodeSejour(),
'idSejour' => $sejour->getId(),
"loginUrl" => $loginUrl ,
'roles' => $sejour->getIdEtablisment()->getUser()->getRoles(),
'fichiers' => [
$pdfFilepathOutput,
$pdfFilepath1Output
]
];
$emailAcco = $sejour->getIdAcommp()->getReponseemail();
// Envoyer l'email au partenaire
$this->emailsCmdService->sendMail(
$emailAcco,
'✅ Votre compte 5sur5séjour est activé ! - Commencez à partager votre séjour',
'ConfirmationActivationAccomp',
$extraDataEmail,
['bcc' => 'contact@5sur5sejour.com']
);
}
return true;
}
//cette fonction envoi seulement le code sejour aux partenaire et acco s'il existe
function EnvoyerEmailCodeSejourToPartenaireAndAcco_old($idSejour)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($Sejour) {
//dd($sejour);
$pdf1 = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf1->setSourceFile($pdfFilepath1);
$pageId = $pdf1->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf1->addPage();
$pdf1->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$MotPass = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$MotPass = $Sejour->getIdAcommp()->getPasswordNonCripted();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf1->importPage(1 + $i);
$pdf1->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf1->SetFont("Arial", "", 5);
} else {
$pdf1->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf1->Text(35, 262, $strTheme);
$pdf1->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf1->Text(125, 262, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf1->Text(125, 262, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf1->Text(125, 262, $strLieu);
}
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(50, 252, $DateDebut->format('d/m/Y'));
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(90, 252, $DateFin->format('d/m/Y'));
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(90, 271, $CodeSejour);
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(75, 279, $MotPass);
}
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$pdf1->Output($pdfFilepath1, "F");
$pdf = new Fpdi();
$paym = $Sejour->getPaym();
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
}
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage($i + 1);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 268, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 268, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 268, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 268, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(80, 279, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(48, 258, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(89, 258, $DateFin->format('d/m/Y'));
}
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent G 5sur5séjour " . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
}
if ($Sejour->getIdEtablisment()) {
if (!is_null($Sejour->getIdEtablisment()->getEmail())) {
$emailPartenaire = $Sejour->getIdEtablisment()->getEmail();
} else {
$emailPartenaire = $Sejour->getIdPartenaire()->getEmail();
}
$partenaire = $Sejour->getIdEtablisment()->getNometab();
$partenaire = $Sejour->getIdEtablisment()->getLogo();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->setFrom('partenariat-contact@5sur5sejour.com')
->setTo($emailPartenaire)
->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
}
$message->setBody(
$this->templating->render(
'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"identifiant" => $Sejour->getCodeSejour(),
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $Sejour->getIdAcommp()->getReponseemail();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->setFrom('contact@5sur5sejour.com')
->setTo($emailAcco);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
}
$message->setBody(
$this->templating->render(
'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
"identifiant" => $Sejour->getCodeSejour(),
'roles' => $Sejour->getIdAcommp()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
}
}
}
//cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
function EnvoyerEmailPasswordSejourToPartenaireAndAcco($idSejour)
{
$logo = '';
$nom = '';
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(28);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
if ($Sejour) {
if ($Sejour->getIdEtablisment()) {
$emailPartenaire = $Sejour->getIdEtablisment()->getEmail();
$partenaire = $Sejour->getIdEtablisment()->getNometab();
$partenaire = $Sejour->getIdEtablisment()->getLogo();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
->setFrom('partenariat-contact@5sur5sejour.com')
->setTo($emailPartenaire);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->setBody(
$this->templating->render(
'emails/SendPasswordSejour.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $Sejour->getIdAcommp()->getReponseemail();
$message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
->setFrom('contact@5sur5sejour.com')
->setTo($emailAcco);
// ->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->attach(\Swift_Attachment::fromPath('pdf/'));
$message->setBody(
$this->templating->render(
'emails/SendPasswordSejour.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$done = $this->mailer->send($message);
//var_dump($done);
// var_dump("send it ");
} catch (\Swift_SwiftException $ex) {
//var_dump( $ex->getMessage());
}
}
}
}
}
//cette fonction envoi seulement le code sejour aux partenaire
function EnvoyerEmailCodeSejourToPartenaire($idSejour)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($Sejour) {
//dd($sejour);
$pdf = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$MotPass = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$MotPass = $Sejour->getIdAcommp()->getPasswordNonCripted();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage(1 + $i);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 262, $strTheme);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(50, 252, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(90, 252, $DateFin->format('d/m/Y'));
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 262, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 262, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 262, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(90, 271, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(75, 279, $MotPass);
}
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
$pdf = new Fpdi();
$paym = $Sejour->getPaym();
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
}
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage($i + 1);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 268, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 268, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 268, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 268, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(80, 279, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(48, 258, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(89, 258, $DateFin->format('d/m/Y'));
}
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
}
if ($Sejour->getIdEtablisment()) {
$emailPartenaire = $Sejour->getIdEtablisment()->getEmail();
$partenaire = $Sejour->getIdEtablisment()->getNometab();
$partenaire = $Sejour->getIdEtablisment()->getLogo();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->setFrom('partenariat-contact@5sur5sejour.com')
->setTo($emailPartenaire);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
}
$message->setBody(
$this->templating->render(
'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"identifiant" => $Sejour->getCodeSejour(),
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
}
}
//cette fonction envoi seulement le code sejour aux acccompagnateur
function EnvoyerEmailCodeSejourToAccomp($idSejour)
{
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($Sejour) {
$pdf = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$MotPass = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$MotPass = $Sejour->getIdAcommp()->getPasswordNonCripted();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage(1 + $i);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 262, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 262, $strLieu);
} elseif ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 262, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 262, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(50, 252, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(90, 252, $DateFin->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(90, 271, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(75, 279, $MotPass);
}
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
// $filename= $this->params->get('kernel.project_dir').'/public/pdf/pdfaccompagnateur.pdf';
$pdf->Output($pdfFilepath, "F");
$pdf = new Fpdi();
$paym = $Sejour->getPaym();
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
}
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage($i + 1);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 268, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 268, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 268, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 268, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(80, 279, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(48, 258, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(89, 258, $DateFin->format('d/m/Y'));
}
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
}
if ($Sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $Sejour->getIdAcommp()->getReponseemail();
$partenaire = $Sejour->getIdEtablisment()->getNometab();
$partenaire = $Sejour->getIdEtablisment()->getLogo();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->setFrom('contact@5sur5sejour.com')
->setTo($emailAcco);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
}
$message->setBody(
$this->templating->render(
'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
"identifiant" => $Sejour->getCodeSejour(),
'roles' => $Sejour->getIdAcommp()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
}
}
//cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
function EnvoyerEmailPasswordSejourToPartenaire($idSejour)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(28);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
if ($Sejour) {
if ($Sejour->getIdEtablisment()) {
$emailPartenaire = $Sejour->getIdEtablisment()->getEmail();
$partenaire = $Sejour->getIdEtablisment()->getNometab();
$partenaire = $Sejour->getIdEtablisment()->getLogo();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
->setFrom('partenariat-contact@5sur5sejour.com')
->setTo($emailPartenaire);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->setBody(
$this->templating->render(
'emails/SendPasswordSejour.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
}
}
//cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
function EnvoyerEmailPasswordSejourToAcco($idSejour)
{
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(28);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
if ($Sejour) {
if ($Sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $Sejour->getIdAcommp()->getReponseemail();
$partenaire = $Sejour->getIdEtablisment()->getNometab();
$partenaire = $Sejour->getIdEtablisment()->getLogo();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
->setFrom('contact@5sur5sejour.com')
->setTo($emailAcco);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->setBody(
$this->templating->render(
'emails/SendPasswordSejour.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdAcommp()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$done = $this->mailer->send($message);
//var_dump($done);
// var_dump("send it ");
} catch (\Swift_SwiftException $ex) {
//var_dump( $ex->getMessage());
}
}
}
}
//Touhemi 03-07: Modifier les services et les twig des mails séjour en masse pour afficher le logo et le nom de partenaire.
//Fonction 1:cette fonction envoi seulement le code sejour aux partenaire et acco s'il existe
function EnvoyerEmailCodeSejourToPartenaireAndAccoAvecNomLogoPartenaire($idSejour)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(21);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
if ($Sejour) {
if ($Sejour->getIdEtablisment()) {
$pdf1 = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf1->setSourceFile($pdfFilepath1);
$pageId = $pdf1->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf1->addPage();
$pdf1->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$MotPass = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$MotPass = $Sejour->getIdAcommp()->getPasswordNonCripted();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf1->importPage(1 + $i);
$pdf1->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf1->SetFont("Arial", "", 5);
} else {
$pdf1->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf1->Text(35, 262, $strTheme);
$pdf1->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf1->Text(125, 262, $strLieu);
} elseif ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf1->Text(125, 262, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf1->Text(125, 262, $strLieu);
}
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(50, 252, $DateDebut->format('d/m/Y'));
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(90, 252, $DateFin->format('d/m/Y'));
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(90, 271, $CodeSejour);
$pdf1->SetFont("Arial", "", 10);
$pdf1->Text(75, 279, $MotPass);
}
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath1 = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
// $filename= $this->params->get('kernel.project_dir').'/public/pdf/pdfaccompagnateur.pdf';
$pdf1->Output($pdfFilepath1, "F");
$emailPartenaire = $Sejour->getIdEtablisment()->getEmail();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
$pdf = new Fpdi();
$paym = $Sejour->getPaym();
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
}
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage($i + 1);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 268, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 268, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 268, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 268, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(80, 279, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(48, 258, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(89, 258, $DateFin->format('d/m/Y'));
}
if ($paym == 1) {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
} else {
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi parent 5sur5séjour" . $idSejour . ".pdf";
$pdf->Output($pdfFilepath, "F");
}
$message = (new \Swift_Message('🔐 Code séjour + mot de passe – Connectez-vous à votre espace 5sur5séjour'))
->setFrom('partenariat-contact@5sur5sejour.com')
->setTo($emailPartenaire);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
}
$message->setBody(
$this->templating->render(
'emails/EnvoiCodeSejourEnMassAcc.html.twig',
[
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"identifiant" => $Sejour->getCodeSejour(),
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $Sejour->getIdAcommp()->getReponseemail();
$message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
->setFrom('contact@5sur5sejour.com')
->setTo($emailAcco);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
if ($paym == 1) {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
} else {
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
}
$message->setBody(
$this->templating->render(
'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"code" => $Sejour->getCodeSejour(),
"dateCreation" => $Sejour->getDateCreationCode(),
"dateFinCode" => $Sejour->getDateFinCode(),
"lieu" => $Sejour->getAdresseSejour(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
"identifiant" => $Sejour->getCodeSejour(),
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
}
}
}
// Fonction 2: cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
function EnvoyerEmailPasswordSejourToPartenaireAndAccoAvecNomLogoPartenaire($idSejour)
{
$logo = '';
$nom = '';
$Sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$RefEmail = $this->em->getRepository(Ref::class)->find(28);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
if ($Sejour) {
if ($Sejour->getIdEtablisment()) {
$emailPartenaire = $Sejour->getIdEtablisment()->getEmail();
$logo = $Sejour->getIdEtablisment()->getLogo();
$nom = $Sejour->getIdEtablisment()->getNometab();
//dd($sejour);
$pdf = new Fpdi();
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode_emploi_5sur5sejour_v5_.pdf";
$pageCount = $pdf->setSourceFile($pdfFilepath);
$pageId = $pdf->importPage(1, PdfReader\PageBoundaries::MEDIA_BOX);
$pdf->addPage();
$pdf->useImportedPage($pageId, 0.5, 0.5, 0.5);
$testText = "abcdefghijklmnopqrstuvwxyz0123456789";
$current_date = date('d-M-Y');
$DateDebut = "";
$DateFin = "";
$Theme = "";
$Lieu = "";
$CodeSejour = "";
$MotPass = "";
$Ville = "";
$Paye = "";
if ($Sejour) {
$DateDebut = $Sejour->getDateDebutSejour();
$DateFin = $Sejour->getDateFinSejour();
$Theme = $Sejour->getThemSejour();
$Lieu = $Sejour->getAdresseSejour();
$CodeSejour = $Sejour->getCodeSejour();
$MotPass = $Sejour->getIdAcommp()->getPasswordNonCripted();
$Ville = $Sejour->getVille();
$Paye = $Sejour->getPays();
}
for ($i = 0; $i < $pageCount; $i++) {
$tplIdx = $pdf->importPage(1 + $i);
$pdf->useTemplate($tplIdx, 0, 0, 200, 300, true);
$theme = $Theme;
if (strlen($theme) > 25) {
$pdf->SetFont("Arial", "", 5);
} else {
$pdf->SetFont("Arial", "", 7);
}
$strTheme = iconv("UTF-8", "WINDOWS-1252", $theme);
$pdf->Text(35, 262, $strTheme);
$pdf->SetFont("Arial", "", 8);
$lieu = $Lieu;
$ville = $Ville;
$paye = $Paye;
if ($Paye && $Ville) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville . " " . $paye);
$pdf->Text(125, 262, $strLieu);
} else if ($Paye) {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $paye);
$pdf->Text(125, 262, $strLieu);
} else {
$strLieu = iconv("UTF-8", "WINDOWS-1252", $ville);
$pdf->Text(125, 262, $strLieu);
}
$pdf->SetFont("Arial", "", 10);
$pdf->Text(50, 252, $DateDebut->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(90, 252, $DateFin->format('d/m/Y'));
$pdf->SetFont("Arial", "", 10);
$pdf->Text(90, 271, $CodeSejour);
$pdf->SetFont("Arial", "", 10);
$pdf->Text(75, 279, $MotPass);
}
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
// $filename= $this->params->get('kernel.project_dir').'/public/pdf/pdfaccompagnateur.pdf';
$pdf->Output($pdfFilepath, "F");
$message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
->setFrom('partenariat-contact@5sur5sejour.com')
->setTo($emailPartenaire);
//->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->setBody(
$this->templating->render(
'emails/EnvoiMotdePassSejouEnMassAcc.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
$emailAcco = $Sejour->getIdAcommp()->getReponseemail();
$message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
->setFrom('contact@5sur5sejour.com')
->setTo($emailAcco);
// ->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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$publicDirectory = $this->params->get('kernel.project_dir') . '/public/pdf/';
$pdfFilepath = $publicDirectory . "Mode d'emploi 5sur5sejour" . $idSejour . ".pdf";
$message->attach(\Swift_Attachment::fromPath($pdfFilepath));
$message->setBody(
$this->templating->render(
'emails/EnvoiMotdePassSejouEnMassAcc.html.twig',
[
"Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$done = $this->mailer->send($message);
//var_dump($done);
// var_dump("send it ");
} catch (\Swift_SwiftException $ex) {
//var_dump( $ex->getMessage());
}
}
}
}
}
//Le nombre de séjours créés
public function getNbrSejourCree($dateDeb, $dateFin)
{
$nbrSejourCree = $this->em->getRepository(Sejour::class)->getNbrSejourCree($dateDeb, $dateFin);
return $nbrSejourCree;
}
public function getNbrSejourCreeParPart($dateDeb, $dateFin, $part)
{
$nbrSejourCree = $this->em->getRepository(Sejour::class)->getNbrSejourCreeParPart($dateDeb, $dateFin, $part);
return $nbrSejourCree;
}
public function getNbrSejourCreeParTypePart($dateDeb, $dateFin, $type)
{
$nbrSejourCree = $this->em->getRepository(Sejour::class)->getNbrSejourCreeParTypePart($dateDeb, $dateFin, $type);
return $nbrSejourCree;
}
//Le nombre de séjours actifs
public function findSejourEncourBetween($dateDeb, $dateFin)
{
$SejourEncourBetween = $this->em->getRepository(Sejour::class)->findSejourEncourBetween($dateDeb, $dateFin);
return $SejourEncourBetween;
}
public function findSejourEncourBetweenParPart($dateDeb, $dateFin, $part)
{
$SejourEncourBetween = $this->em->getRepository(Sejour::class)->findSejourEncourBetweenParPart($dateDeb, $dateFin, $part);
return $SejourEncourBetween;
}
//nommbre de sejour encour
public function findSejourActiveBetween($dateDeb, $dateFin)
{
$SejourActiveBetween = $this->em->getRepository(Sejour::class)->findSejourActiveBetween($dateDeb, $dateFin);
return $SejourActiveBetween;
}
public function findSejourActiveBetweenParPart($dateDeb, $dateFin, $part)
{
$SejourActiveBetween = $this->em->getRepository(Sejour::class)->findSejourActiveBetweenParPart($dateDeb, $dateFin, $part);
return $SejourActiveBetween;
}
public function findSejourActiveBetweenParTypePart($dateDeb, $dateFin, $type)
{
$SejourActiveBetween = $this->em->getRepository(Sejour::class)->findSejourActiveBetweenParTypePart($dateDeb, $dateFin, $type);
return $SejourActiveBetween;
}
//Le nombre d'enfant declare moyen par séjour encour
public function enfantsdeclarer($sejours)
{
$nbrEnfantSejours = 0;
foreach ($sejours as $sejour) {
$nbrEnfantSejours = $nbrEnfantSejours + $sejour->getNbenfan();
}
return $nbrEnfantSejours;
}
public function parentConnecte($sejours)
{
$nbrPArentSejours = 0;
foreach ($sejours as $sejour) {
$parent_Sejour = $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' => $sejour));
$nbrPArentSejours = $nbrPArentSejours + sizeof($parent_Sejour);
}
return $nbrPArentSejours;
}
public function findParentDateBetween($dateDeb, $dateFin)
{
$findParentDateBetween = $this->em->getRepository(ParentSejour::class)->findParentDateBetween($dateDeb, $dateFin);
return $findParentDateBetween;
}
public function findParentDateBetweenParPart($dateDeb, $dateFin, $part)
{
$findParentDateBetween = $this->em->getRepository(ParentSejour::class)->findParentDateBetweenParPart($dateDeb, $dateFin, $part);
return $findParentDateBetween;
}
public function findParentDateBetweenParTypePart($dateDeb, $dateFin, $type)
{
$findParentDateBetween = $this->em->getRepository(ParentSejour::class)->findParentDateBetweenParTypePart($dateDeb, $dateFin, $type);
return $findParentDateBetween;
}
public function FindeUSerParentBetween($dateDeb, $dateFin)
{
$users = $this->em->getRepository(User::class)->FindeUSerParentBetween($dateDeb, $dateFin);
return $users;
}
public function FindeUSerParentActiveBetween($dateDeb, $dateFin)
{
$users = $this->em->getRepository(User::class)->FindeUSerParentActiveBetween($dateDeb, $dateFin);
return $users;
}
public function FindeUSerParentActiveBetweenParPart($dateDeb, $dateFin, $part)
{
$users = $this->em->getRepository(ParentSejour::class)->FindeUSerParentActiveBetweenParPart($dateDeb, $dateFin, $part);
return $users;
}
public function FindeUSerParentActiveBetweenParTypePart($dateDeb, $dateFin, $type)
{
$users = $this->em->getRepository(ParentSejour::class)->FindeUSerParentActiveBetweenParTypePart($dateDeb, $dateFin, $type);
return $users;
}
public function findSejourEncourBetweenParTypePart($dateDeb, $dateFin, $type)
{
$users = $this->em->getRepository(ParentSejour::class)->FindeUSerParentActiveBetweenParPart($dateDeb, $dateFin, $type);
return $users;
}
function caConnexionTotalFree()
{
$etabs = $this->em->getRepository(Etablisment::class)->findAll();
$cconnexionFree = 0;
$nbrConexxion = 0;
foreach ($etabs as $etab) {
$sejours = $this->em->getRepository(Sejour::class)->findBy(array("idEtablisment" => $etab));
$prixtotPArt = 0;
$flag = false;
foreach ($sejours as $sejour) {
$lastday = \DateTime::createFromFormat("Y-m-d H:i:s", date("Y-08-01 00:00:00"));
if ((substr($sejour->getCodeSejour(), 1, 1) == 'F')) {
$flag = true;
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour));
$prixConnPArt = $sejour->getPrixcnxpartenaire();
$nbrConexxion = $nbrConexxion + sizeof($parent_sejours);
$prixtotal = $prixConnPArt * sizeof($parent_sejours);
$prixtotPArt = $prixtotPArt + $prixtotal;
}
}
$cconnexionFree = $cconnexionFree + $prixtotPArt;
}
return [$cconnexionFree, $nbrConexxion];
}
function caConnexionTotalFreeParPart($part)
{
$etabs = $this->em->getRepository(Etablisment::class)->findAll();
$cconnexionFree = 0;
$nbrConexxion = 0;
foreach ($etabs as $etab) {
if ($etab->getId() == $part) {
$sejours = $this->em->getRepository(Sejour::class)->findBy(array("idEtablisment" => $etab));
$prixtotPArt = 0;
$flag = false;
foreach ($sejours as $sejour) {
$lastday = \DateTime::createFromFormat("Y-m-d H:i:s", date("Y-08-01 00:00:00"));
if ((substr($sejour->getCodeSejour(), 1, 1) == 'F')) {
$flag = true;
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour));
$prixConnPArt = $sejour->getPrixcnxpartenaire();
$nbrConexxion = $nbrConexxion + sizeof($parent_sejours);
$prixtotal = $prixConnPArt * sizeof($parent_sejours);
$prixtotPArt = $prixtotPArt + $prixtotal;
}
}
$cconnexionFree = $cconnexionFree + $prixtotPArt;
}
}
return [$cconnexionFree, $nbrConexxion];
}
function caConnexionTotalPaye()
{
$prixtotPArt = 0;
$flag = false;
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("payment" => 1));
$prixConnPArt = 2.9;
$nbrConexxion = sizeof($parent_sejours);
$prixtotal = $prixConnPArt * sizeof($parent_sejours);
$prixtotPArt = $prixtotPArt + $prixtotal;
return [$prixtotPArt, $nbrConexxion];
}
function caConnexionTotalPayeParPart($part)
{
$prixtotPArt = 0;
$flag = false;
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("payment" => 1));
$prixConnPArt = 2.9;
$nbrConexxion = 0;
foreach ($parent_sejours as $sej) {
if ($sej->getIdSejour()->getIdEtablisment()->getId() == $part) {
$nbrConexxion = $nbrConexxion + 1;
}
}
$prixtotal = $prixConnPArt * $nbrConexxion;
$prixtotPArt = $prixtotPArt + $prixtotal;
return [$prixtotPArt, $nbrConexxion];
}
function caConnexionTotal()
{
return [$this->caConnexionTotalPaye()[0] + $this->caConnexionTotalFree()[0], $this->caConnexionTotalPaye()[1] + $this->caConnexionTotalFree()[1]];
}
function caConnexionTotalParPart($part)
{
return [$this->caConnexionTotalPayeParPart($part)[0] + $this->caConnexionTotalFreeParPart($part)[0], $this->caConnexionTotalPayeParPart($part)[1] + $this->caConnexionTotalFreeParPart($part)[1]];
}
function caProduit()
{
return $this->em->getRepository(Commande::class)->caProduit();
}
//Le nombre de comptes ouverts
//Le nombre comptes activés
//Le nombre de commande en cours
//Le nombre de commande moyen par sejour
//Le CA connexion en cours (décomposé en connexion payé partenaire et connexion payé par parent)
//Le montant du panier moyen
//Le nombre moyen de produits par commande
//Montant du reversement connexion
//Montant de reversement commande
function caConnexionTotalFreeEncour()
{
$cconnexionFree = 0;
$nbrConexxion = 0;
$sejours = $this->em->getRepository(Sejour::class)->findSejourListEncourFree();
// dd($sejours);
$prixtotPArt = 0;
$flag = false;
foreach ($sejours as $sejour) {
if ((substr($sejour->getCodeSejour(), 1, 1) == 'F')) {
$flag = true;
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId()));
$prixConnPArt = $sejour->getPrixcnxpartenaire();
$nbrConexxion = $nbrConexxion + sizeof($parent_sejours);
$prixtotal = $prixConnPArt * sizeof($parent_sejours);
$prixtotPArt = $prixtotPArt + $prixtotal;
}
}
return $prixtotPArt;
}
function caConnexionTotalFreeEncourParPart($part)
{
$cconnexionFree = 0;
$nbrConexxion = 0;
$sejours = $this->em->getRepository(Sejour::class)->findSejourListEncourFreeParPart($part);
// dd($sejours);
$prixtotPArt = 0;
$flag = false;
foreach ($sejours as $sejour) {
if ((substr($sejour->getCodeSejour(), 1, 1) == 'F')) {
$flag = true;
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId()));
$prixConnPArt = $sejour->getPrixcnxpartenaire();
$nbrConexxion = $nbrConexxion + sizeof($parent_sejours);
$prixtotal = $prixConnPArt * sizeof($parent_sejours);
$prixtotPArt = $prixtotPArt + $prixtotal;
}
}
return $prixtotPArt;
}
function caConnexionTotalPayEncour()
{
$sejours = $this->em->getRepository(Sejour::class)->findSejourListEncourPay();
$someparsejour = 0;
foreach ($sejours as $sejour) {
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId(), 'payment' => 1));
$someparsejour = $someparsejour + (sizeof($parent_sejours) * 2.9);
}
// var_dump($someparsejour);
return $someparsejour;
}
function caConnexionTotalPayEncourParPart($part)
{
$sejours = $this->em->getRepository(Sejour::class)->findSejourListEncourPay();
$someparsejour = 0;
foreach ($sejours as $sejour) {
// var_dump($sejour);
if ($sejour->getIdEtablisment()->getId() == $part) {
$parent_sejours = $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId(), 'payment' => 1));
$someparsejour = $someparsejour + (sizeof($parent_sejours) * 2.9);
}
}
// var_dump($someparsejour);
return $someparsejour;
}
public function Formaterarraydate($arraytoFormat, $chantest)
{
$arrayFInal = array();
foreach ($arraytoFormat as $entit) {
// var_dump($entit->$chantest()->format('d/m/Y'));
if (array_key_exists($entit->$chantest()->format('d/m/Y'), $arrayFInal)) {
array_push($arrayFInal, $entit);
} else {
$arrayFInal[$entit->$chantest()->format('d/m/Y')] = array($entit);
}
}
return $arrayFInal;
}
public function FormaterarraydateBetween($arraytoFormat, $chanttestDEb, $chantestEnd, $dateDEbut, $dateFinoriginal)
{
// var_dump("dateFin1");
// var_dump($dateFin);
$arrayFInal = array();
$dateFin = clone $dateFinoriginal;
$dateFin->modify('+1 day');
$period = new DatePeriod(
$dateDEbut,
new DateInterval('P1D'),
$dateFin
);
foreach ($period as $key => $value) {
$arrayFInal[$value->format('d/m/Y')] = array();
foreach ($arraytoFormat as $entit) {
if ($value <= $entit->$chantestEnd() && $value >= $entit->$chanttestDEb())
if (array_key_exists($value->format('d/m/Y'), $arrayFInal)) {
array_push($arrayFInal[$value->format('d/m/Y')], $entit->getCodeSejour());
} else {
$arrayFInal[$value->format('d/m/Y')] = array($entit->getCodeSejour());
}
}
}
return $arrayFInal;
}
public function FormaterarraydateBetweennbrEnfant($arraytoFormat, $chanttestDEb, $chantestEnd, $dateDEbut, $dateFin)
{
$arrayFInal = array();
$totalenf = 0;
foreach ($arraytoFormat as $entit) {
if (array_key_exists($entit->getCodeSejour(), $arrayFInal)) {
$arrayFInal[$entit->getCodeSejour()]['nbrenfdec'] = $arrayFInal[$entit->getCodeSejour()]['nbrenfdec'] + $entit->getNbenfan();
$arrayFInal[$entit->getCodeSejour()]['nbrParentCncte'] = $arrayFInal[$entit->getCodeSejour()]['nbrParentCncte'] + $entit->getCountParentSejour();
} else {
$arrayFInal[$entit->getCodeSejour()] = array('nbrenfdec' => $entit->getNbenfan(), 'nbrParentCncte' => $entit->getCountParentSejour());
}
$totalenf = $totalenf + $entit->getNbenfan();
}
$arrayFInal = $this->sort_col($arrayFInal, 'nbrParentCncte');
$arrayFInal['totenf'] = $totalenf;
return $arrayFInal;
}
public function FormaterarraydateBetweennbrPArentCncte($arraytoFormat, $chanttest, $dateDEbut, $dateFinoriginal)
{
$arrayFInal = array();
$dateFin = clone $dateFinoriginal;
$dateFin->modify('+1 day');
$period = new DatePeriod(
$dateDEbut,
new DateInterval('P1D'),
$dateFin
);
foreach ($period as $key => $value) {
$arrayFInal[$value->format('d/m/Y')] = 0;
foreach ($arraytoFormat as $entit) {
if ($value->format('d/m/Y') == $entit->$chanttest()->format('d/m/Y')) {
if (array_key_exists($value->format('d/m/Y'), $arrayFInal)) {
$arrayFInal[$value->format('d/m/Y')] = $arrayFInal[$value->format('d/m/Y')] + 1;
} else {
$arrayFInal[$value->format('d/m/Y')] = 1;
}
}
}
}
return $arrayFInal;
}
function sort_col($table, $colname)
{
$tn = $ts = $temp_num = $temp_str = array();
// dd($table);
foreach ($table as $key => $row) {
/* var_dump($colname);
var_dump($key);
var_dump($row[$colname]);
var_dump(substr($row[$colname],0,1));
var_dump(is_numeric(substr($row[$colname],0,1)));
var_dump($key);
echo '<br>';
*/
if (is_numeric(substr($row[$colname], 0, 1))) {
$tn[$key] = $row[$colname];
$temp_num[$key] = $row;
} else {
$ts[$key] = $row[$colname];
$temp_str[$key] = $row;
}
}
unset($table);
array_multisort($tn, SORT_DESC, SORT_NUMERIC, $temp_num);
array_multisort($ts, SORT_DESC, SORT_STRING, $temp_str);
return array_merge($temp_num, $temp_str);
}
function EnvoyerEmailNewAccompagnateurPlus($partenaire)
{
$logo = '';
$nom = '';
if ($partenaire->hasRole('ROLE_PARTENAIRE')) {
$logo = $partenaire->getLogourl();
$nom = $partenaire->getNometablisment();
}
$RefEmail = $this->em->getRepository(Ref::class)->find(17);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail));
$sendTo = $partenaire->getEmail();
$message = (new \Swift_Message('Nouveau partenaire'))
->setFrom('partenariat-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"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$icon2 = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$icon3 = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$message->setBody(
$this->templating->render(
'emails/AccompagnateurPlusNew.html.twig',
[
"Nomdestinataire" => $partenaire->getNom(),
"Predestinataire" => $partenaire->getPrenom(),
"password" => $partenaire->getPasswordNonCripted(),
"image1" => $image1,
"image2" => $image2,
"icon2" => $icon2,
"icon3" => $icon3,
"iconfooter" => $iconfooter,
"iconmsg" => $iconmsg,
"idPartenaire" => $partenaire->getId(),
"identifiant" => $sendTo,
"password" => $partenaire->getPasswordNonCripted(),
'logo' => $logo,
'nom' => $nom,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function EnvoyerEmailSejourRecapProduitsSansCommandes($nomfilevalid)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(29);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sendTo = "touhemib@gmail.com";
$message = (new \Swift_Message('Produits sans commanes'))
->setFrom('touhemib@gmail.com')
->setTo($sendTo);
$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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->attach(Swift_Attachment::fromPath($this->projectDir . '/public/message//' . $nomfilevalid)->setFilename('Recap_Excel_ProduitsSansCommandes.xlsx'));
$message->setBody(
$this->templating->render(
// Firas : completer Twig
'emails/RecapParentsCreerProduitsSansCommande.html.twig',
[
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
function EnvoyerMailExport($nomfilevalid)
{
$logo = '';
$nom = '';
$RefEmail = $this->em->getRepository(Ref::class)->find(29);
$Email = $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail, 'statut' => 9));
$sendTo = "touhemib@gmail.com";
$message = (new \Swift_Message('Export'))
->setFrom('contact@5sur5sejour.com')
->setTo(['touhemib@gmail.com', 'yousra.tlich@gmail.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://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
$iconloca = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
$iconmsg = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
$iconfooter = $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
$message->attach(Swift_Attachment::fromPath($this->projectDir . '/public/message//' . $nomfilevalid)->setFilename('Recap_Excel_ProduitsSansCommandes.xlsx'));
$message->setBody(
$this->templating->render(
// Firas : completer Twig
'emails/RecapParentsCreerProduitsSansCommande.html.twig',
[
"image1" => $image1,
"image2" => $image2,
"iconfooter" => $iconfooter,
"iconphoto" => $iconphoto,
"iconloca" => $iconloca,
"iconmsg" => $iconmsg,
'logo' => $logo,
'nom' => $nom,
]
),
'text/html'
);
$signMail = $this->params->get('signMail');
if ($signMail == 'yes') {
$domainName = $this->params->get('domaine');
$selector = $this->params->get('selector');
$PrivateKey = file_get_contents($this->params->get('pathDKIM'));
$signer = new \Swift_Signers_DKIMSigner($PrivateKey, $domainName, $selector);
$message->attachSigner($signer);
}
try {
$this->mailer->send($message);
} catch (\Swift_SwiftException $ex) {
$ex->getMessage();
}
}
public function creationPromotion($code, $type, $nbreMaxGeneral, $nbreMaxParUser, $dateDebut, $dateFin, $etat, $pourcentage, $nbreApplique, $strategie)
{
$statutCreate = $this->em->getRepository(Ref::class)->find(1);
$promotion = new Promotions();
$promotion->setCode($code);
$promotion->setType($type);
$promotion->setNbreMaxGeneral(intval($nbreMaxGeneral));
$promotion->setNbreMaxParUser(intval($nbreMaxParUser));
$promotion->setDateCreation(new \DateTime());
$promotion->setStatut($statutCreate);
$dateDebutFormat = date_create_from_format('Y-m-d', $dateDebut);
$promotion->setDateDebut($dateDebutFormat);
$dateFinFormat = date_create_from_format('Y-m-d', $dateFin);
$promotion->setDateFin($dateFinFormat);
$promotion->setEtat(intval($etat));
$promotion->setPourcentage(intval($pourcentage));
$promotion->setStrategie($strategie);
$promotion->setNbreApplicable($nbreApplique);
$this->em->getManager()->persist($promotion);
$this->em->getManager()->flush();
return $promotion;
}
public function listePromotions()
{
$promotions = $this->em->getRepository(Promotions::class)->findBy(array('statut' => 1));
return $promotions;
}
public function detailsPromotion($idPromo)
{
$promotion = $this->em->getRepository(Promotions::class)->find($idPromo);
return $promotion;
}
public function deletePromotion($idPromo)
{
$promotion = $this->em->getRepository(Promotions::class)->find($idPromo);
$statutDelete = $this->em->getRepository(Ref::class)->find(39);
if ($promotion) {
$promotion->setStatut($statutDelete);
$this->em->getManager()->persist($promotion);
$this->em->getManager()->flush();
}
return $promotion;
}
public function updatePromotion($idPromo, $type, $nbreMaxGeneral, $nbreMaxParUser, $dateDebut, $dateFin, $etat, $pourcentage, $nbreApplique)
{
$promotion = $this->em->getRepository(Promotions::class)->find($idPromo);
if ($promotion) {
if ($promotion->getType() == "parents") {
$tabParentsPromo = $this->em->getRepository(PromoParents::class)->findBy(array('promotion' => $promotion));
if (sizeof($tabParentsPromo)) {
foreach ($tabParentsPromo as $pp) {
$this->em->remove($pp);
$this->em->getManager()->flush();
}
}
}
if ($promotion->getType() == "codeSejour") {
$tabSejourParents = $this->em->getRepository(PromoSejour::class)->findBy(array('promotion' => $promotion));
if (sizeof($tabSejourParents)) {
foreach ($tabSejourParents as $pp) {
$this->em->remove($pp);
$this->em->getManager()->flush();
}
}
}
$promotion->setType($type);
$promotion->setNbreMaxGeneral(intval($nbreMaxGeneral));
$promotion->setNbreMaxParUser(intval($nbreMaxParUser));
$dateDebutFormat = date_create_from_format('Y-m-d', $dateDebut);
$promotion->setDateDebut($dateDebutFormat);
$dateFinFormat = date_create_from_format('Y-m-d', $dateFin);
$promotion->setDateFin($dateFinFormat);
$promotion->setEtat(intval($etat));
$promotion->setPourcentage(intval($pourcentage));
$promotion->setNbreApplicable($nbreApplique);
$this->em->getManager()->persist($promotion);
$this->em->getManager()->flush();
}
return $promotion;
}
public function findPromotionByCode($code)
{
$promotion = $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code, 'etat' => 1));
return $promotion;
}
public function checkCodePromoForCreation($code)
{
$promotion = $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code));
if ($promotion) {
$tab['test'] = true;
$tab['pourcentage'] = $promotion->getPourcentage();
return $tab;
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
}
public function checkCodePromoPrents($code, $user)
{
$promotion = $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code, 'etat' => 1));
if ($promotion && $user->getShowdetailsphotos() != "4") {
$tab['test'] = true;
$tab['pourcentage'] = $promotion->getPourcentage();
return $tab;
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
}
public function checkCodePromo($code)
{
$promotion = $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code, 'etat' => 1));
if ($promotion) {
$tab['test'] = true;
$tab['pourcentage'] = $promotion->getPourcentage();
return $tab;
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
}
public function changerEtatPromotion($idPromotion, $etat)
{
$promotion = $this->em->getRepository(Promotions::class)->find($idPromotion);
if ($promotion) {
$promotion->setEtat(intval($etat));
$this->em->getManager()->persist($promotion);
$this->em->getManager()->flush();
}
return $promotion;
}
public function createLogPromotion($idPromotion, $idCommande, $idClient)
{
$logPromotion = new LogPromotions();
$logPromotion->setIdPromotion($idPromotion);
$logPromotion->setIdClient($idClient);
$logPromotion->setIdCommande($idCommande);
$logPromotion->setDateCreation(new \DateTime());
$this->em->getManager()->persist($logPromotion);
$this->em->getManager()->flush();
return $logPromotion;
}
public function checkCodePromoParUser($idPromo, $idClient)
{
$promotion = $this->em->getRepository(Promotions::class)->find($idPromo);
$tabLogPromo = $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $idPromo, 'idClient' => $idClient));
$nbreMaxParUser = $promotion->getNbreMaxParUser();
$nbreLog = sizeOf($tabLogPromo);
if ($nbreLog == $nbreMaxParUser) {
return false;
} else {
return true;
}
}
public function checkCodePromoAvance($code, $idClient, $idSejour, $role, $panier)
{
$panierElPromo = [];
$promotion = $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code, 'etat' => 1));
if ($promotion) {
$type = $promotion->getType();
$affectedProducts = $promotion->getStrategie();
if ($affectedProducts != 'all' && trim($affectedProducts) != null) {
foreach ($panier as $element) {
$panierProduit = $this->em->getRepository(PanierProduit::class)->findOneBy(array('idPanier' => $element['id']));
if ($panierProduit) {
$produit = $panierProduit->getIdProduit();
if ($produit->getType()->getId() == $affectedProducts) {
$panierElPromo[] = $element['id'];
}
}
}
if (!$panierElPromo) {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
}
if (($role == "ROLE_ACC" && $type == "accompagnateur") || ($type == "parent" && $role == "ROLE_PARENT")) {
$tabLogPromo = $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $promotion, 'idClient' => $idClient));
$nbreMaxParUser = $promotion->getNbreMaxParUser();
$nbreLog = sizeOf($tabLogPromo);
if ($nbreMaxParUser != 0 && $nbreLog == $nbreMaxParUser) {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
} else {
$tab['test'] = true;
$tab['pourcentage'] = $promotion->getPourcentage();
$tab['remise'] = $this->caclRemiseInPanier($panier, $promotion->getStrategie(), $promotion->getNbreApplicable(), $promotion->getPourcentage());
return $tab;
}
} elseif ($type == "parents" || $type == "Parents") {
$client = $this->em->getRepository(User::class)->find($idClient);
$promoParents = $this->em->getRepository(PromoParents::class)->findOneBy(array('promotion' => $promotion, 'parent' => $client));
if ($promoParents) {
$tabLogPromo = $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $promotion, 'idClient' => $idClient));
$nbreMaxParUser = $promotion->getNbreMaxParUser();
$nbreLog = sizeOf($tabLogPromo);
if ($nbreMaxParUser != 0 && $nbreLog == $nbreMaxParUser) {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
} else {
$tab['test'] = true;
$tab['pourcentage'] = $promotion->getPourcentage();
$tab['remise'] = $this->caclRemiseInPanier($panier, $promotion->getStrategie(), $promotion->getNbreApplicable(), $promotion->getPourcentage());
return $tab;
}
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
} elseif ($type == "codeSejour") {
$sejour = $this->em->getRepository(Sejour::class)->find($idSejour);
$PromoSejour = $this->em->getRepository(PromoSejour::class)->findOneBy(array('promotion' => $promotion, 'sejour' => $sejour));
if ($PromoSejour) {
$tabLogPromo = $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $promotion, 'idClient' => $idClient));
$nbreMaxParUser = $promotion->getNbreMaxParUser();
$nbreLog = sizeOf($tabLogPromo);
if ($nbreMaxParUser != 0 && $nbreLog == $nbreMaxParUser) {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
} else {
$tab['test'] = true;
$tab['pourcentage'] = $promotion->getPourcentage();
$tab['remise'] = $this->caclRemiseInPanier($panier, $promotion->getStrategie(), $promotion->getNbreApplicable(), $promotion->getPourcentage());
return $tab;
}
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
} else {
$tab['test'] = false;
$tab['pourcentage'] = 0;
return $tab;
}
}
public function caclRemiseInPanier($panier, $strategie, $nbreApplique, $pourcentage)
{
$ttc = 0;
$qte = 0;
$tabPrices = array();
$remise = 0;
if ($nbreApplique == 1) {
foreach ($panier as $item) {
$ttc += $item['mnt'] * $item['qte'];
}
$remise = ($ttc / 100) * $pourcentage;
} else {
foreach ($panier as $item) {
// $ttc += $item['mnt'] * $item['qte'];
for ($i = 0; $i < $item['qte']; $i++) {
array_push($tabPrices, $item['mnt']);
}
$qte += $item['qte'];
}
// dd($tabPrices);
rsort($tabPrices);
// dd($tabPrices);
$x = intval($qte / $nbreApplique);
$tabPricesPromo = array_slice($tabPrices, -$x, $x, true);
// $tabPricesSansPromo= array_slice($tabPrices,0,sizeof($tabPrices)-$x,true);
foreach ($tabPricesPromo as $p) {
$remise += ($p / 100) * $pourcentage;
}
}
return $remise;
}
public function getInfoSejour($sejour)
{
//info sejour
$infoSejour = array(
'code_sejour' => $sejour->getCodeSejour(),
'date_debut_sejour' => $sejour->getDateDebutSejour(),
'date_fin_sejour' => $sejour->getDateFinSejour(),
'theme_sejour' => $sejour->getThemSejour(),
'nombre_enfants' => $sejour->getNbenfan()
);
$adresseSejour = array(
'code_postale' => $sejour->getCodePostal(),
'adresse' => $sejour->getAdresseSejour(),
'ville' => $sejour->getVille(),
'pays' => $sejour->getPays()
);
//info acco
$accompagnateur = $this->em->getRepository(User::class)->find($sejour->getIdAcommp());
$detailsAccompagnateur = array(
'nom' => $accompagnateur->getNom(),
'prenom' => $accompagnateur->getPrenom(),
'email' => $accompagnateur->getEmail()
);
//info partenaire
$partenaire = $this->em->getRepository(User::class)->find($sejour->getIdPartenaire());
$detailsPartenaire = array(
'nom' => $partenaire->getNom(),
'prenom' => $partenaire->getPrenom(),
'email' => $partenaire->getEmail()
);
//info etablissement
$etablissement = $this->em->getRepository(Etablisment::class)->find($sejour->getIdEtablisment());
$detailsEtablissement = array(
'nom' => $etablissement->getNometab(),
'type' => $etablissement->getTypeetablisment(),
'codePostale' => $etablissement->getCodepostaleatb(),
'adresse' => $etablissement->getAdresseetab(),
'ville' => $etablissement->getVille(),
'pays' => $etablissement->getPays(),
);
$nombrePhotos = $this->em->getRepository(SejourAttachment::class)->SearchNombrephotoonsejour($sejour->getId());
$nombreAudio = $this->em->getRepository(SejourAttachment::class)->NombreMessageSejour($sejour->getId());
$listeDescription = $this->em->getRepository(Jourdescripdate::class)->findBy(array('idsejour' => $sejour));
$nombreDescriptions = sizeof($listeDescription);
$detailsSejour = array(
'info_sejour' => $infoSejour,
'adresse_sejour' => $adresseSejour,
'info_accompagnateur' => $detailsAccompagnateur,
'info_partenaire' => $detailsPartenaire,
'info_etablissement' => $detailsEtablissement,
'nombrePhotos' => $nombrePhotos,
'nombreAudio' => $nombreAudio,
'nombreDescriptions' => $nombreDescriptions,
'listeDescriptions' => $listeDescription
);
return $detailsSejour;
}
/**
* Service that generate a random list of photos
* @author Firas Belhadj firasbelhadj686@gmail.com
* @param array $listeFavorites The list of favorites
* @param array $listAlbum The list of sejour photos
* @param int $number The number of photos to generate
* @param string $strategy The generation strategy (optional)
* @return array $randomList
*/
public function generateRandomAlbum(array $listeFavorites, array $listAlbum, int $number, string $strategy = 'FAVORITES_FIRST'): array
{
$randomList = [];
$randFave = [];
foreach ($listeFavorites as $key => $fav) {
$randFave[$key]['id'] = $fav->getIdSejourAttchment()->getIdAttchment()->getId();
$randFave[$key]['path'] = $fav->getIdSejourAttchment()->getIdAttchment()->getPath();
}
if ($strategy == 'FAVORITES_FIRST') {
shuffle($listAlbum);
if ($randFave) {
shuffle($randFave);
if (count($randFave) < $number) {
$remaining = $number - count($randFave);
$randomList = array_merge($randFave, array_slice($listAlbum, 0, $remaining));
} else {
$randomList = array_slice($randFave, 0, $number);
}
return $randomList;
}
$randomList = array_slice($listAlbum, 0, $number);
}
return $randomList;
}
function EnvoyerEmailRappelActivation($accompagnateur, $sejour)
{
try {
return $this->emailsCmdService->sendMail(
$accompagnateur->getEmail(),
'Rappel : Activez votre séjour sur 5sur5sejour',
'rappel-activation-sejour',
[
'accompagnateur' => $accompagnateur,
'sejour' => $sejour,
'password' => $accompagnateur->getPasswordNonCripted(),
'image1' => 'https://res.cloudinary.com/apss-factory/image/upload/a_exif/v1582274063/qw7csxayektmq1leqjpp.png',
'iconfooter' => 'https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png'
],
[], // pas de pièces jointes
true // mettre en queue
);
} catch (\Exception $e) {
return false;
}
}
}