src/Controller/PageController.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Demande;
  4. use DateTime;
  5. use Google_Client;
  6. use Google_Service_Calendar;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  9. use Symfony\Component\Workflow\Registry;
  10. class PageController extends Controller
  11. {
  12.     /**
  13.      * @Route("/connexion",name="connect")
  14.      */
  15.     public function index()
  16.     {
  17.         $auth_checker $this->get('security.authorization_checker');
  18.         if ($auth_checker->isGranted('ROLE_USER')) {
  19.             return $this->redirectToRoute('dashboard');
  20.         }
  21.         return $this->render('page/page-login.html.twig');
  22.     }
  23.     /**
  24.      * @Route("/logout", name="security_logout")
  25.      * @throws \Exception
  26.      */
  27.     public function logout()
  28.     {
  29.         throw new \Exception('Problème de dĂ©connexion');
  30.     }
  31.     /**
  32.      * @Route("/",name="dashboard")
  33.      */
  34.     public function rootPage()
  35.     {
  36.         $soldeOld $this->getDoctrine()->getRepository('App:Solde')
  37.             ->findOneBy([
  38.                 'Annee' => intval((new \DateTime())->format('Y'))-1,
  39.                 'Employe' => $this->getUser()
  40.             ]);
  41.         if($soldeOld) {
  42.             $soldeOld $soldeOld->getRestant();
  43.         } else {
  44.             $soldeOld 0;
  45.         }
  46.         $soldeNew  $this->getDoctrine()->getRepository('App:Solde')
  47.             ->findOneBy([
  48.                 'Annee' => (new \DateTime())->format('Y'),
  49.                 'Employe' => $this->getUser()
  50.             ])->getRestant();
  51.         $listeCongesCY $this->getDoctrine()->getRepository('App:Demande')
  52.             ->findCongesPourAnneeCourante($this->getUser());
  53.         $congeParMois = [0,0,0,0,0,0,0,0,0,0,0,0];
  54.         foreach ($listeCongesCY as $congeCY) {
  55.             $congeParMois[intval($congeCY->getDateDeb()->format('m'))-1] += $congeCY->getNombreJours();
  56.         }
  57.         return $this->render("page/accueil.html.twig",[
  58.             'congesCY' => $congeParMois,
  59.             'Sn' => $soldeNew,
  60.             'So' => $soldeOld
  61.         ]);
  62.     }
  63. }