<?php

namespace App\Controller\BackendAdmin;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

use Doctrine\ORM\EntityManagerInterface;

use App\Entity\User;
use App\Repository\ReservationArticleRepository;

use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\RequestStack;

#[Route('/backend/admin/demo')]
class DemoController extends AbstractController
{
    #[Route('/testa')]
    public function testa(ReservationArticleRepository $reservationArticleRepository)
    {
        $reservationArticle = $reservationArticleRepository->findOneBy(['reference'=>"6781-4065-9580-5000"]);

        //$reservationArticle = $reservationArticleRepository->findByReferenceNotValid("6781-4065-9580-5000");

        dd($reservationArticle);
        die;
    }

    #[Route('/test1')]
    public function test1()
    {
        $duree = 60;
        $between = 15;

        $startTime = "09:00:00";
        $endTime = "13:00:00";
        
        $excludeDay = ["Sun"];

        $intervalDay = new \DateInterval('P1D');
        $dateRangeDay = new \DatePeriod(new \DateTime("2023-09-01"), $intervalDay, new \DateTime("2023-09-03"));

        $range = [];
        foreach ($dateRangeDay as $date) {

            $dateStr = $date->format("Y-m-d");
           

            $Indice = array_search($date->format('D'), $excludeDay);
            if(!$excludeDay || !is_numeric($Indice)){
                
                $debut = new \DateTime("$dateStr $startTime");
                $tempo = new \DateTime("$dateStr $startTime");

                $end = new \DateTime("$dateStr $endTime");
                
                do{
                    
                    $fin = clone $tempo->modify("+$duree minutes");

                    if($fin<$end){
                        $range[] = ['debut'=>$debut, 'fin'=>$fin];
                    }
                    
                    $debut = clone $tempo->modify("+$between minutes");

                }while($debut < $end);
            }
            
        }
    
        dd($range);

        die;
    }

    #[Route('/index', name: 'backend_admin_demo_index')]
    public function index(): Response
    {
        return $this->render('backend_admin/demo/index.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/test', name: 'backend_admin_demo_test')]
    public function test(): Response
    {
        return $this->render('backend_admin/demo/test.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/button', name: 'backend_admin_demo_button')]
    public function button(): Response
    {
        return $this->render('backend_admin/demo/button.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/datatable', name: 'demo_backend_datatable')]
    public function datatable(): Response
    {
        return $this->render('backend_admin/demo/datatable.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/page404', name: 'backend_admin_demo_page404')]
    public function page404(): Response
    {
        return $this->render('backend_admin/demo/page404.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/bootstrap', name: 'demo_backend_bootstrap')]
    public function bootstrap(): Response
    {
        return $this->render('backend_admin/demo/bootstrap.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/cards', name: 'demo_backend_cards')]
    public function cards(): Response
    {
        return $this->render('backend_admin/demo/cards.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    
    #[Route('/charts', name: 'demo_backend_charts')]
    public function charts(): Response
    {
        return $this->render('backend_admin/demo/charts.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }


    #[Route('/animation', name: 'demo_backend_animation')]
    public function animation(): Response
    {
        return $this->render('backend_admin/demo/animation.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }


    #[Route('/border', name: 'demo_backend_border')]
    public function border(): Response
    {
        return $this->render('backend_admin/demo/border.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }
    
    #[Route('/color', name: 'demo_backend_color')]
    public function color(): Response
    {
        return $this->render('backend_admin/demo/color.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }


    #[Route('/other', name: 'demo_backend_other')]
    public function other(): Response
    {
        return $this->render('backend_admin/demo/other.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    #[Route('/authentication', name: 'demo_backend_authentication')]
    public function authentication(): Response
    {
        return $this->render('backend_admin/demo/authentication.html.twig', [
            'controller_name' => 'HomeController',
        ]);
    }

    
    
    #[Route('/phpinfo', name: 'demo_backend_phpinfo')]
    public function phpinfo()
    {
        phpinfo();die;
    }

    
}


//datatable.html.twig