<?php
namespace App\Controller\admin;
use App\Constant\TheProperty\ThePropertyConstants;
use App\Entity\Offer;
use App\Entity\Plan\PlanSubscription;
use App\Entity\TheProperty;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/admin")
*/
class TableaudebordController extends AbstractController
{
/**
* @Route("/", name="tableaudebord")
*/
public function index(EntityManagerInterface $em): Response
{
$allPersonals = $em->getRepository(User::class)->ListOfPersonnels();
$allClients = $em->getRepository(User::class)->ListOfClients();
$allOffers = $em->getRepository(Offer::class)->getoffernotarchive();
$propertiesWaiting = $em->getRepository(TheProperty::class)->findBy(['status' => ThePropertyConstants::THE_PROPERTY_STATUS_WAITING]);
$propertiesValid = $em->getRepository(TheProperty::class)->findBy(['status' => ThePropertyConstants::THE_PROPERTY_STATUS_VALID]);
$userSubscribed = $em->getRepository(User::class)->findUserHavingActiveSubscriptions();
return $this->render('admin/tableaudebord/list.html.twig', [
'nbrpersonnels' => count($allPersonals),
'nbrclients' => count($allClients),
'nbroffres' => count($allOffers),
'nbrbienenattente' => count($propertiesWaiting),
'nbrbienvalider' => count($propertiesValid),
'numberUserSubscribed' => count($userSubscribed),
]);
}
}