<?php
namespace App\Controller;
use App\Services\BuzzActualiteService;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\BuzzOperations;
use App\Entity\BuzzRoles;
use App\Entity\BuzzActualites;
use App\Entity\BuzzTypesRoles;
use App\Entity\ServicesPrestataire;
use App\Entity\Localisations;
use App\Services\Util;
use App\Entity\CoordonneesServicePrestataire;
use App\Services\{
PaysAnnuaireExperts,
TelephoneInternational
};
use App\Services\ManagerEntity\{
ServicesPrestataireManagers
};
class DetailClassementController extends AbstractController
{
/**
* @var EntityManagerInterface
*/
public $em;
/**
* @var BuzzActualiteService
*/
public $buzzService;
// états (inchangés)
public $raison_sociale;
public $id_societe_prestataire;
public $type_operation;
public $type_role;
public $annee_operation;
public $id_localisation;
public $segment;
public $tri;
public $conseil_banque_type_role_liste = ["5","8","11","14","17"];
public $avocat_affaire_type_role_liste = ["6","9","12","15","18"];
public $cabinet_audit_type_role_liste = ["7","10","13","16","19"];
/**
* @var TelephoneInternational
*/
public $ti;
public function __construct(BuzzActualiteService $buzzService,EntityManagerInterface $em, TelephoneInternational $ti, ServicesPrestataireManagers $spm)
{
$this->em = $em;
$this->buzzService = $buzzService;
$this->ti = $ti;
$this->spm = $spm;
}
public function detailclassementitemsociete(Request $request, string $params): Response
{
// ====== récupération des paramètres (identique à ZF2) ======
$liste_id_operation = [];
$liste_operation = [];
$params = ltrim($params, '-');
$parts = explode(',', $params);
$result = [
'nom' => $parts[0] ?? null,
'id' => $parts[1] ?? null,
'structure' => $parts[2] ?? null,
'prestation' => $parts[3] ?? null,
'annee' => $parts[4] ?? null,
'localisation' => $parts[5] ?? null,
'segment' => $parts[6] ?? null,
'rank' => $parts[7] ?? null,
'tri' => $parts[8] ?? null,
];
$this->raison_sociale = $result["nom"];
$this->id_societe_prestataire = $result["id"];
$this->type_operation = $result["prestation"];
$this->type_role = $result["structure"];
$this->annee_operation = ($result["annee"] === "") ? $this->get_annee_defaut() : $result["annee"];
$lien_retour_loc = $result["localisation"];
$rankParam = $result["rank"];
if ($result["localisation"] !== null && $result["localisation"] !== "") {
$this->id_localisation = $result["localisation"];
} else {
$this->id_localisation = "33";
}
$liste_loc = $this->get_liste_localisation();
$nom_loc = $liste_loc[$this->id_localisation] ?? '';
if ($this->id_localisation === "00") {
$this->id_localisation = "";
}
$this->segment = ($result["segment"] === "") ? $this->get_segment_defaut() : $result["segment"];
$this->tri = ($result["tri"] === "") ? 0 : $result["tri"];
// ====== liste actualités (identique) ======
$actualites = $this->get_actualites($this->id_societe_prestataire, $this->annee_operation, 'S');
// mapping rôle => type pour lien retour (identique)
if ($this->type_role == "banques_affaires") {
$parametre_type_role = $this->conseil_banque_type_role_liste;
$lien_retour_type = "banques-affaires-conseils";
} elseif ($this->type_role == "avocats_affaires") {
$parametre_type_role = $this->avocat_affaire_type_role_liste;
$lien_retour_type = "avocats-affaires";
} elseif ($this->type_role == "cabinets_audit") {
$parametre_type_role = $this->cabinet_audit_type_role_liste;
$lien_retour_type = "cabinets-audit";
} else {
$parametre_type_role = [];
$lien_retour_type = "";
}
$lien_retour_oper = "";
if ($this->type_operation == "fusion_acquisition") {
$lien_retour_oper = "fusions-acquisitions";
} elseif ($this->type_operation == "levee_fonds") {
$lien_retour_oper = "levees-de-fonds";
} elseif ($this->type_operation == "tous") {
$lien_retour_oper = "tous";
}
$str_lien_retour = $lien_retour_type . '-' . $lien_retour_oper . '-' . $this->annee_operation . ',' . $lien_retour_loc . ',' . $this->segment . ',' . $this->tri;
// ====== boucle identique sur les actualités / opérations ======
foreach ($actualites as $actualite) {
if ($actualite instanceof BuzzActualites) {
$operation = $actualite->_get("id_operation");
$operation = $this->em->getRepository(BuzzOperations::class)->find($operation);
if ($operation instanceof BuzzOperations) {
$id_op = $operation->_get("id_operation");
if (!in_array($id_op, $liste_id_operation)) {
$type_oper = $operation->_get("type_operation");
$date_oper = $operation->_get("date_operation");
$id_loc = $operation->_get("id_localisation");
$id_loc2 = $operation->_get("id_localisation_2");
if ($this->type_operation == BuzzOperations::TYPE_OPERATION_TOUS) {
if (
($type_oper == BuzzOperations::TYPE_OPERATION_LEVEE_FONDS ||
$type_oper == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) &&
substr($date_oper, 0, 4) == $this->annee_operation &&
$actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
(substr($id_loc2, 0, strlen($this->id_localisation)) == $this->id_localisation ||
substr($id_loc, 0, strlen($this->id_localisation)) == $this->id_localisation)
) {
$flag = false;
$roles = $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
foreach ($roles as $buzz_role) {
if ($buzz_role instanceof BuzzRoles) {
$id_type_role = $buzz_role->_get("id_type_role");
if ($id_type_role != "" && in_array($id_type_role, $parametre_type_role)) {
$flag = true;
}
}
}
if ($flag) {
$operation->_set("titre_operation", $actualite->_get("titre_actualite"));
$operation->_set("id_actualite_principale", $actualite->_get("id_actualite"));
$operation->_set("autorisation_blog", $actualite->_get("autorisation_blog"));
if ($type_oper == "fusion_acquisition") {
$montant_seuil = $this->buzzService->get_seuil_max_min($this->segment); // <-- service
$temp_ca = $operation->_get("ca_societe_achetee") ?? 0;
$fourchette_ca = $operation->_get("fourchette_ca") ?? 0;
if (
($temp_ca != 0 && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
|| ($temp_ca == 0 && $fourchette_ca == 0 && ($this->segment == 1 || $this->segment == 2 || $this->segment == 3))
|| ($temp_ca == 0 && $fourchette_ca != 0 && $fourchette_ca <= $this->segment && ($fourchette_ca + 2) >= $this->segment)
) {
if ($operation->_get("maj_min_capital") == "0") {
$tempMontant = $operation->_get("ca_societe_achetee");
$pct = $operation->_get("pct_capital_achete");
$montant = $tempMontant * $pct / 100;
$operation->__set("ca_societe_achetee", round($montant, 0, PHP_ROUND_HALF_DOWN));
}
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
} else {
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
}
}
} else {
if (
$type_oper == $this->type_operation &&
substr($date_oper, 0, 4) == $this->annee_operation &&
$actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
(substr($id_loc, 0, strlen($this->id_localisation)) == $this->id_localisation ||
substr($id_loc2, 0, strlen($this->id_localisation)) == $this->id_localisation)
) {
$flag = false;
$roles = $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
foreach ($roles as $buzz_role) {
if ($buzz_role instanceof BuzzRoles) {
$id_type_role = $buzz_role->_get("id_type_role");
if ($id_type_role != "" && in_array($id_type_role, $parametre_type_role)) {
$flag = true;
}
}
}
if ($flag) {
$operation->_set("titre_operation", $actualite->_get("titre_actualite"));
$operation->_set("id_actualite_principale", $actualite->_get("id_actualite"));
$operation->_set("autorisation_blog", $actualite->_get("autorisation_blog"));
if ($this->type_operation == "fusion_acquisition") {
$montant_seuil = $this->buzzService->get_seuil_max_min($this->segment); // <-- service
$temp_ca = $operation->_get("ca_societe_achetee") ?? 0;
$fourchette_ca = $operation->_get("fourchette_ca") ?? 0;
if (
($temp_ca != 0 && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
|| ($temp_ca == 0 && $fourchette_ca == 0 && ($this->segment == 1 || $this->segment == 2 || $this->segment == 3))
|| ($temp_ca == 0 && $fourchette_ca != 0 && $fourchette_ca <= $this->segment && ($fourchette_ca + 2) >= $this->segment)
) {
if ($operation->_get("maj_min_capital") == "0") {
$tempMontant = $operation->_get("ca_societe_achetee");
$pct = $operation->_get("pct_capital_achete");
$montant = $tempMontant * $pct / 100;
$operation->__set("ca_societe_achetee", round($montant, 0, PHP_ROUND_HALF_DOWN));
}
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
} else {
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
}
}
}
}
}
}
}
// tri identique par date_operation DESC
usort($liste_operation, function ($a, $b) {
return $b->_get("date_operation") - $a->_get("date_operation");
});
// données "fiche"
$societe = $this->get_societe_par_id($this->id_societe_prestataire);
$service_prestataire = $this->get_services_prestataire_pour_societe($this->id_societe_prestataire);
$coordonnees_societe = $this->get_coordonnee_service_prestataire($service_prestataire->_get("id_service_prestataire"));
$buzz_type_role = $this->get_roles_par_societe($this->id_societe_prestataire, $liste_id_operation);
$util = new Util();
// lien site identique
if ($service_prestataire->_get('url_site_web') != "") {
$lien_shrinktheweb = $service_prestataire->_get('url_site_web');
} elseif ($service_prestataire->_get('url_site_web_visible') != "") {
$lien_shrinktheweb = $service_prestataire->_get('url_site_web_visible');
} else {
$lien_shrinktheweb = "www.fusacq.com";
}
$prestation = (!empty($service_prestataire)&&!empty($service_prestataire->_get("id_service_prestataire")))? $this->spm->getDetailServicesPrestataireById($service_prestataire->_get("id_service_prestataire"), $this->ti):[];
// rendu Twig (équivalent de ViewModel->setVariables)
return $this->render('classement/detail_societe.html.twig', [
"type_operation" => $this->type_operation,
"annee_operation" => $this->annee_operation,
"rank" => $rankParam,
"lien_expert" => 'https://www.fusacq.com' . '/activite-' . $service_prestataire->_get("id_service_prestataire") . ',' . $util->reecriture_pour_url($service_prestataire->_get("titre_service"), "-"),
"lien_shrinktheweb" => $lien_shrinktheweb,
"class" => $liste_operation,
"societe" => $societe,
"service_prestataire"=> $service_prestataire,
"coordonnees" => $coordonnees_societe,
"buzz_type_role" => $buzz_type_role,
"liste_type_role" => $this->get_tous_types_roles(),
"str_lien_retour" => $str_lien_retour,
"segment" => $this->segment,
"type_role" => $this->type_role,
"nom_loc" => $nom_loc,
"prestation" =>$prestation
]);
}
// =========================
// DÉTAIL RÉSEAU
// =========================
public function detailclassementitemreseau(Request $request, string $params): Response
{
$liste_id_operation = [];
$liste_operation = [];
$indexNonAutorisation = 0;
$params = ltrim($params, '-');
$parts = explode(',', $params);
$result = [
'nom' => $parts[0] ?? null,
'id' => $parts[1] ?? null,
'structure' => $parts[2] ?? null,
'prestation' => $parts[3] ?? null,
'annee' => $parts[4] ?? null,
'localisation' => $parts[5] ?? null,
'segment' => $parts[6] ?? null,
'rank' => $parts[7] ?? null,
'tri' => $parts[8] ?? null,
];
$this->raison_sociale = $result["nom"];
$this->id_societe_prestataire = $result["id"];
$this->type_operation = $result["prestation"];
$this->type_role = $result["structure"];
$this->annee_operation = ($result["annee"] === "") ? $this->get_annee_defaut() : $result["annee"];
$lien_retour_loc = $result["localisation"];
$rankParam = $result["rank"];
if ($result["localisation"] !== null && $result["localisation"] !== "") {
$this->id_localisation = $result["localisation"];
} else {
$this->id_localisation = "33";
}
$liste_loc = $this->get_liste_localisation();
$nom_loc = $liste_loc[$this->id_localisation] ?? '';
if ($this->id_localisation === "00") {
$this->id_localisation = "";
}
$this->segment = ($result["segment"] === "") ? $this->get_segment_defaut() : $result["segment"];
$this->tri = ($result["tri"] === "") ? 0 : $result["tri"];
$actualites = $this->get_actualites($this->id_societe_prestataire, $this->annee_operation, 'R');
if ($this->type_role == "banques_affaires") {
$parametre_type_role = $this->conseil_banque_type_role_liste;
$lien_retour_type = "banques-affaires-conseils";
} elseif ($this->type_role == "avocats_affaires") {
$parametre_type_role = $this->avocat_affaire_type_role_liste;
$lien_retour_type = "avocats-affaires";
} elseif ($this->type_role == "cabinets_audit") {
$parametre_type_role = $this->cabinet_audit_type_role_liste;
$lien_retour_type = "cabinets-audit";
} else {
$parametre_type_role = [];
$lien_retour_type = "";
}
$lien_retour_oper = "";
if ($this->type_operation == "fusion_acquisition") {
$lien_retour_oper = "fusions-acquisitions";
} elseif ($this->type_operation == 'levee_fonds') {
$lien_retour_oper = "levees-de-fonds";
} elseif ($this->type_operation == "tous") {
$lien_retour_oper = "tous";
}
$str_lien_retour = $lien_retour_type . '-' . $lien_retour_oper . '-' . $this->annee_operation . ',' . $lien_retour_loc . ',' . $this->segment . ',' . $this->tri;
foreach ($actualites as $actualite) {
if ($actualite instanceof BuzzActualites) {
$operation = $actualite->_get("id_operation");
$operation = $this->em->getRepository(BuzzOperations::class)->find($operation);
if ($operation instanceof BuzzOperations) {
$id_op = $operation->_get("id_operation");
if (!in_array($id_op, $liste_id_operation)) {
$type_oper = $operation->_get("type_operation");
$date_oper = $operation->_get("date_operation");
$id_loc = $operation->_get("id_localisation");
$id_loc2 = $operation->_get("id_localisation_2");
if ($this->type_operation == BuzzOperations::TYPE_OPERATION_TOUS) {
if (
($type_oper == BuzzOperations::TYPE_OPERATION_LEVEE_FONDS ||
$type_oper == BuzzOperations::TYPE_OPERATION_FUSION_ACQUISITION) &&
substr($date_oper, 0, 4) == $this->annee_operation &&
$actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
(substr($id_loc, 0, strlen($this->id_localisation)) == $this->id_localisation ||
substr($id_loc2, 0, strlen($this->id_localisation)) == $this->id_localisation)
) {
$flag = false;
$roles = $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
foreach ($roles as $buzz_role) {
if ($buzz_role instanceof BuzzRoles) {
$id_type_role = $buzz_role->_get("id_type_role");
if ($id_type_role != "" && in_array($id_type_role, $parametre_type_role)) {
$flag = true;
}
}
}
if ($flag) {
$operation->_set("titre_operation", $actualite->_get("titre_actualite"));
$operation->_set("id_actualite_principale", $actualite->_get("id_actualite"));
$operation->_set("autorisation_blog", $actualite->_get("autorisation_blog"));
if ($operation->_get("autorisation_blog") == "non") {
$indexNonAutorisation++;
}
if ($type_oper == "fusion_acquisition") {
$montant_seuil = $this->buzzService->get_seuil_max_min($this->segment); // <-- service
$temp_ca = $operation->_get("ca_societe_achetee") ?? 0;
$fourchette_ca = $operation->_get("fourchette_ca") ?? 0;
if (
($temp_ca != 0 && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
|| ($temp_ca == 0 && $fourchette_ca == 0 && ($this->segment == 1 || $this->segment == 2 || $this->segment == 3))
|| ($temp_ca == 0 && $fourchette_ca != 0 && $fourchette_ca <= $this->segment && ($fourchette_ca + 2) >= $this->segment)
) {
if ($operation->_get("maj_min_capital") == "0") {
$tempMontant = $operation->_get("ca_societe_achetee");
$pct = $operation->_get("pct_capital_achete");
$montant = $tempMontant * $pct / 100;
$operation->__set("ca_societe_achetee", round($montant, 0, PHP_ROUND_HALF_DOWN));
}
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
} else {
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
}
}
} else {
if (
$type_oper == $this->type_operation &&
substr($date_oper, 0, 4) == $this->annee_operation &&
$actualite->_get("type_actualite") == BuzzActualites::TYPE_ACTUALITE_REFERENCE &&
(substr($id_loc, 0, strlen($this->id_localisation)) == $this->id_localisation ||
substr($id_loc2, 0, strlen($this->id_localisation)) == $this->id_localisation)
) {
$flag = false;
$roles = $this->em->getRepository(BuzzRoles::class)->findBy(array("id_operation"=>$operation->_get("id_operation")));
foreach ($roles as $buzz_role) {
if ($buzz_role instanceof BuzzRoles) {
$id_type_role = $buzz_role->_get("id_type_role");
if ($id_type_role != "" && in_array($id_type_role, $parametre_type_role)) {
$flag = true;
}
}
}
if ($flag) {
$operation->_set("titre_operation", $actualite->_get("titre_actualite"));
$operation->_set("id_actualite_principale", $actualite->_get("id_actualite"));
$operation->_set("autorisation_blog", $actualite->_get("autorisation_blog"));
if ($operation->_get("autorisation_blog") == "non") {
$indexNonAutorisation++;
}
if ($this->type_operation == "fusion_acquisition") {
$montant_seuil = $this->buzzService->get_seuil_max_min($this->segment); // <-- service
$temp_ca = $operation->_get("ca_societe_achetee") ?? 0;
$fourchette_ca = $operation->_get("fourchette_ca") ?? 0;
if (
($temp_ca != 0 && $montant_seuil["min"] <= $temp_ca && $temp_ca <= $montant_seuil["max"])
|| ($temp_ca == 0 && $fourchette_ca == 0 && ($this->segment == 1 || $this->segment == 2 || $this->segment == 3))
|| ($temp_ca == 0 && $fourchette_ca != 0 && $fourchette_ca <= $this->segment && ($fourchette_ca + 2) >= $this->segment)
) {
if ($operation->_get("maj_min_capital") == "0") {
$tempMontant = $operation->_get("ca_societe_achetee");
$pct = $operation->_get("pct_capital_achete");
$montant = $tempMontant * $pct / 100;
$operation->_set("ca_societe_achetee", round($montant, 0, PHP_ROUND_HALF_DOWN));
}
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
} else {
$liste_id_operation[] = $id_op;
$liste_operation[] = $operation;
}
}
}
}
}
}
}
}
usort($liste_operation, function ($a, $b) {
return $b->_get("date_operation") - $a->_get("date_operation");
});
$reseau = $this->get_reseaux_par_id($this->id_societe_prestataire);
$service_prestataire = $this->get_services_prestataire_par_id($reseau->__get("id_service_prestataire"));
$coordonnees_reseau = $this->get_coordonnee_service_prestataire($reseau->__get("id_service_prestataire"));
if ($reseau->__get("id_service_prestataire") == "") {
$service_prestataire = $this->get_service_prestataire_pour_reseau($reseau->__get("id_reseau"));
$coordonnees_reseau = new CoordonneesServicePrestataire();
$coordonnees_reseau->_set("adresse", $reseau->__get('adresse'));
$coordonnees_reseau->_set("code_postal", $reseau->__get('code_postal'));
$coordonnees_reseau->_set("ville", $reseau->__get('ville'));
$coordonnees_reseau->_set("telephone", $reseau->__get('telephone'));
$coordonnees_reseau->_set("nom_contact1", $reseau->__get('contact'));
}
$buzz_type_role = $this->get_roles_par_reseau($this->id_societe_prestataire, $liste_id_operation);
$util = new Util();
$liste_membres_reseaux = $this->get_membres_reseaux($reseau->__get("id_reseau"));
$liste_membres = [];
$nom_commercial_societe = [];
foreach ($liste_membres_reseaux as $membre_reseau) {
$membre = [];
if (!in_array($membre_reseau->_get("nom_commercial_societe"), $nom_commercial_societe)) {
$membre["nom_commercial_societe"] = $membre_reseau->_get("nom_commercial_societe");
$membre["lien"] = 'https://www.fusacq.com' . '/activite-' . $membre_reseau->_get("id_service_prestataire") . ',' . $util->reecriture_pour_url($membre_reseau->_get("titre_service"), "-");
$liste_membres[] = $membre;
$nom_commercial_societe[] = $membre["nom_commercial_societe"];
}
}
usort($liste_membres, function ($a, $b) {
return strcasecmp($a['nom_commercial_societe'], $b['nom_commercial_societe']);
});
if ($service_prestataire->_get('url_site_web') != "") {
$lien_shrinktheweb = $service_prestataire->_get('url_site_web');
} elseif ($service_prestataire->_get('url_site_web_visible') != "") {
$lien_shrinktheweb = $service_prestataire->_get('url_site_web_visible');
} else {
$lien_shrinktheweb = "www.fusacq.com";
}
$prestation = (!empty($service_prestataire))? $this->spm->getDetailServicesPrestataireById($service_prestataire->_get("id_service_prestataire"), $this->ti):[];
return $this->render('classement/detail_reseau.html.twig', [
"indexNonAutorisation" => $indexNonAutorisation,
"type_operation" => $this->type_operation,
"annee_operation" => $this->annee_operation,
"rank" => $rankParam,
"lien_expert" => 'https://www.fusacq.com/activite-' . $service_prestataire->_get("id_service_prestataire") . ',' . $util->reecriture_pour_url($service_prestataire->_get("titre_service"), "-"),
"lien_shrinktheweb" => $lien_shrinktheweb,
"class" => $liste_operation,
"reseau" => $reseau,
"service_prestataire" => $service_prestataire,
"coordonnees" => $coordonnees_reseau,
"buzz_type_role" => $buzz_type_role,
"liste_type_role" => $this->get_tous_types_roles(),
"str_lien_retour" => $str_lien_retour,
"segment" => $this->segment,
"type_role" => $this->type_role,
"nom_loc" => $nom_loc,
"liste_membres_reseaux"=> $liste_membres,
"prestation" =>$prestation
]);
}
// =========================
// Méthodes privées = copie conforme logique ZF2
// =========================
private function get_actualites($id_societe, $annee, $type)
{
$annee_avant_str = $annee . '0101000000';
$annee_apres = $annee + 1;
if ($annee == '2019') {
$annee_apres_str = $annee_apres . '0206235959';
} elseif ($annee == '2020') {
$annee_apres_str = $annee_apres . '0204235959';
} elseif ($annee == '2021') {
$annee_apres_str = $annee_apres . '0203235959';
} elseif ($annee == '2022') {
$annee_apres_str = $annee_apres . '0209235959';
} elseif ($annee == '2023') {
$annee_apres_str = $annee_apres . '0208235959';
} elseif ($annee == '2024') {
$annee_apres_str = $annee_apres . '0206235959';
}elseif ($annee == '2025') {
$annee_apres_str = $annee_apres . '0205235959';
}// la date changé chqaue annee et ici c'est la meme façon de calculation date que dans la liste classement
if ($type == 'R') {
$criteria = Criteria::create()
->where(Criteria::expr()->eq("apparition_classement", "oui"))
->andWhere(Criteria::expr()->eq("id_reseau", $id_societe))
->andWhere(Criteria::expr()->eq("classement_reseau", "oui"))
->andWhere(Criteria::expr()->gt("date_mise_en_ligne", $annee_avant_str))
->andWhere(Criteria::expr()->lt("date_mise_en_ligne", $annee_apres_str))
->andWhere(Criteria::expr()->eq("mode_actualite", BuzzActualites::MODE_ACTUALITE_PUBLIQUE));
} else {
$criteria = Criteria::create()
->where(Criteria::expr()->eq("apparition_classement", "oui"))
->andWhere(Criteria::expr()->eq("id_societe_prestataire", $id_societe))
->andWhere(Criteria::expr()->gt("date_mise_en_ligne", $annee_avant_str))
->andWhere(Criteria::expr()->lt("date_mise_en_ligne", $annee_apres_str))
->andWhere(Criteria::expr()->eq("mode_actualite", BuzzActualites::MODE_ACTUALITE_PUBLIQUE));
}
return $this->em->getRepository(BuzzActualites::class)->matching($criteria);
}
private function get_tous_types_roles()
{
$liste_type_role = [];
$resultat = $this->em->getRepository(BuzzTypesRoles::class)->findAll();
foreach ($resultat as $type_role) {
if ($type_role instanceof BuzzTypesRoles) {
$liste_type_role[$type_role->__get("id_type_role")] = $type_role->__get("nom_role");
}
}
return $liste_type_role;
}
private function get_reseaux_par_id($id_reseau)
{
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_reseau", $id_reseau));
$liste = $this->em->getRepository('App\Entity\Reseaux')->matching($criteria);
$reseau = null;
foreach ($liste as $r) { $reseau = $r; }
return $reseau;
}
private function get_societe_par_id($id_societe)
{
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_societe_prestataire", $id_societe));
$liste = $this->em->getRepository('App\Entity\SocietesPrestataire')->matching($criteria);
$societe = null;
foreach ($liste as $r) { $societe = $r; }
return $societe;
}
private function get_services_prestataire_par_id($id_service_prestataire)
{
$service = new ServicesPrestataire();
if ($id_service_prestataire !== null && $id_service_prestataire !== '') {
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_service_prestataire", $id_service_prestataire));
$liste = $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
foreach ($liste as $s) { $service = $s; }
}
return $service;
}
private function get_services_prestataire_pour_societe($id_societe_prestataire)
{
$service = new ServicesPrestataire();
$criteria = Criteria::create()
->where(Criteria::expr()->eq("id_societe_prestataire", $id_societe_prestataire))
->andWhere(Criteria::expr()->orX(
Criteria::expr()->eq("statut", 'publique'),
Criteria::expr()->eq("statut", 'publique_temporaire')
))
->orderBy(["id_service_prestataire" => Criteria::DESC]);
$liste = $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
foreach ($liste as $s) { $service = $s; }
return $service;
}
private function get_coordonnee_service_prestataire($id_service_prestataire)
{
$coordonnee = new CoordonneesServicePrestataire();
if ($id_service_prestataire !== null && $id_service_prestataire !== '') {
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_service_prestataire", $id_service_prestataire));
$liste = $this->em->getRepository(CoordonneesServicePrestataire::class)->matching($criteria);
foreach ($liste as $c) { $coordonnee = $c; }
}
return $coordonnee;
}
private function get_roles_par_reseau($id_reseau, $liste_operation)
{
$liste_id_service_prestataire = [];
$cri = Criteria::create()->where(Criteria::expr()->eq("id_reseau", $id_reseau));
$result_sp = $this->em->getRepository(ServicesPrestataire::class)->matching($cri);
foreach ($result_sp as $sp) {
$liste_id_service_prestataire[] = $sp->_get("id_service_prestataire");
}
$criteria = Criteria::create()
->where(Criteria::expr()->in("id_acteur", $liste_id_service_prestataire))
->andWhere(Criteria::expr()->in("id_operation", $liste_operation))
->andWhere(Criteria::expr()->eq("table_sql_acteur", 'services_prestataire'));
return $this->em->getRepository(BuzzRoles::class)->matching($criteria);
}
private function get_roles_par_societe($id_societe_prestataire, $liste_operation)
{
$liste_id_service_prestataire = [];
$cri = Criteria::create()->where(Criteria::expr()->eq("id_societe_prestataire", $id_societe_prestataire));
$result_sp = $this->em->getRepository(ServicesPrestataire::class)->matching($cri);
foreach ($result_sp as $sp) {
$liste_id_service_prestataire[] = $sp->_get("id_service_prestataire");
}
$criteria = Criteria::create()
->where(Criteria::expr()->in("id_acteur", $liste_id_service_prestataire))
->andWhere(Criteria::expr()->in("id_operation", $liste_operation))
->andWhere(Criteria::expr()->eq("table_sql_acteur", 'services_prestataire'));
return $this->em->getRepository(BuzzRoles::class)->matching($criteria);
}
private function get_service_prestataire_pour_reseau($id_reseau)
{
$service = new ServicesPrestataire();
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_reseau", $id_reseau));
$liste = $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
foreach ($liste as $s) { $service = $s; }
return $service;
}
private function get_liste_localisation()
{
$liste_loc = [];
$liste_loc["00"] = "France - Etranger";
$liste_loc["33"] = "France";
$criteria = Criteria::create()->where(Criteria::expr()->eq("id_localisation_pere", "33"));
$result = $this->em->getRepository(Localisations::class)->matching($criteria);
foreach ($result as $loc) {
if ($loc instanceof Localisations) {
$liste_loc[$loc->__get("id_localisation")] = $loc->__get("nom_localisation");
}
}
return $liste_loc;
}
private function get_annee_defaut()
{
$criteria = Criteria::create()->where(Criteria::expr()->eq("nom_parametre", "annee_defaut_classements"));
$repo = $this->em->getRepository('App\Entity\ParametresGeneraux');
$result = $repo->matching($criteria);
return $result[0]->_get("valeur_parametre");
}
private function get_segment_defaut()
{
$criteria = Criteria::create()->where(Criteria::expr()->eq("nom_parametre", "segment_defaut_classements"));
$repo = $this->em->getRepository('App\Entity\ParametresGeneraux');
$result = $repo->matching($criteria);
return $result[0]->_get("valeur_parametre");
}
private function get_membres_reseaux($id_reseau)
{
$criteria = Criteria::create()
->where(Criteria::expr()->eq("id_reseau", $id_reseau))
->andWhere(Criteria::expr()->eq("statut", "publique"));
return $this->em->getRepository(ServicesPrestataire::class)->matching($criteria);
}
}