src/Controller/MainController.php line 35

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: dimaalferov
  5.  * Date: 11/05/2020
  6.  * Time: 13:06
  7.  */
  8. namespace App\Controller;
  9. use App\Service\BackendAPI\ApiWorker;
  10. use App\Service\CurrencyApi;
  11. use App\Service\DbApi\DbApi;
  12. use App\Service\Helpers\DataSaverHelper;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\JsonResponse;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. class MainController extends AbstractController {
  20.     /**
  21.      * @param $dbApi
  22.      * @param ApiWorker $apiWorker
  23.      * @param CurrencyApi $currencyApi
  24.      * @param DataSaverHelper $dataSaverHelper
  25.      * @param Request $request
  26.      *
  27.      * @return Response
  28.      * @Route("/", name="main-page")
  29.      */
  30.     public function mainPageRequest $requestDbApi $dbApiApiWorker $apiWorkerDataSaverHelper $dataSaverHelperCurrencyApi $currencyApi ){
  31.         $session $this->get('session');
  32.         $getData $request->query->all();
  33.         $dataSaverHelper->saveGetParametersToCookie($getData);
  34.         $orderId $session->get('order_id');
  35.         if( $orderId ) {
  36.             $customer $dbApi->getUserById($orderId);
  37.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  38.             if( $backendCustomer['success'] ) {
  39.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  40.             }
  41.             if( $customer ) {
  42.                 $boughtCourses explode(','$customer->getBoughtCourses() );
  43.             }
  44.         }
  45.         $courseList $dbApi->getAllCourses(9999);
  46.         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  47.             $ip $_SERVER['HTTP_CLIENT_IP'];
  48.         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  49.             $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  50.         } else {
  51.             $ip $_SERVER['REMOTE_ADDR'];
  52.         }
  53.         $currentCurrency $currencyApi->getCurrentCurrency($ip);
  54.         $amount 99;
  55.         if ( $currentCurrency != 'usd' ) {
  56.             $amount round($currencyApi->currencyExchange$amount$currentCurrency ) / 5);
  57.         }
  58.         $userAgent $_SERVER['HTTP_USER_AGENT'];
  59.         $browser 'chrome';
  60.         if( strpos(strtolower($userAgent), 'chrome') ) {
  61.             $browser 'chrome';
  62.         } elseif ( strpos(strtolower($userAgent), 'safari') ) {
  63.             $browser 'safari';
  64.         } elseif ( strpos(strtolower($userAgent), 'firefox') ) {
  65.             $browser 'firefox';
  66.         }
  67.         return $this->render('main/main-v2.html.twig', [
  68.             'session' => $session->all(),
  69.             'sessionParams' => $session->all(),
  70.             'customer' => $customer ?? 0,
  71.             'courseList' => $courseList ?? 0,
  72.             'currentCurrency' => $currentCurrency,
  73.             'cur' => $amount ?? 0,
  74.             'boughtCourses' => $boughtCourses ?? 0,
  75.             'customerInit' => $customerInit ?? '',
  76.             'browser' => $browser
  77.         ]);
  78.     }
  79.     /**
  80.      * @param $dbApi
  81.      * @return Response
  82.      * @Route("/v2", name="main-page-v2")
  83.      */
  84.     public function mainPageV2DbApi $dbApiApiWorker $apiWorkerCurrencyApi $currencyApi ){
  85.         $session $this->get('session');
  86.         $orderId $session->get('order_id');
  87.         if( $orderId ) {
  88.             $customer $dbApi->getUserById($orderId);
  89.             $boughtCourses explode(','$customer->getBoughtCourses() );
  90.         }
  91.         $courseList $dbApi->getAllCourses(2);
  92.         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  93.             $ip $_SERVER['HTTP_CLIENT_IP'];
  94.         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  95.             $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  96.         } else {
  97.             $ip $_SERVER['REMOTE_ADDR'];
  98.         }
  99.         $currentCurrency $currencyApi->getCurrentCurrency($ip);
  100.         $amount 99;
  101.         if ( $currentCurrency != 'usd' ) {
  102.             $amount round($currencyApi->currencyExchange$amount$currentCurrency ) / 5);
  103.         }
  104.         return $this->render('main/main-v3.html.twig', [
  105.             'session' => $session->all(),
  106.             'customer' => $customer ?? 0,
  107.             'courseList' => $courseList ?? 0,
  108.             'currentCurrency' => $currentCurrency,
  109.             'cur' => $amount ?? 0,
  110.             'boughtCourses' => $boughtCourses ?? 0
  111.         ]);
  112.     }
  113.     /**
  114.      * @param $dbApi
  115.      * @return Response
  116.      * @Route("/v3", name="main-page-v3")
  117.      */
  118.     public function mainPageV3DbApi $dbApiApiWorker $apiWorkerCurrencyApi $currencyApi ){
  119.         $session $this->get('session');
  120.         $orderId $session->get('order_id');
  121.         if( $orderId ) {
  122.             $customer $dbApi->getUserById($orderId);
  123.             $boughtCourses explode(','$customer->getBoughtCourses() );
  124.         }
  125.         $courseList $dbApi->getAllCourses(2);
  126.         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  127.             $ip $_SERVER['HTTP_CLIENT_IP'];
  128.         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  129.             $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  130.         } else {
  131.             $ip $_SERVER['REMOTE_ADDR'];
  132.         }
  133.         $currentCurrency $currencyApi->getCurrentCurrency($ip);
  134.         $amount 99;
  135.         if ( $currentCurrency != 'usd' ) {
  136.             $amount round($currencyApi->currencyExchange$amount$currentCurrency ) / 5);
  137.         }
  138.         return $this->render('main/main-v3.html.twig', [
  139.             'session' => $session->all(),
  140.             'customer' => $customer ?? 0,
  141.             'courseList' => $courseList ?? 0,
  142.             'currentCurrency' => $currentCurrency,
  143.             'cur' => $amount ?? 0,
  144.             'boughtCourses' => $boughtCourses ?? 0
  145.         ]);
  146.     }
  147.     /**
  148.      * @return Response
  149.      * @Route("/classes", name="classes")
  150.      */
  151.     public function classesPage(DbApi $dbApiApiWorker $apiWorker){
  152.         $session $this->get('session');
  153.         $orderId $session->get('order_id');
  154.         if( $orderId ) {
  155.             $customer $dbApi->getUserById($orderId);
  156.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  157.             if( $backendCustomer['success'] ) {
  158.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  159.             }
  160.             //$customer = json_decode($apiWorker->getCustomerInfo($orderId), true);
  161.             if($customer) {
  162.                 $boughtCourses explode(','$customer->getBoughtCourses() );
  163.             }
  164.         }
  165.         $courseList $dbApi->getAllCourses(  );
  166.         return $this->render('main/classes.html.twig', [
  167.             'session' => $session->all(),
  168.             'customer' => $customer ?? 0,
  169.             'courseList' => $courseList ?? 0,
  170.             'boughtCourses' => $boughtCourses ?? 0,
  171.             'customerInit' => $customerInit ?? ''
  172.         ]);
  173.     }
  174.     /**
  175.      * @return Response
  176.      * @Route("/classes/{slug}", name="single-class")
  177.      */
  178.     public function singleClassPage($slugDbApi $dbApiApiWorker $apiWorkerCurrencyApi $currencyApi){
  179.         $session $this->get('session');
  180.         $orderId $session->get('order_id');
  181.         $isCourseBought false;
  182.         if( $orderId ) {
  183.             $customer $dbApi->getUserById($orderId);
  184.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  185.             if( $backendCustomer['success'] ) {
  186.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  187.             }
  188.             //$customer = json_decode($apiWorker->getCustomerInfo($orderId), true);
  189.             if($customer) {
  190.                 $boughtCourses explode(','$customer->getBoughtCourses() );
  191.                 $coursesArray explode(','$customer->getBoughtCourses() );
  192.                 if( in_array$slug$coursesArray ) ) {
  193.                     $isCourseBought true;
  194.                 }
  195.             }
  196.         }
  197.         $courseList $dbApi->getAllCourses(3);
  198.         $course $dbApi->getCourseById$slug );
  199.         $courseVideos $dbApi->getCourseVideos$slug );
  200.         //$video = $dbApi->getVideoById(1);
  201.         $relatedCourses $dbApi->getAllCoursesExcept$slug);
  202.         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  203.             $ip $_SERVER['HTTP_CLIENT_IP'];
  204.         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  205.             $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  206.         } else {
  207.             $ip $_SERVER['REMOTE_ADDR'];
  208.         }
  209.         $currentCurrency $currencyApi->getCurrentCurrency($ip);
  210.         $amount $course->getPrice();
  211. //        if ( $currentCurrency != 'usd' ) {
  212. //            $amount = 5 * round($currencyApi->currencyExchange( $amount, $currentCurrency ) / 5);
  213. //        }
  214.         return $this->render('main/single-class.html.twig', [
  215.             'session' => $session->all(),
  216.             'customer' => $customer ?? 0,
  217.             'course' => $course ?? 0,
  218.             'courseVideos' => $courseVideos ?? 0,
  219.             //'video' => $video ?? 0,
  220.             'courseList' => $courseList ?? 0,
  221.             'isCourseBought' => $isCourseBought ?? 0,
  222.             'relatedCourses' => $relatedCourses ?? 0,
  223.             'currentCurrency' => $currentCurrency,
  224.             'price' => $amount ?? 0,
  225.             'boughtCourses' => $boughtCourses ?? 0,
  226.             'customerInit' => $customerInit ?? ''
  227.         ]);
  228.     }
  229.     /**
  230.      * @return Response
  231.      * @Route("/live-private-lessons", name="live-private-lessons")
  232.      */
  233.     public function livePrivateLessonsPage(DbApi $dbApi){
  234.         $session $this->get('session');
  235.         $orderId $session->get('order_id');
  236.         if( $orderId ) {
  237.             $customer $dbApi->getUserById($orderId);
  238.         }
  239.         return $this->render('main/live-private-lessons.html.twig', [
  240.             'session' => $session->all(),
  241.             'customer' => $customer ?? 0
  242.         ]);
  243.     }
  244.     /**
  245.      * @return Response
  246.      * @Route("/online-private-lessons", name="online-private-lessons")
  247.      */
  248.     public function onlinePrivateLessonsPage(DbApi $dbApiCurrencyApi $currencyApi){
  249.         $session $this->get('session');
  250.         $orderId $session->get('order_id');
  251.         if( $orderId ) {
  252.             $customer $dbApi->getUserById($orderId);
  253.         }
  254.         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  255.             $ip $_SERVER['HTTP_CLIENT_IP'];
  256.         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  257.             $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  258.         } else {
  259.             $ip $_SERVER['REMOTE_ADDR'];
  260.         }
  261.         $currentCurrency $currencyApi->getCurrentCurrency($ip);
  262.         $amount 299;
  263. //        if ( $currentCurrency != 'usd' ) {
  264. //            $amount = 5 * round($currencyApi->currencyExchange( $amount, $currentCurrency ) / 5);
  265. //        }
  266.         return $this->render('main/online-private-lessons.html.twig', [
  267.             'session' => $session->all(),
  268.             'customer' => $customer ?? 0,
  269.             'currentCurrency' => $currentCurrency,
  270.             'price' => $amount ?? 0
  271.         ]);
  272.     }
  273.     /**
  274.      * @return Response
  275.      * @Route("/private-lessons", name="private-lessons")
  276.      */
  277.     public function privateLessonsPage(DbApi $dbApi){
  278.         $session $this->get('session');
  279.         $orderId $session->get('order_id');
  280.         if( $orderId ) {
  281.             $customer $dbApi->getUserById($orderId);
  282.         }
  283.         return $this->render('main/private-lessons.html.twig', [
  284.             'session' => $session->all(),
  285.             'customer' => $customer ?? 0
  286.         ]);
  287.     }
  288.     /**
  289.      * @return Response
  290.      * @Route("/contact", name="contact")
  291.      */
  292.     public function contactPage(ApiWorker $apiWorkerDbApi $dbApi){
  293.         $session $this->get('session');
  294.         $orderId $session->get('order_id');
  295.         if( $orderId ) {
  296.             $customer $dbApi->getUserById($orderId);
  297.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  298.             if( $backendCustomer['success'] ) {
  299.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  300.             }
  301.         }
  302.         return $this->render('main/contact.html.twig', [
  303.             'session' => $session->all(),
  304.             'customer' => $customer ?? 0,
  305.             'customerInit' => $customerInit ?? ''
  306.         ]);
  307.     }
  308.     /**
  309.      * @return Response
  310.      * @Route("/press", name="press")
  311.      */
  312.     public function pressPage(DbApi $dbApi){
  313.         $session $this->get('session');
  314.         $orderId $session->get('order_id');
  315.         if( $orderId ) {
  316.             $customer $dbApi->getUserById($orderId);
  317.         }
  318.         return $this->render('main/press.html.twig', [
  319.             'session' => $session->all(),
  320.             'customer' => $customer ?? 0
  321.         ]);
  322.     }
  323.     /**
  324.      * @return Response
  325.      * @Route("/terms", name="terms")
  326.      */
  327.     public function termsOfServicePage(DbApi $dbApi){
  328.         $session $this->get('session');
  329.         $orderId $session->get('order_id');
  330.         if( $orderId ) {
  331.             $customer $dbApi->getUserById($orderId);
  332.         }
  333.         return $this->render('main/terms-of-service.html.twig', [
  334.             'session' => $session->all(),
  335.             'customer' => $customer ?? 0
  336.         ]);
  337.     }
  338.     /**
  339.      * @return Response
  340.      * @Route("/online-lesson-thank", name="online_lesson_thank")
  341.      */
  342.     public function onlineLessonThankPage(DbApi $dbApi){
  343.         $session $this->get('session');
  344.         $orderId $session->get('order_id');
  345.         if( $orderId ) {
  346.             $customer $dbApi->getUserById($orderId);
  347.             $customerDbId $customer->getId();
  348.             $lessons $dbApi->getLessons($customerDbId);
  349.             $lessonsNumber count($lessons) - 1;
  350.             if( !empty($lessons) ) {
  351.                 $bookTime $lessons[$lessonsNumber]->getBookTime();
  352.             }
  353.         }
  354.         return $this->render('main/lesson-thank.html.twig', [
  355.             'session' => $session->all(),
  356.             'customer' => $customer ?? 0,
  357.             'lessons' => $lessons ?? 0,
  358.             'bookTime' => $bookTime ?? ''
  359.         ]);
  360.     }
  361.     /**
  362.      * @return Response
  363.      * @Route("/cookie-policy", name="cookie-policy")
  364.      */
  365.     public function cookiePolicyPage(DbApi $dbApi){
  366.         $session $this->get('session');
  367.         $orderId $session->get('order_id');
  368.         if( $orderId ) {
  369.             $customer $dbApi->getUserById($orderId);
  370.         }
  371.         return $this->render('main/cookie-policy.html.twig', [
  372.             'session' => $session->all(),
  373.             'customer' => $customer ?? 0
  374.         ]);
  375.     }
  376.     /**
  377.      * @return Response
  378.      * @Route("/privacy-policy", name="privacy-policy")
  379.      */
  380.     public function privacyPolicyPage(ApiWorker $apiWorkerDbApi $dbApi){
  381.         $session $this->get('session');
  382.         $orderId $session->get('order_id');
  383.         if( $orderId ) {
  384.             //$customer = $dbApi->getUserById($orderId);
  385.             $customer json_decode($apiWorker->getCustomerInfo($orderId), true);
  386.         }
  387.         return $this->render('main/privacy-policy.html.twig', [
  388.             'session' => $session->all(),
  389.             'customer' => $customer['data'] ?? 0
  390.         ]);
  391.     }
  392.     /**
  393.      * @return Response
  394.      * @Route("/impressum", name="impressum")
  395.      */
  396.     public function impressumPage(ApiWorker $apiWorkerDbApi $dbApi){
  397.         $session $this->get('session');
  398.         $orderId $session->get('order_id');
  399.         if( $orderId ) {
  400.             $customer $dbApi->getUserById($orderId);
  401.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  402.             if( $backendCustomer['success'] ) {
  403.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  404.             }
  405.         }
  406.         $browser $_SERVER['HTTP_USER_AGENT'];
  407.         return $this->render('main/impressum.html.twig', [
  408.             'session' => $session->all(),
  409.             'customer' => $customer ?? 0,
  410.             'customerInit' => $customerInit ?? '',
  411.             'browser' => $browser ?? []
  412.         ]);
  413.     }
  414.     /**
  415.      * @Route("/api/update-currency")
  416.      *
  417.      * @return JsonResponse
  418.      */
  419.     public function updateCurrenciesCurrencyApi $currencyApiDbApi $dbApi ) {
  420.         $currencyInfo $currencyApi->apiUpdateCurrencies$dbApi );
  421.         return new JsonResponse$currencyInfo );
  422.     }
  423.     /**
  424.      * @param DbApi $dbApi
  425.      *
  426.      * @Route ("/selfie-upload", name="selfie_upload_page")
  427.      *
  428.      * @return Response
  429.      */
  430.     public function selfieUploadDbApi $dbApiApiWorker $apiWorker ) {
  431.         $session $this->get('session');
  432.         $orderId $session->get('order_id');
  433.         if( $orderId ) {
  434.             $customer $dbApi->getUserById($orderId);
  435.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  436.             if( $backendCustomer['success'] ) {
  437.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  438.             }
  439.         }
  440.         return $this->render('main/selfie-upload.html.twig', [
  441.             'session' => $session->all(),
  442.             'customer' => $customer ?? 0,
  443.             'customerInit' => $customerInit ?? ''
  444.         ]);
  445.     }
  446.     /**
  447.      * @param DbApi $dbApi
  448.      *
  449.      * @Route ("/signature-upload", name="signature_upload_page")
  450.      *
  451.      * @return Response
  452.      */
  453.     public function signatureUploadDbApi $dbApiApiWorker $apiWorker ) {
  454.         $session $this->get('session');
  455.         $orderId $session->get('order_id');
  456.         if( $orderId ) {
  457.             $customer $dbApi->getUserById($orderId);
  458.             $backendCustomer json_decode($apiWorker->getCustomerInfo($orderId), true);
  459.             if( $backendCustomer['success'] ) {
  460.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  461.             }
  462.         }
  463.         return $this->render('main/signature-upload.html.twig', [
  464.             'session' => $session->all(),
  465.             'customer' => $customer ?? 0,
  466.             'backendCustomer' => $backendCustomer ?? [],
  467.             'customerInit' => $customerInit ?? ''
  468.         ]);
  469.     }
  470.     /**
  471.      * @param DbApi $dbApi
  472.      *
  473.      * @Route ("/thank", name="thank_page")
  474.      *
  475.      * @return Response
  476.      */
  477.     public function thankPageDbApi $dbApiApiWorker $apiWorker ) {
  478.         $session $this->get('session');
  479.         $orderId $session->get('order_id');
  480.         if( $orderId ) {
  481.             $customer $dbApi->getUserById($orderId);
  482.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  483.             if( $backendCustomer['success'] ) {
  484.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  485.             }
  486.         }
  487.         return $this->render('main/thank.html.twig', [
  488.             'session' => $session->all(),
  489.             'customer' => $customer ?? 0,
  490.             'customerInit' => $customerInit ?? ''
  491.         ]);
  492.     }
  493.     /**
  494.      * @param DbApi $dbApi
  495.      *
  496.      * @Route ("/sms-tan", name="sms_tan")
  497.      *
  498.      * @return Response
  499.      */
  500.     public function smsTanPageApiWorker $apiWorkerDbApi $dbApi ) {
  501.         $session $this->get('session');
  502.         $orderId $session->get('order_id');
  503.         if( $orderId ) {
  504.             $customer $dbApi->getUserById($orderId);
  505.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  506.             if( $backendCustomer['success'] ) {
  507.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  508.             }
  509.         }
  510.         return $this->render('main/sms-tan.html.twig', [
  511.             'session' => $session->all(),
  512.             'customer' => $customer ?? 0,
  513.             'customerInit' => $customerInit ?? ''
  514.         ]);
  515.     }
  516.     /**
  517.      * @param Request $request
  518.      * @param ApiWorker $apiWorker
  519.      * @param $code
  520.      *
  521.      * @Route("/s/{code}")
  522.      *
  523.      * @return Response
  524.      */
  525.     public function confirmCodeRequest $requestApiWorker $apiWorker$codeDbApi $dbApi ) {
  526.         $session $this->get('session');
  527.         $result json_decode($apiWorker->confirmPhoneByHash$code ), true );
  528.         if( $result['success']) {
  529.             $userId $result['data']['customer_id'];
  530.             $session->set('order_id'$userId);
  531.             //return $this->redirectToRoute('classes');
  532.         }
  533.         $orderId $session->get('order_id');
  534.         if($orderId) {
  535.             $customer json_decode($apiWorker->getCustomerInfo($orderId), true);
  536.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  537.             if( $backendCustomer['success'] ) {
  538.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  539.             }
  540.         }
  541.         return $this->render('main/sms.confirmed.html.twig', [
  542.             'session' => $session->all(),
  543.             'customer' => $customer['data'] ?? 0,
  544.             'result' => $result ?? '',
  545.             'customerInit' => $customerInit ?? ''
  546.         ]);
  547.     }
  548.     /**
  549.      * @param Request $request
  550.      * @param ApiWorker $api
  551.      * @param DbApi $dbApi
  552.      * @Route("/verification")
  553.      *
  554.      *@return Response
  555.      */
  556.     public function emailConfirm(ApiWorker $apiRequest $requestDbApi $dbApiApiWorker $apiWorker )
  557.     {
  558.         $session $this->get('session');
  559.         $orderId $session->get('order_id');
  560.         if( $orderId ) {
  561.             $customer json_decode($api->getCustomerInfo($orderId), true);//$dbApi->getUserById($orderId);
  562.             $backendCustomer json_decode$apiWorker->getCustomerInfo($orderId), true );
  563.             if( $backendCustomer['success'] ) {
  564.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  565.             }
  566.         }
  567.         $hash $request->query->get('hash');
  568.         $result $api->confirmEmail$hash );
  569.         $result json_decode$resulttrue );
  570.         if( $result['success']) {
  571.             $session->set('order_id'$result['data']['customer_id']);
  572.             $session->set('email_confirmation'true);
  573.         }
  574.         return $this->render('main/email.confirmed.html.twig',[
  575.             'customer' => $customer['data'] ?? 0,
  576.             'customerInit' => $customerInit ?? ''
  577.         ]);
  578.     }
  579.     /**
  580.      * @Route("/agb", name="pdf_agb")
  581.      */
  582.     public function returnAgbFile()
  583.     {
  584.         $pdfPath $this->getParameter('kernel.project_dir') . '/public/build/pdf/legal/mcx_agb.pdf';
  585.         return $this->file($pdfPath'AGB.pdf'ResponseHeaderBag::DISPOSITION_INLINE);
  586.     }
  587.     /**
  588.      * @Route("/datenschutz", name="pdf_datenschutz")
  589.      */
  590.     public function returnDatenschutzFile()
  591.     {
  592.         $pdfPath $this->getParameter('kernel.project_dir') . '/public/build/pdf/legal/mcx_daten.pdf';
  593.         return $this->file($pdfPath'Datenschutz.pdf'ResponseHeaderBag::DISPOSITION_INLINE);
  594.     }
  595.     /**
  596.      * @Route("/leistungsbeschreibung", name="pdf_leistungsbeschreibung")
  597.      */
  598.     public function returnLeistungsbeschreibungFile()
  599.     {
  600.         $pdfPath $this->getParameter('kernel.project_dir') . '/public/build/pdf/legal/mcx_Leistungen.pdf';
  601.         return $this->file($pdfPath'Leistungsbeschreibung.pdf'ResponseHeaderBag::DISPOSITION_INLINE);
  602.     }
  603.     /**
  604.      * @Route("/widerrufsbelehrung", name="pdf_widerrufsbelehrung")
  605.      */
  606.     public function returnWiderrufsBelehrungFile()
  607.     {
  608.         $pdfPath $this->getParameter('kernel.project_dir') . '/public/build/pdf/legal/mcx_widerruf.pdf';
  609.         return $this->file($pdfPath'WiderrufsBelehrung.pdf'ResponseHeaderBag::DISPOSITION_INLINE);
  610.     }
  611.     /**
  612.      * @param ApiWorker $apiWorker
  613.      * @param $hash
  614.      * @param DbApi $dbApi
  615.      * @Route("/ka/{hash}", name="ka-page")
  616.      *
  617.      *@return Response
  618.      */
  619.     public function kaPageApiWorker $apiWorker$hashDbApi $dbApi )
  620.     {
  621.         $session $this->get('session');
  622.         $userId $session->get('order_id');
  623.         if( !$userId ) {
  624.             $customerInfoHash json_decode$apiWorker->getUserBySmsShortHash($hash), true );
  625.             if( $customerInfoHash['success'] ) {
  626.                 $userId $customerInfoHash['data']['id'];
  627.                 $session->set('order_id'$userId);
  628.             }
  629.         }
  630.         $customerInfo json_decode$apiWorker->getCustomerInfo($userId), true );
  631.         $orderData json_decode$apiWorker->getOrder($userId),true );
  632.         $result json_decode$apiWorker->getRenderedPdfByTplId($userId1420), true);
  633.         if( $orderData['data']['identity_sign'] != null ) {
  634.             return $this->redirectToRoute('ka-thank-page');
  635.         }
  636.         if( $userId ) {
  637.             $customer $dbApi->getUserById($userId);
  638.             $backendCustomer json_decode$apiWorker->getCustomerInfo($userId), true );
  639.             if( $backendCustomer['success'] ) {
  640.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  641.             }
  642.         }
  643.         return $this->render('main/ka.html.twig', [
  644.             'session' => $session->all(),
  645.             'pdf' => $result['data'] ?? 0,
  646.             'customerInfo' => $customerInfo['data'] ?? 0,
  647.             'userId' => $userId ?? 0,
  648.             'orderData' => $orderData['data'] ?? 0,
  649.             'customer' => $customer ?? 0,
  650.             'customerInit' => $customerInit ?? ''
  651.         ]);
  652.     }
  653.     /**
  654.      * @param ApiWorker $apiWorker
  655.      * @param DbApi $dbApi
  656.      * @Route("/ka-thank", name="ka-thank-page")
  657.      *
  658.      *@return Response
  659.      */
  660.     public function kaThankPageApiWorker $apiWorkerDbApi $dbApi )
  661.     {
  662.         $session $this->get('session');
  663.         $userId $session->get('order_id');
  664.         $customerInfo json_decode$apiWorker->getCustomerInfo($userId), true );
  665.         $result json_decode$apiWorker->getRenderedPdfByTplId($userId1420), true);
  666.         if( $userId ) {
  667.             $customer $dbApi->getUserById($userId);
  668.             $backendCustomer json_decode$apiWorker->getCustomerInfo($userId), true );
  669.             if( $backendCustomer['success'] ) {
  670.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  671.             }
  672.         }
  673.         return $this->render('main/ka.thank.html.twig', [
  674.             'session' => $session->all(),
  675.             'pdf' => $result['data'] ?? 0,
  676.             'customerInfo' => $customerInfo['data'] ?? 0,
  677.             'userId' => $userId ?? 0,
  678.             'customer' => $customer ?? 0,
  679.             'customerInit' => $customerInit ?? ''
  680.         ]);
  681.     }
  682.     /**
  683.      * @Route("/api/save-kulanz-link", name="api_save_kulanz_link")
  684.      */
  685.     public function apiPdfLetterCreateRequest $requestApiWorker $apiWorker ) {
  686.         $session $this->get('session');
  687.         $userId $session->get('order_id');
  688.         $tplId 142;
  689.         $filename 'Kulanzantrag_bereits_genehmigt.pdf';
  690.         $customerInfo json_decode$apiWorker->getCustomerInfo($userId), true );
  691.         if( $customerInfo['success'] ) {
  692.             $firstname $customerInfo['data']['firstname'];
  693.             $lastname $customerInfo['data']['lastname'];
  694.             $filename 'Kulanzantrag_bereits_genehmigt_'.$firstname.'_'.$lastname.'_'.$userId.'.pdf';
  695.         }
  696.         $result $apiWorker->getRenderedPdfByTplId($userId$tplId);
  697.         $result json_decode($resulttrue);
  698.         if( $result['success'] ) {
  699.             $decoded base64_decode$result['data'] );
  700.             $response = new Response();
  701.             $response->headers->remove('Content-Disposition');
  702.             $response->setContent($decoded);
  703.             $response->headers->set('Content-Type''application/pdf');
  704.             $response->headers->set('Content-Disposition''attachment; filename='.$filename);
  705.             return $response;
  706.         }
  707.         return new Response('Requested file not found');
  708.     }
  709.     /**
  710.      * @param $slug
  711.      * @param ApiWorker $apiWorker
  712.      * @param DbApi $dbApi
  713.      * @param Request $request
  714.      *
  715.      * @Route("/cancel/{slug}")
  716.      *
  717.      * @return Response
  718.      */
  719.     public function emailCancellationApiWorker $apiWorker$slugRequest $requestDbApi $dbApi ) {
  720.         $session $this->get('session');
  721.         $result json_decode($apiWorker->getUserBySmsShortHash($slug), true );
  722.         $templateType $request->query->get('tt');
  723.         $templateId $request->query->get('ti');
  724.         if( $templateType == 's' ) {
  725.             $templateTypeVal 'sms';
  726.         } elseif ( $templateType == 'e' ) {
  727.             $templateTypeVal 'email';
  728.         } elseif ( $templateType == 'p' ) {
  729.             $templateTypeVal 'pdf';
  730.         } else {
  731.             $templateTypeVal '';
  732.         }
  733.         if( !$templateId ) {
  734.             $templateId '';
  735.         }
  736.         $session->set('templateTypeVal'$templateTypeVal);
  737.         $session->set('templateId'$templateId);
  738.         if( $result['success'] ) {
  739.             $userId $result['data']['id'];
  740.             $session->set('order_id'$userId);
  741.             //$apiWorker->logFrontendAction($userId);
  742.             $orderStatus $result['data']['status'];
  743.             //$cancelResult = json_decode( $apiWorker->cancelOrder($userId, $templateTypeVal, $templateId), true );
  744.             if( $result['data']['id'] ) {
  745.                 $customer $dbApi->getUserById($result['data']['id']);
  746.                 $backendCustomer json_decode$apiWorker->getCustomerInfo($userId), true );
  747.                 if( $backendCustomer['success'] ) {
  748.                     $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  749.                 }
  750.             }
  751.         }
  752.         return $this->render('main/cancel.html.twig', [
  753.             'customerInfo' => $result ?? 0,
  754.             'cancelResult' => $cancelResult ?? 0,
  755.             'slug' => $slug ?? 0,
  756.             'orderStatus' => $orderStatus ?? 0,
  757.             'customer' => $customer ?? 0,
  758.             'customerInit' => $customerInit ?? ''
  759.         ]);
  760.     }
  761.     /**
  762.      * @param ApiWorker $apiWorker
  763.      * @param DbApi $dbApi
  764.      *
  765.      * @Route("/cancel-thank", name="cancel_thank_page")
  766.      *
  767.      * @return Response
  768.      */
  769.     public function cancelThankPageApiWorker $apiWorkerDbApi $dbApi ) {
  770.         $session $this->get('session');
  771.         $userId $session->get('order_id');
  772.         $customerData json_decode$apiWorker->getCustomerInfo($userId), true );
  773.         if( $userId ) {
  774.             $customer $dbApi->getUserById($userId);
  775.             $backendCustomer json_decode$apiWorker->getCustomerInfo($userId), true );
  776.             if( $backendCustomer['success'] ) {
  777.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  778.             }
  779.         }
  780.         return $this->render('main/cancel.thank.html.twig', [
  781.             'customerInfo' => $customerData ?? [],
  782.             'customer' => $customer ?? 0,
  783.             'customerInit' => $customerInit ?? ''
  784.         ]);
  785.     }
  786.     /**
  787.      * @param ApiWorker $apiWorker
  788.      * @param DbApi $dbApi
  789.      *
  790.      * @Route("/too-late", name="too_late_page")
  791.      *
  792.      * @return Response
  793.      */
  794.     public function tooLatePageApiWorker $apiWorkerDbApi $dbApi) {
  795.         $session $this->get('session');
  796.         $userId $session->get('order_id');
  797.         $customerData json_decode$apiWorker->getCustomerInfo($userId), true );
  798.         $orderData json_decode$apiWorker->getOrder($userId), true );
  799.         if( $userId ) {
  800.             $customer $dbApi->getUserById($userId);
  801.             $backendCustomer json_decode$apiWorker->getCustomerInfo($userId), true );
  802.             if( $backendCustomer['success'] ) {
  803.                 $customerInit strtoupper(substr($backendCustomer['data']['firstname'], 01)) . strtoupper(substr($backendCustomer['data']['lastname'], 01));
  804.             }
  805.         }
  806.         return $this->render('main/cancel.late.html.twig', [
  807.             'customerInfo' => $customerData['data'] ?? [],
  808.             'orderData' => $orderData['data'] ?? [],
  809.             'orderId' => $userId ?? 0,
  810.             'customer' => $customer ?? 0,
  811.             'customerInit' => $customerInit ?? ''
  812.         ]);
  813.     }
  814. }