src/Controller/ClassementFusionAcquisitionController.php line 60

Open in your IDE?
  1. <?php
  2. // src/Controller/ClassementFusionAcquisitionController.php
  3. namespace App\Controller;
  4. use App\Entity\BuzzOperations;
  5. use App\Entity\BuzzRoles;
  6. use App\Entity\BuzzActualites;
  7. use App\Entity\SocietesPrestataire;
  8. use App\Entity\ServicesPrestataire;
  9. use App\Entity\ClassementItem;
  10. use App\Entity\Reseaux;
  11. use App\Services\BuzzActualiteService;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\HttpFoundation\JsonResponse;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Doctrine\ORM\EntityManagerInterface;
  16. use App\Services\Util;
  17. /**
  18.  * Portage Symfony 5.4 sans amélioration et en conservant la logique.
  19.  * Ce contrôleur étend un contrôleur général (ClassementGeneralController)
  20.  * qui fournit les helpers : getEntityManager(), get_actualites(), get_tous_reseaux(),
  21.  * get_services_prestataire(), is_service_prestataire(), get_site(), get_src_image_si_artviper_desactive(),
  22.  * get_lien_fiche(), get_seuil_max_min(), get_liste_localisation(),
  23.  * get_annee_defaut(), get_segment_defaut(), get_localisation_defaut(),
  24.  * get_roles_par_reseau(), get_roles_par_societe(), get_classement_liste_avec_change_moins_un_mois(),
  25.  * date_actuelle_moins_un_mois().
  26.  */
  27. class ClassementFusionAcquisitionController extends ClassementGeneralController
  28. {
  29.     /**
  30.      * @var EntityManagerInterface
  31.      */
  32.     public $em;
  33.     /**
  34.      * @var BuzzActualiteService
  35.      */
  36.     public $buzzActualiteService;
  37.     public $type_role;
  38.     public $type_operation;
  39.     public $annee_operation;
  40.     public $id_localisation;
  41.     public $segment;
  42.     public $actualites;
  43.     public $conseil_banque_type_role_liste = ["5","8","11","14","17"];
  44.     public $avocat_affaire_type_role_liste = ["6","9","12","15","18"];
  45.     public $cabinet_audit_type_role_liste  = ["7","10","13","16","19"];
  46.     public $parametre_conseil_banque_type_role_liste 1;
  47.     public $parametre_avocat_affaire_type_role_liste 2;
  48.     public $parametre_cabinet_audit_type_role_liste  3;
  49.     public function __constructBuzzActualiteService $buzzActualiteService,EntityManagerInterface $em)
  50.     {
  51.         $this->em $em;
  52.         $this->buzzActualiteService $buzzActualiteService;
  53.     }
  54.     public function banquesAffairesConseils(Request $request,$params)
  55.     {
  56.         $type_tir 0;
  57.         $this->segment $this->get_segment_defaut();
  58.         $this->id_localisation $this->get_localisation_defaut();
  59.         $this->annee_operation $this->get_annee_defaut();
  60.         if (!empty($params)) {
  61.             $params ltrim($params'-');
  62.             $parts explode(','$params);
  63.             $this->annee_operation $parts[0] ?? $this->get_annee_defaut();
  64.             $this->id_localisation $parts[1] ?? $this->get_localisation_defaut();
  65.             $this->segment $parts[2] ?? $this->get_segment_defaut();
  66.             $type_tir $parts[3] ?? 0;
  67.         }
  68.         $this->type_operation BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION;
  69.         $this->type_role "banques_affaires";
  70.         $liste_loc $this->get_liste_localisation();
  71.         $nom_loc   $liste_loc[$this->id_localisation] ?? '';
  72.         if ($this->id_localisation == "00") {
  73.             $this->id_localisation "";
  74.         }
  75.         $classementListe $this->buzzActualiteService->getDataClassement(
  76.             $this->parametre_conseil_banque_type_role_liste,
  77.             $this->type_operation,
  78.             $this->annee_operation,
  79.             $this->id_localisation,
  80.             $this->segment,
  81.             false,
  82.             $type_tir
  83.         );
  84.         $classement_liste $this->traiteClassementListe($classementListe$type_tir$this->annee_operation);
  85.         return $this->render('classement/banquesaffairesconseils.html.twig', [
  86.             "type_tir"        => $type_tir,
  87.             "type_role"       => $this->type_role,
  88.             "type_operation"  => $this->type_operation,
  89.             "str_lien_prestations_fu_ac"=>"fusions-acquisitions",
  90.             "annee_operation" => $this->annee_operation,
  91.             "localisation"    => $this->id_localisation,
  92.             "nom_loc"         => $nom_loc,
  93.             "segment"         => $this->segment,
  94.             "class"           => $classement_liste,
  95.             "loc_liste"       => $liste_loc,
  96.         ]);
  97.     }
  98.  /*   public function avocatsaffaires(Request $request)
  99.     {
  100.         $type_tir = $request->get('tri_type', 0);
  101.         $this->type_operation = BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION;
  102.         $this->annee_operation = ($request->get('annee') == "")
  103.             ? $this->get_annee_defaut()
  104.             : $request->get('annee');
  105.         $this->type_role = "avocats_affaires";
  106.         if ($request->get('localisation') !== null && $request->get('localisation') !== "") {
  107.             $this->id_localisation = $request->get('localisation');
  108.         } else {
  109.             $this->id_localisation = "33";
  110.         }
  111.         $liste_loc = $this->get_liste_localisation();
  112.         $nom_loc   = $liste_loc[$this->id_localisation] ?? '';
  113.         if ($this->id_localisation == "00") {
  114.             $this->id_localisation = "";
  115.         }
  116.         $this->segment = ($request->get('segment') !== null)
  117.             ? (int)$request->get('segment')
  118.             : $this->get_segment_defaut();
  119.         $classementListe = $this->buzzActualiteService->getDataClassement(
  120.             $this->parametre_avocat_affaire_type_role_liste,
  121.             $this->type_operation,
  122.             $this->annee_operation,
  123.             $this->id_localisation,
  124.             $this->segment,
  125.             false,
  126.             $type_tir
  127.         );
  128.         $classement_liste = $this->traiteClassementListe($classementListe, $type_tir, $this->annee_operation);
  129.         return $this->render('classement/avocatsaffaires.html.twig', [
  130.             "type_tir"        => $type_tir,
  131.             "type_role"       => $this->type_role,
  132.             "type_operation"  => $this->type_operation,
  133.             "annee_operation" => $this->annee_operation,
  134.             "localisation"    => $this->id_localisation,
  135.             "nom_loc"         => $nom_loc,
  136.             "segment"         => $this->segment,
  137.             "class"           => $classement_liste,
  138.             "loc_liste"       => $liste_loc,
  139.         ]);
  140.     }
  141.     public function cabinetsaudit(Request $request)
  142.     {
  143.         $type_tir = $request->get('tri_type', 0);
  144.         $this->type_operation = BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION;
  145.         $this->annee_operation = ($request->get('annee') == "")
  146.             ? $this->get_annee_defaut()
  147.             : $request->get('annee');
  148.         $this->type_role = "cabinets_audit";
  149.         if ($request->get('localisation') !== null && $request->get('localisation') !== "") {
  150.             $this->id_localisation = $request->get('localisation');
  151.         } else {
  152.             $this->id_localisation = "33";
  153.         }
  154.         $liste_loc = $this->get_liste_localisation();
  155.         $nom_loc   = $liste_loc[$this->id_localisation] ?? '';
  156.         if ($this->id_localisation == "00") {
  157.             $this->id_localisation = "";
  158.         }
  159.         $this->segment = ($request->get('segment') !== null)
  160.             ? (int)$request->get('segment')
  161.             : $this->get_segment_defaut();
  162.         $classementListe = $this->buzzActualiteService->getDataClassement(
  163.             $this->parametre_cabinet_audit_type_role_liste,
  164.             $this->type_operation,
  165.             $this->annee_operation,
  166.             $this->id_localisation,
  167.             $this->segment,
  168.             false,
  169.             $type_tir
  170.         );
  171.         $classement_liste = $this->traiteClassementListe($classementListe, $type_tir, $this->annee_operation);
  172.         return $this->render('classement/cabinetsaudit.html.twig', [
  173.             "type_tir"        => $type_tir,
  174.             "type_role"       => $this->type_role,
  175.             "type_operation"  => $this->type_operation,
  176.             "annee_operation" => $this->annee_operation,
  177.             "localisation"    => $this->id_localisation,
  178.             "nom_loc"         => $nom_loc,
  179.             "segment"         => $this->segment,
  180.             "class"           => $classement_liste,
  181.             "loc_liste"       => $liste_loc,
  182.         ]);
  183.     }
  184.     public function print(Request $request)
  185.     {
  186.         $type_tir = $request->get('tri_type', 0);
  187.         $this->type_operation = BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION;
  188.         $this->annee_operation = ($request->get('annee') == "")
  189.             ? $this->get_annee_defaut()
  190.             : $request->get('annee');
  191.         if ($request->get('localisation') !== null && $request->get('localisation') !== "") {
  192.             $this->id_localisation = $request->get('localisation');
  193.         } else {
  194.             $this->id_localisation = "33";
  195.         }
  196.         $liste_loc = $this->get_liste_localisation();
  197.         $nom_loc   = $liste_loc[$this->id_localisation] ?? '';
  198.         if ($this->id_localisation == "00") {
  199.             $this->id_localisation = "";
  200.         }
  201.         $this->segment = ($request->get('segment') !== null)
  202.             ? (int)$request->get('segment')
  203.             : $this->get_segment_defaut();
  204.         switch ($request->get('type_classe')) {
  205.             case "banques-affaires-conseils":
  206.                 $this->type_role = "banques_affaires";
  207.                 $type_liste = $this->conseil_banque_type_role_liste;
  208.                 $parametre_type_role_liste = $this->parametre_conseil_banque_type_role_liste;
  209.                 break;
  210.             case "avocats-affaires":
  211.                 $this->type_role = "avocats_affaires";
  212.                 $type_liste = $this->avocat_affaire_type_role_liste;
  213.                 $parametre_type_role_liste = $this->parametre_avocat_affaire_type_role_liste;
  214.                 break;
  215.             case "cabinets-audit":
  216.                 $this->type_role = "cabinets_audit";
  217.                 $type_liste = $this->cabinet_audit_type_role_liste;
  218.                 $parametre_type_role_liste = $this->parametre_cabinet_audit_type_role_liste;
  219.                 break;
  220.             default:
  221.                 $this->type_role = "banques_affaires";
  222.                 $type_liste = $this->conseil_banque_type_role_liste;
  223.                 $parametre_type_role_liste = $this->parametre_conseil_banque_type_role_liste;
  224.                 break;
  225.         }
  226.         $classementListe = $this->buzzActualiteService->getDataClassement(
  227.             $parametre_type_role_liste,
  228.             $this->type_operation,
  229.             $this->annee_operation,
  230.             $this->id_localisation,
  231.             $this->segment,
  232.             false,
  233.             $type_tir
  234.         );
  235.         $classement_liste = $this->traiteClassementListe($classementListe, $type_tir, $this->annee_operation);
  236.         if ($this->annee_operation == date("Y") && date("m") != "01") {
  237.             $classementListeMoisUn = $this->buzzActualiteService->getDataClassement(
  238.                 $parametre_type_role_liste,
  239.                 $this->type_operation,
  240.                 $this->annee_operation,
  241.                 $this->id_localisation,
  242.                 $this->segment,
  243.                 true,
  244.                 $type_tir
  245.             );
  246.             $classement_mois_moins_un = $this->traiteClassementListe($classementListeMoisUn, $type_tir, $this->annee_operation);
  247.             $classement_liste = $this->get_classement_liste_avec_change_moins_un_mois($classement_liste, $classement_mois_moins_un);
  248.         }
  249.         $role_type_liste = [
  250.             'banques_affaires'=> "Conseils / Banques d'affaires",
  251.             'cabinets_audit'  => "Cabinets d'audit",
  252.             'avocats_affaires'=> "Avocats d'affaires"
  253.         ];
  254.         $segment_liste = [
  255.             "5" => "ETI",
  256.             "4" => "PME-ETI",
  257.             "3" => "TPE-PME-ETI",
  258.             "2" => "TPE-PME",
  259.             "1" => "TPE"
  260.         ];
  261.         // Rendu d'un template PDF (même logique que ZF2, intégration via ton moteur PDF côté Twig/bundle PDF).
  262.         return $this->render('classement/print.pdf.twig', [
  263.             "type_tir"        => $type_tir,
  264.             "type_role"       => $this->type_role,
  265.             "type_operation"  => $this->type_operation,
  266.             "annee_operation" => $this->annee_operation,
  267.             "localisation"    => $this->id_localisation,
  268.             "segment"         => $this->segment,
  269.             "class"           => $classement_liste,
  270.             "nom_loc"         => $nom_loc,
  271.             "loc_liste"       => $liste_loc,
  272.             "role_type_liste" => $role_type_liste,
  273.             "segment_liste"   => $segment_liste,
  274.         ]);
  275.     }*/
  276.     /**
  277.      * ====== PORTAGE INTÉGRAL ZF2 ➜ Symfony (logique originale conservée) ======
  278.      * get_classement : copie de la méthode ZF2, dépend des helpers du contrôleur général.
  279.      */
  280.     public function get_classement(
  281.         $parametre_type_role,
  282.         $parametre_type_operation,
  283.         $parametre_annee,
  284.         $parametre_localisation,
  285.         $parametre_segment,
  286.         $pour_un_mois_avant=false,
  287.         $tri=0
  288.     ) {
  289.         $util = new \App\Services\Util(); // Util identique à l'original
  290.         $liste_opearation_par_is_societe_ou_reseau = array();
  291.         $target_chiffre null;
  292.         if ($parametre_type_operation == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) {
  293.             $target_chiffre "ca_societe_achetee";
  294.         }
  295.         $societe_liste = array();
  296.         $operations_traites_liste = array();
  297.         $liste_id_operation_temp_comte = array();
  298.         $reseau_id_liste = array();
  299.         $reseau_liste $this->get_tous_reseaux();
  300.         $classement_liste = array();
  301.         $actualites $this->get_actualites($parametre_annee);
  302.         foreach ($actualites as $actualite) {
  303.             if (($actualite instanceof BuzzActualites)) {
  304.                 $operation $actualite->_get("id_operation");
  305.                 $operation $this->em->getRepository(BuzzOperations::class)->find($operation);
  306.                 if ($operation instanceof BuzzOperations) {
  307.                     if ($actualite->__get("classement_reseau") == 'oui') {
  308.                         $id_op $actualite->__get("id_reseau") . '-' $operation->__get("id_operation");
  309.                     } else {
  310.                         $id_op $actualite->__get("id_societe_prestataire") . '-' $operation->__get("id_operation");
  311.                     }
  312.                     if (!in_array($id_op$operations_traites_liste)) {
  313.                         $type_oper $operation->__get("type_operation");
  314.                         $id_loc $operation->__get("id_localisation");
  315.                         $date_oper $operation->__get("date_operation");
  316.                         $date_pub $actualite->getDateMiseEnLigne();
  317.                         $rattrapage $operation->__get("check_rattrapage");
  318.                         $flag_periode false;
  319.                         $annee_maintenant date("Y");
  320.                         if ($annee_maintenant == $parametre_annee) {
  321.                             if (!$pour_un_mois_avant) {
  322.                                 if (substr($date_pub04) == $parametre_annee && substr($date_pub08) <= date("Ymd") && substr($date_oper04) == $parametre_annee) {
  323.                                     $flag_periode true;
  324.                                 }
  325.                             } else {
  326.                                 $date_moins_un_mois $this->date_actuelle_moins_un_mois();
  327.                                 if ($rattrapage == "oui") {
  328.                                     if ($date_oper <= $date_moins_un_mois && substr($date_oper04) == $parametre_annee) {
  329.                                         $flag_periode true;
  330.                                     }
  331.                                 } else {
  332.                                     $date_moins_un_mois $date_moins_un_mois "235959";
  333.                                     if ($date_pub <= $date_moins_un_mois && substr($date_pub04) == $parametre_annee && substr($date_oper04) == $parametre_annee) {
  334.                                         $flag_periode true;
  335.                                     }
  336.                                 }
  337.                             }
  338.                         } else {
  339.                             $flag_periode = (substr($date_oper04) == $parametre_annee); //anne operation
  340.                         }
  341.                         if ($type_oper == $parametre_type_operation  //type operation
  342.                             && $flag_periode //anne operation
  343.                             && $actualite->__get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE
  344.                             && substr($id_loc0strlen($parametre_localisation)) == $parametre_localisation
  345.                         ) {
  346.                             $id_type_role "";
  347.                             $buzz_roles $operation->getRoles();
  348.                             $flag false;
  349.                             foreach ($buzz_roles as $buzz_role) { // if it is a operation of the type we want
  350.                                 if ($buzz_role instanceof BuzzRoles) {
  351.                                     $id_acteur $buzz_role->__get("id_acteur");
  352.                                     $resultatSPs $this->getEntityManager()->getRepository('Core\Entity\ServicesPrestataire')->findBy(array("id_societe_prestataire" => $actualite->__get("id_societe_prestataire")));
  353.                                     foreach ($resultatSPs as $resultatSP):
  354.                                         if ($resultatSP instanceof ServicesPrestataire && $resultatSP->__get("id_service_prestataire") == $id_acteur) {
  355.                                             $id_type_role $buzz_role->__get("id_type_role");
  356.                                             if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  357.                                                 $flag true;
  358.                                             }
  359.                                         }
  360.                                     endforeach;
  361.                                 }
  362.                             }
  363.                             if ($flag) {
  364.                                 array_push($operations_traites_liste$id_op);
  365.                                 $classement_reseau $actualite->__get("classement_reseau");
  366.                                 $maj_min $operation->__get("maj_min_capital");
  367.                                 $pct 1;
  368.                                 $seuil = array();
  369.                                 $seuil $this->get_seuil_max_min($this->segment);
  370.                                 $temp_ca 0;
  371.                                 if ($operation->__get($target_chiffre) != null) {
  372.                                     $temp_ca $operation->__get($target_chiffre);
  373.                                 }
  374.                                 $fourchette_ca 0;
  375.                                 if ($operation->__get("fourchette_ca") != null) {
  376.                                     $fourchette_ca $operation->__get("fourchette_ca");
  377.                                 }
  378.                                 if ($classement_reseau == "oui") { //if the actuality appears in the reseau
  379.                                     $id_reseau $actualite->__get("id_reseau");
  380.                                     $temp_reseau $this->em->getRepository(Reseaux::class)->find($id_reseau);
  381.                                     //$temp_reseau = $actualite->getReseau();
  382.                                     if ($temp_reseau instanceof Reseaux) {
  383.                                         $temp_reseau_segment $temp_reseau->__get("segments_classements_concernes");
  384.                                         if (!in_array($id_reseau$reseau_id_liste) && ($temp_reseau_segment >= $this->segment || $temp_reseau_segment == 3)) { //create the reseau in the classement
  385.                                             if (($temp_ca != && $seuil["min"] <= $temp_ca && $temp_ca <= $seuil["max"])
  386.                                                 || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  387.                                                 || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)) {
  388.                                                 array_push($reseau_id_liste$id_reseau);
  389.                                                 $classement = new ClassementItem();
  390.                                                 $classement->__set("nb_operation"0);
  391.                                                 foreach ($buzz_roles as $buzz_role) {
  392.                                                     if ($buzz_role instanceof BuzzRoles) {
  393.                                                         $id_acteur $buzz_role->__get("id_acteur");
  394.                                                         $resultatSPs $this->getEntityManager()->getRepository('Core\Entity\ServicesPrestataire')->findBy(array("id_societe_prestataire" => $actualite->__get("id_societe_prestataire")));
  395.                                                         foreach ($resultatSPs as $resultatSP):
  396.                                                             if ($resultatSP instanceof ServicesPrestataire && $resultatSP->__get("id_service_prestataire") == $id_acteur) {
  397.                                                                 $id_type_role $buzz_role->__get("id_type_role");
  398.                                                                 if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  399.                                                                     $classement->__set("nb_operation"1);
  400.                                                                 }
  401.                                                             }
  402.                                                         endforeach;
  403.                                                     }
  404.                                                 }
  405.                                                 $montant 0;
  406.                                                 if ($operation->__get($target_chiffre) != null) {
  407.                                                     $montant $operation->__get($target_chiffre);
  408.                                                 }
  409.                                                 if ($maj_min == "0" && $parametre_type_operation == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) {
  410.                                                     $pct $operation->__get("pct_capital_achete");
  411.                                                     $montant round($montant $pct 1000PHP_ROUND_HALF_DOWN);
  412.                                                 }
  413.                                                 $classement->__set("montant_cumule"$montant);
  414.                                                 $classement->__set("id_reseau"$id_reseau);
  415.                                                 $classement->__set("reseau"ClassementItem::RESEAU_OUI);
  416.                                                 $liste_id_operation = array();
  417.                                                 $liste_id_operation[] = $operation->__get('id_operation');
  418.                                                 $classement->__set('liste_id_operation'$liste_id_operation);
  419.                                                 foreach ($reseau_liste as $reseau) {
  420.                                                     if ($reseau instanceof Reseaux) {
  421.                                                         if ($reseau->__get("id_reseau") == $id_reseau) {
  422.                                                             $classement->__set("nom_reseau"$reseau->__get("nom"));
  423.                                                             $classement->__set("lien_detail_nom"'reseau-' $util->reecriture_pour_url($reseau->__get("nom"), "-"));
  424.                                                             $classement->__set("site_internet"$this->get_site($id_reseautrue));
  425.                                                             $classement->__set("src_image_si_artviper_desactive"$this->get_src_image_si_artviper_desactive($id_reseautrue));
  426.                                                             $classement->__set("lien_fiche_expert"$this->get_lien_fiche($id_reseautrue));
  427.                                                         }
  428.                                                     }
  429.                                                 }
  430.                                                 array_push($classement_liste$classement);
  431.                                             }
  432.                                         } else if (in_array($id_reseau$reseau_id_liste) && ($temp_reseau_segment >= $this->segment || $temp_reseau_segment == 3)) { //update this reseau in the classement
  433.                                             if (($temp_ca != && $seuil["min"] <= $temp_ca && $temp_ca <= $seuil["max"])
  434.                                                 || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  435.                                                 || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)) {
  436.                                                 foreach ($classement_liste as $temp_classement) {
  437.                                                     if ($temp_classement instanceof ClassementItem) {
  438.                                                         if ($temp_classement->__get("id_reseau") == $id_reseau) {
  439.                                                             $temp_montant $temp_classement->__get("montant_cumule");
  440.                                                             $new_montant 0;
  441.                                                             if ($operation->__get($target_chiffre) != null) {
  442.                                                                 $new_montant $operation->__get($target_chiffre);
  443.                                                             }
  444.                                                             if ($maj_min == "0" && $parametre_type_operation == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) {
  445.                                                                 $pct $operation->__get("pct_capital_achete");
  446.                                                                 $new_montant round($new_montant $pct 1000PHP_ROUND_HALF_DOWN);
  447.                                                             }
  448.                                                             $montant $temp_montant $new_montant;
  449.                                                             $temp_classement->__set("montant_cumule"$montant);
  450.                                                             $temp_compter $temp_classement->__get("nb_operation");
  451.                                                             $pluscom false;
  452.                                                             foreach ($buzz_roles as $buzz_role) {
  453.                                                                 if ($buzz_role instanceof BuzzRoles) {
  454.                                                                     $id_acteur $buzz_role->__get("id_acteur");
  455.                                                                     $resultatSPs $this->getEntityManager()->getRepository('Core\Entity\ServicesPrestataire')->findBy(array("id_societe_prestataire" => $actualite->__get("id_societe_prestataire")));
  456.                                                                     foreach ($resultatSPs as $resultatSP):
  457.                                                                         if ($resultatSP instanceof ServicesPrestataire && $resultatSP->__get("id_service_prestataire") == $id_acteur) {
  458.                                                                             $id_type_role $buzz_role->__get("id_type_role");
  459.                                                                             if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  460.                                                                                 $pluscom true;
  461.                                                                             }
  462.                                                                         }
  463.                                                                     endforeach;
  464.                                                                 }
  465.                                                             }
  466.                                                             if ($pluscom) {
  467.                                                                 $temp_compter++;
  468.                                                             }
  469.                                                             $temp_classement->__set("nb_operation"$temp_compter);
  470.                                                             $liste_temp_id_operation $temp_classement->__get('liste_id_operation');
  471.                                                             if (!in_array($operation->__get('id_operation'), $liste_temp_id_operation)) {
  472.                                                                 $liste_temp_id_operation[] = $operation->__get('id_operation');
  473.                                                             }
  474.                                                             $temp_classement->__set('liste_id_operation'$liste_temp_id_operation);
  475.                                                         }
  476.                                                     }
  477.                                                 }
  478.                                             }
  479.                                         }
  480.                                     }
  481.                                 } else { //if it is not part of a reseau
  482.                                     $temp_societe $actualite->_get("id_societe_prestataire");
  483.                                     $temp_societe $this->em->getRepository(SocietesPrestataire::class)->find($temp_societe);
  484.                                     if ($temp_societe instanceof SocietesPrestataire) {
  485.                                         $id_societe $temp_societe->__get("id_societe_prestataire");
  486.                                         if ($this->is_service_prestataire($id_societefalse$buzz_roles$parametre_type_role)) {
  487.                                             $temp_societe_segment = (int)$temp_societe->__get("segments_classements_concernes");
  488.                                             if (!in_array($id_societe$societe_liste) && ($temp_societe_segment >= $this->segment || $temp_societe_segment == 3)) { //create new company
  489.                                                 if (($temp_ca != && $seuil["min"] <= $temp_ca && $temp_ca <= $seuil["max"])
  490.                                                     || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  491.                                                     || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)) {
  492.                                                     array_push($societe_liste$id_societe);
  493.                                                     $classement = new ClassementItem();
  494.                                                     $classement->__set("id_societe_prestataire"$id_societe);
  495.                                                     $classement->__set("raison_sociale"$actualite->__get("service_principal")->__get("nom_commercial_societe"));
  496.                                                     $classement->__set("lien_detail_nom"$util->reecriture_pour_url($temp_societe->__get("raison_sociale"), "-"));
  497.                                                     $classement->__set("nb_operation"0);
  498.                                                     $pluscom false;
  499.                                                     foreach ($buzz_roles as $buzz_role) {
  500.                                                         if ($buzz_role instanceof BuzzRoles) {
  501.                                                             $id_acteur $buzz_role->__get("id_acteur");
  502.                                                             $resultatSPs $this->getEntityManager()->getRepository('Core\Entity\ServicesPrestataire')->findBy(array("id_societe_prestataire" => $actualite->__get("id_societe_prestataire")));
  503.                                                             foreach ($resultatSPs as $resultatSP):
  504.                                                                 if ($resultatSP instanceof ServicesPrestataire && $resultatSP->__get("id_service_prestataire") == $id_acteur) {
  505.                                                                     $id_type_role $buzz_role->__get("id_type_role");
  506.                                                                     if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  507.                                                                         $pluscom true;
  508.                                                                     }
  509.                                                                 }
  510.                                                             endforeach;
  511.                                                         }
  512.                                                     }
  513.                                                     if ($pluscom) {
  514.                                                         $classement->__set("nb_operation"1);
  515.                                                     }
  516.                                                     $montant 0;
  517.                                                     if ($operation->__get($target_chiffre) != null) {
  518.                                                         $montant $operation->__get($target_chiffre);
  519.                                                     }
  520.                                                     if ($maj_min == "0" && $parametre_type_operation == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) {
  521.                                                         $pct $operation->__get("pct_capital_achete");
  522.                                                         $montant round($montant $pct 1000PHP_ROUND_HALF_DOWN);
  523.                                                     }
  524.                                                     $classement->__set("montant_cumule"$montant);
  525.                                                     $classement->__set("reseau"ClassementItem::RESEAU_NON);
  526.                                                     $classement->__set("site_internet"$this->get_site($id_societefalse));
  527.                                                     // NOTE : ligne fidèle au code d'origine (référence $id_reseau dans ce bloc non réseau)
  528.                                                     $classement->__set("src_image_si_artviper_desactive"$this->get_src_image_si_artviper_desactive($id_reseautrue));
  529.                                                     $classement->__set("lien_fiche_expert"$this->get_lien_fiche($id_societefalse));
  530.                                                     $liste_id_operation = array();
  531.                                                     $liste_id_operation[] = $operation->__get('id_operation');
  532.                                                     $classement->__set('liste_id_operation'$liste_id_operation);
  533.                                                     array_push($classement_liste$classement);
  534.                                                 }
  535.                                             } else if (in_array($id_societe$societe_liste) && ($temp_societe_segment >= $this->segment || $temp_societe_segment == 3)) { //update
  536.                                                 if (($temp_ca != && $seuil["min"] <= $temp_ca && $temp_ca <= $seuil["max"])
  537.                                                     || ($temp_ca == && $fourchette_ca == && ($this->segment == || $this->segment == || $this->segment == 3))
  538.                                                     || ($temp_ca == && $fourchette_ca != && $fourchette_ca <= $this->segment && ($fourchette_ca 2) >= $this->segment)) {
  539.                                                     foreach ($classement_liste as $temp_classement) {
  540.                                                         if ($temp_classement instanceof ClassementItem) {
  541.                                                             if ($temp_classement->__get("id_societe_prestataire") == $id_societe) {
  542.                                                                 $temp_montant $temp_classement->__get("montant_cumule");
  543.                                                                 $new_montant 0;
  544.                                                                 if ($operation->__get($target_chiffre) != null) {
  545.                                                                     $new_montant $operation->__get($target_chiffre);
  546.                                                                 }
  547.                                                                 if ($maj_min == "0" && $parametre_type_operation == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) {
  548.                                                                     $pct $operation->__get("pct_capital_achete");
  549.                                                                     $new_montant round($new_montant $pct 1000PHP_ROUND_HALF_DOWN);
  550.                                                                 }
  551.                                                                 $montant $temp_montant $new_montant;
  552.                                                                 $temp_classement->__set("montant_cumule"$montant);
  553.                                                                 $temp_compter $temp_classement->__get("nb_operation");
  554.                                                                 $pluscom false;
  555.                                                                 foreach ($buzz_roles as $buzz_role) {
  556.                                                                     if ($buzz_role instanceof BuzzRoles) {
  557.                                                                         $id_acteur $buzz_role->__get("id_acteur");
  558.                                                                         $resultatSPs $this->getEntityManager()->getRepository('Core\Entity\ServicesPrestataire')->findBy(array("id_societe_prestataire" => $actualite->__get("id_societe_prestataire")));
  559.                                                                         foreach ($resultatSPs as $resultatSP):
  560.                                                                             if ($resultatSP instanceof ServicesPrestataire && $resultatSP->__get("id_service_prestataire") == $id_acteur) {
  561.                                                                                 $id_type_role $buzz_role->__get("id_type_role");
  562.                                                                                 if ($id_type_role != "" && in_array($id_type_role$parametre_type_role)) {
  563.                                                                                     $pluscom true;
  564.                                                                                 }
  565.                                                                             }
  566.                                                                         endforeach;
  567.                                                                     }
  568.                                                                 }
  569.                                                                 if ($pluscom) {
  570.                                                                     $temp_compter++;
  571.                                                                 }
  572.                                                                 $temp_classement->__set("nb_operation"$temp_compter);
  573.                                                                 $liste_temp_id_operation $temp_classement->__get('liste_id_operation');
  574.                                                                 if (!in_array($operation->__get('id_operation'), $liste_temp_id_operation)) {
  575.                                                                     $liste_temp_id_operation[] = $operation->__get('id_operation');
  576.                                                                 }
  577.                                                                 $temp_classement->__set('liste_id_operation'$liste_temp_id_operation);
  578.                                                             }
  579.                                                         }
  580.                                                     }
  581.                                                 }
  582.                                             }
  583.                                         }
  584.                                     }
  585.                                 }
  586.                             }
  587.                         }
  588.                     }
  589.                 }
  590.             }
  591.         }
  592.         foreach ($classement_liste as $cl) {
  593.             $liste_buzz_role = array();
  594.             if ($cl->__get('reseau') == ClassementItem::RESEAU_OUI) {
  595.                 $liste_buzz_role $this->get_roles_par_reseau($cl->__get('id_reseau'), $cl->__get('liste_id_operation'));
  596.             } else {
  597.                 $liste_buzz_role $this->get_roles_par_societe($cl->__get('id_societe_prestataire'), $cl->__get('liste_id_operation'));
  598.             }
  599.             $liste_operation_par_societe_ou_reseau = array();
  600.             $liste_operation = array();
  601.             foreach ($liste_buzz_role as $buzz_role) {
  602.                 if ($buzz_role->__get('id_type_role') == '5' || $buzz_role->__get('id_type_role') == '8') {
  603.                     $id_operation $buzz_role->__get('id_operation')->__get('id_operation');
  604.                     if (null !== $liste_operation_par_societe_ou_reseau[$id_operation]) {
  605.                         $temp $liste_operation_par_societe_ou_reseau[$id_operation];
  606.                         if (in_array($buzz_role->__get('id_type_role'), $temp)) {
  607.                         } else {
  608.                             $cl->__set('nb_operation'$cl->__get('nb_operation') + 1);
  609.                             $cl->__set('montant_cumule'$cl->__get('montant_cumule') + $buzz_role->__get('id_operation')->__get('ca_societe_achetee'));
  610.                             $temp[] = $buzz_role->__get('id_type_role');
  611.                             $liste_operation_par_societe_ou_reseau[$id_operation] = $temp;
  612.                         }
  613.                     } else {
  614.                         $temp = array();
  615.                         $temp[] = $buzz_role->__get('id_type_role');
  616.                         $liste_operation_par_societe_ou_reseau[$id_operation] = $temp;
  617.                     }
  618.                 }
  619.             }
  620.         }
  621.         if ($tri == 1) {
  622.             usort($classement_liste, function ($a$b) {
  623.                 if ($b->__get("nb_operation") == $a->__get("nb_operation")) {
  624.                     return $b->__get("montant_cumule") - $a->__get("montant_cumule");
  625.                 } else {
  626.                     return $b->__get("nb_operation") - $a->__get("nb_operation");
  627.                 }
  628.             });
  629.         } else {
  630.             usort($classement_liste, function ($a$b) {
  631.                 if ($b->__get("montant_cumule") == $a->__get("montant_cumule")) {
  632.                     return $b->__get("nb_operation") - $a->__get("nb_operation");
  633.                 } else {
  634.                     return $b->__get("montant_cumule") - $a->__get("montant_cumule");
  635.                 }
  636.             });
  637.         }
  638.         $r 0;
  639.         foreach ($classement_liste as $cl) {
  640.             if ($cl instanceof ClassementItem) {
  641.                 $r $r 1;
  642.                 $cl->__set("rank"$r);
  643.             }
  644.         }
  645.         return $classement_liste;
  646.     }
  647.     /**
  648.      * ====== PORTAGE INTÉGRAL ZF2 ➜ Symfony (logique originale conservée) ======
  649.      */
  650.     public function traiteClassementListe($classement_liste$tri$annee)
  651.     {
  652.         if ($annee <= 2023) {
  653.             foreach ($classement_liste as $cl) {
  654.                 $liste_buzz_role = array();
  655.                 if ($cl->__get('reseau') == ClassementItem::RESEAU_OUI) {
  656.                     $liste_buzz_role $this->get_roles_par_reseau($cl->__get('id_reseau'), $cl->__get('liste_id_operation'));
  657.                 } else {
  658.                     $liste_buzz_role $this->get_roles_par_societe($cl->__get('id_societe_prestataire'), $cl->__get('liste_id_operation'));
  659.                 }
  660.                 $liste_operation_par_societe_ou_reseau = array();
  661.                 $liste_operation = array();
  662.                 foreach ($liste_buzz_role as $buzz_role) {
  663.                     if ($buzz_role->__get('id_type_role') == '5' || $buzz_role->__get('id_type_role') == '8') {
  664.                         $id_operation $buzz_role->__get('id_operation')->__get('id_operation');
  665.                         if (null !== $liste_operation_par_societe_ou_reseau[$id_operation]) {
  666.                             $temp $liste_operation_par_societe_ou_reseau[$id_operation];
  667.                             if (in_array($buzz_role->__get('id_type_role'), $temp)) {
  668.                             } else {
  669.                                 $cl->__set('nb_operation'$cl->__get('nb_operation') + 1);
  670.                                 $cl->__set('montant_cumule'$cl->__get('montant_cumule') + $buzz_role->__get('id_operation')->__get('ca_societe_achetee'));
  671.                                 $temp[] = $buzz_role->__get('id_type_role');
  672.                                 $liste_operation_par_societe_ou_reseau[$id_operation] = $temp;
  673.                             }
  674.                         } else {
  675.                             $temp = array();
  676.                             $temp[] = $buzz_role->__get('id_type_role');
  677.                             $liste_operation_par_societe_ou_reseau[$id_operation] = $temp;
  678.                         }
  679.                     }
  680.                 }
  681.             }
  682.         }
  683.         if ($tri == 1) {
  684.             usort($classement_liste, function ($a$b) {
  685.                 if ($b->__get("nb_operation") == $a->__get("nb_operation")) {
  686.                     return $b->__get("montant_cumule") - $a->__get("montant_cumule");
  687.                 } else {
  688.                     return $b->__get("nb_operation") - $a->__get("nb_operation");
  689.                 }
  690.             });
  691.         } else {
  692.             usort($classement_liste, function ($a$b) {
  693.                 if ($b->__get("montant_cumule") == $a->__get("montant_cumule")) {
  694.                     return $b->__get("nb_operation") - $a->__get("nb_operation");
  695.                 } else {
  696.                     return $b->__get("montant_cumule") - $a->__get("montant_cumule");
  697.                 }
  698.             });
  699.         }
  700.         $r 0;
  701.         $rCount 0;
  702.         $nbOperationPrece 0;
  703.         foreach ($classement_liste as $cl) {
  704.             if ($cl instanceof ClassementItem) {
  705.                 if ($tri == 1) {
  706.                     if ($nbOperationPrece == $cl->__get("nb_operation")) {
  707.                         $rCount $rCount 1;
  708.                         $cl->__set("rank"$r);
  709.                     } else {
  710.                         $rCount $rCount 1;
  711.                         $r $rCount;
  712.                         $cl->__set("rank"$rCount);
  713.                     }
  714.                     $nbOperationPrece $cl->__get("nb_operation");
  715.                 } else {
  716.                     $r $r 1;
  717.                     $cl->__set("rank"$r);
  718.                 }
  719.             }
  720.         }
  721.         return $classement_liste;
  722.     }
  723. }