src/Controller/FormationController.php line 80

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * @author Mehrez Labidi
  5.  */
  6. namespace App\Controller;
  7. use App\Services\MetaTag;
  8. use App\Helper\Utils;
  9. use App\Services\ManagerEntity\EvaluationsFormationsManagers;
  10. use App\Services\ManagerEntity\FormationsManager;
  11. use App\Services\PDFGenerator;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use App\Twig\TranslationExtension;
  14. use Symfony\Component\HttpFoundation\Request;
  15. class FormationController extends EntityUsingController {
  16.     public const MAX_AGE 43200// 12heures
  17.     public const REF_EXPERT = ["MOD34""MOD32""MOD01""MOD16""MOD35""MOD02""MOD01"];
  18.     /**
  19.      * @var \App\Services\PDFGenerator
  20.      */
  21.     private $pg;
  22.     /**
  23.      * @var \App\Services\ManagerEntity\EvaluationsFormationsManagers
  24.      */
  25.     private $efm;
  26.     /**
  27.      * @var FormationsManager
  28.      */
  29.     private $fm;
  30.     /**
  31.      * @var MetaTag
  32.      */
  33.     private $metaTag;
  34.     public function __construct(FormationsManager $fmPDFGenerator $pgEvaluationsFormationsManagers $efmMetaTag $metaTag) {
  35.         $this->fm $fm;
  36.         $this->pg $pg;
  37.         $this->efm $efm;
  38.         $this->metaTag $metaTag;
  39.     }
  40.     /**
  41.      * @throws \Exception
  42.      */
  43.     public function index(): Response {
  44.         $jrFormations array_slice($this->fm->getFormationJR(truenull10), 03);
  45.         $expertsFormations $this->fm->getFormationExpert(truenullnull);
  46.        $expertsFormations Utils::array_unique_multidiemension($expertsFormations);
  47.            
  48.         $repriseCommerceFormations array_slice($this->fm->getFormationRepriseCommerce(truetrue10), 03);
  49.         $croissanceExterneFormations array_slice($this->fm->getFormationCroissanceExterne(truenull10), 03);
  50.         $idRefFormations $this->fm->getIdRefTitreFormations();
  51.         return $this->render('formation/index.html.twig', [
  52.                     'controller_name' => 'FormationController',
  53.                     'jrFormations' => $jrFormations,
  54.                     'idRefFormations' => $idRefFormations,
  55.                     'expertsFormations' => $expertsFormations,
  56.                     'rcFormations' => $repriseCommerceFormations,
  57.                     'ceFormations' => $croissanceExterneFormations,
  58.         ]);
  59.     }
  60.     /**
  61.      * @param $idformation
  62.      * @param $date
  63.      * @return \Symfony\Component\HttpFoundation\Response
  64.      * @throws \Exception
  65.      */
  66.     public function detail(Request $requestTranslationExtension $translationExtension$idformation$date) {
  67.         if (!$idformation) {
  68.             throw $this->createNotFoundException('No Formation found for id ' $idformation);
  69.         }
  70.         $formation $this->fm->getFormationDetail($idformation);
  71.         $autresDates $this->fm->getAutresSession($formation['reference']);
  72.         if (!in_array($formation['reference'], ["JR1""JR2""JR3""CE1""CE2""CE3""PDC01""PDC02""PDC03"])) {// session expert seulement
  73.             $autresDates $this->fm->getAutresSessionExpert($formation['reference']);
  74.         }
  75.         $prochaineDates $this->fm->getProchaineDate($formation['reference']);
  76.         $currentDateSession = (Utils::isValidDate($date)) ? Utils::getDateObjectFromFUSACQDate($date) : NULL;
  77.         $formationsRelated $this->fm->getFormationsRelated($idformation);
  78.         $formation_expert = (bool) in_array($formation['reference'], self::REF_EXPERT);
  79.         if (in_array($formation['reference'], ["JR1""JR2""JR3"])) {
  80.             $metaTitle 'formation à la reprise d\'entreprise - devenez un repreneur opérationnel en trois jours';
  81.             $metaDescription 'formation à la reprise d\'entreprise - devenez un repreneur opérationnel en trois jours';
  82.         } elseif (in_array($formation['reference'], ["CE1""CE2""CE3"])) {
  83.             $metaTitle 'formation à la croissance externe - réussir votre opération de croissance externe';
  84.             $metaDescription 'formation à la croissance externe - réussir votre opération de croissance externe';
  85.         } elseif (in_array($formation['reference'], ["PDC01""PDC02""PDC03"])) {
  86.             $metaTitle 'formation à la reprise de commerce - 3 jours pour comprendre comment';
  87.             $metaDescription 'formation à la reprise de commerce - 3 jours pour comprendre comment';
  88.         } elseif (in_array($formation['reference'], self::REF_EXPERT)) {
  89.             $metaTitle 'formations "Expert" - savoir lire et analyser un Bilan et un Compte de résultat, sur 2 jours';
  90.             $metaDescription 'Formations "Expert" - savoir lire et analyser un Bilan et un Compte de résultat, sur 2 jours';
  91.         } else {
  92.             $metaTitle 'formation à la reprise d\'entreprise, et formations pour les experts en fusions-acquisitions';
  93.             $metaDescription 'Participez à nos formation à la reprise d\'entreprise et formations pour les experts en fusions-acquisitions';
  94.         }
  95.         $lang $request->getSession()->get('lang');
  96.         $metaTag $this->metaTag
  97.                 ->setTitle($translationExtension->translate($metaTitle$lang"""M"""))
  98.                 ->setDescription($translationExtension->translate($metaDescription$lang"""M"""));
  99.         return $this->render('formation/detail.html.twig', [
  100.                     'metaTag' => $metaTag,
  101.                     'controller_name' => 'FormationController',
  102.                     'formation' => $formation"formation_expert" => $formation_expert,
  103.                     'prochaineDates' => $prochaineDates'formationsRelated' => $formationsRelated,
  104.                     'autresDates' => $autresDates,
  105.                     'currentDateSession' => $currentDateSession,
  106.         ]);
  107.     }
  108.     /**
  109.      * @param $idformation
  110.      */
  111.     public function downloadProgram($idformation) {
  112.         if (!$idformation) {
  113.             throw $this->createNotFoundException('No Formation found for id ' $idformation);
  114.         }
  115.         $url $this->fm->getUrlProgram($idformation);
  116.         if (!$url) {
  117.             throw $this->createNotFoundException('No program found for id ' $url);
  118.         }
  119.         return $this->pg->displayPDFByURL($url);
  120.     }
  121.     /**
  122.      * @return \Symfony\Component\HttpFoundation\Response
  123.      */
  124.     public function financements() {
  125.         $response $this->render('formation/financements.html.twig',
  126.                 ['controller_name' => 'FormationController']
  127.         );
  128.         $response->setPublic();
  129.         $response->setMaxAge(self::MAX_AGE); // 12heures
  130.         return $response;
  131.     }
  132.     /**
  133.      * @return Response
  134.      */
  135.     public function detailFinancements(): Response {
  136.         $response $this->render('formation/detail_financements.html.twig',
  137.                 ['controller_name' => 'FormationController']
  138.         );
  139.         $response->setPublic();
  140.         $response->setMaxAge(self::MAX_AGE); // 12heures
  141.         return $response;
  142.     }
  143.     /**
  144.      * @param $idformation
  145.      * @param $date
  146.      */
  147.     public function evaluations(Request $requestTranslationExtension $translationExtension$idformation$reference): Response {
  148.         if (!$idformation) {
  149.             throw $this->createNotFoundException('No Formation found for id ' $idformation);
  150.         }
  151.         $evaluations $this->efm->getEvaluationsByRefFormation($referencenull);
  152.         $formation $this->fm->getFormationDetail($idformation);
  153.         $autresDates $this->fm->getAutresSession($formation['reference']);
  154.         $prochaineDates $this->fm->getProchaineDate($formation['reference']);
  155.         $formationsRelated $this->fm->getFormationsRelated($idformation);
  156.         $formation_expert = (bool) in_array($formation['reference'], self::REF_EXPERT);
  157.         if (in_array($formation['reference'], ["JR1""JR2""JR3"])) {
  158.             $metaTitle 'évaluation de la formation à la reprise d\'entreprise - devenez un repreneur opérationnel en trois jours';
  159.             $metaDescription 'consultez les évaluations de la formation à la reprise d\'entreprise - devenez un repreneur opérationnel en trois jours';
  160.         } elseif (in_array($formation['reference'], ["CE1""CE2""CE3"])) {
  161.             $metaTitle 'évaluation des formation à la croissance externe - réussir votre opération de croissance externe';
  162.             $metaDescription 'consultez les évaluations des formation à la croissance externe - réussir votre opération de croissance externe';
  163.         } elseif (in_array($formation['reference'], ["PDC01""PDC02""PDC03"])) {
  164.             $metaTitle 'évaluation des formation à la reprise de commerce - 3 jours pour comprendre comment';
  165.             $metaDescription 'consultez les évaluations des formation à la reprise de commerce - 3 jours pour comprendre comment';
  166.         } elseif (in_array($formation['reference'], self::REF_EXPERT)) {
  167.             $metaTitle 'évaluation des formations "Expert" - savoir lire et analyser un Bilan et un Compte de résultat, sur 2 jours';
  168.             $metaDescription 'consultez les évaluations des Formations "Expert" - savoir lire et analyser un Bilan et un Compte de résultat, sur 2 jours';
  169.         } else {
  170.             $metaTitle 'formation à la reprise d\'entreprise, et formations pour les experts en fusions-acquisitions';
  171.             $metaDescription 'Participez à nos formation à la reprise d\'entreprise et formations pour les experts en fusions-acquisitions';
  172.         }
  173.         $lang $request->getSession()->get('lang');
  174.         $metaTag $this->metaTag
  175.                 ->setTitle($translationExtension->translate($metaTitle$lang"""M"""))
  176.                 ->setDescription($translationExtension->translate($metaDescription$lang"""M"""));
  177.         return $this->render('formation/evaluations.html.twig', [
  178.                     'metaTag' => $metaTag,
  179.                     'controller_name' => 'FormationController',
  180.                     'evaluations' => $evaluations"formation_expert" => $formation_expert,
  181.                     'formation' => $formation,
  182.                     'prochaineDates' => $prochaineDates'formationsRelated' => $formationsRelated,
  183.                     'autresDates' => $autresDates,
  184.         ]);
  185.     }
  186.     public function listeFormationsExpert(): Response {
  187.         $formationsAll $this->fm->getFormationExpert();
  188.         $formationsPrecis array_filter($formationsAll, fn($item) => ($item["date_formation"] != "A venir"));
  189.         $formationsAvenir array_filter($formationsAll, fn($item) => ( $item["date_formation"] == "A venir"));
  190.         $formations array_merge($formationsPrecis$formationsAvenir);
  191.         $listRef = [];
  192.         foreach ($formations as $key => $value) {
  193.             $listRef[] = $value["reference"];
  194.             if ($value["date_formation"] == "A venir" && in_array($value["reference"], $listRef)) {
  195.                 // unset($formations[$key]);
  196.             }
  197.         }
  198.      
  199.  
  200.         $formations Utils::array_unique_multidiemension($formations);
  201.         $metaTag $this->metaTag
  202.                 ->setTitle("Formations à Transmission d'entreprise pour les professionnels")
  203.                 ->setDescription("Formations à Transmission d'entreprise pour les professionnels");
  204.         return $this->render('formation/liste_formations_expert.html.twig', [
  205.                     'controller_name' => 'FormationController''formations' => $formations,
  206.                     'metaTag' => $metaTag,
  207.         ]);
  208.     }
  209.     /**
  210.      * 
  211.      * @param Request $request
  212.      * @param type $codePays
  213.      * @return Response
  214.      */
  215.     public function temoignagesFormation(Request $request$codePays): Response {
  216.         $filters $request->query->all();
  217.         $temoignages $this->fm->getTemoignagesFormation($filters);
  218.         $rangesDates range(date("Y"), date("Y") - 5);
  219.         $response $this->render('formation/temoignages_formation.html.twig',
  220.                 [
  221.                     'controller_name' => 'FormationController',
  222.                     'temoignages' => $temoignages"rangesDates" => $rangesDates
  223.                 ]
  224.         );
  225.         $response->setPublic();
  226.         $response->setMaxAge(self::MAX_AGE); // 12heures
  227.         return $response;
  228.     }
  229. }