src/Controller/MainController.php line 44

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\BusinessTime;
  4. use App\Entity\Impressum;
  5. use App\Entity\Invoices;
  6. use App\Entity\Licence;
  7. use App\Entity\LicenceType;
  8. use App\Entity\Notifications;
  9. use App\Entity\Orders;
  10. use App\Entity\Pages;
  11. use App\Entity\Playlists;
  12. use App\Entity\Questions;
  13. use App\Entity\ShopData;
  14. use App\Entity\ShopRequest;
  15. use App\Entity\Tables;
  16. use App\Entity\Tickets;
  17. use App\Entity\UpgradeLicenceBlitzkasse;
  18. use App\Entity\Users;
  19. use App\Form\BussinesTimeType;
  20. use App\Form\ImpressumFormType;
  21. use App\Form\RegistrationFormType;
  22. use App\Form\ShopDataFormType;
  23. use App\Form\UserFormType;
  24. use Doctrine\ORM\EntityManagerInterface;
  25. use Endroid\QrCode\Color\Color;
  26. use Endroid\QrCode\Encoding\Encoding;
  27. use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow;
  28. use Endroid\QrCode\Label\Label;
  29. use Endroid\QrCode\Logo\Logo;
  30. use Endroid\QrCode\QrCode;
  31. use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
  32. use Endroid\QrCode\Writer\PngWriter;
  33. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  34. use Symfony\Component\HttpFoundation\Request;
  35. use Symfony\Component\HttpFoundation\Response;
  36. use Symfony\Component\Routing\Annotation\Route;
  37. use Symfony\Component\Uid\Uuid;
  38. class MainController extends AbstractController
  39. {
  40.     #[Route('/'name'main')]
  41.     public function index(EntityManagerInterface $entityManager): Response
  42.     {
  43.         //$content = $entityManager->getRepository(Pages::class)->findOneBy(['slug'=> 'index']);
  44.         return $this->render('main/index.html.twig', [
  45.             'controller_name' => 'MainController',
  46.             'user' => $this->getUser(),
  47.           //  'content' => $content
  48.         ]);
  49.     }
  50.     #[Route('/registration/confirm'name'userNotificationBeta')]
  51.     public function confirmRegistration(): Response
  52.     {
  53.         return $this->render('security/userNotificationBeta.html.twig', [
  54.             'controller_name' => 'MainController',
  55.             'user' => $this->getUser()
  56.         ]);
  57.     }
  58.     #[Route('dashboard/user/shopProfile'name:'shopProfile')]
  59.     public function shopProfile(Request $requestEntityManagerInterface $entityManager): Response
  60.     {
  61.         $currentUser $this->getUser();
  62.         $shop $entityManager->getRepository(ShopData::class)->findOneBy(array('createdBy'=> $this->getUser()->getId()));
  63.         $form $this->createForm(ShopDataFormType::class, $shop);
  64.         $form->handleRequest($request);
  65.         $impressum $entityManager->getRepository(Impressum::class)->findOneBy(['createdBy'=> $this->getUser()->getId()]);
  66.         $timeWork $entityManager->getRepository(BusinessTime::class)->findOneBy(array('createdBy'=> $this->getUser()->getId()));
  67.         $tickets $entityManager->getRepository(Tickets::class)->findOneBy(array('createdBy'=> $this->getUser()->getId()));
  68.         $invoices $entityManager->getRepository(Invoices::class)->findOneBy(array('createdBy'=> $this->getUser()->getId()));
  69.         $licencesType $entityManager->getRepository(LicenceType::class)->findAll();
  70.         $licencesMy $entityManager->getRepository(Licence::class)->findOneBy(array('createdBy'=> $this->getUser()->getId()));
  71.         $notification $entityManager->getRepository(Notifications::class)->findOneBy(array('createdBy'=> $this->getUser()->getId()));
  72.         $form2 null;
  73.         $form3 null;
  74.         $btime = new BusinessTime();
  75.         if($timeWork) {
  76.             $form2 $this->createForm(BussinesTimeType::class, $timeWork);
  77.         } else {
  78.             $btime->setCreatedBy($this->getUser());
  79.             $form2 $this->createForm(BussinesTimeType::class, $btime);
  80.         }
  81.         $impressumData = new Impressum();
  82.         if($impressum) {
  83.             $form3 $this->createForm(ImpressumFormType::class, $impressum);
  84.         } else {
  85.             $impressumData->setCreatedBy($this->getUser());
  86.             $form3 $this->createForm(ImpressumFormType::class, $impressumData);
  87.         }
  88.         $form2->handleRequest($request);
  89.         if ($form2->isSubmitted() && $form2->isValid()) {
  90.             $entityManager->persist($btime);
  91.             $entityManager->flush();
  92.             return $this->render('security/userShopProfile.html.twig', [
  93.                 'name' => "Test",
  94.                 'form' => $form->createView(),
  95.                 'form2' => $form2->createView(),
  96.                 'form3' => $form3->createView(),
  97.                 'currentUser' => $currentUser,
  98.                 'user' => $currentUser,
  99.                 'tickets' => $tickets,
  100.                 'invoices' => $invoices,
  101.                 'licenses' => $licencesType,
  102.                 'myLicence' => $licencesMy,
  103.                 'notification' => $notification,
  104.             ]);
  105.         }
  106.         $form3->handleRequest($request);
  107.         if ($form3->isSubmitted()) {
  108.             if(!$impressum) {
  109.                 $entityManager->persist($impressumData);
  110.             }
  111.             $entityManager->flush();
  112.             return $this->render('security/userShopProfile.html.twig', [
  113.                 'name' => "Test",
  114.                 'form' => $form->createView(),
  115.                 'form2' => $form2->createView(),
  116.                 'form3' => $form3->createView(),
  117.                 'currentUser' => $currentUser,
  118.                 'user' => $currentUser,
  119.                 'tickets' => $tickets,
  120.                 'invoices' => $invoices,
  121.                 'licenses' => $licencesType,
  122.                 'myLicence' => $licencesMy,
  123.                 'notification' => $notification,
  124.             ]);
  125.         }
  126.         if ($form->isSubmitted()) {
  127.             // encode the plain password
  128.             $shop->setShopUrl($this->slugify($form->get('geschaftName')->getData()));
  129.             $entityManager->flush();
  130.             return $this->render('security/userShopProfile.html.twig', [
  131.                 'name' => "Test",
  132.                 'form' => $form->createView(),
  133.                 'form2' => $form2->createView(),
  134.                 'form3' => $form3->createView(),
  135.                 'currentUser' => $currentUser,
  136.                 'user' => $currentUser,
  137.                 'tickets' => $tickets,
  138.                 'invoices' => $invoices,
  139.                 'licenses' => $licencesType,
  140.                 'myLicence' => $licencesMy,
  141.                 'notification' => $notification,
  142.             ]);
  143.         }
  144.         return $this->render('security/userShopProfile.html.twig', [
  145.             'name' => "Test",
  146.             'form' => $form->createView(),
  147.             'form2' => $form2->createView(),
  148.             'form3' => $form3->createView(),
  149.             'currentUser' => $currentUser,
  150.             'tickets' => $tickets,
  151.             'invoices' => $invoices,
  152.             'licenses' => $licencesType,
  153.             'myLicence' => $licencesMy,
  154.             'notification' => $notification,
  155.             'user' => $currentUser
  156.         ]);
  157.     }
  158.     public function slugify($textstring $divider '-')
  159.     {
  160.         // replace non letter or digits by divider
  161.         $text preg_replace('~[^\pL\d]+~u'$divider$text);
  162.         // transliterate
  163.         $text iconv('utf-8''us-ascii//TRANSLIT'$text);
  164.         // remove unwanted characters
  165.         $text preg_replace('~[^-\w]+~'''$text);
  166.         // trim
  167.         $text trim($text$divider);
  168.         // remove duplicate divider
  169.         $text preg_replace('~-+~'$divider$text);
  170.         // lowercase
  171.         $text strtolower($text);
  172.         if (empty($text)) {
  173.             return 'n-a';
  174.         }
  175.         return $text;
  176.     }
  177.     #[Route('dashboard/user/profile'name:'userProfile')]
  178.     public function userProfile(Request $requestEntityManagerInterface $entityManager): Response
  179.     {
  180.         $currentUser $this->getUser();
  181.         $form $this->createForm(UserFormType::class, $currentUser);
  182.         $form->handleRequest($request);
  183.         if ($form->isSubmitted() && $form->isValid()) {
  184.             // encode the plain password
  185.             $entityManager->flush();
  186.             return $this->render('security/userProfile.html.twig', [
  187.                 'name' => "Test",
  188.                 'form' => $form->createView(),
  189.                 'currentUser' => $currentUser,
  190.                 'user' => $currentUser
  191.             ]);
  192.         }
  193.         return $this->render('security/userProfile.html.twig', [
  194.             'name' => "Test",
  195.             'form' => $form->createView(),
  196.             'currentUser' => $currentUser,
  197.             'user' => $currentUser
  198.         ]);
  199.     }
  200.     #[Route('dashboard/shop/qrcodes'name:'allQRCodes')]
  201.     public function allQRCodes(EntityManagerInterface $entityManager): Response
  202.     {
  203.         $currentUser $this->getUser();
  204.         $shop = new ShopData();
  205.         $quest = new Questions();
  206.         $quest $entityManager->getRepository(Questions::class)->findOneBy(['createdBy'=>$this->getUser()]);
  207.         $shop $entityManager->getRepository(ShopData::class)->findOneBy(['createdBy'=> $this->getUser()]);
  208.         $playlist $entityManager->getRepository(Playlists::class)->findBy(['createdBy'=>$this->getUser()]);
  209.             // /questions/view/{id}
  210.         /// /restaurant-und-cafe/shop/Demo
  211.         ///
  212.         $arrayOfQuestion $entityManager->getRepository(Questions::class)->findBy(['createdBy'=>$this->getUser()]);
  213.         $arrayOfTische $entityManager->getRepository(Tables::class)->findBy(['createdBy'=>$this->getUser()]);
  214.         /// /restaurant-und-cafe/menu/Demo
  215.         ///
  216.         ///
  217.         $arrrayQR = array();
  218.         $arrrayPlaylist = array();
  219.         $arrayTische = array();
  220.         $arrayTischeAdditional = array();
  221.         $image "https://blitzconnect.de/images/logos/" $shop->getImageNameLogo();
  222.         foreach($arrayOfTische as $tische) {
  223.             $tischeURl $_SERVER['HTTP_HOST'] . "/restaurant-und-cafe/shop/" $shop->getShopUrl() . "/" $tische->getName();
  224.             $tischeQRCODE QrCode::create($tischeURl)
  225.                 ->setEncoding(new Encoding('UTF-8'))
  226.                 ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
  227.                 ->setSize(300)
  228.                 ->setMargin(10)
  229.                 ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
  230.                 ->setForegroundColor(new Color(000))
  231.                 ->setBackgroundColor(new Color(255255255));
  232.             $writer = new PngWriter();
  233. // Create generic label
  234.             $label Label::create($shop->getShopUrl())
  235.                 ->setTextColor(new Color(25500));
  236.             $tischeResultQR $writer->write($tischeQRCODE);
  237.             $dataUri $tischeResultQR->getDataUri();
  238.             array_push($arrayTische, ["url"=>$dataUri"link"=>$tischeURl"name"=> $tische->getName()]);
  239.         }
  240.         foreach($arrayOfTische as $tische) {
  241.             $tischeURl $_SERVER['HTTP_HOST'] . "/restaurant-und-cafe/shops/" $shop->getShopUrl() . "/" $tische->getName();
  242.             $tischeQRCODE QrCode::create($tischeURl)
  243.                 ->setEncoding(new Encoding('UTF-8'))
  244.                 ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
  245.                 ->setSize(300)
  246.                 ->setMargin(10)
  247.                 ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
  248.                 ->setForegroundColor(new Color(000))
  249.                 ->setBackgroundColor(new Color(255255255));
  250.             $writer = new PngWriter();
  251. // Create generic label
  252.             $label Label::create($shop->getGeschaftName())
  253.                 ->setTextColor(new Color(25500));
  254.             $tischeResultQR $writer->write($tischeQRCODE);
  255.             $dataUri $tischeResultQR->getDataUri();
  256.             array_push($arrayTischeAdditional, ["url"=>$dataUri"link"=>$tischeURl"name"=> $tische->getName()]);
  257.         }
  258.         foreach($arrayOfQuestion as $quest1) {
  259.             $question $_SERVER['HTTP_HOST'] . "/questions/view/" $quest1->getId();
  260.             $qrCodeQuestionT QrCode::create($question)
  261.                 ->setEncoding(new Encoding('UTF-8'))
  262.                 ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
  263.                 ->setSize(300)
  264.                 ->setMargin(10)
  265.                 ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
  266.                 ->setForegroundColor(new Color(000))
  267.                 ->setBackgroundColor(new Color(255255255));
  268.             $writer = new PngWriter();
  269. // Create generic label
  270.             $label Label::create('')
  271.                 ->setTextColor(new Color(25500));
  272.             $resultquestion $writer->write($qrCodeQuestionT);
  273.             $dataUri $resultquestion->getDataUri();
  274.             array_push($arrrayQR$dataUri);
  275.         }
  276.         $arrayPlaylistLink = array();
  277.         foreach($playlist as $p) {
  278.             $url $p->getPlaylistUrl();
  279.             array_push($arrayPlaylistLink$p->getId());
  280.             $qrCodeQuestionT QrCode::create($url)
  281.                 ->setEncoding(new Encoding('UTF-8'))
  282.                 ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
  283.                 ->setSize(300)
  284.                 ->setMargin(10)
  285.                 ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
  286.                 ->setForegroundColor(new Color(000))
  287.                 ->setBackgroundColor(new Color(255255255));
  288.             $writer = new PngWriter();
  289. // Create generic label
  290.             $label Label::create('')
  291.                 ->setTextColor(new Color(25500));
  292.             $resultquestion $writer->write($qrCodeQuestionT);
  293.             $dataUri $resultquestion->getDataUri();
  294.             $question $_SERVER['HTTP_HOST'] . "/stream/"$shop->getShopUrl() ."/" $p->getId();
  295.             array_push($arrrayPlaylist, ["url"=>$dataUri"link"=>$question]);
  296.         }
  297.         $menuUrl =  $_SERVER['HTTP_HOST'] . "/restaurant-und-cafe/menu/" $shop->getShopUrl();
  298.         $shopUrl $_SERVER['HTTP_HOST'] . "/restaurant-und-cafe/shop/" $shop->getShopUrl();
  299.         $writer = new PngWriter();
  300.         $qrCode QrCode::create($menuUrl)
  301.             ->setEncoding(new Encoding('UTF-8'))
  302.             ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
  303.             ->setSize(300)
  304.             ->setMargin(10)
  305.             ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
  306.             ->setForegroundColor(new Color(000))
  307.             ->setBackgroundColor(new Color(255255255));
  308.         $qrCode2 QrCode::create($shopUrl)
  309.             ->setEncoding(new Encoding('UTF-8'))
  310.             ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
  311.             ->setSize(300)
  312.             ->setMargin(10)
  313.             ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
  314.             ->setForegroundColor(new Color(000))
  315.             ->setBackgroundColor(new Color(255255255));
  316. // Create generic logo
  317. // Create generic label
  318.         $label Label::create('')
  319.             ->setTextColor(new Color(25500));
  320.         $resultmenu $writer->write($qrCode);
  321.         $resultshop $writer->write($qrCode2);
  322.         $dataUri $resultmenu->getDataUri();
  323.         $dataUrishop $resultshop->getDataUri();
  324.         return $this->render('security/qrcodeShop.html.twig', [
  325.             'name' => "Test",
  326.             'menuQR' => $dataUri,
  327.             'shopQR' => $dataUrishop,
  328.             'questionQR' => $arrrayQR,
  329.             'currentUser' => $currentUser,
  330.             'menu_link' => $menuUrl,
  331.             'shop_link' => $shopUrl,
  332.             'playlist' => $arrrayPlaylist,
  333.             'tische'=> $arrayTische
  334.         ]);
  335.     }
  336.     #[Route('dashboard/shop/setting'name:'shopSetting')]
  337.     public function shopSetting(Request $requestEntityManagerInterface $entityManager): Response
  338.     {
  339.         $currentUser $this->getUser();
  340.         $shop $entityManager->getRepository(ShopData::class)->findOneBy(array("createdBy"=>$currentUser));
  341.         $form $this->createForm(ShopDataFormType::class, $shop);
  342.         $form->handleRequest($request);
  343.         if ($form->isSubmitted() && $form->isValid()) {
  344.             // encode the plain password
  345.             $shop->setUniqueShopID(Uuid::v4());
  346.             $entityManager->flush();
  347.             $sendRequest = new ShopRequest();
  348.             $sendRequest->setCreatedBy($this->getUser());
  349.             $entityManager->persist($sendRequest);
  350.             $entityManager->flush();
  351.             return $this->render('security/shopSetting.html.twig', [
  352.                 'name' => "Test",
  353.                 'form' => $form->createView(),
  354.                 'currentUser' => $currentUser
  355.             ]);
  356.         }
  357.         return $this->render('security/shopSetting.html.twig', [
  358.             'name' => "Test",
  359.             'form' => $form->createView(),
  360.             'currentUser' => $currentUser
  361.         ]);
  362.     }
  363.     #[Route('dashboard/comming-soon'name:'commingsoon')]
  364.     public function commingsoon(Request $requestEntityManagerInterface $entityManager): Response
  365.     {
  366.         $currentUser $this->getUser();
  367.         return $this->render('security/commingsoon.html.twig', [
  368.             'name' => "Test",
  369.             'currentUser' => $currentUser
  370.         ]);
  371.     }
  372.     #[Route('licence/key/requests'name:'checkKeyLicence')]
  373.     public function CheckLicenceKeyBlitzkasseUpdate(Request $requestEntityManagerInterface $entityManager): Response
  374.     {
  375.         $key $request->get("key");
  376.         $licence $entityManager->getRepository(UpgradeLicenceBlitzkasse::class)->findOneBy(['keylicence'=>$key]);
  377.        return $this->json($licence);
  378.     }
  379.     #[Route('licence/key/update'name:'checkKeyLicenceupdate')]
  380.     public function CheckLicenceKeyBlitzkasseUpdateEdit(Request $requestEntityManagerInterface $entityManager): Response
  381.     {
  382.         $key $request->get("key");
  383.         $licence $entityManager->getRepository(UpgradeLicenceBlitzkasse::class)->findOneBy(['keylicence'=>$key]);
  384.         $licence->setStatus("1");
  385.         $entityManager->persist($licence);
  386.         $entityManager->flush();
  387.         return $this->json("true");
  388.     }
  389.     #[Route('dashboard/admin/requests/{id}'name:'showAllRequest')]
  390.     public function showAllRequest(Request $requestEntityManagerInterface $entityManager): Response
  391.     {
  392.         $currentUser $this->getUser();
  393.         $shop = new ShopData();
  394.         $form $this->createForm(ShopDataFormType::class, $shop);
  395.         $form->handleRequest($request);
  396.         if ($form->isSubmitted() && $form->isValid()) {
  397.             // encode the plain password
  398.             $entityManager->flush();
  399.             $sendRequest = new ShopRequest();
  400.             $sendRequest->setCreatedBy($this->getUser());
  401.             return $this->render('security/shopSetting.html.twig', [
  402.                 'name' => "Test",
  403.                 'form' => $form->createView(),
  404.                 'currentUser' => $currentUser
  405.             ]);
  406.         }
  407.         return $this->render('security/shopSetting.html.twig', [
  408.             'name' => "Test",
  409.             'form' => $form->createView(),
  410.             'currentUser' => $currentUser
  411.         ]);
  412.     }
  413. }