src/Service/StatistiquesService.php line 44

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use App\Repository\SubscriptionRepository;
  5. use App\Repository\ClassRoomRepository;
  6. use App\Repository\SchoolYearRepository;
  7. use App\Repository\UserRepository;
  8. use App\Service\SchoolYearService;
  9. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  10. class StatistiquesService
  11. {
  12.     private SubscriptionRepository $subRepo;
  13.     private SchoolYearRepository $scRepo;
  14.     private ClassRoomRepository $roomRepo;
  15.     private UserRepository $userRepo;
  16.     private SessionInterface $session;
  17.     private SchoolYearService $schoolYearService;
  18.     private EntityManagerInterface $em;
  19.     public function __constructSchoolYearService $schoolYearServiceEntityManagerInterface $emUserRepository $userRepoSchoolYearRepository $scRepoClassRoomRepository $rmRepoSubscriptionRepository $subRepoSessionInterface $session)
  20.     {
  21.         $this->em $em;
  22.         $this->userRepo $userRepo;
  23.         $this->scRepo $scRepo;
  24.         $this->roomRepo $rmRepo;
  25.         $this->subRepo $subRepo;
  26.         $this->session $session;
  27.         $this->schoolYearService $schoolYearService;
  28.     }
  29.     public function teachers()
  30.     {
  31.         
  32.         
  33.         $users $this->userRepo->findAllOfCurrentYear($this->schoolYearService->sessionYearById());
  34.         return count($users);
  35.     }
  36.     public function students()
  37.     {
  38.         $students $this->subRepo->findBy(array("schoolYear" => $this->schoolYearService->sessionYearById()));
  39.         return count($students);
  40.     }
  41.     public function rooms()
  42.     {
  43.         $roomsEnabled $this->roomRepo->countEnabledClassRoom($this->schoolYearService->sessionYearById());
  44.         return count($roomsEnabled);
  45.     }
  46.     public function insolvents()
  47.     {
  48.         $year $this->schoolYearService->sessionYearById();
  49.         $paymentPlan =  $year->getPaymentPlan();
  50.         $subscriptions $this->subRepo->findBy(array("schoolYear" =>  $year));
  51.         $students = [];
  52.      
  53.         foreach($subscriptions as $sub){
  54.             if($year->paymentThresholdAmount($sub->getClassRoom()) > $sub->getStudent()->getPaymentsSum($year) ){
  55.                 $students[] = $sub->getStudent() ;
  56.             }
  57.         }
  58.         return count$students);
  59.     }
  60. }