src/Controller/ScreenController.php line 640

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Doctrine\Persistence\ManagerRegistry;
  4. //use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. //use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  13. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
  16. use Symfony\Component\HttpKernel\KernelInterface;
  17. use Symfony\Contracts\Translation\TranslatorInterface;
  18. use App\Entity\Department;
  19. use App\Entity\Language;
  20. use App\Entity\Server;
  21. use App\Entity\Service;
  22. use App\Entity\ShoppingWindow;
  23. use App\Entity\User;
  24. use App\Entity\UserStory;
  25. use App\Entity\Module;
  26. use App\Entity\Order;
  27. use App\Entity\EshopLink;
  28. use App\Entity\Feed;
  29. use App\Entity\FormResponse;
  30. class ScreenController extends DefaultController
  31. {
  32.     protected string $databaseUser "root";
  33.     protected string $databasePassword "pswdb33";
  34.     /** KernelInterface $appKernel */
  35.     protected $appKernel;
  36.     protected $translator;
  37.     public function __construct(KernelInterface $appKernel,
  38.                                 ManagerRegistry $doctrine,
  39.                                 TranslatorInterface $translator)
  40.     {
  41.         $this->appKernel $appKernel;
  42.         $this->doctrine $doctrine;
  43.         $this->translator $translator;
  44.     }
  45.     #[Route('/'name'root')]
  46.     public function indexAction(Request $requestManagerRegistry $doctrine) {
  47.         /* we load session data */
  48.         parent::init($request$doctrine);
  49.         $session $request->getSession();
  50.         $em $this->doctrine->getManager();
  51.         //print('<br>QQW session: '.$session->get('server')->getLabel());
  52.         //$translator->trans('symfony.great');
  53.         $homePage '';
  54.         //$homePage = $this->parseContent($request, "{INTERACTIVESLIDESHOW_3}");
  55.         if(!empty($session->get('user'))) {
  56.             $userId $session->get('user')->getUserId();
  57.             $user $em->getRepository(User::class)->getUser($userId);
  58.         } else {
  59.             $user null;
  60.         }
  61.         // we get root departments
  62.         $rootDepartments $em->getRepository(Department::class)->getRootNodes();
  63.         // we add sub departments
  64.         $subDepartments = array();
  65.         foreach($rootDepartments as $dep)
  66.         {
  67.             $depId $dep->getDepartmentId();
  68.             $dep->setLocale($session->get('lang')->getLangKey());
  69.             $em->refresh($dep);
  70. //            print('<br>departmentId: '.$depId);
  71. //            print('<br>departmentName: '.$dep->getDepartmentName());
  72.             $subDeps $em->getRepository(Server::class)->getSubDepartments($depId);
  73.             $subDepartments[$depId] = $subDeps;
  74.         }
  75.         /* we load list of departments for marketplace service */
  76.         $departmentArray[] =  $em->getRepository(Server::class)->getDepartment(3);
  77.         /* we load list of shopping windows */
  78.         $shoppingWindowList $em->getRepository(ShoppingWindow::class)->getShoppingWindowList($departmentArray06);
  79.         $templatesDir $this->appKernel->getProjectDir() . '/app/Resources/views';
  80.         $serviceIcons = [];
  81.         foreach($session->get('server')->getServices() as $service) {
  82.             $serviceId $service->getServiceId();
  83.             $icon3d '/users/Kantona/freeworld/FUTURE_'.$this->getNormalisedText($service->getServiceName());
  84.             $icon3d $icon3d.'.x3d';
  85.             //if($session->get('label') == 'webexciter.com') {
  86.             //$icon3d = $icon3d.'.x3d';
  87.             //} else {
  88.             //$icon3d = $icon3d.'-White.x3d';
  89.             //}
  90.             //echo "<br>The file:".$icon3d;
  91.             if (is_file('.'.$icon3d)) {
  92.                 //echo "<br>The file $icon3d exists";
  93.                 $serviceIcons[$serviceId] = $icon3d;
  94.             }
  95.         }
  96.         $server_request_scheme 'https';
  97.         $uri $server_request_scheme '://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  98.         if (strpos($uri'app_dev.php') == false) {
  99.             $urlBase '/';
  100.         } else {
  101.             $urlBase $server_request_scheme '://' $_SERVER['HTTP_HOST'] . '/';
  102.         }
  103.         $eCommerceNews $this->getRedactionList($request1);
  104.         /*
  105.         print('<br>Server: ');
  106.         \Doctrine\Common\Util\Debug::dump($session->get('server'));
  107.         */
  108.         /* we render data */
  109.         return $this->render('index.html.twig',
  110.             array('headerData' => $this -> getPageHeader($request),
  111.                 'homePage' => $homePage,
  112.                 'user' => $user,
  113.                 'rootDepartments' => $rootDepartments,
  114.                 'subDepartments' => $subDepartments,
  115.                 'shoppingWindowList' => $shoppingWindowList,
  116.                 'templatesDir' => $templatesDir,
  117.                 'serviceIcons' => $serviceIcons,
  118.                 'uri' => $uri,
  119.                 'urlBase' => $urlBase,
  120.                 'eCommerceNews' => $eCommerceNews,
  121.             )
  122.         );
  123.     }
  124.     #[Route('/login'name'login')]
  125.     public function loginAction(Request $requestManagerRegistry $doctrine) {
  126.         /* we load session data */
  127.         parent::init($request$doctrine);
  128.         $em $this->doctrine->getManager();
  129.         $user = new User();
  130.         /* we build login form */
  131.         $formBuilder $this->createFormBuilder($user);
  132.         /*
  133.           $formBuilder->add('username', TextType::class, [
  134.               'required' => true,
  135.               'label' => $this->translator->trans('user.username')
  136.           ]);
  137.         */
  138.   $formBuilder->add('username'TextType::class, array(
  139.       'required' => true,
  140.       'label' => $this->translator->trans('user.username'),
  141.       'attr' => array('class' => 'simple_text_form''size' => 22),
  142.       'label_attr' => array('class' => 'simple_form_field_label'),
  143.   ));
  144.   $formBuilder->add('psw'PasswordType::class, array(
  145.       'required' => true,
  146.       'label' => $this->translator->trans('user.password'),
  147.       'attr' => array('class' => 'simple_text_form''size' => 22),
  148.       'label_attr' => array('class' => 'simple_form_field_label'),
  149.   ));
  150.   $formBuilder->add('save'SubmitType::class, array('label' => 'Login',
  151.       'attr' => array('class' => 'butt_big')));
  152.         //$formBuilder->add('save', SubmitType::class, ['label' => 'Login']);
  153.         $form $formBuilder->getForm();
  154.         /*
  155.         $form = $this->createFormBuilder()
  156.             ->add('task', TextType::class)
  157.             ->add('save', SubmitType::class, ['label' => 'Create Task'])
  158.             ->getForm();
  159.         */
  160.         $form->handleRequest($request);
  161.         //print('<br>Form: ');
  162.         //\Doctrine\Common\Util\Debug::dump($form);
  163.         if ($request->getMethod() == 'POST') {
  164.             //$form->bindRequest($request);
  165.             $em $this->doctrine->getManager();
  166.             $formData $form->getData();
  167.             if (!empty($request->request->get('username'))) {
  168.                 $loginUserName $request->request->get('username');
  169.                 $isHashedLogin true;
  170.             } else {
  171.                 $loginUserName $formData->getUserName();
  172.                 $isHashedLogin false;
  173.             }
  174.             if(!empty($request->request->get('password'))) {
  175.                 $loginPsw $request->request->get('password');
  176.             } else {
  177.                 $loginPsw $formData->getPsw();
  178.             }            
  179.             if(!empty($loginUserName) && !empty($loginPsw)) {
  180.                 //print('<br>qqw login 001a');
  181.                 if ($isHashedLogin) {
  182.                     $userExist $em->getRepository(User::class)->getUserFromHashedLogin($loginUserName$loginPsw);
  183.                 } else {
  184.                     $userExist $em->getRepository(User::class)->getUserFromLogin($loginUserName$loginPsw);
  185.                 }
  186.             }
  187.             //print('<br>userExist: '.$loginUserName.' :: '.$loginPsw);
  188.             //die();
  189.             /* we check if this username exists */
  190.             if(!empty($userExist)) {
  191.                 /* we load logged user into session */
  192.                 $session $request->getSession();
  193.                 $session->set('user'$userExist);
  194.                 /*
  195.                 print('<hr>we set session user: ');
  196.                 \Doctrine\Common\Util\Debug::dump($session->get('user'));
  197.                 */
  198.                 $flashMessage $this->translator->trans('system.welcome').' '.$loginUserName.'. '.$this->translator->trans('system.you_are_logged');
  199.                 $this->addFlash('notice'$flashMessage);
  200.                 $userExist->setLastLogin(new \DateTime());
  201.                 $em->persist($userExist);
  202.                 $em->flush();
  203.                 // we redirect to request route or to homeuser
  204.                 if(!empty($userExist->getServices()) && count($userExist->getServices())==) {
  205.                     foreach($userExist->getServices() as $service) {
  206.                         return $this->redirectToRoute($service->getLandingUrl().'Admin');
  207.                     }
  208.                 } else {
  209.                     return $this->redirectToRoute('homeuser');
  210.                 }
  211.             }
  212.             else {
  213.                 $this->addFlash('error''Login error.');
  214.             }
  215.             //}
  216.         }
  217.         /* we render data */
  218.         return $this->render('login.html.twig',
  219.             array('form' => $formBuilder->getForm()->createView(),
  220.                 'headerData' => $this -> getPageHeader($request)
  221.             )
  222.         );
  223.     }
  224.     /**
  225.      * @Route("/homeuser", name="homeuser")
  226.      */
  227.     #[Route('/homeuser'name'homeuser')]
  228.     public function homeuserAction(Request $request) {
  229.         /* we load session data */
  230.         parent::init($request);
  231.         $session $request->getSession();
  232.         // we check if any user is logged in
  233.         if(!$this->isLoggedUser($request)) {
  234.             return $this->redirectToRoute('login');
  235.         }
  236.         /* we load entity managers */
  237.         $em $this->doctrine->getManager();
  238.         $dem $this->doctrine->getManager('dynamic_em');
  239.         $userId $session->get('user')->getUserId();
  240.         $user $em->getRepository(User::class)->getUser($userId);
  241.         $userDirs $this->getUserFolderPathsFromUserId($userId);
  242.         $moduleCollection $em->getRepository(Module::class)->getModuleList();
  243.         /* we check users database */
  244.         if(!$this->checkUserDB($request)) {
  245.             return $this->redirectToRoute('homeuser');
  246.         }
  247.         /* we check user entities */
  248.         $this->checkUserEntities($request);
  249.         //$this->generateUserEntities($request);
  250.         /* we load dynamic entity manager */
  251.         //$dem = $this->doctrine->getManager('dynamic_em');
  252.         //return $this->redirectToRoute('eshopAdmin');
  253.         $orderList null;
  254.         $orderPrices = array();
  255.         $eshopService $em->getRepository(Service::class)->getService(1);
  256.         $isService $em->getRepository(User::class)->userHasService($user$eshopService);
  257.         if($isService) {
  258.             /* we load recent orders */
  259.             //$orderList = $dem->getRepository(Order::class)->getOrderList("orderId", "DESC", 5);
  260.             $orderList = [];
  261.             if(!empty($orderList) && count($orderList) > 0) {
  262.                 /* we get current e-shop */
  263.                 $eshop $em->getRepository('AppBundle:Eshop')->getCurrentEshop($userId);
  264.                 if(!empty($eshop)) {
  265.                     $defaultCurrency $em->getRepository('AppBundle:Currency')->getCurrency($eshop->getPreferredCurrencyId());
  266.                 }
  267.             }
  268.             /* we load order prices */
  269.             foreach($orderList as $order) {
  270.                 if(!empty($order->getCurrencyKey())) {
  271.                     $targetCurrency $em->getRepository('AppBundle:Currency')->getCurrencyByKey($order->getCurrencyKey());
  272.                 } else {
  273.                     $targetCurrency $defaultCurrency;
  274.                 }
  275.                 $orderPrices[$order->getOrderId()] = $dem->getRepository('AppBundle:Order')->getOrderPrice($order->getOrderId(), $targetCurrencyfalse$eshop$defaultCurrency);
  276.             }
  277.         }
  278.         //we check if user has Form Builder module and get recent form responses
  279.         $module $em->getRepository(Module::class)->getModule(12);
  280.         $isModule $em->getRepository(User::class)->userHasModule($user$module);
  281.         $formResponseList null;
  282.         if($isModule) {
  283.             //print('<br>qqw is Form Builder');
  284.             $formResponseList $dem->getRepository(FormResponse::class)->getFormResponseList2("formResponseId""DESC"5);
  285.             //$formResponseList = $dem->getRepository('AppBundle:FormResponse')->getFormResponseList();
  286.         }
  287.         //we check if user has UserStory module and get recent form responses
  288.         $module $em->getRepository(Module::class)->getModule(24);
  289.         $isModule $em->getRepository(User::class)->userHasModule($user$module);
  290.         $taskList null;
  291.         if($isModule) {
  292.             $dateStart date("Y-m-d",strtotime('monday this week'));
  293.             $dateEnd date("Y-m-d",strtotime('sunday this week'));
  294.             $taskList $dem->getRepository(UserStory::class)->getUserStoryStartBetweenDatesList($dateStart$dateEnd);
  295.         }
  296.         /*
  297.         $serverExist = $em->getRepository('AppBundle:Server')->getServerFromLabel('webexciter.com');
  298.         print('<br>QQW Current server: ');
  299.         \Doctrine\Common\Util\Debug::dump($serverExist);
  300.         print('<hr>QQW UD: ');
  301.         \Doctrine\Common\Util\Debug::dump($userDirs);
  302.         */
  303.         /* we render data */
  304.         return $this->render('homeuser.html.twig',
  305.             array('headerData' => $this -> getPageHeader($request),
  306.                 'user' => $user,
  307.                 'orderList' => $orderList,
  308.                 'orderPrices' => $orderPrices,
  309.                 'formResponseList' => $formResponseList,
  310.                 'userDirs' => $userDirs,
  311.                 'taskList' => $taskList,
  312.                 'menu' => $this -> adminMenu($request),
  313.                 'mainMenu' => $this -> adminMainMenu($request),
  314.                 'moduleCollection' => $moduleCollection
  315.             )
  316.         );
  317.     }
  318.     #[Route('/homeuser/config'name'config')]
  319.     public function configAction(Request $request) {
  320.         /* we load session data */
  321.         parent::init($request);
  322.         $session $request->getSession();
  323.         // we check if any user is logged in
  324.         if(!$this->isLoggedUser($request)) {
  325.             return $this->redirectToRoute('login');
  326.         }
  327.         $em $this->doctrine->getManager();
  328.         $userId $session->get('user')->getUserId();
  329.         $user $em->getRepository(User::class)->getUser($userId);
  330.         $serviceCollection $em->getRepository(Service::class)->getServiceList();
  331.         /*
  332.         print('<br>QQW user ID: '.$userId);
  333.         \Doctrine\Common\Util\Debug::dump($user);
  334.         */
  335.         /*
  336.          $serverExist = $em->getRepository('AppBundle:Server')->getServerFromLabel('webexciter.com');
  337.          print('<br>QQW Current server: ');
  338.          \Doctrine\Common\Util\Debug::dump($serverExist);
  339.          print('<hr>QQW Current user: ');
  340.          \Doctrine\Common\Util\Debug::dump($session->get('user'));
  341.          */
  342.         /* we build register form */
  343.         $formBuilder $this->createFormBuilder($user);
  344.         $formBuilder->add('company'TextType::class, array(
  345.             'required' => false,
  346.             'label' => $this->translator->trans('user.company'),
  347.             'attr' => array('class' => 'text_form''size' => 35'value' => $user->getCompany()),
  348.             'label_attr' => array('class' => 'form_field_label')
  349.         ));
  350.         $formBuilder->add('email'EmailType::class, array(
  351.             'required' => true,
  352.             'attr' => array('class' => 'text_form''size' => 35'value' => $user->getEmail()),
  353.             'label_attr' => array('class' => 'form_field_label_required'),
  354.         ));
  355.         $formBuilder->add('contactPersonEmail'EmailType::class, array(
  356.             'required' => false,
  357.             'attr' => array('class' => 'text_form''size' => 35'value' => $user->getContactPersonEmail()),
  358.             'label_attr' => array('class' => 'form_field_label_required'),
  359.         ));
  360.         $formBuilder->add('telephone'TextType::class, array(
  361.             'required' => false,
  362.             'label' => $this->translator->trans('user.telephone'),
  363.             'attr' => array('class' => 'text_form''size' => 35'value' => $user->getTelephone()),
  364.             'label_attr' => array('class' => 'form_field_label'),
  365.         ));
  366.         $formBuilder->add('address'TextareaType::class, array(
  367.             'required' => false,
  368.             'label' => $this->translator->trans('user.address'),
  369.             'attr' => array('class' => 'textarea_form''cols' => 33'rows' => 2'value' => $user->getAddress()),
  370.             'label_attr' => array('class' => 'form_textarea_label'),
  371.             'data' => $user->getAddress(),
  372.         ));
  373.         $formBuilder->add('bankAccount'TextType::class, array(
  374.             'required' => false,
  375.             'label' => $this->translator->trans('user.bank_account'),
  376.             'attr' => array('class' => 'text_form''size' => 35'value' => $user->getBankAccount()),
  377.             'label_attr' => array('class' => 'form_field_label'),
  378.         ));
  379.         $formBuilder->add('ico'TextType::class, array(
  380.             'required' => false,
  381.             'label' => $this->translator->trans('user.business_number'),
  382.             'attr' => array('class' => 'text_form''size' => 35'value' => $user->getIco()),
  383.             'label_attr' => array('class' => 'form_field_label'),
  384.         ));
  385.         /* we add service list */
  386.         $services = array();
  387.         foreach($serviceCollection as $service)
  388.         {
  389.             $serviceId $service->getServiceId();
  390.             $services[$service->getServiceName()] = $service->getServiceId();
  391.         }
  392.         $selectedServices = array();
  393.         foreach($user->getServices() as $service)
  394.         {
  395.             $selectedServices[] = $service->getServiceId();
  396.         }
  397.         $formBuilder->add('services'ChoiceType::class, array(
  398.             'choices' => $services,
  399.             'required' => false,
  400.             'mapped' => false,
  401.             'multiple' => true,
  402.             'expanded' => true,
  403.             'data' => $selectedServices
  404.         ));
  405.         // if is module email provider
  406.         $module $em->getRepository(Module::class)->getModule(40);
  407.         $isModule $em->getRepository(User::class)->userHasModule($user$module);
  408.         /*
  409.         if($isModule) {
  410.             $formBuilder->add('emailProviderName', TextType::class, array(
  411.                 'required' => false,
  412.                 'label' => $this->translator->trans('user.company'),
  413.                 'attr' => array('class' => 'text_form', 'size' => 35, 'value' => $user->getCompany()),
  414.                 'label_attr' => array('class' => 'form_field_label')
  415.             ));
  416.         }
  417.         */
  418.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('form.send'),
  419.             'attr' => array('class' => 'butt_big')));
  420.         $form $formBuilder->getForm();
  421.         $form->handleRequest($request);
  422.         if ($request->getMethod() == 'POST') {
  423.             //$form->bindRequest($request);
  424.             if ($form->isValid()) {
  425.                 // perform some action, such as save the object to the database
  426.                 //print('<br>qqw post form 2: ');
  427.                 $formData $form->getData();
  428.                 //print('<br>We create new user');
  429.                 //$user = new User;
  430.                 /* we load user data from register form into user object */
  431.                 $user->setCompany($formData->getCompany());
  432.                 $user->setEmail($formData->getEmail());
  433.                 $user->setContactPersonEmail($formData->getContactPersonEmail());
  434.                 $user->setTelephone($formData->getTelephone());
  435.                 $user->setAddress($formData->getAddress());
  436.                 $user->setBankAccount($formData->getBankAccount());
  437.                 $user->setIco($formData->getIco());
  438.                 /* we remove old service associations */
  439.                 foreach($user->getServices() as $service) {
  440.                     $user->removeService($service);
  441.                     //$session->get('user')->removeService($service);
  442.                 }
  443.                 /* we load user services */
  444.                 $formServices $form['services']->getData();
  445.                 if(!empty($formServices)) {
  446.                     foreach($formServices as $serviceId) {
  447.                         $addService $em->getRepository(Service::class)->getService($serviceId);
  448.                         $user->addService($addService);
  449.                         //$session->get('user')->addService($addService);
  450.                     }
  451.                 }
  452.                 /*
  453.                 print('<br>qqw user exists: ');
  454.                 \Doctrine\Common\Util\Debug::dump($user);
  455.                 */
  456.                 /* we persist and save user *//* we persist and save user */
  457.                 $em->persist($user);
  458.                 $em->flush();
  459.                 /* we update user session */
  460.                 $session->set('user'$user);
  461.                 $this->addFlash('notice''User was updated.');
  462.                 return $this->redirectToRoute('config');
  463.             }
  464.         }
  465.         /* we render data */
  466.         return $this->render('userConfig.html.twig',
  467.             array(  'form' => $formBuilder->getForm()->createView(),
  468.                 'headerData' => $this -> getPageHeader($request)
  469.             )
  470.         );
  471.     }
  472.     #[Route('/moduleInfo'name'moduleInfo')]
  473.     public function moduleInfoAction(Request $request) {
  474.         /* we load session data */
  475.         parent::init($request);
  476.         $session $request->getSession();
  477.         // we check if any user is logged in
  478.         if(!$this->isLoggedUser($request)) {
  479.             return $this->redirectToRoute('login');
  480.         }
  481.         $em $this->doctrine->getManager();
  482.         $userId $session->get('user')->getUserId();
  483.         $user $em->getRepository(User::class)->getUser($userId);
  484.         $serviceCollection $em->getRepository(Service::class)->getServiceList();
  485.         /* we render data */
  486.         return $this->render('moduleInfo.html.php',
  487.             array(  'headerData' => $this -> getPageHeader($request)
  488.             )
  489.         );
  490.     }
  491.     /**
  492.      * @Route("/newaccount", name="newaccount")
  493.      */
  494.     #[Route('/newaccount'name'newaccount')]
  495.     public function newAccountAction(Request $request) {
  496.         /* we load session data */
  497.         parent::init($request);
  498.         $session $request->getSession();
  499.         $em $this->doctrine->getManager();
  500.         $serviceCollection $em->getRepository(Service::class)->getServiceList();
  501.         $user = new User();
  502.         $server $this->getServerByLabel($session->get('label'));
  503.         /* we prepare data for the form */
  504.         if(!empty($request->request->get('form2')['company'])) {
  505.             $company $request->request->get('form')['company'];
  506.         } else {
  507.             $company '';
  508.         }
  509.         if(!empty($request->request->get('form2')['email'])) {
  510.             $email $request->request->get('form2')['email'];
  511.         } else {
  512.             $email '';
  513.         }
  514.         if(!empty($request->request->get('form2')['telephone'])) {
  515.             $telefon $request->request->get('form2')['telephone'];
  516.         } else {
  517.             $telefon '';
  518.         }
  519.         if(!empty($request->request->get('form2')['address'])) {
  520.             $address $request->request->get('form2')['address'];
  521.         } else {
  522.             $address '';
  523.         }
  524.         if(!empty($request->request->get('form2')['username'])) {
  525.             $username $request->request->get('form2')['username'];
  526.         } else {
  527.             $username '';
  528.         }
  529.         if(!empty($request->request->get('form2')['password'])) {
  530.             $password $request->request->get('form2')['password'];
  531.         } else {
  532.             $password '';
  533.         }
  534.         if(!empty($request->request->get('form2')['password_retype'])) {
  535.             $password_retype $request->request->get('form2')['password_retype'];
  536.         } else {
  537.             $password_retype '';
  538.         }
  539.         /* we build register form */
  540.         $formBuilder $this->createFormBuilder($user);
  541.         // $formBuilder->add('save2', SubmitType::class, array('label' => $this->translator->trans('system.register'),
  542.         //                   'attr' => array('class' => 'butt_big')));
  543.         $formBuilder->add('company'TextType::class, array(
  544.             'required' => false,
  545.             'label' => $this->translator->trans('user.company'),
  546.             'attr' => array('class' => 'text_form''size' => 35'value' => $company),
  547.             'label_attr' => array('class' => 'form_field_label')
  548.         ));
  549.         $formBuilder->add('email'EmailType::class, array(
  550.             'required' => true,
  551.             'attr' => array('class' => 'text_form''size' => 35'value' => $email),
  552.             'label_attr' => array('class' => 'form_field_label_required'),
  553.         ));
  554.         $formBuilder->add('telephone'TextType::class, array(
  555.             'required' => false,
  556.             'label' => $this->translator->trans('user.telephone'),
  557.             'attr' => array('class' => 'text_form''size' => 35'value' => $telefon),
  558.             'label_attr' => array('class' => 'form_field_label'),
  559.         ));
  560.         $formBuilder->add('address'TextareaType::class, array(
  561.             'required' => false,
  562.             'label' => $this->translator->trans('user.address'),
  563.             'attr' => array('class' => 'textarea_form''cols' => 33'rows' => 2'value' => $address),
  564.             'label_attr' => array('class' => 'form_textarea_label'),
  565.         ));
  566.         $formBuilder->add('username'TextType::class, array(
  567.             'required' => true,
  568.             'label' => $this->translator->trans('user.username'),
  569.             'empty_data'  => '',
  570.             'attr' => array('class' => 'text_form''size' => 35'value' => $username),
  571.             'label_attr' => array('class' => 'form_field_label_required'),
  572.         ));
  573.         $formBuilder->add('psw'PasswordType::class, array(
  574.             'required' => true,
  575.             'label' => $this->translator->trans('user.password'),
  576.             'attr' => array('class' => 'text_form''size' => 35'value' => $password),
  577.             'label_attr' => array('class' => 'form_field_label_required'),
  578.         ));
  579.         $formBuilder->add('psw_retype'PasswordType::class, array(
  580.             'required' => true,
  581.             'label' => $this->translator->trans('user.password_retype'),
  582.             'attr' => array('class' => 'text_form''size' => 35'value' => $password_retype),
  583.             'label_attr' => array('class' => 'form_field_label_required'),
  584.             'mapped' => false
  585.         ));
  586.         $formBuilder->add('control_question'TextType::class, array(
  587.             'required' => true,
  588.             'label' => '7 + 4 =',
  589.             'attr' => array('class' => 'text_form''size' => 35'value' => ''),
  590.             'label_attr' => array('class' => 'form_field_label_control_question'),
  591.             'mapped' => false
  592.         ));
  593.         //die('<br>qqw post form 0: ');
  594.         // we add service list
  595.         // we add preselected service registrations
  596.         $selectedServices = [];
  597.         if(!empty($session->get('eshopLink'))) {
  598.             $selectedServices[] = 4;
  599.         }
  600.         if(!empty($request->get('addService'))) {
  601.             $selectedServices[] = $request->get('addService');
  602.         }
  603.         // we add preselected module registrations
  604.         if(!empty($request->get('addModule'))) {
  605.             $selectedServices[] = 'module_'.$request->get('addModule');
  606.         }
  607.         // we add second preselected module registrations
  608.         if(!empty($request->get('addModule2'))) {
  609.             $selectedServices[] = 'module_'.$request->get('addModule2');
  610.         }
  611.         $services = array();
  612.         $serviceCount 0;
  613.         foreach($serviceCollection as $service)
  614.         {
  615.             $serviceId $service->getServiceId();
  616.             $localisedServiceName $this->translator->trans('service.'.$service->getAction());
  617.             $services[$localisedServiceName] = $service->getServiceId();
  618.             $serviceModules $service->getModules();
  619.             $moduleArray = array();
  620.             if(!empty($serviceModules)) {
  621.                 foreach($serviceModules as $mod) {
  622.                     $services[$mod->getModuleName()] = 'module_'.$mod->getModuleId();
  623.                 }
  624.             }
  625.             $serviceCount++;
  626.         }
  627.         // we sort the array - selected services first
  628.         $sortedServices = array();
  629.         foreach($selectedServices as $key => $serviceId)
  630.         {
  631.             foreach($serviceCollection as $service)
  632.             {
  633.                 if ($service->getServiceId() == $serviceId) {
  634.                     $localisedServiceName $this->translator->trans('service.'.$service->getAction());
  635.                     $sortedServices[$localisedServiceName] = $service->getServiceId();
  636.                     $serviceModules $service->getModules();
  637.                     $moduleArray = array();
  638.                     if(!empty($serviceModules)) {
  639.                         foreach($serviceModules as $mod) {
  640.                             $sortedServices[$mod->getModuleName()] = 'module_'.$mod->getModuleId();
  641.                         }
  642.                     }
  643.                 }
  644.             }
  645.         }
  646.         // we add other not checked services
  647.         foreach($serviceCollection as $service)
  648.         {
  649.             if (!in_array($service->getServiceId(), $sortedServices)) {
  650.                 $localisedServiceName $this->translator->trans('service.'.$service->getAction());
  651.                 $sortedServices[$localisedServiceName] = $service->getServiceId();
  652.                 $serviceModules $service->getModules();
  653.                 $moduleArray = array();
  654.                 if(!empty($serviceModules)) {
  655.                     foreach($serviceModules as $mod) {
  656.                         $sortedServices[$mod->getModuleName()] = 'module_'.$mod->getModuleId();
  657.                     }
  658.                 }
  659.             }
  660.         }
  661.         $services $sortedServices;
  662.         //print('<hr>qqw selectedServices: ');
  663.         //var_dump($selectedServices);
  664.         $formBuilder->add('services'ChoiceType::class, array(
  665.             'choices' => $services,
  666.             'required' => false,
  667.             'label' => $this->translator->trans('service.services'),
  668.             'attr' => array('class' => 'form_choice'),
  669.             'label_attr' => array('class' => 'form_choice_label'),
  670.             'label_format' => 'form.address.%name%',
  671.             //'choice_name' => 'texteditor',
  672.             'choice_attr' => function($val$key$index) {
  673.                 // adds a class like attending_yes, attending_no, etc
  674.                 $pos strpos($val'module');
  675.                 if ($pos === false) {
  676.                     $cssClass 'service-item';
  677.                 } else {
  678.                     $cssClass 'module-item';
  679.                 }
  680.                 return ['class' => $cssClass];
  681.             },
  682.             'mapped' => false,
  683.             'multiple' => true,
  684.             'expanded' => true,
  685.             'data' => $selectedServices
  686.         ));
  687.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('system.register_free'),
  688.             'attr' => array('class' => 'butt_big')));
  689.         $form $formBuilder->getForm();
  690.         $form->handleRequest($request);
  691.         if ($request->getMethod() == 'POST') {
  692.             //print('<br>qqw post form 1: ');
  693.             $formData $form->getData();
  694.             //$form->bindRequest($request);
  695.             if(!empty($server->getGoogleApiKey()) && $server->getGoogleApiKey() !== '') {
  696.                 //we load re-captcha
  697.                 $captchaResponse $request->get('g-recaptcha-response');
  698.             } else {
  699.                 $captchaResponse "noCaptcha";
  700.             }
  701.             $controlQuestion = (int)$form['control_question']->getData();
  702.             if ($form->isValid() && $captchaResponse != "" && $controlQuestion == 11) {
  703.                 // perform some action, such as save the object to the database
  704.                 print('<br>qqw post form 2: ');
  705.                 /* we check if this username already exists */
  706.                 $em $this->doctrine->getManager();
  707.                 $formData $form->getData();
  708.                 $userExist $em->getRepository(User::class)->getUserFromUsername($formData->getUserName());
  709.                 // print('<br>qqw user exists: ');
  710.                 // \Doctrine\Common\Util\Debug::dump($userExist);
  711.                 if($userExist === null) {
  712.                     /* we check if the password fields are the same */
  713.                     $password $formData->getPsw();
  714.                     //$retypePassword = $formData->get('psw_retype');
  715.                     $retypePassword $form['psw_retype']->getData();
  716.                     $hashPassword md5($password);
  717.                     /*
  718.                     print('<br>qqw password: '.$password);
  719.                     print('<br>qqw retypePassword: '.$retypePassword);
  720.                     print('<br>qqw hashPassword: '.$hashPassword);
  721.                     */
  722.                     if ($password != '' && $password == $retypePassword) {
  723.                         //print('<br>We create new user');
  724.                         $newUser = new User;
  725.                         $password md5($formData->getPsw());
  726.                         /* we load user data from register form into user object */
  727.                         $newUser->setCompany($formData->getCompany());
  728.                         $newUser->setUserName($formData->getUserName());
  729.                         $newUser->setEmail($formData->getEmail());
  730.                         $newUser->setAddress($formData->getAddress());
  731.                         $newUser->setPsw($password);
  732.                         $user->setPsw($password);
  733.                         $newUser->setDatabaseUser($this->databaseUser);
  734.                         $newUser->setDatabasePassword($this->databasePassword);
  735.                         $newUser->setDateInserted(new \DateTime());
  736.                         $user->setDateInserted(new \DateTime());
  737.                         $servicesString "";
  738.                         $modulesString "";
  739.                         /* we load user services */
  740.                         $formServices $form['services']->getData();
  741.                         if(!empty($formServices)) {
  742.                             foreach($formServices as $key=>$serviceId) {
  743.                                 $pos strpos($serviceId'module');
  744.                                 if ($pos === false) {
  745.                                     //we add service to user
  746.                                     $addService $em->getRepository(Service::class)->getService($serviceId);
  747.                                     $user->addService($addService);
  748.                                     $servicesString .= $addService->getServiceName(). " | ";
  749.                                 } else {
  750.                                     //we add module to user
  751.                                     $moduleExplode explode("_"$serviceId);
  752.                                     $addModule $em->getRepository(Module::class)->getModule($moduleExplode[1]);
  753.                                     $user->addModule($addModule);
  754.                                     $modulesString .= $addModule->getModuleName(). " | ";
  755.                                 }
  756.                             }
  757.                         }
  758.                         /* we persist and save user */
  759.                         $em->persist($user);
  760.                         $em->flush();
  761.                         //die("<br>qqw die");
  762.                         /*
  763.                         print('<br>qqw user exists: ');
  764.                         \Doctrine\Common\Util\Debug::dump($user);
  765.                         */
  766.                         /* we add preselected service registrations */
  767.                         if(!empty($session->get('eshopLink'))) {
  768.                             print('<br>qqw eshopLink: ');
  769.                             \Doctrine\Common\Util\Debug::dump($session->get('eshopLink'));
  770.                             /*
  771.                             if(!empty($session->get('eshopLink')->getDepartments())) {
  772.                                 foreach($session->get('eshopLink')->getDepartments() as $dep) {
  773.                                   print('<hr>qqw eshopLink department: ');
  774.                                   \Doctrine\Common\Util\Debug::dump($dep);
  775.                                 }
  776.                             }
  777.                             */
  778.                             $moduleId 11;
  779.                             $addModule $em->getRepository(Module::class)->getModule($moduleId);
  780.                             $user->addModule($addModule);
  781.                             $eshopLink $session->get('eshopLink');
  782.                             $userExist $em->getRepository(User::class)->getUserFromUsername($request->request->get('form')['username']);
  783.                             $eshopLink->setUserId($userExist->getUserId());
  784.                             print('<br>qqw eshopLink: ');
  785.                             \Doctrine\Common\Util\Debug::dump($eshopLink->getDepartments());
  786.                             /* we persist associated eshop link departments */
  787.                             if(!empty($eshopLink->getDepartments())) {
  788.                                 foreach($eshopLink->getDepartments() as $dep) {
  789.                                     $depExist $em->getRepository(Server::class)->getDepartment($dep->getDepartmentId());
  790.                                     print('<hr>qqw eshopLink dep: ');
  791.                                     \Doctrine\Common\Util\Debug::dump($dep);
  792.                                     print('<br>qqw eshopLink dep: ');
  793.                                     \Doctrine\Common\Util\Debug::dump($depExist);
  794.                                     if(!is_array($dep) && $eshopLink->getDepartments()->contains($dep) ) {
  795.                                         @$eshopLink->removeDepartment($dep);
  796.                                     }
  797.                                     if(!empty($depExist)) {
  798.                                         $eshopLink->addDepartment($depExist);
  799.                                         $em->persist($depExist);
  800.                                     }
  801.                                 }
  802.                             }
  803.                             $feed $session->get('feed');
  804.                             $feed->setUserId($userExist->getUserId());
  805.                             /* we persist associated feed departments */
  806.                             if(!empty($feed->getDepartments())) {
  807.                                 foreach($feed->getDepartments() as $dep) {
  808.                                     $depExist $em->getRepository(Server::class)->getDepartment($dep->getDepartmentId());
  809.                                     if(!is_array($dep) && $feed->getDepartments()->contains($dep) ) {
  810.                                         @$feed->removeDepartment($dep);
  811.                                     }
  812.                                     if(!empty($depExist)) {
  813.                                         $feed->addDepartment($depExist);
  814.                                         $em->persist($depExist);
  815.                                     }
  816.                                 }
  817.                             }
  818.                             // we set this eshopLink as current one
  819.                             $em->getRepository(EshopLink::class)->unsetCurrentEshopLink($user->getUserId());
  820.                             $eshopLink->setEshopLinkCurrent(true);
  821.                             /* we set this feed as current one */
  822.                             $em->getRepository(Feed::class)->unsetCurrentFeed($user->getUserId());
  823.                             $feed->setFeedCurrent(true);
  824.                             $user->setDatabaseUser($this->databaseUser);
  825.                             $user->setDatabasePassword($this->databasePassword);
  826.                             /* we persist and save user (again) */
  827.                             $em->persist($user);
  828.                             $em->flush();
  829.                             /* we persist and save eshopLink */
  830.                             //$em->persist($eshopLink->getDepartments());
  831.                             $em->persist($eshopLink);
  832.                             $em->persist($feed);
  833.                             $em->flush();
  834.                             //$session->remove('eshopLink');
  835.                             $session->remove('eshopLink');
  836.                             $session->remove('feed');
  837.                         }
  838.                         /* we load logged user into session */
  839.                         $session $request->getSession();
  840.                         $session->set('user'$user);
  841.                         //sends email to owner
  842.                         $subject 'New User Registered - '.$session->get('label');
  843.                         $from 'info@webexciter.com';
  844.                         $message 'New User Registered on '.$session->get('label')
  845.                             ."\n"."Company: ".$user->getCompany()
  846.                             ."\n"."Email: ".$user->getEmail()
  847.                             ."\n"."Username: ".$user->getUserName()
  848.                             ."\n"."Password: ".$password
  849.                             ."\n"."---------------------------"
  850.                             ."\n"."Services: ".$servicesString
  851.                             ."\n"."Modules: ".$modulesString
  852.                         ;
  853.                         //$this->sendAdminEmail($subject, $from, $message);
  854.                         /*
  855.                          print('<hr>we set session user: ');
  856.                          \Doctrine\Common\Util\Debug::dump($session->get('user'));
  857.                         */
  858.                         $this->addFlash('notice''New user was created.');
  859.                         $this->addFlash('notice''Welcome '.$user->getUserName().'. You are logged in.');
  860.                         return $this->redirectToRoute('homeuser');
  861.                     }
  862.                     else {
  863.                         $this->addFlash('error''Both password fields must be the same.');
  864.                     }
  865.                 }
  866.                 else {
  867.                     $this->addFlash('error''User with this username already exists.');
  868.                 }
  869.             } else {
  870.                 $this->addFlash('error''Wrong form data.');
  871.             }
  872.         }
  873.         /* we render data */
  874.         return $this->render('newaccount.html.twig',
  875.             array('form' => $formBuilder->getForm()->createView(),
  876.                 'headerData' => $this -> getPageHeader($request),
  877.                 'server' => $server
  878.             )
  879.         );
  880.     }
  881.     #[Route('/logout'name'logout')]
  882.     public function logoutAction(Request $request) {
  883.         /* we load session data */
  884.         parent::init($request);
  885.         /* we unload logged user session */
  886.         $session $request->getSession();
  887.         //$session->set('user', null);
  888.         $session->remove('user');
  889.         $session->remove('label');
  890.         $flashMessage $this->translator->trans('system.user_logged_out');
  891.         $this->addFlash('notice'$flashMessage);
  892.         return $this->redirectToRoute('root');
  893.     }
  894.     #[Route('/newlang'name'newlang')]
  895.     public function newlangAction(Request $request) {
  896.         /* we load session data */
  897.         parent::init($request);
  898.         $em $this->doctrine->getManager();
  899.         $session $request->getSession();
  900.         /* setting new language */
  901.         if(!empty($request->query->get('newlang'))) {
  902.             print("<br>QQW setting new language: ".$request->query->get('newlang'));
  903.             $lang $em->getRepository(Language::class)->getLanguageByKey($request->query->get('newlang'));
  904.             if(!empty($lang)) {
  905.                 $session->set('lang'$lang);
  906.                 $this->addFlash('notice''Language was changed to '.$lang->getLangName().'.');
  907.             }
  908.         }
  909.         /*
  910.         print("<br>QQW newlangAction: ");
  911.         \Doctrine\Common\Util\Debug::dump($session->get('lang'));
  912.         die();
  913.         */
  914.         /*
  915.         if(!empty($request->query->get('routeName'))) {
  916.           $redirectRoute = $request->query->get('routeName');
  917.         } else {
  918.           $redirectRoute = 'root';
  919.         }
  920.         */
  921.         if(!empty($request->query->get('routePath'))) {
  922.             $redirectPath $request->query->get('routePath');
  923.         } else {
  924.             $redirectPath './';
  925.         }
  926.         return $this->redirect($redirectPath);
  927.         //return $this->redirectToRoute($redirectRoute);
  928.     }
  929.     #[Route('/installModule/{moduleId}'name'installModule')]
  930.     public function installModuleAction(Request $request$moduleId)
  931.     {
  932.         /* we load session data */
  933.         parent::init($request);
  934.         $em $this->doctrine->getManager();
  935.         $session $request->getSession();
  936.         /* we get current user */
  937.         $currentUserId $session->get('user')->getUserId();
  938.         $user $em->getRepository(User::class)->getUser($currentUserId);
  939.         $module $em->getRepository(Module::class)->getModule($moduleId);
  940.         $moduleCollection $em->getRepository(Module::class)->getModuleList();
  941.         /*
  942.         print('<br>qqw moduleCollection: ');
  943.         \Doctrine\Common\Util\Debug::dump($moduleCollection);
  944.         print('<hr>qqw userModuleCollection: ');
  945.         \Doctrine\Common\Util\Debug::dump($user->getModules());
  946.         print('<br>qqw new module: '.$module->getModuleName());
  947.         */
  948.         //$user->addModule($module);
  949.         /*
  950.         print('<hr>qqw userModuleCollection 77: ');
  951.         \Doctrine\Common\Util\Debug::dump($user->getModules());
  952.         */
  953.         /* we check if user has this module already */
  954.         $isModule false;
  955.         foreach($user->getModules() as $mod) {
  956.             //print('<hr>qqw travModule '.$mod->getModuleId().': '.$mod->getModuleName());
  957.             //print('<hr>qqw currModule '.$module->getModuleId().': '.$module->getModuleName());
  958.             if($mod->getModuleId() == $module->getModuleId()) {
  959.                 $isModule true;
  960.             }
  961.             /*
  962.             print('<hr>qqw installing module: ');
  963.             \Doctrine\Common\Util\Debug::dump($module->getModuleName());
  964.             */
  965.         }
  966.         /*
  967.         print('<hr>qqw is module: ');
  968.         \Doctrine\Common\Util\Debug::dump($isModule);
  969.         */
  970.         if($isModule == false) {
  971.             /* we add module to user */
  972.             $user->addModule($module);
  973.             $session->get('user')->addModule($module);
  974.             //print('<hr>qqw adding module ');
  975.             //print('<hr>qqw persist user: ');
  976.             /* we persist and save user */
  977.             $em->persist($user);
  978.             //$em->persist($user->getModules());
  979.             $em->flush();
  980.             $this->addFlash('notice''Module was installed.');
  981.         }
  982.         /*
  983.         \Doctrine\Common\Util\Debug::dump($user->getModules());
  984.         */
  985.         //die();
  986.         print('<hr>qqw getAction: '.$module->getAction());
  987.         //if(!empty($module->getLandingUrl())) {
  988.         //return $this->redirectToRoute($module->getLandingUrl());
  989.         //} else {
  990.         //return $this->redirectToRoute($module->getAction());
  991.         //}
  992.         return $this->redirectToRoute($module->getAction());
  993.         //return $this->redirectToRoute('homeuser');
  994.     }
  995.     #[Route('/module/{moduleId}'name'module')]
  996.     public function moduleAction(Request $request$moduleId)
  997.     {
  998.         /* we load session data */
  999.         parent::init($request);
  1000.         $em $this->doctrine->getManager();
  1001.         $session $request->getSession();
  1002.         $module $em->getRepository(Module::class)->getModule($moduleId);
  1003.         /* we render data */
  1004.         return $this->render('module.html.php',
  1005.             array('headerData' => $this -> getPageHeader($request),
  1006.                 'module' => $module
  1007.             )
  1008.         );
  1009.     }
  1010.     #[Route('/contact'name'contact')]
  1011.     public function contactAction(Request $request) {
  1012.         /* we load session data */
  1013.         parent::init($request);
  1014.         $em $this->doctrine->getManager();
  1015.         /* we render data */
  1016.         return $this->render('contact.html.twig',
  1017.             array('headerData' => $this -> getPageHeader($request)
  1018.             )
  1019.         );
  1020.     }
  1021.     #[Route('/aboutus'name'aboutus')]
  1022.     public function aboutusAction(Request $request) {
  1023.         /* we load session data */
  1024.         parent::init($request);
  1025.         $em $this->doctrine->getManager();
  1026.         /* we render data */
  1027.         return $this->render('aboutus.html.twig',
  1028.             array('headerData' => $this -> getPageHeader($request)
  1029.             )
  1030.         );
  1031.     }
  1032.     #[Route('/request'name'request')]
  1033.     public function requestAction(Request $request) {
  1034.         /* we load session data */
  1035.         parent::init($request);
  1036.         $em $this->doctrine->getManager();
  1037.         /* we prepare data for the form */
  1038.         if(!empty($request->request->get('company'))) {
  1039.             $company $request->request->get('company');
  1040.         } else {
  1041.             $company '';
  1042.         }
  1043.         if(!empty($request->request->get('email'))) {
  1044.             $email $request->request->get('email');
  1045.         } else {
  1046.             $email '';
  1047.         }
  1048.         if(!empty($request->request->get('telephone'))) {
  1049.             $telefon $request->request->get('telephone');
  1050.         } else {
  1051.             $telefon '';
  1052.         }
  1053.         if(!empty($request->request->get('subject'))) {
  1054.             $subject $request->request->get('subject');
  1055.         } else {
  1056.             $subject '';
  1057.         }
  1058.         if(!empty($request->request->get('message'))) {
  1059.             $message $request->request->get('message');
  1060.         } else {
  1061.             $message '';
  1062.         }
  1063.         /* we build register form */
  1064.         $formBuilder $this->createFormBuilder();
  1065.         $formBuilder->add('company'TextType::class, array(
  1066.             'required' => false,
  1067.             'label' => $this->translator->trans('user.company'),
  1068.             'attr' => array('class' => 'text_form''size' => 35'value' => $company),
  1069.             'label_attr' => array('class' => 'form_field_label')
  1070.         ));
  1071.         $formBuilder->add('email'EmailType::class, array(
  1072.             'required' => true,
  1073.             'attr' => array('class' => 'text_form''size' => 35'value' => $email),
  1074.             'label_attr' => array('class' => 'form_field_label_required'),
  1075.         ));
  1076.         $formBuilder->add('telefon'TextType::class, array(
  1077.             'required' => false,
  1078.             'label' => $this->translator->trans('user.telephone'),
  1079.             'attr' => array('class' => 'text_form''size' => 35'value' => $telefon),
  1080.             'label_attr' => array('class' => 'form_field_label'),
  1081.         ));
  1082.         $formBuilder->add('subject'TextType::class, array(
  1083.             'required' => false,
  1084.             'label' => $this->translator->trans('eshop.request_subject'),
  1085.             'attr' => array('class' => 'text_form''size' => 35'value' => $subject),
  1086.             'label_attr' => array('class' => 'form_field_label'),
  1087.         ));
  1088.         $formBuilder->add('message'TextareaType::class, array(
  1089.             'required' => false,
  1090.             'label' => $this->translator->trans('eshop.request_message'),
  1091.             'attr' => array('class' => 'textarea_form''cols' => 70'rows' => 10'value' => $message),
  1092.             'label_attr' => array('class' => 'form_textarea_label'),
  1093.         ));
  1094.         $formBuilder->add('save'SubmitType::class, array('label' => $this->translator->trans('eshop.request_send'),
  1095.             'attr' => array('class' => 'butt_big')));
  1096.         $form $formBuilder->getForm();
  1097.         $form->handleRequest($request);
  1098.         if ($request->getMethod() == 'POST') {
  1099.             //$form->bindRequest($request);
  1100.             if ($form->isValid()) {
  1101.                 $subject $form['subject']->getData();
  1102.                 $message "\n message: ".$form['message']->getData();
  1103.                 $from $form['email']->getData();
  1104.                 $message .= "\n company: ".$form['company']->getData();
  1105.                 $message .= "\n email: ".$form['email']->getData();
  1106.                 $message .= "\n tel: ".$form['telefon']->getData();
  1107.                 $body $message;
  1108.                 $this->sendAdminEmail($subject$from$message);
  1109.                 //print('<br>Sending email data...');
  1110.             }
  1111.         }
  1112.         /* we render data */
  1113.         return $this->render('request.html.twig',
  1114.             array('headerData' => $this -> getPageHeader($request),
  1115.                 'form' => $formBuilder->getForm()->createView()
  1116.             )
  1117.         );
  1118.     }
  1119.     public function adminMenu(Request $request)
  1120.     {
  1121.         $menuItems = array(=> array('link' => 'homeuser''langKey' => 'user.admin''routeName' => 'homeuser'),
  1122.             => array('link' => 'eshopAdmin''langKey' => 'eshop.admin''routeName' => 'eshopAdmin'),
  1123.             => array('link' => 'orderlist''langKey' => 'eshop.orders''routeName' => 'orderList'),
  1124.             => array('link' => 'productedit''langKey' => 'eshop.products''routeName' => 'productListEdit'),
  1125.             => array('link' => 'productnew''langKey' => 'eshop.new_product''routeName' => 'productNew'),
  1126.             => array('link' => 'categories''langKey' => 'eshop.categories''routeName' => 'categories'),
  1127.             => array('link' => 'categorynew''langKey' => 'eshop.new_category''routeName' => 'categoryNew'),
  1128.             => array('link' => 'contacts''langKey' => 'knowledgebase.contacts''routeName' => 'contacts'),
  1129.             => array('link' => 'eshopnew''langKey' => 'eshop.new_eshop''routeName' => 'eshopNew'),
  1130.             => array('link' => 'eshopConfig''langKey' => 'eshop.config''routeName' => 'eshopConfig'),
  1131.         );
  1132.         return $menuItems;
  1133.     }
  1134. }