src/Controller/RapoarteManagementController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Repository\NotificariRepository;
  5. use App\Repository\SarciniRepository;
  6. use App\Repository\UserRepository;
  7. use CMEN\GoogleChartsBundle\GoogleCharts\Charts\AnnotationChart;
  8. use CMEN\GoogleChartsBundle\GoogleCharts\Charts\AreaChart;
  9. use CMEN\GoogleChartsBundle\GoogleCharts\Charts\BarChart;
  10. use CMEN\GoogleChartsBundle\GoogleCharts\Charts\GanttChart;
  11. use CMEN\GoogleChartsBundle\GoogleCharts\Charts\Histogram;
  12. use CMEN\GoogleChartsBundle\GoogleCharts\Charts\PieChart;
  13. use DateTime;
  14. use PhpOffice\PhpSpreadsheet\Shared\Date;
  15. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\Routing\Annotation\Route;
  18. use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
  19. use Symfony\UX\Chartjs\Model\Chart;
  20. class RapoarteManagementController extends AbstractController
  21. {
  22.     /**
  23.      * @Route("/rapoarte/management", name="app_rapoarte_management")
  24.      */
  25.     public function index(UserRepository $userRepositorySarciniRepository $sarciniRepositoryNotificariRepository $notificariRepository): Response
  26.     {
  27.         $user $this->getUser();
  28.         $sarciniInLucru $sarciniRepository->findBy(['responsabil' => $user]);
  29.         $cntCurrentDay 0;
  30.         $pastDueCurrentDay 0;
  31.         $cntNotif 0;
  32.         foreach ($sarciniInLucru as $sarcini) {
  33.             $status $sarcini->getStatus();
  34.             $date $sarcini->getDate()->format('Y/m/d');
  35.             $date2 = new DateTime($date, new \DateTimeZone('Europe/Bucharest'));
  36.             $now = new DateTime("today", new \DateTimeZone('Europe/Bucharest'));
  37.             if ($status == 'In Lucru' && $date2 == $now) {
  38.                 $cntCurrentDay++;
  39.             } elseif ($status == 'In Lucru' && $date2 $now) {
  40.                 $pastDueCurrentDay++;
  41.             }
  42.         }
  43.         $notificari $notificariRepository->findBy(['responsabil' => $user'viewed' => null]);
  44.         foreach ($notificari as $notificare) {
  45.             $cntNotif++;
  46.         }
  47.         $allSarcini $sarciniRepository->findBy(['Status'=>'In Lucru']);
  48.         $cntAllSarciniToday0;
  49.         $cntAllPastDue 0;
  50.         foreach ($allSarcini as $sarcina){
  51.             $dateAll $sarcina->getDate()->format('Y/m/d');
  52.             $dateAll2 = new DateTime($dateAll, new \DateTimeZone('Europe/Bucharest'));
  53.             $now = new DateTime("today", new \DateTimeZone('Europe/Bucharest'));
  54.             if ($dateAll2 == $now) {
  55.                 $cntAllSarciniToday++;
  56.             } elseif ( $dateAll2 $now) {
  57.                 $cntAllPastDue++;
  58.             }
  59.         }
  60. //
  61.         return $this->render('rapoarte_management/index.html.twig', [
  62.             'cntCurrentDay' => $cntCurrentDay,
  63.             'pastDueCurrentDay' => $pastDueCurrentDay,
  64.             'cntNotif' => $cntNotif,
  65.             'cntAllSarciniToday'=>$cntAllSarciniToday,
  66.             'cntAllPastDue'=>$cntAllPastDue
  67.         ]);
  68.     }
  69. }