src/Controller/IndexController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Query\TaskQuery;
  4. use App\Query\UserQuery;
  5. use App\Repository\TasksRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  12. class IndexController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/", name="app_index")
  16.      */
  17.     public function index(
  18.         TaskQuery $taskQuery,
  19.         Request $request
  20.     ): Response
  21.     {
  22.         $defaultDateFrom = (new \DateTime())->format('01/01/Y');        
  23.         $session $request->getSession();          
  24.         if ($request->isXmlHttpRequest()) {          
  25.             if ($request->isMethod('POST')) {
  26.                 $session->set('dateFrom'$request->request->get('dateFrom'));
  27.                 $session->set('dateTo'$request->request->get('dateTo'));
  28.             }
  29.             $params = [
  30.                 'dateFrom' => $session->get('dateFrom'$defaultDateFrom),
  31.                 'dateTo' => $session->get('dateTo'),
  32.             ];
  33.             $data $taskQuery->generateTaskByUser($params);
  34.         dump($data);
  35.         // PCZ
  36.             return $this->json([
  37.                 'data' => array_values($data['tasks']),
  38.                 'totalJh' =>  $data['totalJh'],
  39.                 'totalcoutJh' => $this->renderView('index/_filter_currency.html.twig',  ['price' => $data['totalcoutJh']]),
  40.                 'totalcoutTasks' => $this->renderView('index/_filter_currency.html.twig',  ['price' => $data['totalcoutTasks']]),
  41.         //'totalcoutJhVente' => $this->renderView('index/_filter_currency.html.twig',  ['price' => $data['totalcoutJhVente']]),
  42.                 'totalcoutTasksVente' => $this->renderView('index/_filter_currency.html.twig',  ['price' => $data['totalcoutTasksVente']]),
  43.             ]);
  44.         }
  45.         $params = [
  46.             'dateFrom' => $session->get('dateFrom'$defaultDateFrom),
  47.             'dateTo' => $session->get('dateTo'),
  48.         ];
  49.         return $this->render('index/index.html.twig', [
  50.             'data' => [],
  51.             'params' => $params
  52.         ]);
  53.     }
  54.      /**
  55.      * @Route("/suivi", name="app_follow_up")
  56.      */
  57.     public function followUp(
  58.         TaskQuery $taskQuery,
  59.         Request $request
  60.     ): Response
  61.     {
  62.         $defaultDateFrom = (new \DateTime())->format('01/01/Y');
  63.         $session $request->getSession();
  64.         if ($request->isMethod('POST')) {
  65.             $session->set('dateFrom'$request->request->get('dateFrom'));
  66.             $session->set('dateTo'$request->request->get('dateTo'));
  67.         }
  68.         $params = [
  69.             'dateFrom' => $session->get('dateFrom'$defaultDateFrom),
  70.             'dateTo' => $session->get('dateTo'),
  71.         ];
  72.         return $this->render('index/follow-up.html.twig', [
  73.             'data' =>  $taskQuery->generateTaskByProduct($params),
  74.             'colors' => $taskQuery->getColor(),
  75.             'params' => $params
  76.         ]);
  77.     }
  78. }