src/Controller/Client/HomeController.php line 68

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Client;
  3. use DateTime;
  4. use App\Util\ParameterUtil;
  5. use App\Service\AuthService;
  6. use App\Service\EquipeService;
  7. use App\Service\WalletService;
  8. use App\Service\ContratService;
  9. use App\Service\PackBuyService;
  10. use App\Service\RevenueService;
  11. use App\Service\CarriereService;
  12. use App\Service\LicenciasService;
  13. use App\Repository\UsersRepository;
  14. use App\Repository\WalletRepository;
  15. use App\Repository\AnnoncesRepository;
  16. use Doctrine\ORM\EntityManagerInterface;
  17. use App\Service\CommissionHandlerService;
  18. use App\Repository\RevenueReportsRepository;
  19. use App\Repository\UserInformationRepository;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use ContainerEeeIkK5\getPackBuyServiceService;
  22. use Symfony\Component\HttpFoundation\Response;
  23. use Symfony\Component\Routing\Annotation\Route;
  24. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  25. class HomeController extends AbstractController
  26. {
  27.     private $walletRepository;
  28.     private $carriereService;
  29.     private $packBuyService;
  30.     private $revenueReportsRepository;
  31.     private $equipeService;
  32.     private $licenceService;
  33.     private $revenueService;
  34.     public function __construct(
  35.         WalletRepository $walletRepository,
  36.         CarriereService $carriereService,
  37.         PackBuyService $packBuyService,
  38.         RevenueReportsRepository $revenueReportsRepository,
  39.         EquipeService $equipeService,
  40.         LicenciasService $licenceService,
  41.         RevenueService $revenueService,
  42.         private EntityManagerInterface $entityManager,
  43.         private PackBuyService $packService,
  44.         private UsersRepository $usersRepository,
  45.         private CommissionHandlerService $commissionHandlerService,
  46.         private ContratService $contratService,
  47.         private UserInformationRepository $userInformationRepository,
  48.     ){
  49.         $this->walletRepository $walletRepository;
  50.         $this->carriereService $carriereService;
  51.         $this->packBuyService $packBuyService;
  52.         $this->revenueReportsRepository $revenueReportsRepository;
  53.         $this->equipeService $equipeService;
  54.         $this->licenceService=$licenceService;
  55.         $this->revenueService $revenueService;
  56.     }
  57.     #[Route('/'name'app_home_index')]
  58.     public function index(): Response
  59.     {
  60.         $user $this->getUser();
  61.         if(in_array("ROLE_PLAYER"$user->getRoles())){
  62.             return $this->redirectToRoute('app_player_index');
  63.         }
  64.         return $this->redirectToRoute('app_client_dahsboard');
  65.     }
  66.     #[Route('/dashboard'name'app_client_dahsboard')]
  67.     public function dashboard(AnnoncesRepository $annoncesRepository,AuthService $authService): Response
  68.     {
  69.         if(in_array("ROLE_PLAYER"$this->getUser()->getRoles())){
  70.             return $this->redirectToRoute('app_player_index');
  71.         }
  72.         $now = new DateTime();
  73.         
  74.         $annonce $annoncesRepository->getActiveAnnoncesByBackOfficeLevel($this->getUser()->getCurrentBackOfficeLevel(),$now);
  75.         $plafond $this->licenceService->getUserPlafond($this->getUser());
  76.         $wallet $this->walletRepository->findOneBy(['userId' =>$this->getUser()->getId()]);
  77.         $carriere $this->carriereService->getUserDenormalizedQualification($this->getUser());
  78.         $nextQualification ParameterUtil::getQualificationByRank($carriere->getUserRank() +);
  79.         $packActifInformation $this->packBuyService->getPackActifInformation($this->getUser());
  80.         $weekIncome $this->revenueService->getTotalRevenueByUserWeekAndYear($this->getUser());
  81.         $directMembersInformation $this->equipeService->getDirectMemberInformation($this->getUser());
  82.         $userRevenue $this->revenueReportsRepository->getTotalRevenueByUser($this->getUser());
  83.         $directChildrenHighestPack $this->packService->getHighestPackOfDirectChildrenBySide($this->getUser());
  84.         $directMembers $this->usersRepository->countDirectChildren($this->getUser());
  85.         $directMembersSample $this->usersRepository->getDirectMembersSample($this->getUser());
  86.         $downMembersSampleOfEachSide $authService->getDownMembersOfEachSideSample($this->getUser());
  87.         $parrainageCommission$this->commissionHandlerService->getCurrentParrainageCommission($this->getUser());
  88.         $directMembersActifs $this->userInformationRepository->countActifDirectChildren($this->getUser());
  89.         if($userRevenue['rv_gauche'] == || $userRevenue['rv_droite'] == ){
  90.             $weekIncome['rv_gauche'] = $userRevenue['rv_gauche'];
  91.             $weekIncome['rv_droite'] = $userRevenue['rv_droite'];
  92.         }
  93.         $contratState $this->contratService->checkPendingContrat($this->getUser());
  94.         $dayLeftForFastStart $this->carriereService->getDayLeftForFastStart($this->getUser());
  95.         return $this->render('dashboard/client_dashboard.html.twig',[
  96.             'wallet' => $wallet,
  97.             'annonces'=> $annonce,
  98.             'carriere' => $carriere,
  99.             'nextQualification' => $nextQualification,
  100.             'packActifInformation' => $packActifInformation,
  101.             'weekIncome' => $weekIncome,
  102.             'directMembersInformation' => $directMembersInformation,
  103.             'plafond' => $plafond,
  104.             'userRevenue' => $userRevenue,
  105.             'directChildrenHighestPack' => $directChildrenHighestPack,
  106.             'directMembers' => $directMembers,
  107.             'directMembersSample' => $directMembersSample,
  108.             'downMembersSampleOfEachSide' => $downMembersSampleOfEachSide,
  109.             'parrainageCommission'=> $parrainageCommission,
  110.             'contratState' => $contratState ,
  111.             'directMembersActifs' => $directMembersActifs,
  112.             'dayLeftForFastStart' => $dayLeftForFastStart
  113.         ]);
  114.     }
  115.     #[Route('/informations'name'app_important_infos')]
  116.     public function informations(): Response
  117.     {
  118.         return $this->render('infos/infos.html.twig',[
  119.             
  120.         ]);
  121.     }
  122.     #[Route('/data-protection-infos'name'app_data_protection_infos')]
  123.     public function dataProtectionInfos(Request $request): Response
  124.     {
  125.         if ($request->isMethod('POST')) { 
  126.             $dataProtectionChecked $request->get('dataProtectionChecked');
  127.             if($dataProtectionChecked){
  128.                 $user = (object)$this->getUser();
  129.                 $user->setDataProtectionChecked(true);
  130.                 $this->entityManager->persist($user);
  131.                 $this->entityManager->flush();
  132.                 if($this->isGranted('KYC_INFO_SUBMITTED')){
  133.                     return $this->redirectToRoute('app_client_dahsboard');
  134.                 }
  135.                 return $this->redirectToRoute('app_kyc');
  136.             }
  137.         }
  138.         return $this->render('infos/data-protection-infos.html.twig',[
  139.             
  140.         ]);
  141.     }
  142.     
  143. }