src/Controller/DetailClassementController.php line 62

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Services\BuzzActualiteService;
  4. use Doctrine\Common\Collections\Criteria;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use App\Entity\BuzzOperations;
  11. use App\Entity\BuzzRoles;
  12. use App\Entity\BuzzActualites;
  13. use App\Entity\BuzzTypesRoles;
  14. use App\Entity\ServicesPrestataire;
  15. use App\Entity\Localisations;
  16. use App\Services\Util;
  17. use App\Entity\CoordonneesServicePrestataire;
  18. use App\Services\{
  19.     PaysAnnuaireExperts,
  20.     TelephoneInternational
  21. };
  22. use App\Services\ManagerEntity\{
  23.     ServicesPrestataireManagers
  24. };
  25. class DetailClassementController extends AbstractController
  26. {
  27.     /**
  28.      * @var EntityManagerInterface
  29.      */
  30.     public $em;
  31.     /**
  32.      * @var BuzzActualiteService
  33.      */
  34.     public $buzzService;
  35.     // états (inchangés)
  36.     public $raison_sociale;
  37.     public $id_societe_prestataire;
  38.     public $type_operation;
  39.     public $type_role;
  40.     public $annee_operation;
  41.     public $id_localisation;
  42.     public $segment;
  43.     public $tri;
  44.     public $conseil_banque_type_role_liste = ["5","8","11","14","17"];
  45.     public $avocat_affaire_type_role_liste  = ["6","9","12","15","18"];
  46.     public $cabinet_audit_type_role_liste   = ["7","10","13","16","19"];
  47.     /**
  48.      * @var TelephoneInternational
  49.      */
  50.     public $ti;
  51.     public function __construct(BuzzActualiteService $buzzService,EntityManagerInterface $emTelephoneInternational $tiServicesPrestataireManagers $spm)
  52.     {
  53.         $this->em $em;
  54.         $this->buzzService $buzzService;
  55.         $this->ti $ti;
  56.         $this->spm $spm;
  57.     }
  58.     public function detailclassementitemsociete(Request $requeststring $params): Response
  59.     {
  60.         // ====== récupération des paramètres (identique à ZF2) ======
  61.         $liste_id_operation = [];
  62.         $liste_operation    = [];
  63.         $params ltrim($params'-');
  64.         $parts explode(','$params);
  65.         $result = [
  66.             'nom'          => $parts[0] ?? null,
  67.             'id'           => $parts[1] ?? null,
  68.             'structure'    => $parts[2] ?? null,
  69.             'prestation'   => $parts[3] ?? null,
  70.             'annee'        => $parts[4] ?? null,
  71.             'localisation' => $parts[5] ?? null,
  72.             'segment'      => $parts[6] ?? null,
  73.             'rank'         => $parts[7] ?? null,
  74.             'tri'          => $parts[8] ?? null,
  75.         ];
  76.         $this->raison_sociale        $result["nom"];
  77.         $this->id_societe_prestataire $result["id"];
  78.         $this->type_operation        $result["prestation"];
  79.         $this->type_role             $result["structure"];
  80.         $this->annee_operation       = ($result["annee"] === "") ? $this->get_annee_defaut() : $result["annee"];
  81.         $lien_retour_loc $result["localisation"];
  82.         $rankParam       $result["rank"];
  83.         if ($result["localisation"] !== null && $result["localisation"] !== "") {
  84.             $this->id_localisation $result["localisation"];
  85.         } else {
  86.             $this->id_localisation "33";
  87.         }
  88.         $liste_loc $this->get_liste_localisation();
  89.         $nom_loc   $liste_loc[$this->id_localisation] ?? '';
  90.         if ($this->id_localisation === "00") {
  91.             $this->id_localisation "";
  92.         }
  93.         $this->segment = ($result["segment"] === "") ? $this->get_segment_defaut() : $result["segment"];
  94.         $this->tri     = ($result["tri"] === "") ? $result["tri"];
  95.         // ====== liste actualités (identique) ======
  96.         $actualites $this->get_actualites($this->id_societe_prestataire$this->annee_operation'S');
  97.         // mapping rôle => type pour lien retour (identique)
  98.         if ($this->type_role == "banques_affaires") {
  99.             $parametre_type_role $this->conseil_banque_type_role_liste;
  100.             $lien_retour_type    "banques-affaires-conseils";
  101.         } elseif ($this->type_role == "avocats_affaires") {
  102.             $parametre_type_role $this->avocat_affaire_type_role_liste;
  103.             $lien_retour_type    "avocats-affaires";
  104.         } elseif ($this->type_role == "cabinets_audit") {
  105.             $parametre_type_role $this->cabinet_audit_type_role_liste;
  106.             $lien_retour_type    "cabinets-audit";
  107.         } else {
  108.             $parametre_type_role = [];
  109.             $lien_retour_type    "";
  110.         }
  111.         $lien_retour_oper "";
  112.         if ($this->type_operation == "fusion_acquisition") {
  113.             $lien_retour_oper "fusions-acquisitions";
  114.         } elseif ($this->type_operation == "levee_fonds") {
  115.             $lien_retour_oper "levees-de-fonds";
  116.         } elseif ($this->type_operation == "tous") {
  117.             $lien_retour_oper "tous";
  118.         }
  119.         $str_lien_retour $lien_retour_type '-' $lien_retour_oper '-' $this->annee_operation ',' $lien_retour_loc ',' $this->segment ',' $this->tri;
  120.         // ====== boucle identique sur les actualités / opérations ======
  121.         foreach ($actualites as $actualite) {
  122.             if ($actualite instanceof BuzzActualites) {
  123.                 $operation $actualite->_get("id_operation");
  124.                 $operation $this->em->getRepository(BuzzOperations::class)->find($operation);
  125.                 if ($operation instanceof BuzzOperations) {
  126.                     $id_op $operation->_get("id_operation");
  127.                     if (!in_array($id_op$liste_id_operation)) {
  128.                         $type_oper $operation->_get("type_operation");
  129.                         $date_oper $operation->_get("date_operation");
  130.                         $id_loc    $operation->_get("id_localisation");
  131.                         $id_loc2   $operation->_get("id_localisation_2");
  132.                         if ($this->type_operation == BuzzOperations::TYPE_OPERATION_TOUS) {
  133.                             if (
  134.                                 ($type_oper == BuzzOperations::TYPE_OPERATION_LEVEE_FONDS ||
  135.                                  $type_oper == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) &&
  136.                                 substr($date_oper04) == $this->annee_operation &&
  137.                                 $actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
  138.                                 (substr($id_loc20strlen($this->id_localisation)) == $this->id_localisation ||
  139.                                  substr($id_loc0strlen($this->id_localisation)) == $this->id_localisation)
  140.                             ) {
  141.                                 $flag false;
  142.                                 $roles $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
  143.                                 foreach ($roles as $buzz_role) {
  144.                                     if ($buzz_role instanceof BuzzRoles) {
  145.                                         $id_type_role $buzz_role->_get("id_type_role");
  146.                                         if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  147.                                             $flag true;
  148.                                         }
  149.                                     }
  150.                                 }
  151.                                 if ($flag) {
  152.                                     $operation->_set("titre_operation"$actualite->_get("titre_actualite"));
  153.                                     $operation->_set("id_actualite_principale"$actualite->_get("id_actualite"));
  154.                                     $operation->_set("autorisation_blog"$actualite->_get("autorisation_blog"));
  155.                                     if ($type_oper == "fusion_acquisition") {
  156.                                         $montant_seuil $this->buzzService->get_seuil_max_min($this->segment); // <-- service
  157.                                         $temp_ca $operation->_get("ca_societe_achetee") ?? 0;
  158.                                         $fourchette_ca $operation->_get("fourchette_ca") ?? 0;
  159.                                         if (
  160.                                             ($temp_ca != && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
  161.                                             || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  162.                                             || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)
  163.                                         ) {
  164.                                             if ($operation->_get("maj_min_capital") == "0") {
  165.                                                 $tempMontant $operation->_get("ca_societe_achetee");
  166.                                                 $pct         $operation->_get("pct_capital_achete");
  167.                                                 $montant     $tempMontant $pct 100;
  168.                                                 $operation->__set("ca_societe_achetee"round($montant0PHP_ROUND_HALF_DOWN));
  169.                                             }
  170.                                             $liste_id_operation[] = $id_op;
  171.                                             $liste_operation[]    = $operation;
  172.                                         }
  173.                                     } else {
  174.                                         $liste_id_operation[] = $id_op;
  175.                                         $liste_operation[]    = $operation;
  176.                                     }
  177.                                 }
  178.                             }
  179.                         } else {
  180.                             if (
  181.                                 $type_oper == $this->type_operation &&
  182.                                 substr($date_oper04) == $this->annee_operation &&
  183.                                 $actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
  184.                                 (substr($id_loc0strlen($this->id_localisation)) == $this->id_localisation ||
  185.                                  substr($id_loc20strlen($this->id_localisation)) == $this->id_localisation)
  186.                             ) {
  187.                                 $flag false;
  188.                                 $roles $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
  189.                                 foreach ($roles as $buzz_role) {
  190.                                     if ($buzz_role instanceof BuzzRoles) {
  191.                                         $id_type_role $buzz_role->_get("id_type_role");
  192.                                         if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  193.                                             $flag true;
  194.                                         }
  195.                                     }
  196.                                 }
  197.                                 if ($flag) {
  198.                                     $operation->_set("titre_operation"$actualite->_get("titre_actualite"));
  199.                                     $operation->_set("id_actualite_principale"$actualite->_get("id_actualite"));
  200.                                     $operation->_set("autorisation_blog"$actualite->_get("autorisation_blog"));
  201.                                     if ($this->type_operation == "fusion_acquisition") {
  202.                                         $montant_seuil $this->buzzService->get_seuil_max_min($this->segment); // <-- service
  203.                                         $temp_ca $operation->_get("ca_societe_achetee") ?? 0;
  204.                                         $fourchette_ca $operation->_get("fourchette_ca") ?? 0;
  205.                                         if (
  206.                                             ($temp_ca != && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
  207.                                             || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  208.                                             || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)
  209.                                         ) {
  210.                                             if ($operation->_get("maj_min_capital") == "0") {
  211.                                                 $tempMontant $operation->_get("ca_societe_achetee");
  212.                                                 $pct         $operation->_get("pct_capital_achete");
  213.                                                 $montant     $tempMontant $pct 100;
  214.                                                 $operation->__set("ca_societe_achetee"round($montant0PHP_ROUND_HALF_DOWN));
  215.                                             }
  216.                                             $liste_id_operation[] = $id_op;
  217.                                             $liste_operation[]    = $operation;
  218.                                         }
  219.                                     } else {
  220.                                         $liste_id_operation[] = $id_op;
  221.                                         $liste_operation[]    = $operation;
  222.                                     }
  223.                                 }
  224.                             }
  225.                         }
  226.                     }
  227.                 }
  228.             }
  229.         }
  230.         // tri identique par date_operation DESC
  231.         usort($liste_operation, function ($a$b) {
  232.             return $b->_get("date_operation") - $a->_get("date_operation");
  233.         });
  234.         // données "fiche"
  235.         $societe             $this->get_societe_par_id($this->id_societe_prestataire);
  236.         $service_prestataire $this->get_services_prestataire_pour_societe($this->id_societe_prestataire);
  237.         $coordonnees_societe $this->get_coordonnee_service_prestataire($service_prestataire->_get("id_service_prestataire"));
  238.         $buzz_type_role      $this->get_roles_par_societe($this->id_societe_prestataire$liste_id_operation);
  239.         $util = new Util();
  240.         // lien site identique
  241.         if ($service_prestataire->_get('url_site_web') != "") {
  242.             $lien_shrinktheweb $service_prestataire->_get('url_site_web');
  243.         } elseif ($service_prestataire->_get('url_site_web_visible') != "") {
  244.             $lien_shrinktheweb $service_prestataire->_get('url_site_web_visible');
  245.         } else {
  246.             $lien_shrinktheweb "www.fusacq.com";
  247.         }
  248.         $prestation = (!empty($service_prestataire)&&!empty($service_prestataire->_get("id_service_prestataire")))? $this->spm->getDetailServicesPrestataireById($service_prestataire->_get("id_service_prestataire"), $this->ti):[];
  249.         
  250.         // rendu Twig (équivalent de ViewModel->setVariables)
  251.         return $this->render('classement/detail_societe.html.twig', [
  252.             "type_operation"     => $this->type_operation,
  253.             "annee_operation"    => $this->annee_operation,
  254.             "rank"               => $rankParam,
  255.             "lien_expert"        => 'https://www.fusacq.com' '/activite-' $service_prestataire->_get("id_service_prestataire") . ',' $util->reecriture_pour_url($service_prestataire->_get("titre_service"), "-"),
  256.             "lien_shrinktheweb"  => $lien_shrinktheweb,
  257.             "class"              => $liste_operation,
  258.             "societe"            => $societe,
  259.             "service_prestataire"=> $service_prestataire,
  260.             "coordonnees"        => $coordonnees_societe,
  261.             "buzz_type_role"     => $buzz_type_role,
  262.             "liste_type_role"    => $this->get_tous_types_roles(),
  263.             "str_lien_retour"    => $str_lien_retour,
  264.             "segment"            => $this->segment,
  265.             "type_role"          => $this->type_role,
  266.             "nom_loc"            => $nom_loc,
  267.             "prestation"        =>$prestation
  268.         ]);
  269.     }
  270.     // =========================
  271.     // DÉTAIL RÉSEAU
  272.     // =========================
  273.     public function detailclassementitemreseau(Request $requeststring $params): Response
  274.     {
  275.         $liste_id_operation = [];
  276.         $liste_operation    = [];
  277.         $indexNonAutorisation 0;
  278.         $params ltrim($params'-');
  279.         $parts explode(','$params);
  280.         $result = [
  281.             'nom'          => $parts[0] ?? null,
  282.             'id'           => $parts[1] ?? null,
  283.             'structure'    => $parts[2] ?? null,
  284.             'prestation'   => $parts[3] ?? null,
  285.             'annee'        => $parts[4] ?? null,
  286.             'localisation' => $parts[5] ?? null,
  287.             'segment'      => $parts[6] ?? null,
  288.             'rank'         => $parts[7] ?? null,
  289.             'tri'          => $parts[8] ?? null,
  290.         ];
  291.         $this->raison_sociale        $result["nom"];
  292.         $this->id_societe_prestataire $result["id"];
  293.         $this->type_operation        $result["prestation"];
  294.         $this->type_role             $result["structure"];
  295.         $this->annee_operation       = ($result["annee"] === "") ? $this->get_annee_defaut() : $result["annee"];
  296.         $lien_retour_loc $result["localisation"];
  297.         $rankParam       $result["rank"];
  298.         if ($result["localisation"] !== null && $result["localisation"] !== "") {
  299.             $this->id_localisation $result["localisation"];
  300.         } else {
  301.             $this->id_localisation "33";
  302.         }
  303.         $liste_loc $this->get_liste_localisation();
  304.         $nom_loc   $liste_loc[$this->id_localisation] ?? '';
  305.         if ($this->id_localisation === "00") {
  306.             $this->id_localisation "";
  307.         }
  308.         $this->segment = ($result["segment"] === "") ? $this->get_segment_defaut() : $result["segment"];
  309.         $this->tri     = ($result["tri"] === "") ? $result["tri"];
  310.         $actualites $this->get_actualites($this->id_societe_prestataire$this->annee_operation'R');
  311.         if ($this->type_role == "banques_affaires") {
  312.             $parametre_type_role $this->conseil_banque_type_role_liste;
  313.             $lien_retour_type    "banques-affaires-conseils";
  314.         } elseif ($this->type_role == "avocats_affaires") {
  315.             $parametre_type_role $this->avocat_affaire_type_role_liste;
  316.             $lien_retour_type    "avocats-affaires";
  317.         } elseif ($this->type_role == "cabinets_audit") {
  318.             $parametre_type_role $this->cabinet_audit_type_role_liste;
  319.             $lien_retour_type    "cabinets-audit";
  320.         } else {
  321.             $parametre_type_role = [];
  322.             $lien_retour_type    "";
  323.         }
  324.         $lien_retour_oper "";
  325.         if ($this->type_operation == "fusion_acquisition") {
  326.             $lien_retour_oper "fusions-acquisitions";
  327.         } elseif ($this->type_operation == 'levee_fonds') {
  328.             $lien_retour_oper "levees-de-fonds";
  329.         } elseif ($this->type_operation == "tous") {
  330.             $lien_retour_oper "tous";
  331.         }
  332.         $str_lien_retour $lien_retour_type '-' $lien_retour_oper '-' $this->annee_operation ',' $lien_retour_loc ',' $this->segment ',' $this->tri;
  333.         foreach ($actualites as $actualite) {
  334.             if ($actualite instanceof BuzzActualites) {
  335.                 $operation $actualite->_get("id_operation");
  336.                 $operation $this->em->getRepository(BuzzOperations::class)->find($operation);
  337.                 if ($operation instanceof BuzzOperations) {
  338.                     $id_op $operation->_get("id_operation");
  339.                     if (!in_array($id_op$liste_id_operation)) {
  340.                         $type_oper $operation->_get("type_operation");
  341.                         $date_oper $operation->_get("date_operation");
  342.                         $id_loc    $operation->_get("id_localisation");
  343.                         $id_loc2   $operation->_get("id_localisation_2");
  344.                         if ($this->type_operation == BuzzOperations::TYPE_OPERATION_TOUS) {
  345.                             if (
  346.                                 ($type_oper == BuzzOperations::TYPE_OPERATION_LEVEE_FONDS ||
  347.                                  $type_oper == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) &&
  348.                                 substr($date_oper04) == $this->annee_operation &&
  349.                                 $actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
  350.                                 (substr($id_loc0strlen($this->id_localisation)) == $this->id_localisation ||
  351.                                  substr($id_loc20strlen($this->id_localisation)) == $this->id_localisation)
  352.                             ) {
  353.                                 $flag false;
  354.                                 $roles $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
  355.                                 foreach ($roles as $buzz_role) {
  356.                                     if ($buzz_role instanceof BuzzRoles) {
  357.                                         $id_type_role $buzz_role->_get("id_type_role");
  358.                                         if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  359.                                             $flag true;
  360.                                         }
  361.                                     }
  362.                                 }
  363.                                 if ($flag) {
  364.                                     $operation->_set("titre_operation"$actualite->_get("titre_actualite"));
  365.                                     $operation->_set("id_actualite_principale"$actualite->_get("id_actualite"));
  366.                                     $operation->_set("autorisation_blog"$actualite->_get("autorisation_blog"));
  367.                                     if ($operation->_get("autorisation_blog") == "non") {
  368.                                         $indexNonAutorisation++;
  369.                                     }
  370.                                     if ($type_oper == "fusion_acquisition") {
  371.                                         $montant_seuil $this->buzzService->get_seuil_max_min($this->segment); // <-- service
  372.                                         $temp_ca $operation->_get("ca_societe_achetee") ?? 0;
  373.                                         $fourchette_ca $operation->_get("fourchette_ca") ?? 0;
  374.                                         if (
  375.                                             ($temp_ca != && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
  376.                                             || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  377.                                             || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)
  378.                                         ) {
  379.                                             if ($operation->_get("maj_min_capital") == "0") {
  380.                                                 $tempMontant $operation->_get("ca_societe_achetee");
  381.                                                 $pct         $operation->_get("pct_capital_achete");
  382.                                                 $montant     $tempMontant $pct 100;
  383.                                                 $operation->__set("ca_societe_achetee"round($montant0PHP_ROUND_HALF_DOWN));
  384.                                             }
  385.                                             $liste_id_operation[] = $id_op;
  386.                                             $liste_operation[]    = $operation;
  387.                                         }
  388.                                     } else {
  389.                                         $liste_id_operation[] = $id_op;
  390.                                         $liste_operation[]    = $operation;
  391.                                     }
  392.                                 }
  393.                             }
  394.                         } else {
  395.                             if (
  396.                                 $type_oper == $this->type_operation &&
  397.                                 substr($date_oper04) == $this->annee_operation &&
  398.                                 $actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
  399.                                 (substr($id_loc0strlen($this->id_localisation)) == $this->id_localisation ||
  400.                                  substr($id_loc20strlen($this->id_localisation)) == $this->id_localisation)
  401.                             ) {
  402.                                 $flag false;
  403.                                 $roles $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
  404.                                 foreach ($roles as $buzz_role) {
  405.                                     if ($buzz_role instanceof BuzzRoles) {
  406.                                         $id_type_role $buzz_role->_get("id_type_role");
  407.                                         if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  408.                                             $flag true;
  409.                                         }
  410.                                     }
  411.                                 }
  412.                                 if ($flag) {
  413.                                     $operation->_set("titre_operation"$actualite->_get("titre_actualite"));
  414.                                     $operation->_set("id_actualite_principale"$actualite->_get("id_actualite"));
  415.                                     $operation->_set("autorisation_blog"$actualite->_get("autorisation_blog"));
  416.                                     if ($operation->_get("autorisation_blog") == "non") {
  417.                                         $indexNonAutorisation++;
  418.                                     }
  419.                                     if ($this->type_operation == "fusion_acquisition") {
  420.                                         $montant_seuil $this->buzzService->get_seuil_max_min($this->segment); // <-- service
  421.                                         $temp_ca $operation->_get("ca_societe_achetee") ?? 0;
  422.                                         $fourchette_ca $operation->_get("fourchette_ca") ?? 0;
  423.                                         if (
  424.                                             ($temp_ca != && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
  425.                                             || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  426.                                             || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)
  427.                                         ) {
  428.                                             if ($operation->_get("maj_min_capital") == "0") {
  429.                                                 $tempMontant $operation->_get("ca_societe_achetee");
  430.                                                 $pct         $operation->_get("pct_capital_achete");
  431.                                                 $montant     $tempMontant $pct 100;
  432.                                                 $operation->_set("ca_societe_achetee"round($montant0PHP_ROUND_HALF_DOWN));
  433.                                             }
  434.                                             $liste_id_operation[] = $id_op;
  435.                                             $liste_operation[]    = $operation;
  436.                                         }
  437.                                     } else {
  438.                                         $liste_id_operation[] = $id_op;
  439.                                         $liste_operation[]    = $operation;
  440.                                     }
  441.                                 }
  442.                             }
  443.                         }
  444.                     }
  445.                 }
  446.             }
  447.         }
  448.         usort($liste_operation, function ($a$b) {
  449.             return $b->_get("date_operation") - $a->_get("date_operation");
  450.         });
  451.         $reseau $this->get_reseaux_par_id($this->id_societe_prestataire);
  452.         $service_prestataire $this->get_services_prestataire_par_id($reseau->__get("id_service_prestataire"));
  453.         $coordonnees_reseau  $this->get_coordonnee_service_prestataire($reseau->__get("id_service_prestataire"));
  454.         if ($reseau->__get("id_service_prestataire") == "") {
  455.             $service_prestataire $this->get_service_prestataire_pour_reseau($reseau->__get("id_reseau"));
  456.             $coordonnees_reseau  = new CoordonneesServicePrestataire();
  457.             $coordonnees_reseau->_set("adresse",      $reseau->__get('adresse'));
  458.             $coordonnees_reseau->_set("code_postal",  $reseau->__get('code_postal'));
  459.             $coordonnees_reseau->_set("ville",        $reseau->__get('ville'));
  460.             $coordonnees_reseau->_set("telephone",    $reseau->__get('telephone'));
  461.             $coordonnees_reseau->_set("nom_contact1"$reseau->__get('contact'));
  462.         }
  463.         $buzz_type_role $this->get_roles_par_reseau($this->id_societe_prestataire$liste_id_operation);
  464.         $util = new Util();
  465.         $liste_membres_reseaux $this->get_membres_reseaux($reseau->__get("id_reseau"));
  466.         $liste_membres = [];
  467.         $nom_commercial_societe = [];
  468.         foreach ($liste_membres_reseaux as $membre_reseau) {
  469.             $membre = [];
  470.             if (!in_array($membre_reseau->_get("nom_commercial_societe"), $nom_commercial_societe)) {
  471.                 $membre["nom_commercial_societe"] = $membre_reseau->_get("nom_commercial_societe");
  472.                 $membre["lien"] = 'https://www.fusacq.com' '/activite-' $membre_reseau->_get("id_service_prestataire") . ',' $util->reecriture_pour_url($membre_reseau->_get("titre_service"), "-");
  473.                 $liste_membres[] = $membre;
  474.                 $nom_commercial_societe[] = $membre["nom_commercial_societe"];
  475.             }
  476.         }
  477.         usort($liste_membres, function ($a$b) {
  478.             return strcasecmp($a['nom_commercial_societe'], $b['nom_commercial_societe']);
  479.         });
  480.         if ($service_prestataire->_get('url_site_web') != "") {
  481.             $lien_shrinktheweb $service_prestataire->_get('url_site_web');
  482.         } elseif ($service_prestataire->_get('url_site_web_visible') != "") {
  483.             $lien_shrinktheweb $service_prestataire->_get('url_site_web_visible');
  484.         } else {
  485.             $lien_shrinktheweb "www.fusacq.com";
  486.         }
  487.         $prestation = (!empty($service_prestataire))? $this->spm->getDetailServicesPrestataireById($service_prestataire->_get("id_service_prestataire"), $this->ti):[];
  488.         return $this->render('classement/detail_reseau.html.twig', [
  489.             "indexNonAutorisation" => $indexNonAutorisation,
  490.             "type_operation"       => $this->type_operation,
  491.             "annee_operation"      => $this->annee_operation,
  492.             "rank"                 => $rankParam,
  493.             "lien_expert"          => 'https://www.fusacq.com/activite-' $service_prestataire->_get("id_service_prestataire") . ',' $util->reecriture_pour_url($service_prestataire->_get("titre_service"), "-"),
  494.             "lien_shrinktheweb"    => $lien_shrinktheweb,
  495.             "class"                => $liste_operation,
  496.             "reseau"               => $reseau,
  497.             "service_prestataire"  => $service_prestataire,
  498.             "coordonnees"          => $coordonnees_reseau,
  499.             "buzz_type_role"       => $buzz_type_role,
  500.             "liste_type_role"      => $this->get_tous_types_roles(),
  501.             "str_lien_retour"      => $str_lien_retour,
  502.             "segment"              => $this->segment,
  503.             "type_role"            => $this->type_role,
  504.             "nom_loc"              => $nom_loc,
  505.             "liste_membres_reseaux"=> $liste_membres,
  506.             "prestation"        =>$prestation
  507.         ]);
  508.     }
  509.     // =========================
  510.     // Méthodes privées = copie conforme logique ZF2
  511.     // =========================
  512.     private function get_actualites($id_societe$annee$type)
  513.     {
  514.         $annee_avant_str $annee '0101000000';
  515.         $annee_apres $annee 1;
  516.         if ($annee == '2019') {
  517.             $annee_apres_str $annee_apres '0206235959';
  518.         } elseif ($annee == '2020') {
  519.             $annee_apres_str $annee_apres '0204235959';
  520.         } elseif ($annee == '2021') {
  521.             $annee_apres_str $annee_apres '0203235959';
  522.         } elseif ($annee == '2022') {
  523.             $annee_apres_str $annee_apres '0209235959';
  524.         } elseif ($annee == '2023') {
  525.             $annee_apres_str $annee_apres '0208235959';
  526.         } elseif ($annee == '2024') {
  527.             $annee_apres_str $annee_apres '0206235959';
  528.         }elseif ($annee == '2025') {
  529.             $annee_apres_str $annee_apres '0205235959';
  530.         }// la date changé chqaue annee et ici c'est la meme façon de calculation date que dans la liste classement
  531.         if ($type == 'R') {
  532.             $criteria Criteria::create()
  533.                 ->where(Criteria::expr()->eq("apparition_classement""oui"))
  534.                 ->andWhere(Criteria::expr()->eq("id_reseau"$id_societe))
  535.                 ->andWhere(Criteria::expr()->eq("classement_reseau""oui"))
  536.                 ->andWhere(Criteria::expr()->gt("date_mise_en_ligne"$annee_avant_str))
  537.                 ->andWhere(Criteria::expr()->lt("date_mise_en_ligne"$annee_apres_str))
  538.                 ->andWhere(Criteria::expr()->eq("mode_actualite"BuzzActualites::MODE_ACTUALITE_PUBLIQUE));
  539.         } else {
  540.             $criteria Criteria::create()
  541.                 ->where(Criteria::expr()->eq("apparition_classement""oui"))
  542.                 ->andWhere(Criteria::expr()->eq("id_societe_prestataire"$id_societe))
  543.                 ->andWhere(Criteria::expr()->gt("date_mise_en_ligne"$annee_avant_str))
  544.                 ->andWhere(Criteria::expr()->lt("date_mise_en_ligne"$annee_apres_str))
  545.                 ->andWhere(Criteria::expr()->eq("mode_actualite"BuzzActualites::MODE_ACTUALITE_PUBLIQUE));
  546.         }
  547.         return $this->em->getRepository(BuzzActualites::class)->matching($criteria);
  548.     }
  549.     private function get_tous_types_roles()
  550.     {
  551.         $liste_type_role = [];
  552.         $resultat $this->em->getRepository(BuzzTypesRoles::class)->findAll();
  553.         foreach ($resultat as $type_role) {
  554.             if ($type_role instanceof BuzzTypesRoles) {
  555.                 $liste_type_role[$type_role->__get("id_type_role")] = $type_role->__get("nom_role");
  556.             }
  557.         }
  558.         return $liste_type_role;
  559.     }
  560.     private function get_reseaux_par_id($id_reseau)
  561.     {
  562.         $criteria Criteria::create()->where(Criteria::expr()->eq("id_reseau"$id_reseau));
  563.         $liste $this->em->getRepository('App\Entity\Reseaux')->matching($criteria);
  564.         $reseau null;
  565.         foreach ($liste as $r) { $reseau $r; }
  566.         return $reseau;
  567.     }
  568.     private function get_societe_par_id($id_societe)
  569.     {
  570.         $criteria Criteria::create()->where(Criteria::expr()->eq("id_societe_prestataire"$id_societe));
  571.         $liste $this->em->getRepository('App\Entity\SocietesPrestataire')->matching($criteria);
  572.         $societe null;
  573.         foreach ($liste as $r) { $societe $r; }
  574.         return $societe;
  575.     }
  576.     private function get_services_prestataire_par_id($id_service_prestataire)
  577.     {
  578.         $service = new ServicesPrestataire();
  579.         if ($id_service_prestataire !== null && $id_service_prestataire !== '') {
  580.             $criteria Criteria::create()->where(Criteria::expr()->eq("id_service_prestataire"$id_service_prestataire));
  581.             $liste $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
  582.             foreach ($liste as $s) { $service $s; }
  583.         }
  584.         return $service;
  585.     }
  586.     private function get_services_prestataire_pour_societe($id_societe_prestataire)
  587.     {
  588.         $service = new ServicesPrestataire();
  589.         $criteria Criteria::create()
  590.             ->where(Criteria::expr()->eq("id_societe_prestataire"$id_societe_prestataire))
  591.             ->andWhere(Criteria::expr()->orX(
  592.                 Criteria::expr()->eq("statut"'publique'),
  593.                 Criteria::expr()->eq("statut"'publique_temporaire')
  594.             ))
  595.             ->orderBy(["id_service_prestataire" => Criteria::DESC]);
  596.         $liste $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
  597.         foreach ($liste as $s) { $service $s; }
  598.         return $service;
  599.     }
  600.     private function get_coordonnee_service_prestataire($id_service_prestataire)
  601.     {
  602.         $coordonnee = new CoordonneesServicePrestataire();
  603.         if ($id_service_prestataire !== null && $id_service_prestataire !== '') {
  604.             $criteria Criteria::create()->where(Criteria::expr()->eq("id_service_prestataire"$id_service_prestataire));
  605.             $liste $this->em->getRepository(CoordonneesServicePrestataire::class)->matching($criteria);
  606.             foreach ($liste as $c) { $coordonnee $c; }
  607.         }
  608.         return $coordonnee;
  609.     }
  610.     private function get_roles_par_reseau($id_reseau$liste_operation)
  611.     {
  612.         $liste_id_service_prestataire = [];
  613.         $cri Criteria::create()->where(Criteria::expr()->eq("id_reseau"$id_reseau));
  614.         $result_sp $this->em->getRepository(ServicesPrestataire::class)->matching($cri);
  615.         foreach ($result_sp as $sp) {
  616.             $liste_id_service_prestataire[] = $sp->_get("id_service_prestataire");
  617.         }
  618.         $criteria Criteria::create()
  619.             ->where(Criteria::expr()->in("id_acteur"$liste_id_service_prestataire))
  620.             ->andWhere(Criteria::expr()->in("id_operation"$liste_operation))
  621.             ->andWhere(Criteria::expr()->eq("table_sql_acteur"'services_prestataire'));
  622.         return $this->em->getRepository(BuzzRoles::class)->matching($criteria);
  623.     }
  624.     private function get_roles_par_societe($id_societe_prestataire$liste_operation)
  625.     {
  626.         $liste_id_service_prestataire = [];
  627.         $cri Criteria::create()->where(Criteria::expr()->eq("id_societe_prestataire"$id_societe_prestataire));
  628.         $result_sp $this->em->getRepository(ServicesPrestataire::class)->matching($cri);
  629.         foreach ($result_sp as $sp) {
  630.             $liste_id_service_prestataire[] = $sp->_get("id_service_prestataire");
  631.         }
  632.         $criteria Criteria::create()
  633.             ->where(Criteria::expr()->in("id_acteur"$liste_id_service_prestataire))
  634.             ->andWhere(Criteria::expr()->in("id_operation"$liste_operation))
  635.             ->andWhere(Criteria::expr()->eq("table_sql_acteur"'services_prestataire'));
  636.         return $this->em->getRepository(BuzzRoles::class)->matching($criteria);
  637.     }
  638.     private function get_service_prestataire_pour_reseau($id_reseau)
  639.     {
  640.         $service = new ServicesPrestataire();
  641.         $criteria Criteria::create()->where(Criteria::expr()->eq("id_reseau"$id_reseau));
  642.         $liste $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
  643.         foreach ($liste as $s) { $service $s; }
  644.         return $service;
  645.     }
  646.     private function get_liste_localisation()
  647.     {
  648.         $liste_loc = [];
  649.         $liste_loc["00"] = "France - Etranger";
  650.         $liste_loc["33"] = "France";
  651.         $criteria Criteria::create()->where(Criteria::expr()->eq("id_localisation_pere""33"));
  652.         $result $this->em->getRepository(Localisations::class)->matching($criteria);
  653.         foreach ($result as $loc) {
  654.             if ($loc instanceof Localisations) {
  655.                 $liste_loc[$loc->__get("id_localisation")] = $loc->__get("nom_localisation");
  656.             }
  657.         }
  658.         return $liste_loc;
  659.     }
  660.     private function get_annee_defaut()
  661.     {
  662.         $criteria Criteria::create()->where(Criteria::expr()->eq("nom_parametre""annee_defaut_classements"));
  663.         $repo $this->em->getRepository('App\Entity\ParametresGeneraux');
  664.         $result $repo->matching($criteria);
  665.         return $result[0]->_get("valeur_parametre");
  666.     }
  667.     private function get_segment_defaut()
  668.     {
  669.         $criteria Criteria::create()->where(Criteria::expr()->eq("nom_parametre""segment_defaut_classements"));
  670.         $repo $this->em->getRepository('App\Entity\ParametresGeneraux');
  671.         $result $repo->matching($criteria);
  672.         return $result[0]->_get("valeur_parametre");
  673.     }
  674.     private function get_membres_reseaux($id_reseau)
  675.     {
  676.         $criteria Criteria::create()
  677.             ->where(Criteria::expr()->eq("id_reseau"$id_reseau))
  678.             ->andWhere(Criteria::expr()->eq("statut""publique"));
  679.         return $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
  680.     }
  681. }