src/Controller/DashboardController.php line 549

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\HttpFoundation\RedirectResponse;
  10. use Symfony\Component\HttpFoundation\Cookie;
  11. use Symfony\Component\HttpKernel\Exception\HttpException;
  12. use Psr\Log\LoggerInterface;
  13. use App\Entity\BannedDomainEntity;
  14. use App\Entity\BannedUserEntity;
  15. use App\Entity\BonusEntity;
  16. use App\Entity\GeneratedWalletEntity;
  17. use App\Entity\MessageEntity;
  18. use App\Entity\NotificationEntity;
  19. use App\Entity\RecycledWalletEntity;
  20. use App\Entity\ReferralEntity;
  21. use App\Entity\SettingEntity;
  22. use App\Entity\SupportTicketEntity;
  23. use App\Entity\SupportTicketResponseEntity;
  24. use App\Entity\UserAdjustedTokenEntity;
  25. use App\Entity\UserBonusTokenEntity;
  26. use App\Entity\UserEntity;
  27. use App\Entity\UserOrderTokenEntity;
  28. use App\Entity\UserStakeTokenEntity;
  29. use App\Entity\UserMemeCoinEntity;
  30. use Doctrine\ORM\EntityManagerInterface;
  31. use App\Service\AuthService;
  32. use App\Service\MailService;
  33. use App\Service\BlockIoService;
  34. class DashboardController extends AbstractController
  35. {
  36.     private LoggerInterface $logger;
  37.     public function __construct(LoggerInterface $logger)
  38.     {
  39.         $this->logger $logger;
  40.     }
  41.      #[Route("/dd"name:"dashboard_index")]
  42.     public function indexAction(AuthService $authServiceBlockIoService $blockIoService)
  43.     {
  44.         $em $this->getDoctrine()->getManager();
  45.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  46.         $em $this->getDoctrine()->getManager();
  47.         $user $authService->getUser();
  48.         $session $this->get('session');
  49.         if(!$user->isVerifiedProfile()){
  50.             $session->getFlashBag()->add('error_messages''Please complete your profile before continuing.');
  51.             return $this->redirect($this->generateUrl('dashboard_profile'),302);
  52.         }
  53.     
  54.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  55.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  56.         
  57.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  58.         $totalOrder  $stagePurchase['stagePurchase'];
  59.         $referralTotalEarnings $em->getRepository(UserEntity::class)->refEarnings($user);
  60.         $totalUser $em->getRepository(UserEntity::class)->userCount();
  61.         $referralsss $em->getRepository(UserEntity::class)->referralBonusByReferrentUser($user);
  62.        
  63.         return $this->render('Dashboard/index.html.twig',array(
  64.             'page_header' => ' Welcome To Your AiETF Wallet Dashboard',
  65.             'user' => $user,
  66.             'totalUser' => $totalUser
  67.             'tokenDollarValue' => $tokenDollarValue,
  68.             'pb' => $pb,
  69.             'refTotalEarnings' => $referralTotalEarnings,
  70.             'page_title' => 'Dashboard',
  71.             'allReferrals' => count($referralsss),
  72.              'title' => 'Dashboard AiETF Token',   
  73.              'totalOrder' => $totalOrder ,
  74.             'javascripts' => [
  75.                 'dashboard/index.js',
  76.                 'plugins/dragula/dragula.min.js',
  77.                 'plugins/jkanban/jkanban.js',
  78.                 'plugins/chartjs.min.js',
  79.                 'plugins/threejs.js',
  80.                 'plugins/orbit-controls.js'
  81.             ],  
  82.             'min_order' => $this->getParameter('app.min_order'),
  83.             'max_order' => $this->getParameter('app.max_order'),
  84.         ));
  85.     }
  86.    #[Route("/tokens"name:"dashboard_purchase")]
  87.     public function purchaseAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  88.     {
  89.         
  90.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  91.         $user $authService->getUser();
  92.         $em $this->getDoctrine()->getManager();
  93.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  94.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  95.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  96.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  97.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  98.         $totalOrder  $stagePurchase['stagePurchase'];
  99.         $totalBonus $em->getRepository(UserBonusTokenEntity::class)->totalBonus();
  100.         $btcPrc $blockIoService->getNetworkPrice('btc');
  101.         $ethPrc $blockIoService->getNetworkPrice('eth'); 
  102.         $bnbPrc $blockIoService->getNetworkPrice('bnb');
  103.         $xrpPrc $blockIoService->getNetworkPrice('xrp');
  104.         $adaPrc $blockIoService->getNetworkPrice('ada');
  105.         $solPrc $blockIoService->getNetworkPrice('sol');
  106.         $ltcPrc $blockIoService->getNetworkPrice('ltc');
  107.         $dogePrc $blockIoService->getNetworkPrice('doge');
  108.         $usdtPrc $blockIoService->getNetworkPrice('usdt');
  109.         $daiPrc $blockIoService->getNetworkPrice('dai');
  110.         $shibPrc $blockIoService->getNetworkPrice('shib');
  111.         $pepePrc $blockIoService->getNetworkPrice('pepe');
  112.         $dotPrc $blockIoService->getNetworkPrice('dot');
  113.         $trxPrc $blockIoService->getNetworkPrice('trx');
  114.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  115.         $totalOrder  $stagePurchase['stagePurchase'];           
  116.         // $tokenDollarValue = $this->getParameter('app.token_dollar_value');
  117.         // $pb = $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  118.         // $tokenAmt = $params['checkout']['token_quantity'] ? $params['checkout']['token_quantity'] : 0;
  119.         // $paymentType = $params['checkout']['payment_type'] ? $params['checkout']['payment_type'] : '';
  120.         return $this->render('Dashboard/purchase.html.twig',array(
  121.             'page_header' => 'Purchase AiETF Tokens',
  122.              'userNotifications' => $userNotifications,
  123.              'userMessages' => $userMessages,
  124.             'purchaseBonus' => $pb,
  125.             'totalOrder'=> $totalOrder $totalOrder 0,
  126.             'tokenDollarValue' => $tokenDollarValue,
  127.             'btcPrc' => $btcPrc,
  128.             'ethPrc' => $ethPrc,
  129.             'bnbPrc' => $bnbPrc,
  130.             'xrpPrc' => $xrpPrc,
  131.             'adaPrc' => $adaPrc,
  132.             'solPrc' => $solPrc,
  133.             'user' =>  $user,
  134.             'ltcPrc' => $ltcPrc,
  135.             'dogePrc' => $dogePrc,
  136.             'usdtPrc' => $usdtPrc,
  137.             'daiPrc' => $daiPrc,
  138.             'dotPrc' => $dotPrc,
  139.             'shibPrc' => $shibPrc,
  140.             'pepePrc' => $pepePrc,
  141.             'trxPrc' => $trxPrc,
  142.             'title' => 'Purchase AiETF Token',  
  143.             'min_order' => $this->getParameter('app.min_order'),
  144.             'max_order' => $this->getParameter('app.max_order'),
  145.             'javascripts' => [
  146.                 'dashboard/purchase_token.js'
  147.             ]
  148.         ));
  149.     }
  150.     
  151.     #[Route("/purchase_token_inquiry/{id}"name:"dashboard_purchase_token_inquiry")]
  152.     public function purchaseTokenInquiryAction(Request $requestAuthService $authService$idMailService $mailService)
  153.     {
  154.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  155.         $user $authService->getUser();
  156.         $em $this->getDoctrine()->getManager();
  157.         $session $this->get('session');
  158.         $orderToken $em->getRepository(UserOrderTokenEntity::class)->find(base64_decode($id));
  159.         if(!$orderToken){
  160.             $session->getFlashBag()->add('error_messages''Ooops something wen`t wrong please try again later.');
  161.         } else {
  162.             $currentDateTime = new \DateTime();
  163.             $interval $currentDateTime->diff($orderToken->getUpdatedAt());
  164.             $diffInSeconds = ($interval->3600) + ($interval->60) + $interval->s;
  165.             if($orderToken->getInquirySentCtr() == 0) { 
  166.                 
  167.                 $orderToken->setInquirySentCtr($orderToken->getInquirySentCtr() + 1);
  168.                 $em->flush();
  169.                $msg $this->renderView('Email/purchase_inquiry.html.twig' , ['orderToken' => $orderToken]);
  170.                $mailService->sendMail('New Purchase Inquiry'$msg'[email protected]');
  171.                 $session->getFlashBag()->set('success_messages''Your inquiry successfully sent to us. we will back to you as soon as possible.');
  172.                 return $this->redirectToRoute('dashboard_index' , array(), 302);
  173.             }  else {
  174.                 
  175.                     $remainingSeconds 7200 $diffInSeconds;
  176.     
  177.                     $hours floor($remainingSeconds 3600); // Get the number of hours
  178.                     $minutes floor(($remainingSeconds 3600) / 60); // Get the remaining minutes
  179.                    // $session->getFlashBag()->set('error_messages', 'Please wait ' . ($hours > 0 ? $hours . "hours and " : "") . ($minutes > 0 ? $minutes . " minutes"  : "")  . ' to send a missing payment inquiry.' );
  180.                    $session->getFlashBag()->set('error_messages''Inquiry already sent we will come back to you as soon as possible.' ); 
  181.                    return $this->redirectToRoute('dashboard_index' , array(), 302);
  182.             }
  183.        
  184.         }
  185.         return $this->render('Dashboard/stake.html.twig',array(
  186.             'user' =>  $user
  187.         ));
  188.     }
  189.     
  190. #[Route("/stake"name:"dashboard_stake")]
  191.     public function stakeAction(Request $requestAuthService $authService)
  192.     {
  193.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  194.         $user $authService->getUser();
  195.         $em $this->getDoctrine()->getManager();
  196.        
  197.     
  198.           if($request->getMethod() == 'POST'){
  199.             $errors = [];
  200.             $data $request->request->get('stake');
  201.             $errors $this->validateStake($data$user);
  202.             if(count($errors)){
  203.                 foreach($errors as $error) {
  204.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  205.                 }
  206.             } else {
  207.                 return $this->redirect($this->generateUrl('dashboard_stake_review', ['amount' => $data['amount'], 'type' => $data['type']]), 302);
  208.             }
  209.         } 
  210.         return $this->render('Dashboard/stake.html.twig',array(
  211.             'user' =>  $user
  212.         ));
  213.     }
  214.     private function validateStake($formData$user){
  215.         $errors = [];
  216.         $amount str_replace(','''$formData['amount']);  
  217.         switch ($formData['type']) {
  218.             case 1:
  219.                 
  220.                 if(floatval$amount) < 10000000){
  221.                     $errors[] = 'Minimum amount is 10,000,000';
  222.                 }
  223.                 break;
  224.             case :
  225.                 
  226.                 if(floatval$amount) < 50000000){
  227.                     $errors[] = 'Minimum amount is 50,000,000';
  228.                 }
  229.                 break;
  230.             case 3:
  231.             
  232.                 if(floatval$amount) < 100000000){
  233.                     $errors[] = 'Minimum amount is 100,000,000';
  234.                 }
  235.                 
  236.                 break;
  237.         }
  238.         if(floatval($amount) > $user->totalBalance()){
  239.             $errors[] = 'Insufficient balance to stake.';
  240.         }
  241.         return $errors;
  242.     }
  243.       
  244.       
  245. #[Route("/stakereview"name:"dashboard_stake_review")]
  246.     public function stakereviewAction(Request $requestAuthService $authService)
  247.     {
  248.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  249.         $user $authService->getUser();
  250.         $em $this->getDoctrine()->getManager();
  251.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  252.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  253.         $data $request->query->all();
  254.         $data['amount'] = str_replace(','''$data['amount']);
  255.         if($request->getMethod() == 'POST'){
  256.             $errors = [];
  257.             $data $request->request->get('stake');
  258.            $errors $this->validateStake($data$user);
  259.             if(count($errors)){
  260.                 foreach($errors as $error) {
  261.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  262.                 }
  263.             } else {
  264.                     $amount str_replace(','''$data['amount']);
  265.                     $userStakeToken  = new UserStakeTokenEntity();
  266.                     $userStakeToken->setTokenAmount($amount);
  267.                     $userStakeToken->setType($data['type']);
  268.                     $userStakeToken->setInterest((($data['type'] ==  '1' 7.45 : ($data['type'] ==  '2' 13 23.75) ) / 100) * floatval($amount));
  269.                     $userStakeToken->setInterestPercent(($data['type'] ==  '1' 7.45 : ($data['type'] ==  '2' 13 23.75)));
  270.                     $userStakeToken->setUser($user);
  271.                     $userStakeToken->setStartDate(new \DateTime(date('Y/m/d')));
  272.                     $userStakeToken->setEndDate(new \DateTime(date('Y/m/d'strtotime("+" .($data['type'] ==  '1' '6' '12'). "month"))));
  273.                     $userStakeToken->setTokenDollarValue($this->getParameter('app.token_dollar_value'));
  274.                     $em->persist($userStakeToken);
  275.                     $em->flush();
  276.                     $this->get('session')->getFlashBag()->add('success_messages''Your token is successfully staking.');
  277.                     return $this->redirect($this->generateUrl('dashboard_stake'), 302);
  278.               }
  279.         } 
  280.         return $this->render('Dashboard/stakereview.html.twig',array(
  281.             'purchaseBonus' => $pb,
  282.             'tokenDollarValue' => $tokenDollarValue,
  283.             'data'=> $data,
  284.             'user' =>  $user,
  285.             
  286.         ));
  287.     }
  288.     
  289.     
  290. #[Route("/staking"name:"dashboard_staking")]
  291.     public function stakingAction(Request $requestAuthService $authService)
  292.     {
  293.         
  294.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  295.         $user $authService->getUser();
  296.         $em $this->getDoctrine()->getManager();
  297.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  298.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  299.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  300.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  301.    $amount $em->getRepository(UserStakeTokenEntity::class)->findAll();
  302.        $stakelist $em->getRepository(UserStakeTokenEntity::class)->findBy(['user' => $user]);
  303.         return $this->render('Dashboard/staking.html.twig',array(
  304.        'userNotifications' => $userNotifications,
  305.      'userMessages' => $userMessages,
  306.             'purchaseBonus' => $pb,
  307.             'tokenDollarValue' => $tokenDollarValue,
  308.             'user' =>  $user,
  309.             'page_title' => 'My GLN Stakes',
  310.             'amount' => $amount,
  311. 'stakelist' => $stakelist,
  312.         ));
  313.     }
  314.     
  315.     
  316. #[Route("/staking2"name:"dashboard_staking2")]
  317.     public function staking2Action(Request $requestAuthService $authService)
  318.     {
  319.         
  320.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  321.         $user $authService->getUser();
  322.         $em $this->getDoctrine()->getManager();
  323.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  324.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  325.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  326.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  327.       $amount $em->getRepository(UserStakeTokenEntity::class)->findAll();
  328.        $stakelist $em->getRepository(UserStakeTokenEntity::class)->findBy(['user' => $user]);
  329.         return $this->render('Dashboard/staking2.html.twig',array(
  330.             'userNotifications' => $userNotifications,
  331.             'userMessages' => $userMessages,
  332.             'purchaseBonus' => $pb,
  333.             'tokenDollarValue' => $tokenDollarValue,
  334.             'user' =>  $user,
  335.             'page_title' => 'My GLN Stakes',
  336.             'amount' => $amount,
  337.             'stakelist' => $stakelist,
  338.         ));
  339.     }
  340.      #[Route("/tokens/review"name:"dashboard_purchase_review")]
  341.     public function purchase_reviewAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  342.     {
  343.         
  344.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  345.                  
  346.         if($request->getMethod() != 'POST'){
  347.             $this->get('session')->getFlashBag()->add('error_messages''Unauthorized Access Please contact a system administrator.');
  348.             return $this->redirect$this->generateUrl('dashboard_purchase'), 302);
  349.         } 
  350.         $user $authService->getUser();
  351.         $em $this->getDoctrine()->getManager();
  352.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  353.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  354.         $params $request->request->all();
  355.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  356.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  357.         $tokenAmt $params['checkout']['token_quantity'] ? $params['checkout']['token_quantity'] : 0;
  358.         $paymentType $params['checkout']['payment_type'] && $params['checkout']['payment_type'] != ''  $params['checkout']['payment_type'] : 'btc';
  359.         $bonusToken $params['checkout']['bonus'] ?  $this->stringToInt($params['checkout']['bonus']) : '';
  360.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  361.         $totalOrder  $stagePurchase['stagePurchase']; 
  362.         $tokenAmtInt $this->stringToInt($tokenAmt);
  363. $usdtValue $this->stringToInt($tokenAmt) * $tokenDollarValue;
  364.         $minOrder $this->getParameter('app.min_order');
  365.         $maxOrder $this->getParameter('app.max_order');
  366.         if(floatval($this->stringToInt($tokenAmt)) < floatval($minOrder) || floatval($this->stringToInt($tokenAmt)) > floatval($maxOrder)){
  367.            
  368.             $this->get('session')->getFlashBag()->add('error_messages''Minimum order should ' number_format($minOrder2'.' ',') . ' and Maximum order shoul be ' number_format($maxOrder2'.' ',') );
  369.             return $this->redirect$this->generateUrl('dashboard_purchase'), 302);
  370.         }
  371.         
  372.      return $this->render('Dashboard/purchase_review.html.twig', array(
  373.     'page_header' => 'Purchase AiETF Tokens',
  374.     'userNotifications' => $userNotifications,
  375.     'userMessages' => $userMessages,
  376.     'totalOrder'=> $totalOrder $totalOrder 0,
  377.     'purchaseBonus' => $pb,
  378.     'tokenDollarValue' => $usdtValue,
  379.     'user' =>  $user,
  380.     'tokenAmt' => $tokenAmt,
  381.     'paymentType' => $paymentType,
  382.     'bonusToken' => $bonusToken,
  383.     'usdtValue' => $usdtValue,
  384.     'title' => 'Purchase Review AiETF Token',
  385. ));
  386.     }
  387.      #[Route("/tokens/checkout"name:"dashboard_purchase_checkout")]
  388.     public function purchase_checkoutAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  389.     {
  390.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  391.         $params $request->query->all();
  392.         $minOrder $this->getParameter('app.min_order');
  393.         $maxOrder $this->getParameter('app.max_order');
  394.         if(isset($params['paymentType']) && isset($params['tokenAmt']) ){
  395.           
  396.             $user $authService->getUser();
  397.             $em $this->getDoctrine()->getManager();
  398.             $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  399.             $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  400.         
  401.             $tokenDollarValue $this->getParameter('app.token_dollar_value');
  402.             $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  403.             $promoB $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB10000'));
  404.             $tokenAmt =  $this->stringToInt($params['tokenAmt']);
  405.             $paymentType $params['paymentType'];
  406.             $label time() . '-' $this->generateRandomString();
  407.        
  408.             if(floatval($tokenAmt) < floatval($minOrder) || floatval($tokenAmt) > floatval($maxOrder)){
  409.            
  410.                 $this->get('session')->getFlashBag()->add('error_messages''Ooops something went wrong please try again later.');
  411.                 return $this->redirect$this->generateUrl('dashboard_purchase'), 302);
  412.             }
  413.            
  414.     
  415.     
  416.             $recycledWallet $em->getRepository(RecycledWalletEntity::class)->findOneBy(array('network' => $paymentType'status' => 'Available'));
  417.             if(!$recycledWallet){
  418.                 $recycledWallet $this->sdasdsa($em$paymentType$blockIoService);
  419.             }
  420.             // $recycledWallet = $blockIoService->wallet($paymentType);
  421.             
  422.             $cryptoPrc $blockIoService->getNetworkPrice($paymentType);
  423.             $duelInDollar $this->stringToInt($tokenAmt) * $this->stringToInt($tokenDollarValue);
  424.             $dueToCrt $this->stringToInt($duelInDollar) /  $this->stringToInt($cryptoPrc);
  425.             $newOrderToken = new UserOrderTokenEntity();
  426.             $newOrderToken->setTokenValue($tokenDollarValue);
  427.             $newOrderToken->setTokenAmount($tokenAmt);
  428.             $newOrderToken->setLabel($recycledWallet->getWalletAddress());
  429.             $newOrderToken->setAddress($recycledWallet->getWalletAddress());
  430.             $newOrderToken->setAmount($dueToCrt);
  431.             $newOrderToken->setNetwork($paymentType);
  432.             $newOrderToken->setUser($user);
  433.             $em->persist($newOrderToken);
  434.             $em->flush();
  435.             
  436.             
  437.             $recycledWallet->setStatus('Used');
  438.             $em->flush();
  439.             
  440.            
  441.             return $this->redirect($this->generateUrl('dashboard_purchase_details' , array('transactionId' => $newOrderToken->getIdEncoded())), 302);
  442.         } else {
  443.             $this->get('session')->getFlashBag()->add('error_messages''Oppsss something went wrong please try again.');
  444.             return $this->redirect$this->generateUrl('dashboard_purchase'), 302);
  445.         }
  446.     }
  447.     private function stringToInt($n){
  448.         return str_replace(","""$n); 
  449.     }
  450.       #[Route("/tokens/details/{transactionId}"name:"dashboard_purchase_details")]
  451.     public function purchase_detailsAction(Request $requestAuthService $authServiceBlockIoService $blockIoService$transactionId)
  452.     {
  453.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin() (isset($params['paymentType']) && isset($params['tokenAmt']) );
  454.         $user $authService->getUser();
  455.         $em $this->getDoctrine()->getManager();
  456.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  457.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  458.         $orderToken $em->getRepository(UserOrderTokenEntity::class)->find(base64_decode($transactionId));
  459.         
  460.         
  461.          $params $request->request->all();
  462.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  463.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  464.         $tokenAmt $orderToken->getAmount();
  465.         $paymentType $orderToken->getNetwork();
  466.    
  467.         $cryptoPrc =300000;
  468.         $amtDue $tokenAmt $tokenDollarValue;
  469.         $prcToCrt $amtDue $cryptoPrc;
  470.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  471.         $totalOrder  $stagePurchase['stagePurchase'];           
  472.         
  473.        
  474.        
  475.         return $this->render('Dashboard/purchase_details.html.twig',array(
  476.             'userNotifications' => $userNotifications,
  477.             'userMessages' => $userMessages,
  478.             'orderToken' => $orderToken,
  479.             'bonusToken' => $orderToken->getAmount() >= 10000 ? ($orderToken->getAmount() / 2.5) : 0,
  480.             'user' =>  $user,
  481.             'totalOrder'=> $totalOrder $totalOrder 0,
  482.             'paymentType' => $orderToken->getNetwork(),
  483.             'purchaseBonus' => $pb,
  484.             'tokenDollarValue' => $tokenDollarValue,
  485.             'tokenAmt' => $tokenAmt,
  486.             'paymentType' => $paymentType,
  487.             'prcToCrt' => $prcToCrt,
  488.             'title' => 'Purchase Checkout AiETF Token',   
  489.             'page_header' => 'Purchase AiETF Tokens'
  490.         ));
  491.     }
  492.    #[Route("/profile_avatar"name:"dashboard_profile_avatar")]
  493.     public function profileAvatarAction(Request $requestAuthService $authService)
  494.     {
  495.         
  496.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  497.         $user $authService->getUser();
  498.         $em $this->getDoctrine()->getManager();
  499.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  500.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  501.         if($request->getMethod() == 'POST'){
  502.             $user->setAvatar($request->get('avatar'));
  503.             $em->flush();
  504.         }
  505.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  506.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  507.         return $this->render('Dashboard/profile_avatar.html.twig',array(
  508.        'userNotifications' => $userNotifications,
  509.      'userMessages' => $userMessages,
  510.             'purchaseBonus' => $pb,
  511.             'tokenDollarValue' => $tokenDollarValue,
  512.             'user' =>  $user,
  513.         ));
  514.     }
  515.     #[Route("/getting_started"name:"dashboard_getting_started")]
  516.     public function gettingStartedAction(Request $requestAuthService $authService)
  517.     {
  518.         
  519.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  520.         $user $authService->getUser();
  521.         $em $this->getDoctrine()->getManager();
  522.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  523.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  524.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  525.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  526.         return $this->render('Dashboard/getting_started.html.twig',array(
  527.        'userNotifications' => $userNotifications,
  528.      'userMessages' => $userMessages,
  529.             'purchaseBonus' => $pb,
  530.             'tokenDollarValue' => $tokenDollarValue,
  531.             'user' =>  $user,
  532.         ));
  533.     }
  534.     #[Route("/purchase_meme/{id}"name:"dashboard_purchase_meme")]
  535.     public function purchaseMemeAction(Request $requestAuthService $authService$id)
  536.     {
  537.         
  538.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  539.     
  540.         $user $authService->getUser();
  541.         $em $this->getDoctrine()->getManager();
  542.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  543.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  544.         $memeCoin $em->getRepository(UserMemeCoinEntity::class)->find($id);
  545.         if(!$memeCoin){
  546.             $this->get('session')->getFlashBag()->add('error_messages''Invalid MemeCoin.');
  547.             return $this->redirect($this->generateUrl('dashboard_meme_gallery'), 302);
  548.         }
  549.         return $this->render('Dashboard/purchase_meme.html.twig',array(
  550.         'userNotifications' => $userNotifications,
  551.         'userMessages' => $userMessages,
  552.             'user' =>  $user,
  553.         ));
  554.     }
  555.     #[Route("/meme_gallery"name:"dashboard_meme_gallery")]
  556.     public function galleryMemeAction(Request $requestAuthService $authService)
  557.     {
  558.         
  559.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  560.         $user $authService->getUser();
  561.         $em $this->getDoctrine()->getManager();
  562.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  563.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  564.         $memeCoins $em->getRepository(UserMemeCoinEntity::class)->findAll();
  565.         return $this->render('Dashboard/meme_gallery.html.twig',array(
  566.             'userNotifications' => $userNotifications,
  567.             'userMessages' => $userMessages,
  568.             'user' =>  $user,
  569.             'memeCoins' => $memeCoins
  570.         ));
  571.     }
  572.     
  573.     
  574.     #[Route("/total_assets"name:"dashboard_total_assets")]
  575.     public function totalAssetsAction(Request $requestAuthService $authService)
  576.     {
  577.         
  578.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  579.         $user $authService->getUser();
  580.         $em $this->getDoctrine()->getManager();
  581.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  582.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  583.         $memeCoins $em->getRepository(UserMemeCoinEntity::class)->findAll();
  584.         return $this->render('Dashboard/totalassets.html.twig',array(
  585.             'userNotifications' => $userNotifications,
  586.             'userMessages' => $userMessages,
  587.             'user' =>  $user,
  588.             'memeCoins' => $memeCoins
  589.         ));
  590.     }
  591.     
  592.     
  593.     #[Route("/meme_creator"name:"dashboard_meme_creator")]
  594.     public function memeCreatorAction(Request $requestAuthService $authService)
  595.     {
  596.         
  597.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  598.         $user $authService->getUser();
  599.         $em $this->getDoctrine()->getManager();
  600.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  601.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  602.         if($request->getMethod() == 'POST'){
  603.             $formData $request->request->all();
  604.             if(isset($formData['form'])){
  605.                 $strToInt preg_replace('/[^0-9.]/'''$formData['form']['creation_cost']);
  606.                 $floatVal = (float)$strToInt;
  607.                 $errors '';
  608.                 
  609.                     $memeCoinExist $em->getRepository(UserMemeCoinEntity::class)
  610.                             ->findOneBy(['name' => $formData['form']['name']]) 
  611.                             ?? $em->getRepository(UserMemeCoinEntity::class)
  612.                                 ->findOneBy(['symbol' => $formData['form']['symbol']]);
  613.                 if($memeCoinExist){
  614.                     $errors 'MemeCoin name or symbols are already exist.';
  615.                 }
  616.                 if($user->totalBalance() < $floatVal){
  617.                     $errors 'Insufficient balance.';
  618.                 }
  619.                 if(!empty($errors) || $errors != ''){
  620.                      $this->get('session')->getFlashBag()->add('error_messages'$errors);
  621.                     return $this->redirect($this->generateUrl('dashboard_meme_creator'), 302);
  622.                 }
  623.                 $userMemeCoin = new UserMemeCoinEntity();
  624.                 $userMemeCoin->setUser($user);
  625.                 $userMemeCoin->setName($formData['form']['name']);
  626.                 $userMemeCoin->setSymbol($formData['form']['symbol']);
  627.                 $userMemeCoin->setBasePrice($formData['form']['base_price']);
  628.                 $userMemeCoin->setTotalSupply($formData['form']['total_supply']);
  629.                 $userMemeCoin->setBurnAmount($floatVal 0.75);
  630.                 $userMemeCoin->setRecycleAmount($floatVal 0.25);
  631.                 $em->persist($userMemeCoin);
  632.                 $em->flush();
  633.                 $this->get('session')->getFlashBag()->add('success_messages''MemeCoin successfully created');
  634.                 return $this->redirect($this->generateUrl('dashboard_meme_creator'), 302);
  635.               
  636.             }
  637.         }
  638.         return $this->render('Dashboard/meme_creator.html.twig',array(
  639.             'userNotifications' => $userNotifications,
  640.             'userMessages' => $userMessages,
  641.             'user' =>  $user,
  642.         ));
  643.     }
  644.     #[Route("/meme_purchase"name:"dashboard_meme_purchase")]
  645.     public function memePurchaseAction(Request $requestAuthService $authService)
  646.     {
  647.         
  648.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  649.         $user $authService->getUser();
  650.         $em $this->getDoctrine()->getManager();
  651.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  652.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  653.         if($request->getMethod() == 'POST'){
  654.             $formData $request->request->all();
  655.             if(isset($formData['form'])){
  656.                 $strToInt preg_replace('/[^0-9.]/'''$formData['form']['creation_cost']);
  657.                 $floatVal = (float)$strToInt;
  658.                 if($user->totalBalance() < $floatVal){
  659.                     $this->get('session')->getFlashBag()->add('error_messages''You dont have enough balance.');
  660.                     return $this->redirect($this->generateUrl('dashboard_meme_creator'), 302);
  661.                 }
  662.                 $userMemeCoin = new UserMemeCoinEntity();
  663.                 $userMemeCoin->setUser($user);
  664.                 $userMemeCoin->setName($formData['form']['name']);
  665.                 $userMemeCoin->setSymbol($formData['form']['symbol']);
  666.                 $userMemeCoin->setBasePrice($formData['form']['base_price']);
  667.                 $userMemeCoin->setTotalSupply($formData['form']['total_supply']);
  668.                 $userMemeCoin->setBurnAmount($floatVal 0.75);
  669.                 $userMemeCoin->setRecycleAmount($floatVal 0.25);
  670.                 $em->persist($userMemeCoin);
  671.                 $em->flush();
  672.                 $this->get('session')->getFlashBag()->add('success_messages''MemeCoin successfully created');
  673.                 return $this->redirect($this->generateUrl('dashboard_meme_creator'), 302);
  674.               
  675.             }
  676.         }
  677.         return $this->render('Dashboard/meme_purchase.html.twig',array(
  678.             'userNotifications' => $userNotifications,
  679.             'userMessages' => $userMessages,
  680.             'user' =>  $user,
  681.         ));
  682.     }
  683.     #[Route("/tracker"name:"dashboard_tracker")]
  684.     public function trackerAction(Request $requestAuthService $authService)
  685.     {
  686.         
  687.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  688.         $user $authService->getUser();
  689.         $em $this->getDoctrine()->getManager();
  690.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  691.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  692.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  693.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  694.         return $this->render('Dashboard/tracker.html.twig',array(
  695.        'userNotifications' => $userNotifications,
  696.      'userMessages' => $userMessages,
  697.             'purchaseBonus' => $pb,
  698.             'tokenDollarValue' => $tokenDollarValue,
  699.             'user' =>  $user,
  700.                'title' => 'ETF Portfolio Tracker',  
  701.         ));
  702.     }
  703. #[Route("/burn"name:"dashboard_burn")]
  704. public function burnAction(Request $requestAuthService $authService)
  705. {
  706.     if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  707.     $user $authService->getUser();
  708.     $em $this->getDoctrine()->getManager();
  709.     $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  710.     $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  711.     $tokenDollarValue $this->getParameter('app.token_dollar_value');
  712.     $pb $em->getRepository(BonusEntity::class)->findOneBy(['code' => 'PB']);
  713.     // ðŸ”¹ Total burned (all users)
  714.     $totalBurned = (int) $em->createQueryBuilder()
  715.         ->select('COALESCE(SUM(ua.amount), 0)')
  716.         ->from(\App\Entity\UserAdjustedTokenEntity::class, 'ua')
  717.         ->where('ua.reason = :reason')
  718.         ->setParameter('reason''burn')
  719.         ->getQuery()
  720.         ->getSingleScalarResult();
  721.     // ðŸ”¹ User's burned
  722.     $userBurned = (int) $em->createQueryBuilder()
  723.         ->select('COALESCE(SUM(ua.amount), 0)')
  724.         ->from(\App\Entity\UserAdjustedTokenEntity::class, 'ua')
  725.         ->where('ua.reason = :reason AND ua.user = :user')
  726.         ->setParameter('reason''burn')
  727.         ->setParameter('user'$user)
  728.         ->getQuery()
  729.         ->getSingleScalarResult();
  730.     // ðŸ”¹ Remaining supply
  731.         $totalBurned = (int) $em->createQueryBuilder()
  732.         ->select('COALESCE(SUM(ua.amount), 0)')
  733.         ->from(\App\Entity\UserAdjustedTokenEntity::class, 'ua')
  734.         ->where('ua.reason = :reason')
  735.         ->setParameter('reason''burn')
  736.         ->getQuery()
  737.         ->getSingleScalarResult();
  738.         $recentUserBurneds $em->createQueryBuilder()
  739.             ->select('ua.amount, u.email')
  740.             ->from(\App\Entity\UserAdjustedTokenEntity::class, 'ua')
  741.             ->leftJoin('ua.user''u'
  742.             ->where('ua.reason = :reason')
  743.             ->setParameter('reason''burn')
  744.             ->orderBy('ua.id''DESC'
  745.             ->setMaxResults(10)
  746.             ->getQuery()
  747.             ->getResult();
  748.     $initialSupply 200000000000// adjust this constant
  749.     $remainingSupply $initialSupply $totalBurned;
  750.     return $this->render('Dashboard/burn.html.twig', [
  751.         'userNotifications' => $userNotifications,
  752.         'userMessages' => $userMessages,
  753.         'purchaseBonus' => $pb,
  754.         'tokenDollarValue' => $tokenDollarValue,
  755.         'user' => $user,
  756.         'min_order' => 100,
  757.         'title' => 'XRPV Burn Protocol',
  758.         'totalBurned' => $totalBurned,
  759.         'remainingSupply' => $remainingSupply,
  760.         'userBurned' => $userBurned,
  761.         'recentBurneds' => $recentUserBurneds
  762.     ]);
  763. }
  764. #[Route("/burnconfirm"name:"dashboard_burnconfirm")]
  765. public function burnconfirmAction(Request $requestAuthService $authService)
  766. {
  767.     if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  768.     $user $authService->getUser();
  769.     $em $this->getDoctrine()->getManager();
  770.     $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  771.     $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  772.     $tokenDollarValue $this->getParameter('app.token_dollar_value');
  773.     $pb $em->getRepository(BonusEntity::class)->findOneBy(['code' => 'PB']);
  774.     if ($request->isMethod('GET')) {
  775.         $burnAmount = (int) $request->query->get('burn_amount'0);
  776.         return $this->render('Dashboard/burnconfirm.html.twig', [
  777.             'userNotifications' => $userNotifications,
  778.             'userMessages' => $userMessages,
  779.             'purchaseBonus' => $pb,
  780.             'tokenDollarValue' => $tokenDollarValue,
  781.             'user' => $user,
  782.             'burnAmount' => $burnAmount,
  783.             'title' => 'XRPV Burn Confirm',
  784.         ]);
  785.     }
  786.     if ($request->isMethod('POST')) {
  787.         $burnAmount = (int) $request->request->get('burn_amount'0);
  788.         $currentBalance $user->totalBalance();
  789.         if ($burnAmount && $burnAmount <= $currentBalance) {
  790.             $burn = new UserAdjustedTokenEntity();
  791.             $burn->setUser($user);
  792.             $burn->setAmount($burnAmount);  
  793.             $burn->setReason('Burn');        
  794.             $burn->setCreatedAt(new \DateTime());
  795.             $em->persist($burn);
  796.             $em->flush();
  797.             $this->addFlash('burn_success''🔥 You successfully burned '.number_format($burnAmount).' XRPV!');
  798.             return $this->redirectToRoute('dashboard_index');
  799.         }
  800.         $this->addFlash('burn_error''Invalid burn amount.');
  801.         return $this->redirectToRoute('dashboard_burn');
  802.     }
  803. }
  804.        #[Route("/referral_media"name"dashboard_project_media")]
  805.     public function projectMediaAction(Request $requestAuthService $authService)
  806.     {
  807.         
  808.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  809.         $user $authService->getUser();
  810.         $em $this->getDoctrine()->getManager();
  811.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  812.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  813.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  814.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  815.         return $this->render('Dashboard/project_media.html.twig',array(
  816.        'userNotifications' => $userNotifications,
  817.      'userMessages' => $userMessages,
  818.             'purchaseBonus' => $pb,
  819.             'tokenDollarValue' => $tokenDollarValue,
  820.             'user' =>  $user,
  821.             'title' => 'Referral Media AiETF Token',   
  822.             'page_header' => 'AiEFT Referral Media'
  823.         ));
  824.     }
  825.     #[Route("/project_statistics"name:"dashboard_project_statistics")]
  826.     public function projectStatisticsAction(Request $requestAuthService $authService)
  827.     {
  828.         
  829.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  830.         $user $authService->getUser();
  831.         $em $this->getDoctrine()->getManager();
  832.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  833.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  834.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  835.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  836.         return $this->render('Dashboard/project_statistics.html.twig',array(
  837.        'userNotifications' => $userNotifications,
  838.      'userMessages' => $userMessages,
  839.             'purchaseBonus' => $pb,
  840.             'tokenDollarValue' => $tokenDollarValue,
  841.             'user' =>  $user,
  842.         ));
  843.     }
  844.     #[Route("/walletholdings"name:"dashboard_walletholdings")]
  845.     public function walletholdingsAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  846.     {
  847.         
  848.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  849.         $user $authService->getUser();
  850.         $em $this->getDoctrine()->getManager();
  851.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  852.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  853.         $sevenDaysOrder $em->getRepository(UserEntity::class)->userLast7DaysOrderStatistics($user);
  854.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  855.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  856.         $cryptoPrice = [
  857.             'btc' => $blockIoService->getNetworkDetails('btc'),
  858.             'eth' =>  $blockIoService->getNetworkDetails('eth'),
  859.             'bnb' =>  $blockIoService->getNetworkDetails('bnb')
  860.         ];
  861.         return $this->render('Dashboard/walletholdings.html.twig',array(
  862.             'page_title' => 'Account Activity',
  863.             'userNotifications' => $userNotifications,
  864.             'userMessages' => $userMessages,
  865.             'purchaseBonus' => $pb,
  866.             'tokenDollarValue' => $tokenDollarValue,
  867.             'user' =>  $user,
  868.             'cryptoPrice' => $cryptoPrice,
  869.             'sevenDaysOrder' => $sevenDaysOrder
  870.         ));
  871.     }       
  872.     
  873.     
  874.     #[Route("/stages"name:"dashboard_stages")]
  875.     public function stagesAction(Request $requestAuthService $authService)
  876.     {
  877.         
  878.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  879.         $user $authService->getUser();
  880.         $em $this->getDoctrine()->getManager();
  881.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  882.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  883.                  $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  884.        $totalOrder  $stagePurchase['stagePurchase'];
  885.            $totalBonus $em->getRepository(UserBonusTokenEntity::class)->totalBonus();
  886.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  887.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  888.         return $this->render('Dashboard/stages.html.twig',array(
  889.             'page_title' => 'Project Stages',
  890.             'userNotifications' => $userNotifications,
  891.             'userMessages' => $userMessages,
  892.             'purchaseBonus' => $pb,
  893.             'tokenDollarValue' => $tokenDollarValue,
  894.             
  895.             'totalOrder'=> $totalOrder $totalOrder 0,
  896.             'tokenDisctributedall' => 10000000000 $totalOrder - ($totalBonus['amt'] ? $totalBonus['amt'] : 0),
  897.             'user' =>  $user,
  898.         ));
  899.     }       
  900.     
  901.     
  902.    #[Route("/account_activity"name:"dashboard_account_activity")]
  903.     public function accountActivityAction(Request $requestAuthService $authService)
  904.     {
  905.         
  906.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  907.         $user $authService->getUser();
  908.         $em $this->getDoctrine()->getManager();
  909.         $orders $em->getRepository(UserOrderTokenEntity::class)->findBy([
  910.             'user' => $user->getId()
  911.         ]);
  912.         $bonuses $em->getRepository(UserBonusTokenEntity::class)->findBy([
  913.             'user' => $user->getId()
  914.         ]);
  915.         return $this->render('Dashboard/account_activity.html.twig',array(
  916.             'title' => 'Transactions AiETF Token',   
  917.             'orders' => $orders,
  918.             'user' => $user,
  919.             'bonuses' => $bonuses,
  920.             'page_header' => 'Transactions & Bonuses'
  921.         ));
  922.     }    
  923.    #[Route("/callisto_network"name:"dashboard_callisto_network")]
  924.     public function callisto_networkAction(Request $requestAuthService $authService)
  925.     {
  926.         
  927.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  928.         //$tokenBtcValue = $this->getParameter('token_btc_value');
  929.         $user $authService->getUser();
  930.         $em $this->getDoctrine()->getManager();
  931.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  932.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  933.         if($request->getMethod() == 'POST'){
  934.             $address $request->get('address');
  935.             
  936.             $user->setCloAddress($address);
  937.             $em->flush();
  938.             $this->get('session')->getFlashBag()->add('success_messages''Callisto Network Address successfully updated.');
  939.             return $this->redirect($this->generateUrl('dashboard_profile'),302);
  940.         }
  941.         return $this->render('Dashboard/callisto_network.html.twig',array(
  942.             'page_title' => 'Buy Tokens',
  943.        'userNotifications' => $userNotifications,
  944.      'userMessages' => $userMessages,
  945.             'user' => $user
  946.         ));
  947.     }
  948.    #[Route("/order_preview"name:"dashboard_order_preview")]
  949.     public function order_previewAction(Request $requestAuthService $authService)
  950.     {
  951.         
  952.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  953.         $em $this->getDoctrine()->getManager();
  954.         $tokenAmt 0;
  955.         $totalDue 0;
  956.         if($request->getMethod() == 'POST'){
  957.             $order $request->request->get('order');
  958.             $errors = array();
  959.             $pendingOrderCtr $em->getRepository(UserOrderTokenEntity::class)->pendingOrderCtr($authService->getUser());
  960.             // if(floatval($order['amount']) > 500){
  961.             //     $errors[] = 'Maximum amount is 500,000.';
  962.             // }
  963.            if(floatval($pendingOrderCtr[0]['orderCtr']) > 5){
  964.                 $errors[] = 'Please complete your pending order to make a new order.';
  965.            }
  966.             if(floatval($order['amount']) < 100){
  967.                 $errors[] = 'Minimum amount is 25.';
  968.             } 
  969.             if(count($errors)){
  970.                foreach($errors as $error) {
  971.                  
  972.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  973.                 }
  974.                 return $this->redirect($this->generateUrl('dashboard_buy_token'),302);
  975.             
  976.             } else {
  977.                     $tokenAmt str_replace(','''$order['amount']);
  978.                     $totalDue str_replace(',''',$order['due_amount']);
  979.                     $session $this->container->get('session');
  980.                     $btcToDollar $session->get('btr');
  981.                     $tokenBtcValuenumber_format($this->container->getParameter('token_usd_value') / $btcToDollar 8'.''');
  982.                     $amountDue $tokenAmt $tokenBtcValue;
  983.                     if(intval($totalDue) != intval(number_format($amountDue,8,'.',''))){
  984.                        
  985.                         throw new \Exception();
  986.                     }
  987.             }
  988.         }
  989.         $user $authService->getUser();
  990.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  991.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  992.         return $this->render('Dashboard/order_preview.html.twig',array(
  993.        'userNotifications' => $userNotifications,
  994.      'userMessages' => $userMessages,
  995.             'price' => $tokenBtcValue,
  996.             'totalAmt' => $tokenAmt,
  997.             'totalDue' => $totalDue,
  998.             'page_title' => 'Order Preview',
  999.         ));
  1000.     }
  1001.    #[Route("/checkout_order_action"name:"dashboard_checkout_order_action")]
  1002.     public function checkout_order_actionAction(Request $requestAuthService $authService)
  1003.     {
  1004.         
  1005.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1006.         if($request->getMethod() == 'POST'){
  1007.             $order $request->request->get('order');
  1008.             $tokenAmt $order['amt'];
  1009.             $session $this->container->get('session');
  1010.             $tokenBtcValuenumber_format($this->container->getParameter('token_usd_value') / $session->get('btr'), 8'.''');
  1011.             $amountDue $tokenAmt $tokenBtcValue;
  1012.             $blockIoService $this->get('fullMoon.blockIoService');
  1013.             $em $this->getDoctrine()->getManager();
  1014.             $label time() . '-' $this->generateRandomString();
  1015.             $newAddress $blockIoService->getNewAddress($label);
  1016.             $walletAddress $newAddress->data->address;  
  1017.             $newOrderToken = new UserOrderTokenEntity();
  1018.             $newOrderToken->setTokenValue($tokenBtcValue);
  1019.             $newOrderToken->setTokenAmount($tokenAmt);
  1020.             $newOrderToken->setLabel($label);
  1021.             $newOrderToken->setAddress($walletAddress);
  1022.             $newOrderToken->setAmount($amountDue);
  1023.             $newOrderToken->setNetwork('BTC');
  1024.             $newOrderToken->setUser($authService->getUser());
  1025.             $em->persist($newOrderToken);
  1026.             $em->flush();
  1027.             $notification = new NotificationEntity();
  1028.             $notification->setType('Token Order Placed');
  1029.             $notification->setMessage('Your Token Order  ' .$tokenAmt 'Has Been Received');
  1030.             $notification->setUser($authService->getUser());
  1031.             $em->persist($notification);
  1032.             $em->flush();
  1033.             return $this->redirect($this->generateUrl('dashboard_order_details' ,array('id' => $newOrderToken->getIdEncoded())),302);
  1034.         } else {
  1035.             throw new \Exception();
  1036.         }
  1037.     }
  1038.    #[Route("/order_details/{id}"name:"dashboard_order_details")]
  1039.     public function order_detailsAction(Request $request$idAuthService $authService)
  1040.     {
  1041.         
  1042.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1043.         $em $this->getDoctrine()->getManager();
  1044.         $user $authService->getUser();
  1045.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1046.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1047.         return $this->render('Dashboard/order_details.html.twig',array(
  1048.       'userNotifications' => $userNotifications,
  1049.      'userMessages' => $userMessages,
  1050.                  'page_title' => 'Order Details',
  1051.            'order' => $em->getRepository(UserOrderTokenEntity::class)->find(base64_decode($id)) 
  1052.         ));
  1053.     }
  1054.    #[Route("/settings"name:"dashboard_profile")]
  1055.     public function profileAction(Request $requestAuthService $authService)
  1056.     {
  1057.         
  1058.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1059.         $user $authService->getUser();
  1060.         $em $this->getDoctrine()->getManager();
  1061.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1062.         $receiveMsgs  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1063.         if($request->getMethod() == 'POST'){
  1064.             $pr $request->get('user');
  1065.             $errors = array();
  1066.             if(!count($errors)){
  1067.                 if(isset($pr['passowrd']) && !empty($pr['password'])){
  1068.                     $user->setPassword($authService->better_crypt(md5($registrationForm['password']), 15));
  1069.                 }
  1070.                 // if(isset($pr['2fa'])){
  1071.                 //     if(!$user->getHasEnabledTwoFa()){
  1072.                 //            $enabledTwoFa = $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'FETFAB'));
  1073.                 //            $bonus = new UserBonusTokenEntity();
  1074.                 //            $bonus->setUser($user);
  1075.                 //            $bonus->setBonus($enabledTwoFa);
  1076.                 //            $bonus->setAmount($enabledTwoFa->getBonusToken());
  1077.                 //            $em->persist($bonus);
  1078.                 //            $user->setHasEnabledTwoFa(true);
  1079.                 //            $em->flush();
  1080.                 //            $notification = new NotificationEntity();
  1081.                 //            $notification->setType('Enaled 2Fa Rewards');
  1082.                 //            $notification->setMessage('You just have received ' . $enabledTwoFa->getBonusToken() . ' Token for enabled your 2Fa.');
  1083.                 //            $notification->setUser($user);
  1084.                 //            $em->persist($notification);
  1085.                 //            $em->flush();
  1086.                        
  1087.                 //     }
  1088.                 //     $user->setTwoFa(true);
  1089.                 // } else {
  1090.                 //     $user->setTwoFa(false);
  1091.                 // }
  1092.                 $user->setTwoFa(isset($pr['2fa']) ? true false);
  1093.                 $user->setIsNewsletterSubscriber(isset($pr['isNewsLetterSubscriber']) ? true false);
  1094.                 $user->setFirstName($pr['first_name']);
  1095.                 $user->setLastName($pr['last_name']);
  1096.                 $user->setAddress1($pr['address1']);
  1097.                 $user->setCity($pr['city']);
  1098.                 $user->setZipCode($pr['zip_code']);
  1099.                 $user->setCountry($pr['country']);
  1100.                 $em->flush();
  1101.                 $this->get('session')->getFlashBag()->add('success_messages''Profile successfully updated.');
  1102.             } else {
  1103.                 foreach($errors as $error) {
  1104.                  
  1105.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  1106.                 }
  1107.             }
  1108.         }
  1109.         return $this->render('Dashboard/profile.html.twig',array(
  1110.             'user' => $user,
  1111.             'page_title' => 'Profile',
  1112.             'messages' => $receiveMsgs,
  1113.             'title' => 'Profile AiETF Token',   
  1114.             'page_header' => 'AiEFT Profile Settings'
  1115.         ));
  1116.     }
  1117.        #[Route("/security"name:"dashboard_security")]
  1118.     public function securityAction(Request $requestAuthService $authService)
  1119.     {
  1120.         
  1121.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1122.         $user $authService->getUser();
  1123.         $em $this->getDoctrine()->getManager();
  1124.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1125.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1126.         if($request->getMethod() == 'POST'){
  1127.             $pr $request->get('user');
  1128.             $errors = array();
  1129.             if($user->getPassword() !==  crypt(md5($pr['current_password']), $user->getPassword())){
  1130.                 $errors[] = 'Current Password Is Incorrect.'
  1131.             } else {
  1132.                 if(isset($pr['password']) && !empty($pr['password'])){
  1133.                     if(!$em->getRepository(UserEntity::class)->validatePassword($pr['password'])){
  1134.                       
  1135.                         $errors[] = 'Password should be at least 8 characters in length and should include at least one upper case letter, one number, and one special character.';
  1136.                     } else {
  1137.     
  1138.                         if($pr['password'] != $pr['confirm_password']){
  1139.                             $errors[] = 'Password is not match';
  1140.                         }
  1141.                     }
  1142.                 }
  1143.             }
  1144.             
  1145.             if(!count($errors)){
  1146.                 if(isset($pr['passowrd']) && !empty($pr['password'])){
  1147.                     $user->setPassword($authService->better_crypt(md5($registrationForm['password']), 15));
  1148.                 }
  1149.                 if(isset($pr['2fa'])){
  1150.                     if(!$user->getHasEnabledTwoFa()){
  1151.                            $enabledTwoFa $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'FETFAB'));
  1152.                            $bonus = new UserBonusTokenEntity();
  1153.                            $bonus->setUser($user);
  1154.                            $bonus->setBonus($enabledTwoFa);
  1155.                            $bonus->setAmount($enabledTwoFa->getBonusToken());
  1156.                            $em->persist($bonus);
  1157.                            $user->setHasEnabledTwoFa(true);
  1158.                            $em->flush();
  1159.                            $notification = new NotificationEntity();
  1160.                            $notification->setType('Enaled 2Fa Rewards');
  1161.                            $notification->setMessage('You just have received ' $enabledTwoFa->getBonusToken() . ' Token for enabled your 2Fa.');
  1162.                            $notification->setUser($user);
  1163.                            $em->persist($notification);
  1164.                            $em->flush();
  1165.                        
  1166.                     }
  1167.                     $user->setTwoFa(true);
  1168.                 } else {
  1169.                     $user->setTwoFa(false);
  1170.                 }
  1171.                 $em->flush();
  1172.                 $this->get('session')->getFlashBag()->add('success_messages''Security successfully updated.');
  1173.             } else {
  1174.                 foreach($errors as $error) {
  1175.                  
  1176.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  1177.                 }
  1178.             }
  1179.         }
  1180.         return $this->render('Dashboard/security.html.twig',array(
  1181.        'userNotifications' => $userNotifications,
  1182.      'userMessages' => $userMessages,
  1183.             'user' => $user,
  1184.             'page_title' => 'Security'
  1185.         ));
  1186.     }
  1187.    #[Route("/transaction"name:"dashboard_transaction")]
  1188.     public function transactionAction(Request $requestAuthService $authService)
  1189.     {
  1190.         
  1191.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1192.        $user $authService->getUser();
  1193.        $em $this->getDoctrine()->getManager();
  1194.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1195.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1196.     
  1197.     
  1198.         return $this->render('Dashboard/transaction.html.twig',array(
  1199.        'userNotifications' => $userNotifications,
  1200.      'userMessages' => $userMessages,
  1201.             'page_title' => 'Transaction',
  1202.             'user' =>  $user
  1203.         ));
  1204.     }
  1205.     
  1206.      #[Route("/global"name:"dashboard_global")]
  1207.     public function globalAction(Request $requestAuthService $authService)
  1208.     {
  1209.         
  1210.             $em $this->getDoctrine()->getManager();
  1211.         
  1212.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1213.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  1214.         $em $this->getDoctrine()->getManager();
  1215.         $user $authService->getUser();
  1216.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1217.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1218.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  1219.         $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  1220.         $totalUser $em->getRepository(UserEntity::class)->userCount();
  1221.        $totalOrder  $stagePurchase['stagePurchase'];
  1222.          $referralTotalEarnings $em->getRepository(UserEntity::class)->refEarnings($user);
  1223.         $userReferral1 $em->getRepository(UserEntity::class)->levelReferral($user1);
  1224.        $totalBonus $em->getRepository(UserBonusTokenEntity::class)->totalBonus();
  1225.        $totaluserslist $em->getRepository(UserEntity::class)->findAll();
  1226.        $totalreferrallist $em->getRepository(UserEntity::class)->findAll();
  1227.        
  1228.        
  1229.        
  1230.        $totalusertokens $em->getRepository(UserOrderTokenEntity::class)->findAll();
  1231.   
  1232.         return $this->render('Dashboard/global.html.twig',array(
  1233.        'userNotifications' => $userNotifications,
  1234.      'userMessages' => $userMessages,
  1235.             'user' => $user,
  1236.             'tokenDollarValue' => $tokenDollarValue,
  1237.             'pb' => $pb,
  1238.             'totalUser' => $totalUser,
  1239.             'totalOrder'=> $totalOrder $totalOrder 0,
  1240.             'tokenRaised' => $totalOrder $totalOrder $tokenDollarValue 0,
  1241.             'refTotalEarnings' => $referralTotalEarnings,
  1242.             'level1Referrals' => $userReferral1,
  1243.             'page_title' => 'Global Rankings',
  1244.             'totaluserslist' => $totaluserslist,
  1245.             'totalreferrallist' => $totalreferrallist,
  1246.             'totalusertokens' => $totalusertokens,
  1247.             'tokenDisctributed' => $totalOrder + ($totalBonus['amt'] ? $totalBonus['amt'] : 0)
  1248.     
  1249.         ));
  1250.     }
  1251.     
  1252.   
  1253.   
  1254.    #[Route("/my_reward"name:"dashboard_my_reward")]
  1255.     public function my_rewardAction(Request $requestAuthService $authService)
  1256.     {
  1257.         
  1258.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1259.                $user $authService->getUser();
  1260.                $em $this->getDoctrine()->getManager();
  1261.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1262.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1263.         return $this->render('Dashboard/my_reward.html.twig',array(
  1264.        'userNotifications' => $userNotifications,
  1265.      'userMessages' => $userMessages,
  1266.             'page_title' => 'My Rewards'
  1267.         ));
  1268.     }
  1269.        #[Route("/web5d"name:"web5_dollar")]
  1270.     public function dashboard_web5dollarAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  1271.     {
  1272.         
  1273.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1274.      $btcPrice $blockIoService->getNetworkPrice('btc');
  1275.        $ethPrice $blockIoService->getNetworkPrice('eth');
  1276.     
  1277.                $user $authService->getUser();
  1278.                $em $this->getDoctrine()->getManager();
  1279.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1280.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1281.         return $this->render('Dashboard/web5d.html.twig',array(
  1282.             
  1283.        'userNotifications' => $userNotifications,
  1284.      'userMessages' => $userMessages,
  1285.             'user' => $user,
  1286.             'tokenDollarValue' => $tokenDollarValue,
  1287.             'pb' => $pb,
  1288.             'btcPrice' => $btcPrice,
  1289.             'ethPrice' => $ethPrice,
  1290.             'totalUser' => $totalUser,
  1291.             'totalOrder'=> $totalOrder $totalOrder 0,
  1292.             'tokenRaised' => $totalOrder $totalOrder $tokenDollarValue 0,
  1293.         
  1294.             
  1295.             
  1296.             
  1297.        'userNotifications' => $userNotifications,
  1298.      'userMessages' => $userMessages,
  1299.             'page_title' => 'Web5Dollar',
  1300.             'user' => $user
  1301.         ));
  1302.     }
  1303.        #[Route("/card_payment"name:"dashboard_card_payment")]
  1304.     public function dashboard_card_paymentAction(Request $requestAuthService $authService)
  1305.     {
  1306.         
  1307.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1308.                $user $authService->getUser();
  1309.                $em $this->getDoctrine()->getManager();
  1310.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1311.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1312.         return $this->render('Dashboard/card_payment.html.twig',array(
  1313.        'userNotifications' => $userNotifications,
  1314.      'userMessages' => $userMessages,
  1315.             'page_title' => 'My Rewards',
  1316.             'user' => $user
  1317.         ));
  1318.     }
  1319.    #[Route("/my_referrals"name:"dashboard_my_referrals")]
  1320.     public function my_referralsAction(Request $requestAuthService $authService)
  1321.     {
  1322.         
  1323.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1324.         $user $authService->getUser();
  1325.         $em $this->getDoctrine()->getManager();
  1326.         $rb  $em->getRepository(BonusEntity::class)->findOneBy(array( 'code' => 'PR'));
  1327.         $rp  $em->getRepository(BonusEntity::class)->findOneBy(array( 'code' => 'Purchase - PRSU'));
  1328.         $referralTotalEarnings $em->getRepository(UserEntity::class)->refEarnings($user);
  1329.         $referrals $em->getRepository(UserEntity::class)->referralBonusByReferrentUser($user);
  1330.         $tokenDollarValue $this->getParameter('app.token_dollar_value');
  1331.         $top5Referrals $em->getRepository(ReferralEntity::class)->top5Referral();
  1332.         return $this->render('Dashboard/my_referrals.html.twig',array(
  1333.             'page_header' => 'Referral Center',
  1334.             'title' => 'My Referrals AiETF Token',   
  1335.             'user' =>  $user,
  1336.             'rb' => $rb,
  1337.             'rp' => $rp,            
  1338.             'referrals' => $referrals,
  1339.             'tokenDollarValue' =>  $tokenDollarValue,
  1340.             'top5Referrals' => $top5Referrals
  1341.             
  1342.         ));
  1343.     }
  1344.    #[Route("/referral_center"name:"dashboard_referral_center")]
  1345.     public function referral_centerAction(Request $requestAuthService $authService)
  1346.     {
  1347.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1348.         $em $this->getDoctrine()->getManager();
  1349.         $user $authService->getUser();
  1350.         $refCtr $em->getRepository(UserEntity::class)->levelOneRefCtr($user);
  1351.         $secRefCtr $em->getRepository(UserEntity::class)->levelTwoRefCtr($user);
  1352.         $thiRefCtr $em->getRepository(UserEntity::class)->levelThirdRefCtr($user);
  1353.         $refEarnings $em->getRepository(UserEntity::class)->refEarnings($user);
  1354.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1355.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1356.         return $this->render('Dashboard/referral_center.html.twig',array(
  1357.             'page_title' => 'Referral Center',
  1358.             'userNotifications' => $userNotifications,
  1359.             'userMessages' => $userMessages,
  1360.             'user' => $user,
  1361.             'refCtr' => $refCtr,
  1362.             'secRefCtr' => $secRefCtr,
  1363.             'thiRefCtr' => $thiRefCtr,
  1364.             'refEarnings' => $refEarnings
  1365.         ));
  1366.     }
  1367.        #[Route("/message"name:"dashboard_message")]
  1368.     public function messageAction(Request $requestAuthService $authService)
  1369.     {
  1370.         
  1371.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1372.         $user $authService->getUser();
  1373.         $em $this->getDoctrine()->getManager();
  1374.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1375.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1376.         $receiveMsgs  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1377.         return $this->render('Dashboard/message.html.twig',array(
  1378.        'userNotifications' => $userNotifications,
  1379.      'userMessages' => $userMessages,
  1380.             'page_title' => 'Messages',
  1381.             'user' =>  $user,
  1382.             'messages' => $receiveMsgs
  1383.         ));
  1384.     }
  1385.       #[Route("/message/view/{message_id}"name:"dashboard_message_view")]
  1386.     public function message_viewAction(Request $requestAuthService $authService$message_id)
  1387.     {
  1388.         
  1389.        
  1390.         $user $authService->getUser();
  1391.         $em $this->getDoctrine()->getManager();
  1392.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1393.         $message $em->getRepository(MessageEntity::class)->find($message_id);
  1394.         if(!$message){
  1395.             return $this->redirect($this->generateUrl('dashboard_message'), 302);
  1396.         } 
  1397.         $message->setStatus('Read');
  1398.         $em->flush();
  1399.         return $this->render('Dashboard/message_view.html.twig',array(
  1400.             'userNotifications' => $userNotifications,
  1401.             'page_title' => 'Message View',
  1402.             'user' =>  $user,
  1403.             'msg' => $message
  1404.         ));
  1405.     }
  1406.     #[Route("/message/form/{receiver_id}"name:"dashboard_message_form")]
  1407.     public function message_formAction(Request $requestAuthService $authService$receiver_id)
  1408.     {
  1409.         
  1410.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1411.         $user $authService->getUser();
  1412.         $em $this->getDoctrine()->getManager();
  1413.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1414.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1415.         $receiver $em->getRepository(UserEntity::class)->find($receiver_id);
  1416.         if(!$receiver){
  1417.             return $this->redirect($this->generateUrl('dashboard_message'), 302);
  1418.         } 
  1419.         $msg null;
  1420.         if($request->getMethod() === 'POST'){
  1421.             
  1422.             $msg $request->get('message');
  1423.             $newMsg = new MessageEntity();
  1424.             $newMsg->setUser($user);
  1425.             $newMsg->setReceiver($receiver);
  1426.             $newMsg->setMessage($msg['message']);
  1427.             $em->persist($newMsg);
  1428.             $em->flush();
  1429.             
  1430.             $newNotif = new NotificationEntity();
  1431.             $newNotif->setType(1);
  1432.             $newNotif->setMessage('You have new Message From ' $user->getFullName());
  1433.             $newNotif->setUser($receiver);
  1434.             $em->persist($newNotif);
  1435.             $em->flush();
  1436.             $this->get('session')->getFlashBag()->add('success_messages''Your message has been successfully sent to the user.');
  1437.             return $this->redirect($this->generateUrl('dashboard_message'), 302);
  1438.         }
  1439.         return $this->render('Dashboard/message_form.html.twig',array(
  1440.             'userNotifications' => $userNotifications,
  1441.             'userMessages' => $userMessages,
  1442.             'page_title' => 'Sent Message To: '.  $receiver->getFullName(),
  1443.             'user' =>  $user,
  1444.             'receiver_id' => $receiver_id
  1445.         ));
  1446.     }
  1447.    #[Route("/support_center"name:"dashboard_support_center")]
  1448.     public function support_centerAction(Request $requestAuthService $authService)
  1449.     {
  1450.         
  1451.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1452.         $em $this->getDoctrine()->getManager();
  1453.         $user $authService->getUser();
  1454.         $supportTicketCtr $em->getRepository(SupportTicketEntity::class)->supportTicketCtr($user);
  1455.         $supportTicketUnreadResCtr $em->getRepository(SupportTicketEntity::class)->supportTicketWithNewReplyCtr($user);
  1456.         if($request->getMethod() === 'POST'){
  1457.             $params $request->get('field');
  1458.             $errors = array();
  1459.             if(empty($params['msg'])){
  1460.                 $errors[] = 'Please Put Your Message.';
  1461.             }
  1462.             if(empty($params['title'])){
  1463.                 $errors[] = 'Please Put A Title To Your Question.';
  1464.             }
  1465.             if(!count($errors)){
  1466.                 $support = new SupportTicketEntity();
  1467.                 $support->setUser($user);
  1468.                 $support->setTitle($params['title']);
  1469.                 $support->setMessage($params['msg']);
  1470.                 $em->persist($support);
  1471.                 $em->flush();
  1472.                 $this->get('session')->getFlashBag()->add('success_messages''Thank You For Connecting With Us We Will Be Back To You As Soon As Possible.');
  1473.             } else {
  1474.                 foreach($errors as $error) {
  1475.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  1476.                 }
  1477.             }
  1478.         }
  1479.                $user $authService->getUser();
  1480.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1481.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1482.         return $this->render('Dashboard/support_center.html.twig',array(
  1483.             'page_title' => 'Support Center',
  1484.        'userNotifications' => $userNotifications,
  1485.      'userMessages' => $userMessages,
  1486.             'user' => $user,
  1487.             'supportTicketCtr' => $supportTicketCtr,
  1488.             'supportTicketUnreadResCtr' => $supportTicketUnreadResCtr
  1489.         ));
  1490.     }
  1491.        #[Route("/support_ticket/details/{id}"name:"dashboard_support_ticket_details")]
  1492.     public function support_ticket_detailsAction(Request $request$idAuthService $authService)
  1493.     {
  1494.         
  1495.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1496.         $em $this->getDoctrine()->getManager();
  1497.         $user $authService->getUser();
  1498.         $supportTicketCtr $em->getRepository(SupportTicketEntity::class)->supportTicketCtr($user);
  1499.         $supportTicketUnreadResCtr $em->getRepository(SupportTicketEntity::class)->supportTicketWithNewReplyCtr($user);
  1500.         $supportTicket $em->getRepository(SupportTicketEntity::class)->find(base64_decode($id));
  1501.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1502.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1503.         return $this->render('Dashboard/support_ticket_details.html.twig',array(
  1504.             'page_title' => 'Support Center',
  1505.        'userNotifications' => $userNotifications,
  1506.      'userMessages' => $userMessages,
  1507.             'user' => $user,
  1508.             'supportTicket' => $supportTicket,
  1509.             'supportTicketCtr' => $supportTicketCtr,
  1510.             'supportTicketUnreadResCtr' => $supportTicketUnreadResCtr
  1511.         ));
  1512.     }
  1513.    #[Route("/promotional_materials"name:"dashboard_promotional_materials")]
  1514.     public function support_promotional_materialsAction(Request $requestAuthService $authService)
  1515.     {
  1516.         
  1517.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1518.         $em $this->getDoctrine()->getManager();
  1519.         $user $authService->getUser();
  1520.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1521.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1522.         return $this->render('Dashboard/promotional_materials.html.twig',array(
  1523.             'page_title' => 'Promotional Materials',
  1524.        'userNotifications' => $userNotifications,
  1525.      'userMessages' => $userMessages,
  1526.             'user' => $user
  1527.         ));
  1528.     }
  1529.    #[Route("/how_to"name:"dashboard_how_to")]
  1530.     public function how_toAction(Request $request)
  1531.     {
  1532.         
  1533.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1534.         $em $this->getDoctrine()->getManager();
  1535.         $user $authService->getUser();
  1536.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1537.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1538.         return $this->render('Dashboard/how_to.html.twig',array(
  1539.             'page_title' => 'How To Articles',
  1540.        'userNotifications' => $userNotifications,
  1541.      'userMessages' => $userMessages,
  1542.             'user' => $user
  1543.         ));
  1544.     }
  1545.     
  1546.    #[Route("/support_ticket/response/form/{supportTicketId}"name:"dashboard_support_ticket_response_form")]
  1547.     public function support_ticket_response_formAction(Request $request$supportTicketIdAuthService $authService)
  1548.     {
  1549.         
  1550.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1551.         $em $this->getDoctrine()->getManager();
  1552.         $user $authService->getUser();
  1553.         $supportTicket $em->getRepository(SupportTicketEntity::class)->find($supportTicketId);
  1554.         if($request->getMethod() === 'POST'){
  1555.             $params $request->get('field');
  1556.             $errors = array();
  1557.             if(empty($params['msg'])){
  1558.                 $errors[] = 'Please Put Your Message.';
  1559.             }
  1560.             if(!count($errors)){
  1561.                 $response = new SupportTicketResponseEntity();
  1562.                 $response->setSupportTicket($supportTicket);
  1563.                 $response->setMessage($params['msg']);
  1564.                 $response->setUser($user);
  1565.                 $em->persist($response);
  1566.                 $em->flush();
  1567.                 $this->get('session')->getFlashBag()->add('success_messages''Thank You For Connecting With Us We Will Be Back To You As Soon As Possible.');
  1568.                 return  $this->redirect($this->generateUrl('dashboard_support_ticket_details', array('id' => base64_encode($supportTicketId))),302);
  1569.             } else {
  1570.                 foreach($errors as $error) {
  1571.                     $this->get('session')->getFlashBag()->add('error_messages'$error);
  1572.                 }
  1573.             }
  1574.         }
  1575.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1576.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1577.         return $this->render('Dashboard/support_ticket_response_form.html.twig',array(
  1578.             'page_title' => 'Support Center',
  1579.        'userNotifications' => $userNotifications,
  1580.      'userMessages' => $userMessages,
  1581.             'user' => $user,
  1582.             'supportTicket' => $supportTicket
  1583.         ));
  1584.     }
  1585.     #[Route("/notification"name:"dashboard_notification")]
  1586.     public function notificationAction(Request $requestAuthService $authService)
  1587.     {
  1588.         
  1589.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1590.         $user $authService->getUser();
  1591.         $em $this->getDoctrine()->getManager();
  1592.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1593.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1594.         
  1595.         return $this->render('Dashboard/notification.html.twig',array(
  1596.        'userNotifications' => $userNotifications,
  1597.      'userMessages' => $userMessages,
  1598.             'page_title' => 'My Notification'
  1599.         ));
  1600.     }
  1601.           #[Route("/notification/details/{id}"name:"dashboard_notification_details")]
  1602.     public function notification_detailsAction(Request $request$idAuthService $authService)
  1603.     {
  1604.         
  1605.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1606.         $em $this->getDoctrine()->getManager();
  1607.         $user $authService->getUser();
  1608.         $notification $em->getRepository(NotificationEntity::class)->find(base64_decode($id));
  1609.         $notification->setStatus('Read');
  1610.         $em->flush();
  1611.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1612.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1613.         return $this->render('Dashboard/notification_details.html.twig',array(
  1614.             'page_title' => 'Support Center',
  1615.        'userNotifications' => $userNotifications,
  1616.      'userMessages' => $userMessages,
  1617.             'user' => $user,
  1618.             'notification' => $notification
  1619.         ));
  1620.     }
  1621.    #[Route("/kyc_application"name:"dashboard_kyc_application")]
  1622.     public function kyc_applicationAction(Request $requestAuthService $authService)
  1623.     {
  1624.         
  1625.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1626.         $em $this->getDoctrine()->getManager();
  1627.         $user $authService->getUser();
  1628.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1629.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1630.         return $this->render('Dashboard/kyc_application.html.twig',array(
  1631.             'page_title' => 'Kyc Application',
  1632.        'userNotifications' => $userNotifications,
  1633.      'userMessages' => $userMessages,
  1634.             'user' => $user
  1635.         ));
  1636.     }
  1637.     
  1638.    #[Route("/live_chat"name:"dashboard_livechat")]
  1639.     public function livechatAction(Request $requestAuthService $authService)
  1640.     {
  1641.         return $this->render('Dashboard/livechat.html.twig' ,array(
  1642.             'page_title' => 'Kyc Application',
  1643.             'userNotifications' => $userNotifications,
  1644.           'userMessages' => $userMessages,
  1645.                  'user' => $user
  1646.         ));
  1647.     }
  1648.    #[Route("/kyc_application_form"name:"dashboard_kyc_application_form")]
  1649.     public function kyc_application_formAction(Request $requestAuthService $authService)
  1650.     {
  1651.         
  1652.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1653.         $em $this->getDoctrine()->getManager();
  1654.         $user $authService->getUser();
  1655.         if($request->getMethod() == 'POST'){
  1656.             $rp $request->request->all();
  1657.             $user->setKycStatus('For-Confirmation');
  1658.             $user->setFirstName($rp['kyc']['firstname']);
  1659.             $user->setLastName($rp['kyc']['lastname']);
  1660.             $user->setEmail($rp['kyc']['email']);
  1661.             $user->setPhoneNo($rp['kyc']['no']);
  1662.             $user->setBirthDate($rp['kyc']['birthdate']);
  1663.             $user->setNationality($rp['kyc']['nationality']);
  1664.             $user->setAddress1($rp['kyc']['address1']);
  1665.             $user->setAddress2($rp['kyc']['address2']);
  1666.             $user->setCity($rp['kyc']['city']);
  1667.             $user->setZipCode($rp['kyc']['zip_code']);
  1668.             
  1669.             // if(isset($_FILES['kyc']) && !empty($_FILES['kyc']['tmp_name']['passport'])) {
  1670.             //     $basename : $user->getId() . '-' . time() . '.' . pathinfo($_FILES['kyc']['name']['passport'], PATHINFO_EXTENSION);
  1671.             //     $uploadFile = $user->getUploadRootDir() . '/' . $baseName;
  1672.             //     if(move_uploaded_file($_FILES['kyc']['tmp_name']['passport'], $uploadFile)) {
  1673.             //         $user->setIdFile($_FILES['kyc']['name']['passport']);
  1674.             //         $user->setIdFileParse($baseName);
  1675.             //         $user->setIdType('Passport');
  1676.             //     }
  1677.             // }   
  1678.             // if(isset($_FILES['kyc']) && !empty($_FILES['kyc']['tmp_name']['national_id'])) {
  1679.             //     $basename : $user->getId() . '-' . time() . '.' . pathinfo($_FILES['kyc']['name']['national_id'], PATHINFO_EXTENSION);
  1680.             //     $uploadFile = $user->getUploadRootDir() . '/' . $baseName;
  1681.             //     if(move_uploaded_file($_FILES['kyc']['tmp_name']['national_id'], $uploadFile)) {
  1682.             //         $user->setIdFile($_FILES['kyc']['name']['national_id']);
  1683.             //         $user->setIdFileParse($baseName);
  1684.             //         $user->setIdType('National Id');
  1685.             //     }
  1686.             // }
  1687.             
  1688.             // if(isset($_FILES['kyc']) && !empty($_FILES['kyc']['tmp_name']['driver_license'])) {
  1689.             //     $basename : $user->getId() . '-' . time() . '.' . pathinfo($_FILES['kyc']['name']['driver_license'], PATHINFO_EXTENSION);
  1690.             //     $uploadFile = $user ->getUploadRootDir() . '/' . $baseName;
  1691.             //     if(move_uploaded_file($_FILES['kyc']['tmp_name']['driver_license'], $uploadFile)) {
  1692.             //         $user->setIdFile($_FILES['kyc']['name']['driver_license']);
  1693.             //         $user->setIdFileParse($baseName);
  1694.             //         $user->setIdType('Driver License');
  1695.             //     }
  1696.             // }
  1697.             $em->flush();
  1698.             return $this->redirect($this->generateUrl('dashboard_kyc_application'),302);
  1699.         }
  1700.         $userNotifications  $em->getRepository(NotificationEntity::class)->newNotifications($user);
  1701.         $userMessages  $em->getRepository(MessageEntity::class)->receiveMessages($user);
  1702.         return $this->render('Dashboard/kyc_application_form.html.twig',array(
  1703.             'page_title' => 'Kyc Application Form',
  1704.        'userNotifications' => $userNotifications,
  1705.      'userMessages' => $userMessages,
  1706.             'user' => $user
  1707.         ));
  1708.     }
  1709.     private function generateRandomString($length 6) {
  1710.        
  1711.         $characters '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1712.         $charactersLength strlen($characters);
  1713.         $randomString '';
  1714.         $em $this->getDoctrine()->getManager();
  1715.         for ($i 0$i $length$i++) {
  1716.             $randomString .= $characters[rand(0$charactersLength 1)];
  1717.         }
  1718.         $orderTokenAddressExists $em->getRepository(UserOrderTokenEntity::class)->findOneBy(array('label' => $randomString));
  1719.         if($orderTokenAddressExists){
  1720.             $this->generateRandomString();
  1721.         }
  1722.         return $randomString;
  1723.     }
  1724.     
  1725.     private function compareByTimeStamp($time1$time2)
  1726.     {
  1727.         if (strtotime($time1) < strtotime($time2))
  1728.             return 1;
  1729.         else if (strtotime($time1) > strtotime($time2)) 
  1730.             return -1;
  1731.         else
  1732.             return 0;
  1733.     }
  1734.     private function sdasdsa($em$network$blockIoService){
  1735.         
  1736.         $wallets $em->getRepository(RecycledWalletEntity::class)->findBy(['network' => $network]);
  1737.         foreach($wallets as  $wallet){
  1738.             $wallet->setStatus('Available');
  1739.             $em->flush();
  1740.             
  1741.         }
  1742.         return $em->getRepository(RecycledWalletEntity::class)->findOneBy(array('status' => 'Available''network' => $network));
  1743.     }
  1744. }