<?php
namespace App\Controller\Client;
use App\Entity\AccountingFirm;
use App\Entity\ContactCreationSociete;
use App\Entity\ContactInvestissementImmo;
use App\Entity\Page;
use App\Entity\Prescriber;
use App\Entity\RedirectionClient;
use App\Entity\SeoPage;
use App\Repository\RedirectionClientRepository;
use App\Services\MoneticoService;
use App\Services\SendContactEmail;
use App\Services\WebSite;
use App\Entity\Actualiters;
use App\Entity\TypeSeoPage;
use App\Entity\WebsiteNews;
use App\Entity\Announcement;
use App\Entity\ApplyRequest;
use App\Entity\SeoPageClient;
use App\Entity\Actualitecabinet;
use App\Entity\ModuleVideo;
use App\Entity\Qrcode;
use Symfony\Component\Mime\Email;
use App\Services\QueriesV2Manager;
use App\Form\AnnouncementApplyType;
use App\Repository\EbookRepository;
use App\Services\SimulateurManager;
use App\Repository\UsefulLinkRepository;
use App\Repository\ActualitersRepository;
use App\Repository\WebsiteNewsRepository;
use App\Repository\AnnouncementRepository;
use App\Repository\AccountingFirmRepository;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\ActualitecabinetRepository;
use App\Repository\ModuleVideoRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
/**
* Class ClientController
* @package App\Controller\Client
*
* TODO :
* - ameliorer la partie outil -> texte en dyn
*/
class ClientController extends AbstractClientController
{
#[Route(name: 'client')]
#[Route(path: '/preview/{host}', name: 'previewclient')]
public function index(): Response
{
$entityManager = $this->getDoctrine()->getManager();
// $annonceUne = $entityManager->getRepository(Announcement::class)->findMyAnnouncementMain($this->accountingFirm);
$annonceUne = [];
if ($this->accountingFirm) {
$annonceUne = $entityManager->getRepository(Announcement::class)->findMyAnnouncementMain($this->accountingFirm);
}
return $this->render('index.html.twig', [
'controller_name' => 'ClientController',
'une_annonce' => count($annonceUne) > 0 ? $annonceUne[0] : null,
]);
}
#[Route(path: '/widget-dates', name: 'widget_dates')]
public function dates(QueriesV2Manager $qm)
{
$tabData = $qm->getDates();
$tabDates = [];
foreach ($tabData as $lignes) {
foreach ($lignes as $ligne) {
$key = array_search($ligne['date'], array_column($tabDates, 'date'));
if ($key === false) { // cas date jamais ajoutée
$tabDates[] = ['date' => $ligne['date'], 'lien' => 'calendrier-fiscal.php?id=' . $ligne['id']];
} else { // cas date déjà ajoutée, donc plusieurs articles à la même date
$tabDates[$key] = ['date' => $ligne['date'], 'lien' => 'actualites-calendrier-fiscal.php?date=' . $ligne['date']];
}
}
}
return $this->json($tabDates);
}
#[Route(path: '/sitemap.xml', defaults: ['_format' => 'xml'], name: 'client_sitemap')]
#[Route(path: '/preview/{host}/sitemap.xml', defaults: ['_format' => 'xml'], name: 'previewclient_sitemap')]
public function sitemap(QueriesV2Manager $qm): Response
{
$isOnePage = false;
// vars bases
$modules = $this->accountingFirm->getParameters()->getModules();
$pages = $this->accountingFirm->getParameters()->getPages();
foreach ($modules as $name => $show) {
if ($show && $name == "OnePage") {
$isOnePage = true;
}
}
$urls = array(
'home' => '',
'primary' => array(),
'secondary' => array()
);
// url de base
$urls['home'] = $this->sitemapUrl('client');
if (!$isOnePage)
array_push($urls['primary'], $this->sitemapUrl('client_contact'));
// array_push($urls['secondary'], $this->sitemapUrl('client_legal_notice'));
// array_push($urls['secondary'], $this->sitemapUrl('client_privacy_policy'));
// url des modules si activés
foreach ($modules as $name => $show) {
if ($show) {
switch ($name) {
case 'Actualites':
if (!$isOnePage)
array_push($urls['primary'], $this->sitemapUrl('client_website_news_index'));
if ($list = $this->accountingFirm->getWebsiteNews()) {
foreach ($list as $key => $value) {
array_push($urls['secondary'], $this->sitemapUrl('client_website_news_show', array('slug' => $value->getSlug())));
}
}
break;
case 'Annonces':
if (!$isOnePage)
array_push($urls['primary'], $this->sitemapUrl('client_announcement_index'));
if ($list = $this->accountingFirm->getAnnouncements()) {
foreach ($list as $key => $value) {
array_push($urls['secondary'], $this->sitemapUrl('client_announcement_show', array('slug' => $value->getSlug())));
}
}
break;
case 'Actualite_du_mois':
if (!$isOnePage) {
// urls module widget ??
array_push($urls['primary'], $this->sitemapUrl('client_widget_news_index'));
array_push($urls['primary'], $this->sitemapUrl('client_widget_recherche'));
}
if ($list = $qm->getActualites()) {
foreach ($list as $key => $value) {
$id = $value['id'] . "-";
$slug = explode($id, $value['new_slug']);
array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_fisc_show', array('id' => $value['id'])));
array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_juri_show', array('id' => $value['id'], 'slug' => $slug[1])));
array_push($urls['secondary'], $this->sitemapUrl('client_widget_bien_etre_show', array('id' => $value['id'], 'slug' => $slug[1])));
array_push($urls['secondary'], $this->sitemapUrl('client_widget_transformation_digitale_show', array('id' => $value['id'], 'slug' => $slug[1])));
}
}
$dates = $qm->getDates();
foreach ($dates as $key1 => $val) {
foreach ($val as $key2 => $date) {
$tab = explode("-", $date['date']);
$month = $tab[1];
$date = $tab[2] . "-" . $tab[1] . "-" . $tab[0];
array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_index_past', array('month' => $month)));
array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_fisc_list_show', array('date' => $date)));
}
}
break;
case 'Tools':
if (!$isOnePage) {
array_push($urls['primary'], $this->sitemapUrl('outil_achat'));
array_push($urls['primary'], $this->sitemapUrl('outil_analyse_cout_revient'));
array_push($urls['primary'], $this->sitemapUrl('outil_banque'));
array_push($urls['primary'], $this->sitemapUrl('outil_caisse'));
array_push($urls['primary'], $this->sitemapUrl('outil_creation'));
array_push($urls['primary'], $this->sitemapUrl('outil_entretien_bilan'));
array_push($urls['primary'], $this->sitemapUrl('outil_evaluation_entreprise'));
array_push($urls['primary'], $this->sitemapUrl('outil_facturation'));
array_push($urls['primary'], $this->sitemapUrl('outil_financement'));
array_push($urls['primary'], $this->sitemapUrl('outil_note_de_frais'));
array_push($urls['primary'], $this->sitemapUrl('outil_optimisation_financement_vehicule'));
array_push($urls['primary'], $this->sitemapUrl('outil_optimisation_investissement_immo'));
array_push($urls['primary'], $this->sitemapUrl('outil_suivi_gestion'));
array_push($urls['primary'], $this->sitemapUrl('outil_index'));
}
break;
case 'Livre_blanc':
if (!$isOnePage) {
array_push($urls['primary'], $this->sitemapUrl('client_ebook_index'));
}
break;
default:
// NOPE
break;
}
}
}
if (!$isOnePage) {
// url des pages customs
if ($pages = $this->accountingFirm->getParameters()->getPages()) {
foreach ($pages as $key => $value) {
array_push($urls['primary'], $this->sitemapUrl('client_custom_page', array('uri' => $value->getUri())));
}
}
}
$this->templateBase = '/';
return $this->render('sitemap.html.twig', [
'urls' => $urls,
'lastmod' => date("Y-m-d"),
'changefreq' => 'monthly'
]);
}
private function sitemapUrl($path, $param = null)
{
try {
if (!is_null($param)) {
return 'https://www.' . $this->accountingFirm->getHost() . $this->generateUrl($path, $param);
} else {
return 'https://www.' . $this->accountingFirm->getHost() . $this->generateUrl($path);
}
} catch (\Throwable $th) {
return null;
}
}
#[Route(path: '/robots.txt', defaults: ['_format' => 'txt'], name: 'client_robots')]
#[Route(path: '/preview/{host}/robots.txt', defaults: ['_format' => 'txt'], name: 'previewclient_robots')]
public function robots(): Response
{
$this->templateBase = '/';
return $this->render('robots.html.twig', [
'sitemap' => 'https://www.' . $this->accountingFirm->getHost() . $this->generateUrl('client_sitemap')
]);
}
#[Route(path: '/contact', name: 'client_contact')]
#[Route(path: '/preview/{host}/contact', name: 'previewclient_contact')]
public function contact(Request $request)
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'name' => 'Contact']);
return $this->render('/contact.html.twig', [
'cabinet' => $this->accountingFirm,
'seopage' => $seopage,
]);
}
#[Route(path: '/contactbis', name: 'client_contactbis')]
#[Route(path: '/preview/{host}/contactbis', name: 'previewclient_contactbis')]
public function contactCustom(Request $request)
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'name' => 'Contact']);
return $this->render('/contact.html.twig', [
'cabinet' => $this->accountingFirm,
'seopage' => $seopage,
]);
}
#[Route(path: '/contactProfession', name: 'client_contactprofession')]
#[Route(path: '/preview/{host}/contactprofession', name: 'previewclient_contactprofession')]
public function contactProfession(Request $request)
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'name' => 'Contact']);
return $this->render('/contact.html.twig', [
'cabinet' => $this->accountingFirm,
'seopage' => $seopage,
]);
}
#[Route(path: '/recrutement', name: 'client_announcement_index')]
#[Route(path: '/preview/{host}/recrutement', name: 'previewclient_announcement_index')]
public function announcementIndex(EntityManagerInterface $entityManager): Response
{
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 10]);
$announcementRepository = $entityManager->getRepository(Announcement::class);
// dd($announcementRepository->findAll(), $this->accountingFirm->getId());
return $this->render('announcement/index.html.twig', [
// 'announcements' => $announcementRepository->findBy(['accountingFirm' => $this->accountingFirm->getId()]),
'announcements' => $announcementRepository->findMyAnnouncementsOffer($this->accountingFirm),
'announcementSpontanee' => $announcementRepository->findMyAnnouncementsSpontanee($this->accountingFirm),
'seopage' => $seopage
]);
}
#[Route(path: '/recrutement/{slug}', name: 'client_announcement_show')]
#[Route(path: '/preview/{host}/recrutement/{slug}', name: 'previewclient_announcement_show')]
public function annoucementShow(string $slug, EntityManagerInterface $entityManager): Response
{
//$this->applyForm_send = false;
$announcementRepository = $entityManager->getRepository(Announcement::class);
$announcement = $announcementRepository->findOneBy(['slug' => $slug]);
$request = $this->get('request_stack')->getCurrentRequest();
$host = $request->get('host');
//$host = 'cabinet-za.de';
$form_send_recrutement = $this->form_send_recrutement;
$form_recrutement = $this->createForm(AnnouncementApplyType::class);
if (($host && $announcement->getAccountingFirm()->getHost() !== $host)
|| ($announcement->getAccountingFirm() !== $this->accountingFirm)
) {
throw new NotFoundHttpException();
}
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 32]);
// $formApply = $this->createForm(AnnouncementApplyType::class, null,['cabinet'=>$this->accountingFirm]);
// $formApply->handleRequest($this->request->getCurrentRequest());
// $this->formapplyview = $formApply->createView();
// $filesystem = new Filesystem();
// if ($formApply->isSubmitted() && $formApply->isValid()) {
// $entityManager = $this->getDoctrine()->getManager();
// $configEmail = $this->accountingFirm->getParameters()->getWebMail();
// $contact=new ApplyRequest();
// $contact->setAnnonce($announcement);
// //upload cv
// $cv = $formApply['tmpCV']->getData();
// if($cv)
// {
// $directory='../'.$contact->getUploadPath();
// try {
// if(!$filesystem->exists($directory))
// {
// $filesystem->mkdir($directory);
// }
// $originalFilename = pathinfo($cv->getClientOriginalName(), PATHINFO_FILENAME);
// $fileName = $originalFilename.'-'.uniqid().'.'.$cv->guessExtension();
// $cv->move($directory, $fileName);
// $contact->setCv($fileName);
// } catch (FileException $e) {
// }
// }
// //upload lettre de motivation
// $lettre = $formApply['tmpLettre']->getData();
// if($lettre)
// {
// $directory='../'.$contact->getUploadPath();
// try {
// if(!$filesystem->exists($directory))
// {
// $filesystem->mkdir($directory);
// }
// $originalFilename = pathinfo($lettre->getClientOriginalName(), PATHINFO_FILENAME);
// $fileName = $originalFilename.'-'.uniqid().'.'.$lettre->guessExtension();
// $lettre->move($directory, $fileName);
// $contact->setLettre($fileName);
// } catch (FileException $e) {
// }
// }
// if(null != $configEmail) {
// $mailbody = '
// <p>Bonjour,</p>
// <p>Vous avez reçus une réponses a une annonce de recrutement depuis votre site web</p>
// <br>
// <h1>Annonce :</h1>
// <br />
// <br />
// <p>Nom : '.$formApply['nom']->getData().'</p>
// <p>Téléphone : '.$formApply['tel']->getData().'</p>
// <p>Email : '.$formApply['email']->getData().'</p>
// <p>Message :</p>
// <br/>
// <p> Vous pouvez consultez ce message directement depuis votre <a href="https://prod.lagence.expert/demanderecrutement/" target=\"_blank\">Espace administration</a></p>
// ';
// $email = (new Email())
// ->from($configEmail)
// ->to($configEmail)
// //->cc('cc@example.com')
//
// //->replyTo('fabien@example.com')
// //->priority(Email::PRIORITY_HIGH)
// ->subject('Réponses a une annonce de recrutement')
// ->html($mailbody);
// $this->mailer->send($email);
// $this->formsend = true;
// $contact->setNom($formApply['nom']->getData());
// $contact->setEmail($formApply['email']->getData());
// $contact->setTel($formApply['tel']->getData());
// $contact->setMessage($formApply['message']->getData());
// $contact->setRgpd($formApply['rgpd']->getData());
// $contact->setDate(new \DateTime('now'));
// $entityManager->persist($contact);
// $entityManager->flush();
// $mailbody_confirm = '
// <p>Bonjour,</p>
// <p>Votre candidature a été envoyée avec succès. Nous allons vous recontacter dans les plus brefs délais. </p>
// <p>Merci de votre confiance </p>
// ';
// $email_confirm = (new Email())
// ->from($configEmail)
// ->to($formApply['email']->getData())
// //->cc('cc@example.com')
//
// //->replyTo('fabien@example.com')
// //->priority(Email::PRIORITY_HIGH)
// ->subject('Confirmation d\'envoi de votre message')
// ->html($mailbody_confirm);
// $this->mailer->send($email_confirm);
// $this->applyForm_send = true;
// }
// }
return $this->render('announcement/show.html.twig', [
'announcement' => $announcement,
// 'applyForm' => $this->formapplyview,
// 'applyForm_send' => $this->applyForm_send,
'seopage' => $seopage,
'form_send_recrutement' => $form_send_recrutement,
'form_recrutement' => $form_recrutement,
]);
}
#[Route(path: '/livre-blanc', name: 'client_ebook_index')]
#[Route(path: '/preview/{host}/livre-blanc', name: 'previewclient_ebook_index')]
#[IsGranted('WEBSITE_EBOOK', statusCode: 404)]
public function ebookIndex(EbookRepository $ebookRepository): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 9]);
return $this->render('ebook/index.html.twig', [
'ebooks' => $ebookRepository->findMyEbooks($this->accountingFirm),
'seopage' => $seopage
]);
}
#[Route(path: '/partenaires', name: 'client_useful_link_index')]
#[Route(path: '/preview/{host}/partenaires', name: 'previewclient_useful_link_index')]
#[IsGranted('WEBSITE_USEFUL_LINK', statusCode: 404)]
public function UsefulLinkIndex(UsefulLinkRepository $usefulLinkRepository): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 8]);
$this->templateBase = '/';
return $this->render('useful_link/website_index.html.twig', [
'useful_links' => $usefulLinkRepository->findUsefulLinks($this->accountingFirm),
'seopage' => $seopage
]);
}
#[Route(path: '/news', name: 'client_website_news_index')]
#[Route(path: '/preview/{host}/news', name: 'previewclient_website_news_index')]
#[IsGranted('WEBSITE_NEWS', statusCode: 404)]
public function websiteNewsIndex(WebsiteNewsRepository $websiteNewsRepository): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 31]);
return $this->render('website_news/index.html.twig', [
'website_news' => $websiteNewsRepository->findMyWebsiteNews($this->accountingFirm),
'seopage' => $seopage
]);
}
#[Route(path: '/news/{slug}', name: 'client_website_news_show')]
#[Route(path: '/preview/{host}/news/{slug}', name: 'previewclient_website_news_show')]
#[IsGranted('WEBSITE_NEWS', statusCode: 404)]
public function websiteNewsShow(WebsiteNews $websiteNews): Response
{
$request = $this->get('request_stack')->getCurrentRequest();
$host = $request->get('host');
// $host = 'cabinet-za.de';
if (($host && $websiteNews->getAccountingFirm()->getHost() !== $host)
|| ($websiteNews->getAccountingFirm() !== $this->accountingFirm)
) {
throw new NotFoundHttpException();
}
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 32]);
return $this->render('website_news/show.html.twig', [
'website_news' => $websiteNews,
'seopage' => $seopage
]);
}
#[Route(path: '/actualite', name: 'client_actualite_index')]
#[Route(path: '/preview/{host}/actualite', name: 'previewclient_actualite_index')]
#[IsGranted('WEBSITE_NEWS', statusCode: 404)]
public function actualitecabinetIndex(ActualitecabinetRepository $actualitecabinetRepository): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 31]);
return $this->render('actualite_cabinet/index.html.twig', [
'actualites' => $actualitecabinetRepository->findMyActualites($this->accountingFirm),
'seopage' => $seopage
]);
}
#[Route(path: '/actualite/{slug}', name: 'client_actualite_show')]
#[Route(path: '/preview/{host}/actualite/{slug}', name: 'previewclient_actualite_show')]
#[IsGranted('WEBSITE_NEWS', statusCode: 404)]
public function actualitecabinetShow(Actualitecabinet $actualitecabinet): Response
{
$request = $this->get('request_stack')->getCurrentRequest();
$host = $request->get('host');
// $host = 'cabinet-za.de';
if (($host && $actualitecabinet->getAccountingFirm()->getHost() !== $host)
|| ($actualitecabinet->getAccountingFirm() !== $this->accountingFirm)
) {
throw new NotFoundHttpException();
}
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 32]);
return $this->render('actualite_cabinet/show.html.twig', [
'actualite' => $actualitecabinet,
'seopage' => $seopage
]);
}
#[Route(path: '/actu-rs', name: 'client_website_actu_rs_index')]
#[Route(path: '/preview/{host}/actu-rs', name: 'previewclient_website_actu_rs_index')]
#[IsGranted('WEBSITE_ACTU_RS', statusCode: 404)]
public function websiteActuRsIndex(ActualitersRepository $acutalitersRepository): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 35]);
return $this->render('actu_rs/index.html.twig', [
'actualiters' => $acutalitersRepository->findMyActuRs($this->accountingFirm),
'seopage' => $seopage
]);
}
#[Route(path: '/actu-rs/{id}-{slugtxt}', name: 'client_website_actu_rs_show')]
#[Route(path: '/preview/{host}/actu-rs/{id}-{slugtxt}', name: 'previewclient_website_actu_rs_show')]
#[IsGranted('WEBSITE_ACTU_RS', statusCode: 404)]
public function websiteActuRsShow(Actualiters $actualiters): Response
{
$request = $this->get('request_stack')->getCurrentRequest();
$host = $request->get('host');
// $host = 'cabinet-za.de';
if (($host && $actualiters->getAccountingFirm()->getHost() !== $host)
|| ($actualiters->getAccountingFirm() !== $this->accountingFirm)
) {
throw new NotFoundHttpException();
}
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 36]);
return $this->render('actu_rs/show.html.twig', [
'actualiters' => $actualiters,
'seopage' => $seopage
]);
}
#[Route(path: '/mentions-legales', name: 'client_legal_notice')]
#[Route(path: '/preview/{host}/mentions-legales', name: 'previewclient_legal_notice')]
public function legalNotice(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 4]);
if ($seopage != null) {
$pageDescription = $seopage->getPageDescripion();
if ($seopage->getPageDescripion() == null) {
$pageDescription = $seopage->getSeopageId()->getPageDescripion();
}
$pageDescription = str_replace("#name#", $this->accountingFirm->getName(), $pageDescription);
$pageDescription = str_replace("#zipCode#", $this->accountingFirm->getZipCode(), $pageDescription);
$pageDescription = str_replace("#address#", $this->accountingFirm->getAddress(), $pageDescription);
$pageDescription = str_replace("#city#", $this->accountingFirm->getCity(), $pageDescription);
$pageDescription = str_replace("#url#", $this->accountingFirm->getUrl(), $pageDescription);
$pageDescription = str_replace("#phone#", $this->accountingFirm->getPhone(), $pageDescription);
$seopage->setPageDescripion($pageDescription);
}
return $this->render('mentions_legales.html.twig', [
'seopage' => $seopage
]);
}
#[Route(path: '/politique-confidentialite', name: 'client_privacy_policy')]
#[Route(path: '/preview/{host}/politique-confidentialite', name: 'previewclient_privacy_policy')]
public function privacyPolicy(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 3]);
if ($seopage != null) {
$pageDescription = $seopage->getPageDescripion();
if ($seopage->getPageDescripion() == null) {
$pageDescription = $seopage->getSeopageId()->getPageDescripion();
}
$pageDescription = str_replace("#name#", $this->accountingFirm->getName(), $pageDescription);
$pageDescription = str_replace("#zipCode#", $this->accountingFirm->getZipCode(), $pageDescription);
$pageDescription = str_replace("#address#", $this->accountingFirm->getAddress(), $pageDescription);
$pageDescription = str_replace("#city#", $this->accountingFirm->getCity(), $pageDescription);
$pageDescription = str_replace("#url#", $this->accountingFirm->getUrl(), $pageDescription);
$pageDescription = str_replace("#phone#", $this->accountingFirm->getPhone(), $pageDescription);
$seopage->setPageDescripion($pageDescription);
}
return $this->render('politique_confidentialite.html.twig', [
'seopage' => $seopage
]);
}
#[Route(path: '/outil-achat', name: 'outil_achat')]
#[Route(path: '/preview/{host}/outil-achat', name: 'previewoutil_achat')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilAchat(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 6]);
return $this->render('tools/tools_achat.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-analyse-cout-revient', name: 'outil_analyse_cout_revient')]
#[Route(path: '/preview/{host}/outil-analyse-cout-revient', name: 'previewoutil_analyse_cout_revient')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilAnalyseCoutRevient(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 21]);
return $this->render('tools/tools_analyse_cout_revient.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-banque', name: 'outil_banque')]
#[Route(path: '/preview/{host}/outil-banque', name: 'previewoutil_banque')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilBanque(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 7]);
return $this->render('tools/tools_banque.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-caisse', name: 'outil_caisse')]
#[Route(path: '/preview/{host}/outil-caisse', name: 'previewoutil_caisse')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilCaisse(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 19]);
return $this->render('tools/tools_caisse.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-creation', name: 'outil_creation')]
#[Route(path: '/preview/{host}/outil-creation', name: 'previewoutil_creation')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilCreation(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 20]);
return $this->render('tools/tools_creation.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-entretien-bilan', name: 'outil_entretien_bilan')]
#[Route(path: '/preview/{host}/outil-entretien-bilan', name: 'previewoutil_entretien_bilan')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilEntretienBilan(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 23]);
return $this->render('tools/tools_entretien_bilan.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-evaluation-entreprise', name: 'outil_evaluation_entreprise')]
#[Route(path: '/preview/{host}/outil-evaluation-entreprise', name: 'previewoutil_evaluation_entreprise')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilEvaluationEntreprise(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 24]);
return $this->render('tools/tools_evaluation_entreprise.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-facturation', name: 'outil_facturation')]
#[Route(path: '/preview/{host}/outil-facturation', name: 'previewoutil_facturation')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilFacturation(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 25]);
return $this->render('tools/tools_facturation.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-financement', name: 'outil_financement')]
#[Route(path: '/preview/{host}/outil-financement', name: 'previewoutil_financement')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilFinancement(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 26]);
return $this->render('tools/tools_financement.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-note-de-frais', name: 'outil_note_de_frais')]
#[Route(path: '/preview/{host}/outil-note-de-frais', name: 'previewoutil_note_de_frais')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilNoteDeFrais(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 27]);
return $this->render('tools/tools_note_de_frais.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-optimisation-financement-vehicule', name: 'outil_optimisation_financement_vehicule')]
#[Route(path: '/preview/{host}/outil-optimisation-financement-vehicule', name: 'previewoutil_optimisation_financement_vehicule')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilOptimisationFinancementVehicule(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 28]);
return $this->render('tools/tools_optimisation_financement_vehicule.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-optimisation-investissement-immo', name: 'outil_optimisation_investissement_immo')]
#[Route(path: '/preview/{host}/outil-optimisation-investissement-immo', name: 'previewoutil_optimisation_investissement_immo')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilOptimisationInvestissementImmo(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 29]);
return $this->render('tools/tools_optimisation_investissement_immo.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-suivi-gestion', name: 'outil_suivi_gestion')]
#[Route(path: '/preview/{host}/outil-suivi-gestion', name: 'previewoutil_suivi_gestion')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilSuiviGestion(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 30]);
return $this->render('tools/tools_suivi_gestion.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/outil-index', name: 'outil_index')]
#[Route(path: '/preview/{host}/outil-index', name: 'previewoutil_index')]
#[IsGranted('WEBSITE_TOOLS', statusCode: 404)]
public function OutilIndex(): Response
{
$entityManager = $this->getDoctrine()->getManager();
$seopageclient = new SeoPageClient();
$parameters = $this->accountingFirm->getParameters();
$seopage = $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 5]);
return $this->render('tools/tools_index.html.twig', ['seopage' => $seopage]);
}
#[Route(path: '/assets/{folder}/{filename}.{_format}', name: 'client_assets', requirements: ['folder' => '.+'])]
#[Route(path: '/preview/{host}/assets/{folder}/{filename}.{_format}', name: 'previewclient_assets', requirements: ['folder' => '.+'])]
public function assets(Request $request, string $folder, string $filename): BinaryFileResponse
{
$host = $this->accountingFirm->getHost();
$base = "clients\\" . $host . "\\assets";
if (!is_string($host)) {
throw new \LogicException('Parameter Host must be defined.');
}
$root = $request->server->get('DOCUMENT_ROOT');
$root = str_replace('public', '', $root);
if (substr($root, -1) != '/') {
$root .= "/";
}
$workspace = $root . $base;
$workspace = str_replace("\\", "/", $workspace);
$workspace = str_replace("//", "/", $workspace);
if (!is_dir($workspace)) {
throw new \LogicException('Workspace must be a directory: ' . $workspace);
}
$filePath = sprintf(
'%s\%s\%s',
$workspace,
$folder,
implode('.', [$filename, $request->getRequestFormat()])
);
$filePath = str_replace("\\", "/", $filePath);
$filePath = str_replace("//", "/", $filePath);
if (!file_exists($filePath)) {
throw $this->createNotFoundException();
}
$response = new BinaryFileResponse($filePath);
if (str_contains($request->getRequestFormat(), 'css') || str_contains($request->getRequestFormat(), 'scss')) {
$response->headers->set('Content-Type', 'text/css');
}
return $response;
}
#[Route(path: '/refresh-csrf-contact-creation-societe', name: 'refresh_csrf_contact_creation_societe')]
#[Route(path: '/preview/{host}/refresh-csrf-contact-creation-societe', name: 'previewrefresh_csrf_contact_creation_societe')]
public function refreshCsrfContactCreationSociete(CsrfTokenManagerInterface $csrfTokenManager)
{
$token = $csrfTokenManager->getToken('contact_creation_societe')->getValue();
return new JsonResponse([
'token' => $token
]);
}
#[Route(path: '/refresh-csrf-contact-previ-immo', name: 'refresh_csrf_contact_creation_previ_immo')]
#[Route(path: '/preview/{host}/refresh-csrf-contact-previ-immo', name: 'previewrefresh_csrf_contact_creation_previ_immo')]
public function refreshCsrfContactPreviImmo(CsrfTokenManagerInterface $csrfTokenManager)
{
$token = $csrfTokenManager->getToken('contact_investissement_immo')->getValue();
return new JsonResponse([
'token' => $token
]);
}
#[Route(path: '/qrcode/{id}', name: 'qrcode_index_redirect_client')]
#[Route(path: '/preview/{host}/qrcode/{id}', name: 'previewclient_qrcode_index_redirect_client')]
public function index_client(Qrcode $qrcode): RedirectResponse
{
return new RedirectResponse($qrcode->getUrl());
}
#[Route(path: '/video/{id}-{slug}', name: 'video_client')]
#[Route(path: '/preview/{host}/video/{id}-{slug}', name: 'previewoutil_video_client')]
public function ModuleVideo(moduleVideo $video, string $slug): Response
{
if (!$video || $video->getAccountingFirm() !== $this->accountingFirm) {
throw new NotFoundHttpException();
}
return $this->render('video/index.html.twig', ['video' => $video]);
}
#[Route(path: '/prescripteur/{id}', name: 'prescripteur_client')]
#[Route(path: '/preview/{host}/prescripteur/{id}', name: 'previewprescripteur_client')]
public function prescripteur(Prescriber $prescriber): Response
{
if (!$prescriber || $prescriber->getAccountingFirm() !== $this->accountingFirm) {
throw new NotFoundHttpException();
}
return $this->render('prescriber/index.html.twig', ['prescriber' => $prescriber]);
}
#[Route('/paiement/retour/{id}', name: 'monetico_return_client')]
#[Route('/preview/{host}/paiement/retour/{id}', name: 'previewmonetico_return_client')]
public function retourMonetico(Request $request, EntityManagerInterface $em, SendContactEmail $ce, string $id): Response
{
$contact = $em->getRepository(ContactCreationSociete::class)->findOneBy(['id' => $id]);
if (!$contact) {
$contact = $em->getRepository(ContactInvestissementImmo::class)->findOneBy(['id' => $id]);
}
$codeRetour = $request->get('code-retour'); // "Annulation", "payetest", "paiement"
if ($codeRetour == 'paiement') {
if ($contact instanceof ContactCreationSociete) {
$this->form_send_previ_creation = true;
$this->CE->sendPreviCreation($contact);
} elseif ($contact instanceof ContactInvestissementImmo) {
$this->form_send_previ_immo = true;
$this->CE->sendPreviImmo($contact);
}
}
if (!$contact) {
return new Response('Contact non trouvé', 404);
}
if ($contact->getStatus() === 'success') {
$this->form_send_previ_creation = true;
}
return $this->render('monetico-payement/return-payement.html.twig');
}
#[Route('/paiement/notification', name: 'monetico_notification', methods: ['POST'])]
#[Route('/preview/{host}/paiement/notification', name: 'previewmonetico_notification', methods: ['POST', 'GET'])]
public function notificationMonetico(Request $request, EntityManagerInterface $em, SendContactEmail $ce): Response
{
$logFile = '/data/www/prod/var/log/monetico.log';
// Petite fonction utilitaire pour écrire dans le log
$log = function (string $message) use ($logFile) {
$datetime = (new \DateTime())->format('Y-m-d H:i:s');
file_put_contents($logFile, "[$datetime] $message\n", FILE_APPEND);
};
$reference = $request->get('reference');
$code = $request->get('code-retour'); // "Annulation", "payetest", "paiement"
$log("Notification reçue - reference: $reference | code-retour: $code | method: " . $request->getMethod());
$contact = $em->getRepository(ContactCreationSociete::class)->findOneBy(['reference' => $reference]);
if ($contact) {
$log("Contact trouvé dans ContactCreationSociete (ID: {$contact->getId()})");
} else {
$contact = $em->getRepository(ContactInvestissementImmo::class)->findOneBy(['reference' => $reference]);
if ($contact) {
$log("Contact trouvé dans ContactInvestissementImmo (ID: {$contact->getId()})");
}
}
if (!$contact) {
$log("Aucun contact trouvé pour la référence $reference");
return new Response('Contact non trouvé', 404);
}
if ($code === 'paiement' || $code === 'payetest') {
$log("Paiement validé - envoi du mail");
// Paiement OK → on envoie le mail
if ($contact instanceof ContactCreationSociete) {
$ce->sendPreviCreation($contact);
$log("Email envoyé avec sendPreviCreation");
} elseif ($contact instanceof ContactInvestissementImmo) {
$ce->sendPreviImmo($contact);
$log("Email envoyé avec sendPreviImmo");
}
// Flag pour dire que le mail est déjà envoyé
$contact->setStatus("success");
$em->persist($contact);
$em->flush();
$log("Statut du contact mis à jour à 'success' et flush");
}
$log("Accusé de réception envoyé à Monetico");
return new Response("version=2\ncdr=0", 200, ['Content-Type' => 'text/plain']);
}
#[Route(path: '/{_prefix}{url}', name: 'client_tools_page', requirements: ['_prefix' => 'outil-'])]
#[Route(path: '/preview/{host}/{_prefix}{url}', name: 'previewclient_tools_page', requirements: ['_prefix' => 'outil-'])]
#[ParamConverter('page', options: ['mapping' => ['url' => 'url']])]
public function customToolsPage(SeoPageClient $page): Response
{
$entityManager = $this->getDoctrine()->getManager();
$parameters = $this->accountingFirm->getParameters();
$page = $entityManager->getRepository(SeoPageClient::class)->findOneBy([
'parameter_id' => $parameters->getId(),
'type' => 2, 'active' => 1, 'template' => $page->getTemplate(), 'url' => $page->getUrl()
]);
return $this->render($page->getTemplate(), ['accountingFirm' => $this->accountingFirm, 'seopage' => $page, 'cabinet' => $this->accountingFirm]);
}
#[Route(path: '/{uri}', name: 'client_custom_page')]
#[Route(path: '/preview/{host}/{uri}', name: 'previewclient_custom_page')]
public function customPage(Page $page, RedirectionClientRepository $redirectionClientRepository): Response
{
$entityManager = $this->getDoctrine()->getManager();
$parameters = $this->accountingFirm->getParameters();
$redirection = $redirectionClientRepository->findOneBy(['parameter' => $parameters->getId(), 'oldurl' => $page->getUri()]);
if ($redirection) {
return $this->redirect($redirection->getNewurl(), 301);
}
$page = $entityManager->getRepository(Page::class)->findOneBy(['parameter' => $parameters->getId(), 'template' => $page->getTemplate()]);
return $this->render($page->getTemplate(), ['page' => $page]);
}
}