src/Controller/Compte/IndexController.php line 102

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * @author Mehrez Labidi
  5.  */
  6. namespace App\Controller\Compte;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use App\Controller\EntityUsingController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use App\Services\Compte\Annonces\AnnoncesManagers;
  12. use App\Services\Compte\Alertes\AlertesManagers;
  13. use App\Services\Compte\Favoris\FavorisManagers;
  14. use App\Services\Compte\Commandes\CommandesManagers;
  15. use App\Services\Compte\DI\DIManagers;
  16. use App\Services\Compte\CvRepreneurs\CvRepreneursManagers;
  17. use App\Services\ManagerEntity\DroitsAccesManagers;
  18. use App\Services\Annonces\Elites\RechercheElite;
  19. class IndexController extends EntityUsingController {
  20.     public function __construct(EntityManagerInterface $emAnnoncesManagers $amAlertesManagers $almFavorisManagers $fmCommandesManagers $cmCvRepreneursManagers $crmDIManagers $dimDroitsAccesManagers $dam) {
  21.         $this->am $am;
  22.         $this->alm $alm;
  23.         $this->em $em;
  24.         $this->fm $fm;
  25.         $this->cm $cm;
  26.         $this->crm $crm;
  27.         $this->dim $dim;
  28.         $this->dam $dam;
  29.     }
  30.     public function index(Request $request$codePays): Response {
  31.         $this->denyAccessUnlessGranted('ROLE_USER'); //  page inaccessible sans authentification
  32.         $nbAlertes $this->alm->getNb();
  33.         $nbFavoris $this->fm->getNb();
  34.         $nbCommandes $this->cm->getNb();
  35.         $cv $this->etatCVRepreneur();
  36.         $etatCV = ($cv) ? $cv->getModeProfil() : "";
  37.         $nbDIs $this->dim->counterDIs();
  38.         $nbIncomplet $this->am->getNbAnnoncesAcheteur("incomplet") + $this->am->getNbAnnoncesVendeur("incomplet");
  39.         if ($nbIncomplet 0) {
  40.             $annonces = ["type_annonce" => "incomplet""nb_annonce" => $nbIncomplet];
  41.             return $this->render('compte/index.html.twig', [
  42.                         "nbAlertes" => $nbAlertes,
  43.                         "nbFavoris" => $nbFavoris"etatCV" => $etatCV"nbDIs" => $nbDIs,
  44.                         "nbCommandes" => $nbCommandes"annonces" => $annonces
  45.             ]);
  46.         }
  47.         $nbPublique $this->am->getNbAnnoncesAcheteur("publique") + $this->am->getNbAnnoncesVendeur("publique")+ $this->am->getNbAnnoncesVendeur("publique_elite");
  48.         if ($nbPublique 0) {
  49.             $annonces = ["type_annonce" => "publique""nb_annonce" => $nbPublique];
  50.             return $this->render('compte/index.html.twig', [
  51.                         "nbAlertes" => $nbAlertes,
  52.                         "nbFavoris" => $nbFavoris"etatCV" => $etatCV"nbDIs" => $nbDIs,
  53.                         "nbCommandes" => $nbCommandes"annonces" => $annonces
  54.             ]);
  55.         }
  56.         $nbValidation $this->am->getNbAnnoncesAcheteur("demande_publication") + $this->am->getNbAnnoncesVendeur("demande_publication");
  57.         if ($nbValidation 0) {
  58.             $annonces = ["type_annonce" => "validation""nb_annonce" => $nbValidation];
  59.             return $this->render('compte/index.html.twig', [
  60.                         "nbAlertes" => $nbAlertes,
  61.                         "nbFavoris" => $nbFavoris"etatCV" => $etatCV"nbDIs" => $nbDIs,
  62.                         "nbCommandes" => $nbCommandes"annonces" => $annonces
  63.             ]);
  64.         }
  65.         $nbAttente $this->am->getNbAnnoncesAcheteur("attente_envoi""oui") + $this->am->getNbAnnoncesVendeur("attente_envoi""oui");
  66.         if ($nbAttente 0) {
  67.             $annonces = ["type_annonce" => "attente""nb_annonce" => $nbAttente];
  68.             return $this->render('compte/index.html.twig', [
  69.                         "nbAlertes" => $nbAlertes,
  70.                         "nbFavoris" => $nbFavoris"etatCV" => $etatCV"nbDIs" => $nbDIs,
  71.                         "nbCommandes" => $nbCommandes"annonces" => $annonces
  72.             ]);
  73.         }
  74.         $nbCreation $this->am->getNbAnnoncesAcheteur("attente_envoi""non") + $this->am->getNbAnnoncesVendeur("attente_envoi""non");
  75.         if ($nbCreation 0) {
  76.             $annonces = ["type_annonce" => "creation""nb_annonce" => $nbCreation];
  77.             return $this->render('compte/index.html.twig', [
  78.                         "nbAlertes" => $nbAlertes,
  79.                         "nbFavoris" => $nbFavoris"etatCV" => $etatCV"nbDIs" => $nbDIs,
  80.                         "nbCommandes" => $nbCommandes"annonces" => $annonces
  81.             ]);
  82.         }
  83.         return $this->render('compte/index.html.twig', [
  84.                     "nbAlertes" => $nbAlertes"nbDIs" => $nbDIs,
  85.                     "nbFavoris" => $nbFavoris"etatCV" => $etatCV,
  86.                     "nbCommandes" => $nbCommandes
  87.         ]);
  88.     }
  89.     public function colonneGauche(Request $request$codePays): Response {
  90.         $this->denyAccessUnlessGranted('ROLE_USER'); //  page inaccessible sans authentification
  91.         $nbAnnonces $this->nbAnnonces();
  92.         $lang $request->getSession()->get('lang');
  93.         $cv $this->etatCVRepreneur();
  94.         $etatCV = ($cv) ? $cv->getModeProfil() : "";
  95.         $accessElite $this->dam->checkIfThisUserHasDroitService($this->getUser(), RechercheElite::CODE_SERVICE); // ELITE
  96.         return $this->render('compte/colonne_gauche.html.twig', [
  97.                     "nbAnnonces" => $nbAnnonces,
  98.                     "etatCV" => $etatCV,
  99.                     "accessElite" => $accessElite,
  100.                     "codePaysWithUnderScore" => $codePays,
  101.                     "lang" => $lang
  102.         ]);
  103.     }
  104.     /**
  105.      * 
  106.      * @return array
  107.      */
  108.     private function nbAnnonces() {
  109.         $nbCreation $this->am->getNbAnnoncesAcheteur("attente_envoi""non") + $this->am->getNbAnnoncesVendeur("attente_envoi""non");
  110.         $nbAttente $this->am->getNbAnnoncesAcheteur("attente_envoi""oui") + $this->am->getNbAnnoncesVendeur("attente_envoi""oui");
  111.         $nbValidation $this->am->getNbAnnoncesAcheteur("demande_publication") + $this->am->getNbAnnoncesVendeur("demande_publication");
  112.         $nbPublique $this->am->getNbAnnoncesAcheteur("publique") + $this->am->getNbAnnoncesVendeur("publique");
  113.         return [
  114.             "creation" => $nbCreation,
  115.             "attente" => $nbAttente,
  116.             "validation" => $nbValidation,
  117.             "publique" => $nbPublique,
  118.             "sum" => (int) $nbCreation + (int) $nbAttente + (int) $nbValidation + (int) $nbPublique
  119.         ];
  120.     }
  121.     private function etatCVRepreneur() {
  122.         $user $this->getUser();
  123.         return $this->crm->getCvByLoginUtilisateur($user->getLogin());
  124.     }
  125. }