src/Controller/AjaxController.php line 1650

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 Symfony\Component\Process\Process;
  13. use Symfony\Component\Process\Exception\ProcessFailedException;
  14. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  15. use App\Entity\BannedDomainEntity;
  16. use App\Entity\BannedUserEntity;
  17. use App\Entity\BonusEntity;
  18. use App\Entity\GeneratedWalletEntity;
  19. use App\Entity\MessageEntity;
  20. use App\Entity\NotificationEntity;
  21. use App\Entity\RecycledWalletEntity;
  22. use App\Entity\ReferralEntity;
  23. use App\Entity\SettingEntity;
  24. use App\Entity\SupportTicketEntity;
  25. use App\Entity\SupportTicketResponseEntity;
  26. use App\Entity\UserAdjustedTokenEntity;
  27. use App\Entity\UserBonusTokenEntity;
  28. use App\Entity\UserEntity;
  29. use App\Entity\UserOrderTokenEntity;
  30. use App\Entity\UserStakeTokenEntity;
  31. use App\Entity\VisitorEntity;
  32. use App\Entity\EmailEntity;
  33. use App\Entity\UserUsdtEntity;
  34. use App\Entity\UserMemeCoinEntity;
  35. use App\Entity\UserMemeCoinTransactionEntity;
  36. use App\Service\AuthService;
  37. use App\Service\BlockIoService;
  38. use App\Service\TOTPService;
  39. #[Route("/ajax")]
  40. class AjaxController extends AbstractController
  41. {
  42.     
  43.     private $totpService;
  44.     public function __construct(TOTPService $totpService)
  45.     {
  46.         $this->totpService $totpService;
  47.     }
  48.     #[Route("/stake_cancel"name:"ajax_stake_cancel")]
  49.     public function stakeCancelAction(Request $requestAuthService $authService)
  50.     {
  51.         $result = ['success' => false, ];
  52.         $id $request->request->get('id');
  53.         if(is_null($id)){
  54.             return new JsonResponse(['success' => false'msg' => 'Opps something went wrong please try again.']);
  55.         }
  56.         $em $this->getDoctrine()->getManager();
  57.         $stake $em->getRepository(UserStakeTokenEntity::class)->find($id);
  58.         if(!$stake){
  59.             $result['msg'] = 'Ooops something went wrong please try again later.'
  60.         } else {
  61.             $result['success'] = true;
  62.             $stake->setStatus('Cancelled');
  63.             $em->flush();
  64.             if((($stake->getInterestPercent() / 100) * ($authService->calculateDaysEarned($stake->getTokenAmount(), $stake->getStartDate(), $stake->getEndDate()) * $stake->getTokenDollarValue())) - (0.01 100)  > 0){
  65.                 //process cancelling
  66.             $usdtWallet = new UserUsdtEntity();
  67.             $usdtWallet->setUserStakeToken($stake);
  68.             $usdtWallet->setAmount((($stake->getInterestPercent() / 100) * ($authService->calculateDaysEarned($stake->getTokenAmount(), $stake->getStartDate(), $stake->getEndDate()) * $stake->getTokenDollarValue())) - (0.01 100) );
  69.             $em->persist($usdtWallet);
  70.             $em->flush();
  71.             if($stake->getType() == 3){
  72.                 $srb $em->getRepository(BonusEntity::class)->findOneBy(['code' => 'SRB']);
  73.                 if($srb){
  74.                     $usrb = new UserBonusTokenEntity();
  75.                     $usrb->setUser($stake->getUser());
  76.                     $usrb->setBonus($srb);
  77.                     $usrb->setAmount($authService->calculateDaysEarned($stake->getTokenAmount(), $stake->getStartDate(), $stake->getEndDate())  - ((0.01 100) * $stake->getTokenAmount()));
  78.                     $usrb->setUserStakeToken($stake);
  79.                     $em->persist($usrb);
  80.                     $em->flush();
  81.                 }
  82.             }
  83.             }
  84.             
  85.             
  86.             $this->get('session')->getFlashBag()->add('success_messages''Your staking is successfully cancelled.');
  87.         }
  88.         
  89.         return new JsonResponse($result);
  90.     }
  91.     #[Route("/referrer_form"name:"ajax_referrer_form")]
  92.     public function referrerFormAction(Request $requestAuthService $authService)
  93.     {
  94.         $result = ['success' => 'msg'];
  95.         $id $request->request->get('id');
  96.         
  97.         if(is_null($id)){
  98.             return new JsonResponse(['success' => false'msg' => 'Opps something went wrong please try again.']);
  99.         }
  100.         $em $this->getDoctrine()->getManager();
  101.         $user $em->getRepository(UserEntity::class)->find($id);
  102.         
  103.         $result['html'] = $this->renderView('Ajax/referrer_form.html.twig', ['user' => $user]);
  104.         return new JsonResponse($result);
  105.     }
  106.     #[Route("/referrer_form_action"name:"ajax_referrer_form_action")]
  107.     public function referrer_form_action(Request $requestAuthService $authService)
  108.     {
  109.         $result = ['success' => true'msg' => ''];
  110.         $user $authService->getUser();    
  111.         $pr $request->request->all();
  112.         $em $this->getDoctrine()->getManager();
  113.         
  114.         if(isset($pr['id'])){
  115.             $user $em->getRepository(UserEntity::class)->find($pr['id']);
  116.             $referrer $em->getRepository(UserEntity::class)->findOneBy(['email' => $pr['referrer']]);
  117.             if(!$user){
  118.                 return new JsonResponse(['success' => false 'msg' => 'Ooops something went wrong please try again later.']);
  119.             } 
  120.             if(!$referrer){
  121.                 return new JsonResponse(['success' => false 'msg' => 'Email address is not exists.']);
  122.             }
  123.             if($user->getReferral() && $user->getReferral()->getReferrer()->getEmail() != $pr['referrer'] || is_null($user->getReferral())){
  124.                 $referral = new ReferralEntity();
  125.                 $referral->setReferrer($referrer);
  126.                 $referral->setlevel(1);
  127.                 $referral->setStatus('Completed');
  128.                 $referral->setReferrentEmail($user->getEmail());
  129.                 $em->persist($referral);
  130.                 $em->flush();
  131.                 $user->setReferral($referral);
  132.                 $em->flush();
  133.                 $primarySignUpBonus $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PR'));
  134.                 if($primarySignUpBonus){
  135.                     $primaryUserBonus = new UserBonusTokenEntity();
  136.                     $primaryUserBonus->setUser($referral->getReferrer());
  137.                     $primaryUserBonus->setBonus($primarySignUpBonus);
  138.                     $primaryUserBonus->setAmount($primarySignUpBonus->getBonusToken());
  139.                     $primaryUserBonus->setReferral($referral);
  140.                     $em->persist($primaryUserBonus);
  141.                     $em->flush();
  142.                     $notification = new NotificationEntity();
  143.                     $notification->setType('Level 1 Referral');
  144.                     $notification->setMessage('You have a new Level 1 Referral');
  145.                     $notification->setUser($referral->getReferrer());
  146.                     $em->persist($notification);
  147.                     $em->flush();
  148.                 }
  149.                 $result['msg'] = 'Referral successfully updated.';
  150.             }
  151.         }
  152.         return new JsonResponse($result);
  153.     }
  154.     #[Route("/get_notification"name:"ajax_get_notification")]
  155.     public function get_notificationAction(Request $requestAuthService $authService)
  156.     {
  157.         $result = ['success' => 'msg'];
  158.         $pr $request->query->all();
  159.         $notification null;
  160.         $em $this->getDoctrine()->getManager();
  161.         switch($pr['action']){
  162.             case 'markAllAsRead':
  163.                 
  164.                 $notifications $em->getRepository(NotificationEntity::class)->findBy(['user' => $authService->getUser()]);
  165.                 foreach($notifications as $notification){
  166.                     $notification->setStatus('Read');
  167.                     $em->flush();
  168.                 }
  169.                 return new JsonResponse($result); 
  170.                 break;
  171.             case 'get':
  172.                    $notification =  $em->getRepository(NotificationEntity::class)->find($pr['id']);
  173.                 break;
  174.             case 'next':
  175.                 $qb $em->createQueryBuilder()
  176.                     ->select('n'// Select the entity
  177.                     ->from('App\Entity\NotificationEntity''n'// Use the fully qualified class name
  178.                     ->where('n.id > :id')
  179.                     ->andWhere('n.user = :userId')
  180.                     ->setParameters([
  181.                         'id' => $pr['id'],
  182.                         'userId' => $authService->getUser()->getId()
  183.                     ])
  184.                     ->setMaxResults(1// Limit the result to one entity
  185.                     ->getQuery();
  186.             
  187.                 $notification $qb->getOneOrNullResult();
  188.                 if(!$notification){
  189.                     $qb $em->createQueryBuilder()
  190.                     ->select('n'// Select the entity
  191.                     ->from('App\Entity\NotificationEntity''n'// Use the fully qualified class name
  192.                     ->where('n.user = :userId')
  193.                     ->setParameters([
  194.                         'userId' => $authService->getUser()->getId()
  195.                     ])
  196.                     ->orderBy('n.createdAt''ASC')
  197.                     ->setMaxResults(1// Limit the result to one entity
  198.                     ->getQuery();
  199.                 
  200.                     $notification $qb->getOneOrNullResult();
  201.                 }
  202.                 break;
  203.             case 'previous':
  204.                 $qb $em->createQueryBuilder()
  205.                     ->select('n'// Select the entity
  206.                     ->from('App\Entity\NotificationEntity''n'// Use the fully qualified class name
  207.                     ->where('n.id < :id')
  208.                     ->andWhere('n.user = :userId')
  209.                     ->setParameters([
  210.                         'id' => $pr['id'],
  211.                         'userId' => $authService->getUser()->getId()
  212.                     ])
  213.                 ->orderBy('n.createdAt''DESC')
  214.                 ->setMaxResults(1// Limit the result to one entity
  215.                 ->getQuery();
  216.             
  217.                 $notification $qb->getOneOrNullResult();
  218.                 if(!$notification){
  219.                     $qb $em->createQueryBuilder()
  220.                     ->select('n'// Select the entity
  221.                     ->from('App\Entity\NotificationEntity''n'// Use the fully qualified class name
  222.                     ->where('n.user = :userId')
  223.                     ->setParameters([
  224.                         'userId' => $authService->getUser()->getId()
  225.                     ])
  226.                     ->orderBy('n.createdAt''DESC')
  227.                     ->setMaxResults(1// Limit the result to one entity
  228.                     ->getQuery();
  229.                 
  230.                     $notification $qb->getOneOrNullResult();
  231.                 }
  232.                 break;        
  233.         }
  234.         
  235.         if($notification){
  236.             $notification->setStatus('Read');
  237.             $em->flush();
  238.         }
  239.         
  240.         $result['html'] = $this->renderView('Ajax/notification_details.html.twig',['notification' => $notification ]);
  241.         return new JsonResponse($result);
  242.     }
  243.     #[Route("/two_fa_generate"name:"ajax_two_fa_generate")]
  244.     public function two_fa_generate(Request $requestAuthService $authService)
  245.     {
  246.         $result = ['success' => true'msg' => ''];
  247.         $user $authService->getUser();    
  248.         $secret $this->totpService->getSecret();
  249.         $provisioningUri $this->totpService->getProvisioningUri($user->getEmail());
  250.         $qr $this->totpService->generateQRCode($provisioningUri);
  251.         $result['html'] = $this->renderView('Ajax/two_fa_generate.html.twig', ['qr' => $qr]);        
  252.         return new JsonResponse($result);
  253.     }
  254.     #[Route("/two_fa_verify"name:"ajax_two_fa_verify")]
  255.     public function two_fa_verify(Request $requestAuthService $authService)
  256.     {
  257.         $result = ['success' => true'msg' => ''];
  258.         $user $authService->getUser();    
  259.         $pr $request->request->all();
  260.         $result['isValid']  = $pr['otp'] == $this->totpService->verifyOTP() ?  true false
  261.            
  262.         return new JsonResponse($result);
  263.     }
  264.     #[Route("/save_visitor"name:"ajax_save_visitor")]
  265.      
  266.     public function save_visitor(Request $requestAuthService $authService)
  267.     {
  268.         
  269.         $result = array();
  270.        
  271.         $ip $_SERVER['REMOTE_ADDR'];
  272.         
  273.         
  274.         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  275.             $ip $_SERVER['HTTP_CLIENT_IP'];
  276.         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  277.             $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  278.         }
  279.         $em $this->getDoctrine()->getManager();
  280.         $visitor $em->getRepository(VisitorEntity::class)->findOneBy(['ipAddress' => $ip]);
  281.         if(is_null($visitor)){
  282.             $visitor = new VisitorEntity();
  283.             $visitor->setIpAddress($ip);
  284.             $visitor->setCount(1);
  285.             $em->persist($visitor);
  286.         } else {
  287.             $visitor->setCount($visitor->getCount() + 1);
  288.         }
  289.         $em->flush();
  290.         $result['success'] = true;
  291.         return new JsonResponse($result);
  292.     }
  293.     #[Route("/visitor_statistics"name:"ajax_visitor_statistics")]
  294.      
  295.     public function visitor_statistics(Request $requestAuthService $authService)
  296.     {
  297.         $result = array();
  298.         
  299.         $em $this->getDoctrine()->getManager();
  300.         $days = [];
  301.         $stats = [];
  302.         $visitorStats $em->getRepository(VisitorEntity::class)->statistics(7); 
  303.         foreach($visitorStats as $stat){
  304.             
  305.             $stats[$stat['vDate']]['newVisitor'] = $stat['newVisitor'];
  306.             $stats[$stat['vDate']]['oldVisitor'] = $stat['oldVisitor'];
  307.             $stats[$stat['vDate']]['date'] = $stat['vDate'];
  308.         }
  309.         usort($stats, function($a1$a2) {
  310.             $v1 strtotime($a1['date']);
  311.             $v2 strtotime($a2['date']);
  312.             return $v1 $v2
  313.          });
  314.     
  315.         $result['success'] = true;
  316.         return new JsonResponse($stats);
  317.     }
  318.     #[Route("/get_users_and_orders_stat"name:"ajax_get_users_and_orders_stat")]
  319.      
  320.     public function get_user_and_order_stat(Request $requestAuthService $authService)
  321.     {
  322.         $result = array();
  323.         
  324.         $em $this->getDoctrine()->getManager();
  325.         $days = [];
  326.         $stats = [];
  327.         $userStats $em->getRepository(UserEntity::class)->userStatistics(7); 
  328.         $orderStats $em->getRepository(UserOrderTokenEntity::class)->orderStatistics();
  329.         foreach($userStats as $stat){
  330.             
  331.             $stats[$stat['regDate']]['regCount'] = $stat['regCount'];
  332.             $stats[$stat['regDate']]['date'] = $stat['regDate'];
  333.         }
  334.         
  335.         foreach ($orderStats as $k => $stat) {
  336.             
  337.             if(isset($stats[$stat['orderDay']])){
  338.                 $stats[$stat['orderDay']]['orderCount'] = $stat['orderAmt'];
  339.             } else {
  340.                $stats[$stat['orderDay']] = ['orderCount' => $stat['orderAmt']];
  341.                $stats[$stat['orderDay']]['date'] =  $stat['orderDay'];
  342.             }
  343.         }
  344.         //Sort array
  345.         usort($stats, function($a1$a2) {
  346.             $v1 strtotime($a1['date']);
  347.             $v2 strtotime($a2['date']);
  348.             return $v1 $v2
  349.          });
  350.     
  351.         $result['success'] = true;
  352.         return new JsonResponse($stats);
  353.     }
  354.     
  355.     #[Route("/get_users_stat"name:"ajax_get_users_stat")]
  356.      
  357.     public function get_user_stat(Request $requestAuthService $authService)
  358.     {
  359.         $result = array();
  360.         
  361.         $em $this->getDoctrine()->getManager();
  362.         $days = [];
  363.         $stats = [];
  364.         $userStats $em->getRepository(UserEntity::class)->userStatistics(7); 
  365.         foreach($userStats as $stat){
  366.             array_push($days$stat['regDate']);
  367.             array_push($stats$stat['regCount']);
  368.         }
  369.         $result['days'] = $days;
  370.         $result['stats'] = $stats;
  371.         $result['success'] = true;
  372.         return new JsonResponse($result);
  373.     }
  374.     #[Route("/get_orders_stat"name:"ajax_get_orders_stat")]
  375.     public function get_orders_stat(Request $requestAuthService $authService)
  376.     {
  377.         $result = array();
  378.         
  379.         $em $this->getDoctrine()->getManager();
  380.         $days = [];
  381.         $stats = [];
  382.         $orderStats $em->getRepository(UserOrderTokenEntity::class)->orderStatistics();
  383.         foreach($orderStats as $stat){
  384.             array_push($days$stat['orderDate']);
  385.             array_push($stats$stat['orderCount']);
  386.         }
  387.         $result['days'] = $days;
  388.         $result['stats'] = $stats;
  389.         $result['success'] = true;
  390.         return new JsonResponse($result);
  391.     }
  392.      #[Route("/get_active_users_ctr"name:"ajax_get_active_users_ctr")]
  393.     public function get_active_users_ctr(Request $requestAuthService $authService)
  394.     {
  395.         $result = array();
  396.         
  397.         $em $this->getDoctrine()->getManager();
  398.         $result['ctr'] = $em->getRepository(UserEntity::class)->userCount();
  399.         $result['success'] = true;
  400.         return new JsonResponse($result);
  401.     }
  402.     #[Route("/get_coin_value"name:"ajax_get_coin_value")]
  403.     public function get_coin_value(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  404.     {
  405.         $result = array();
  406.         
  407.         $result['success'] = true;
  408.         $result['price'] = $blockIoService->getNetworkPrice($request->get('pm'));
  409.         return new JsonResponse($result);
  410.     }
  411.     #[Route("/stage_info"name:"ajax_stage_info")]
  412.     public function stage_info_Action(Request $requestAuthService $authService)
  413.     {
  414.         $data = array();
  415.         $em $this->getDoctrine()->getManager();
  416.         $stagePurchase $em->getRepository(UserOrderTokenEntity::class)->stagePurchase();
  417.         $stageBonus $em->getRepository(UserBonusTokenEntity::class)->totalDistribution();
  418.         $data['stagePurchase'] = $stagePurchase['stagePurchase'] + $stageBonus;
  419.         $data['stageToken'] =  888000000000;
  420.         $data['remainingStageToken'] =  $data['stageToken'] - $stagePurchase['stagePurchase'] + $stageBonus;
  421.         return new JsonResponse($data);
  422.     }
  423.     #[Route("/profits"name:"ajax_user_profits")]  
  424.     public function userProfits_Action(Request $requestAuthService $authService)
  425.     {
  426.         $em $this->getDoctrine()->getManager();
  427.         $profits = ['bonus' => $authService->getUser()->getTotalBonus(), 'purchase' => $authService->getUser()->getTotalPurchase() ];
  428.     
  429.         return new JsonResponse($profits);
  430.     }
  431.       #[Route("/graph_data"name:"ajax_graph_data")]
  432.     public function graph_data_Action(Request $requestAuthService $authService)
  433.     {
  434.         $data = array();
  435.         $em $this->getDoctrine()->getManager();
  436.         $purchaseStats $em->getRepository(UserOrderTokenEntity::class)->orderStatistics();
  437.         $bonusStats $em->getRepository(UserBonusTokenEntity::class)->statistics(7);
  438.         $stats = array();
  439.        
  440.         /*Get the purchase stats*/
  441.         foreach ($purchaseStats as $k => $purchaseStat) {
  442.             $stats[$purchaseStat['orderDate']]['purchaseTokenAmt'] = $purchaseStat['orderAmt'];
  443.             $stats[$purchaseStat['orderDate']]['day'] = $purchaseStat['orderDay'];
  444.             $stats[$purchaseStat['orderDate']]['date'] = $purchaseStat['orderDate'];
  445.         }
  446.         /*Get the bonus stats*/
  447.         foreach ($bonusStats as $k => $bonusStat) {
  448.             
  449.             if(isset($stats[$bonusStat['bonusDate']])){
  450.                 $stats[$bonusStat['bonusDate']]['bonusTokenAmt'] = $bonusStat['totalBonusToken'];
  451.             } else {
  452.                $stats[$bonusStat['bonusDate']] = ['bonusTokenAmt' => $bonusStat['totalBonusToken']];
  453.                $stats[$bonusStat['bonusDate']]['day'] =  $bonusStat['bonusDay'];
  454.                $stats[$bonusStat['bonusDate']]['date'] =  $bonusStat['bonusDate'];
  455.             }
  456.         }
  457.         //Sort array
  458.         usort($stats, function($a1$a2) {
  459.             $v1 strtotime($a1['date']);
  460.             $v2 strtotime($a2['date']);
  461.             return $v1 $v2
  462.          });
  463.     
  464.         return new JsonResponse(array_reverse($stats));
  465.     }
  466.     #[Route("/email_list"name:"ajax_email_list")]
  467.     public function email_Action(Request $requestAuthService $authService)
  468.     {
  469.         $get $request->query->all();
  470.         $result = array(
  471.             "draw" => intval($get['draw']),
  472.             "recordsTotal" => 0,
  473.             "recordsFiltered" => 0,
  474.             "data" => array()
  475.         );
  476.         $authService =$authService;
  477.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  478.         if($authService->getUser()->getType() == 'Super Admin') {
  479.             $data $this->getDoctrine()->getManager()->getRepository(EmailEntity::class)->ajax_list($get);
  480.            
  481.             foreach($data['results'] as $row) {
  482.                 $url $this->generateUrl('manage_email_form', array(
  483.                     'id' => base64_encode($row['id']),
  484.                     'action' => 'u'
  485.                 ));
  486.                 $values = array(
  487.                     $row['subject'],
  488.                     $row['message'],
  489.                     '',
  490.                     "<a class='action-button-style' href='$url'>Update</a>"
  491.                 );
  492.                 $result['data'][] = $values;
  493.             }
  494.             $result['recordsTotal'] = $data['total'];
  495.             $result['recordsFiltered'] = $data['total'];
  496.         }
  497.         return new JsonResponse($result);
  498.     }
  499.     
  500.     #[Route("/user_adjusted_token_list"name:"ajax_user_adjusted_token_list")]
  501.     public function user_adjusted_tokenList_Action(Request $requestAuthService $authService)
  502.     {
  503.         $get $request->query->all();
  504.         $result = array(
  505.             "draw" => intval($get['draw']),
  506.             "recordsTotal" => 0,
  507.             "recordsFiltered" => 0,
  508.             "data" => array()
  509.         );
  510.         $authService =$authService;
  511.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  512.         if($authService->getUser()->getType() == 'Super Admin') {
  513.             $data $this->getDoctrine()->getManager()->getRepository(UserAdjustedTokenEntity::class)->ajax_list($get);
  514.             foreach($data['results'] as $row) {
  515.                 $values = array(
  516.                     $row['name'],
  517.                     $row['createdDate'],
  518.                     $row['amt']
  519.                 );
  520.                 $result['data'][] = $values;
  521.             }
  522.             $result['recordsTotal'] = $data['total'];
  523.             $result['recordsFiltered'] = $data['total'];
  524.         }
  525.         return new JsonResponse($result);
  526.     }
  527.     #[Route("/user_remove/{id}"name:"ajax_remove_user")]
  528.     public function remove_Action(Request $requestAuthService $authService$id)
  529.     {
  530.         $result = ['success' => true'msg' => ''];
  531.         $em $this->getDoctrine()->getManager();
  532.         $user $em->getRepository(UserEntity::class)->find(base64_decode($id));
  533.         if(!$user){
  534.             $result = ['success' => false'msg' => 'Oooops something went wrong please try again later.'];
  535.         } else {
  536.             $user->setStatus('Banned');
  537.             $em->flush();
  538.             $projectDir $this->getParameter('kernel.project_dir');
  539.             // $process = Process::fromShellCommandline('php '. $projectDir. '/bin/console app:banned-user-command ' . base64_encode($emailForm['id'])  ); //window
  540.              $process Process::fromShellCommandline('php '$projectDir'/bin/console app:banned-user-command ' $user->getId() . '  > /dev/null 2>&1 &' ); //linux
  541.              $process->start();
  542.               //window
  543.              // $process->waitUntil(function ($type, $output): bool {
  544.              //     return $output === 'Ready. Waiting for commands...';
  545.              // });
  546.             $result['success'] = true;
  547.             $result['msg'] = 'User successfully remove';
  548.         }
  549.         return new JsonResponse($result);
  550.     }   
  551.     #[Route("/user_list"name:"ajax_user_list")]
  552.     public function userList_Action(Request $requestAuthService $authService)
  553.     {
  554.         $get $request->query->all();
  555.         $result = array(
  556.             "draw" => intval($get['draw']),
  557.             "recordsTotal" => 0,
  558.             "recordsFiltered" => 0,
  559.             "data" => array()
  560.         );
  561.         $authService =$authService;
  562.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  563.         if($authService->getUser()->getType() == 'Super Admin') {
  564.             $data $this->getDoctrine()->getManager()->getRepository(UserEntity::class)->ajax_list($get);
  565.             foreach($data['results'] as $row) {
  566.                 $url $this->generateUrl('manage_user_referrals', array(
  567.                     'id' => $row['id']
  568.                 ));
  569.                 $url2 $this->generateUrl('manage_user_transactions', array(
  570.                     'id' => $row['id']
  571.                 ));
  572.                 $removeUser $this->generateUrl('ajax_remove_user', array(
  573.                     'id' => base64_encode($row['id'])
  574.                 ));
  575.                 $userRefAction "<a class='action-button-style' href='$url'>".($row['userTotalReferral'] ? $row['userTotalReferral'] : 0)."</a>";
  576.                 $userTransactionAction "<a class='action-button-style' href='$url2'>".($row['userTotalToken'] ? $row['userTotalToken'] : 0)."</a>";
  577.                 $values = array(
  578.                     $row['id'],
  579.                     $row['email'],
  580.                     $row['name'],
  581.                     $row['joinDate'],
  582.                     '<a href="javascript:void(0);" class="href-modal"  data-action="referrer" data-id="'.$row["id"].'">' .  ($row['referrer']  ? $row['referrer']   : "Set Referrer") . '</a>',
  583.                     $row['status'],
  584.                     $userTransactionAction,
  585.                     $userRefAction,
  586.                     '<a href="javascript:void(0);" class="href-remove-user"  data-url="'.$removeUser.'"> Banned</a>',
  587.                 );
  588.                 $result['data'][] = $values;
  589.             }
  590.             $result['recordsTotal'] = $data['total'];
  591.             $result['recordsFiltered'] = $data['total'];
  592.         }
  593.         return new JsonResponse($result);
  594.     }
  595.     #[Route("/recycled_wallet_list"name:"ajax_recycled_wallet_list")]
  596.     public function recycledWalletList_Action(Request $requestAuthService $authService)
  597.     {
  598.         $get $request->query->all();
  599.         $result = array(
  600.             "draw" => intval($get['draw']),
  601.             "recordsTotal" => 0,
  602.             "recordsFiltered" => 0,
  603.             "data" => array()
  604.         );
  605.         $authService =$authService;
  606.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  607.         if($authService->getUser()->getType() == 'Super Admin') {
  608.             $data $this->getDoctrine()->getManager()->getRepository(RecycledWalletEntity::class)->ajax_list($get);
  609.             foreach($data['results'] as $row) {
  610.                 $values = array(
  611.                     $row['network'],
  612.                     $row['address'],
  613.                     $row['status']
  614.                 );
  615.                 $result['data'][] = $values;
  616.             }
  617.             $result['recordsTotal'] = $data['total'];
  618.             $result['recordsFiltered'] = $data['total'];
  619.         }
  620.         return new JsonResponse($result);
  621.     }
  622.     #[Route("/order_list"name:"ajax_order_list")]
  623.     public function orderList_Action(Request $requestAuthService $authService)
  624.     {
  625.         $get $request->query->all();
  626.         $result = array(
  627.             "draw" => intval($get['draw']),
  628.             "recordsTotal" => 0,
  629.             "recordsFiltered" => 0,
  630.             "data" => array()
  631.         );
  632.         $authService =$authService;
  633.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  634.         if($authService->getUser()->getType() == 'Super Admin') {
  635.             $data $this->getDoctrine()->getManager()->getRepository(UserOrderTokenEntity::class)->ajax_list($get);
  636.             $tokenDollarValue $this->getParameter('app.token_dollar_value');
  637.             foreach($data['results'] as $row) {
  638.                 $action '';
  639.                 $url $this->generateUrl('manage_confirm_transaction', array(
  640.                     'id' => base64_encode($row['id'])
  641.                 ));
  642.                 $adjustTransacrionUrl $this->generateUrl('manage_transaction_adjust', array(
  643.                     'id' => base64_encode($row['id'])
  644.                 ));
  645.                 $cancelUrl $this->generateUrl('manage_cancel_transaction', array(
  646.                     'id' => base64_encode($row['id'])
  647.                 ));
  648.                 $action .= "<a class='action-button-style text-primary' href='$url'>Confirm</a>" ;
  649.                 $action .= "<a class='action-button-style text-primary' href='$cancelUrl'>| Cancel</a>" ;
  650.                 $action .= "<a class='action-button-style text-primary' href='$adjustTransacrionUrl'> | Adjust</a>" ;
  651.                 $values = array(
  652.                     $row['id'],
  653.                     $row['member'],
  654.                     $row['email'],
  655.                     $row['transactionDate'],
  656.                     '<a class="text-primary" href="https://chain.so/address/' $row['network'] . '/' $row['address'].'" target="_blank">'$row['address'].'</a>',
  657.                     $row['currency'],
  658.                     number_format(($row['tokenAmt']  * $tokenDollarValue) , 2'.',','),
  659.                     $row['amount'],
  660.                     empty($row['amountReceived']) ? '0.00' $row['amountReceived'],
  661.                     $row['status'],
  662.                     $row['status'] == 'Pending' $action ''
  663.                 );
  664.                 $result['data'][] = $values;
  665.             }
  666.             $result['recordsTotal'] = $data['total'];
  667.             $result['recordsFiltered'] = $data['total'];
  668.         }
  669.         return new JsonResponse($result);
  670.     }
  671.     #[Route("/bonus_list"name:"ajax_bonus_list")]
  672.     public function bonusList_Action(Request $requestAuthService $authService)
  673.     {
  674.         $get $request->query->all();
  675.         $result = array(
  676.             "draw" => intval($get['draw']),
  677.             "recordsTotal" => 0,
  678.             "recordsFiltered" => 0,
  679.             "data" => array()
  680.         );
  681.         $authService =$authService;
  682.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  683.         if($authService->getUser()->getType() == 'Super Admin') {
  684.             $data $this->getDoctrine()->getManager()->getRepository(BonusEntity::class)->ajax_list($get);
  685.             foreach($data['results'] as $row) {
  686.                 $action '';
  687.                 $url $this->generateUrl('manage_bonus_form', array(
  688.                     'id' => base64_encode($row['id']),
  689.                     'action' => 'u'
  690.                 ));
  691.                 $action .= "<a class='action-button-style' href='$url'>Update</a>" ;
  692.                 $values = array(
  693.                     $row['code'],
  694.                     $row['description'],
  695.                     $row['percent'],
  696.                     $row['bonus_token'],
  697.                     $action
  698.                 );
  699.                 $result['data'][] = $values;
  700.             }
  701.             $result['recordsTotal'] = $data['total'];
  702.             $result['recordsFiltered'] = $data['total'];
  703.         }
  704.         return new JsonResponse($result);
  705.     }
  706.       #[Route("/setting_list"name:"ajax_setting_list")]
  707.     public function settingList_Action(Request $requestAuthService $authService)
  708.     {
  709.         $get $request->query->all();
  710.         $result = array(
  711.             "draw" => intval($get['draw']),
  712.             "recordsTotal" => 0,
  713.             "recordsFiltered" => 0,
  714.             "data" => array()
  715.         );
  716.         $authService =$authService;
  717.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  718.         if($authService->getUser()->getType() == 'Super Admin') {
  719.             $data $this->getDoctrine()->getManager()->getRepository(SettingEntity::class)->ajax_list($get);
  720.             foreach($data['results'] as $row) {
  721.                 $action '';
  722.                 $url $this->generateUrl('manage_setting_form', array(
  723.                     'id' => base64_encode($row['id']),
  724.                     'action' => 'u'
  725.                 ));
  726.                 $action .= "<a class='action-button-style' href='$url'>Update</a>" ;
  727.                 $values = array(
  728.                     $row['description'],
  729.                     $row['settingValue'],
  730.                     $action
  731.                 );
  732.                 $result['data'][] = $values;
  733.             }
  734.             $result['recordsTotal'] = $data['total'];
  735.             $result['recordsFiltered'] = $data['total'];
  736.         }
  737.         return new JsonResponse($result);
  738.     }
  739.       #[Route("/banned_domain_list"name:"ajax_banned_domain_list")]
  740.     public function banned_domain_listAction(Request $requestAuthService $authService)
  741.     {
  742.         $get $request->query->all();
  743.         $result = array(
  744.             "draw" => intval($get['draw']),
  745.             "recordsTotal" => 0,
  746.             "recordsFiltered" => 0,
  747.             "data" => array()
  748.         );
  749.         $authService =$authService;
  750.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  751.         if($authService->getUser()->getType() == 'Super Admin') {
  752.             $data $this->getDoctrine()->getManager()->getRepository(BannedDomainEntity::class)->ajax_list($get);
  753.             foreach($data['results'] as $row) {
  754.                 $action '';
  755.                 $url $this->generateUrl('manage_banned_domain_form', array(
  756.                     'id' => base64_encode($row['id']),
  757.                     'action' => 'u'
  758.                 ));
  759.                 $action .= "<a class='action-button-style' href='$url'>Update</a>" ;
  760.                 $values = array(
  761.                     $row['description'],
  762.                     $action
  763.                 );
  764.                 $result['data'][] = $values;
  765.             }
  766.             $result['recordsTotal'] = $data['total'];
  767.             $result['recordsFiltered'] = $data['total'];
  768.         }
  769.         return new JsonResponse($result);
  770.     }
  771.     #[Route("/user_order_list"name:"ajax_user_order_list")]
  772.     public function user_order_listAction(Request $requestAuthService $authService)
  773.     {
  774.         $get $request->query->all();
  775.         $result = array(
  776.             "draw" => intval($get['draw']),
  777.             "recordsTotal" => 0,
  778.             "recordsFiltered" => 0,
  779.             "data" => array()
  780.         );
  781.         $authService =$authService;
  782.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  783.         $data $this->getDoctrine()->getManager()->getRepository(UserOrderTokenEntity::class)->userOrderList($get$authService->getUser());
  784.         foreach($data['results'] as $row) {
  785.             $url $this->generateUrl('dashboard_order_details', array(
  786.                     'id' => base64_encode($row['id'])
  787.             ));
  788.        $transid base64_encode( ($row['id']) );
  789.           $GLN "GLN" 
  790.        $action "<a class='action-button-style text-primary' href='$url'>".substr($row['address'],0,5) . (strlen($row['address']) > '...' '') ."</a>" ;
  791.         
  792.         
  793.             $values = array(
  794.                 "<a class='orderList' data-transaction='".$row['id']."'>".sprintf($row['id'])."</a>" ,
  795.                 $row['created_at'],
  796.                 $row['token_value'] . $row['network'],
  797.                 number_format($row['tokenAmt'], 0'' ',') . ".$GLN."
  798.                                    "<a class='orderList' data-transaction='".$row['status']."'>".sprintf($row['status'])."</a>" ,
  799.                   "<a href='https://gleancoin.com/purchase/details/".$transid."' class='btn btn-primary'>View Details</a>",
  800.              "<a class='orderList' href='javascript:void(0);' data-transaction='".$row['id']."'><em class='ti ti-more-alt'></em></a>" 
  801.             
  802.             );
  803.             $result['data'][] = $values;
  804.         }
  805.         $result['recordsTotal'] = $data['total'];
  806.         $result['recordsFiltered'] = $data['total'];
  807.         
  808.         return new JsonResponse($result);
  809.     }
  810.     #[Route("/user_reward_list"name:"ajax_user_reward_list")]
  811.     public function user_reward_listAction(Request $requestAuthService $authService)
  812.     {
  813.         $get $request->query->all();
  814.         $result = array(
  815.             "draw" => intval($get['draw']),
  816.             "recordsTotal" => 0,
  817.             "recordsFiltered" => 0,
  818.             "data" => array()
  819.         );
  820.         $authService =$authService;
  821.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  822.         $data $this->getDoctrine()->getManager()->getRepository(UserBonusTokenEntity::class)->userBonusList($get$authService->getUser());
  823.         foreach($data['results'] as $row) {
  824.             $values = array(
  825.                 $row['bonus'],
  826.                 $row['amt'],
  827.             );
  828.             $result['data'][] = $values;
  829.         }
  830.         $result['recordsTotal'] = $data['total'];
  831.         $result['recordsFiltered'] = $data['total'];
  832.         
  833.         return new JsonResponse($result);
  834.     }
  835.     #[Route("/user_referral_list"name:"ajax_user_referral_list")]
  836.     public function user_referral_listAction(Request $requestAuthService $authService)
  837.     {
  838.         $get $request->query->all();
  839.         $result = array(
  840.             "draw" => intval($get['draw']),
  841.             "recordsTotal" => 0,
  842.             "recordsFiltered" => 0,
  843.             "data" => array()
  844.         );
  845.         $authService =$authService;
  846.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  847.         $data $this->getDoctrine()->getManager()->getRepository(UserBonusTokenEntity::class)->getReferralByLevel($get$authService->getUser());
  848.        foreach($data['results'] as $row) {
  849.             $values = array(
  850.                 $row['name'],
  851.                 $row['amount'],
  852.                 $row['email'],
  853.                 $row['createdDate'],
  854.                 $row['status'],
  855.             );
  856.             $result['data'][] = $values;
  857.         }
  858.         $result['recordsTotal'] = $data['total'];
  859.         $result['recordsFiltered'] = $data['total'];
  860.         
  861.         return new JsonResponse($result);
  862.     }
  863.      #[Route("/user_support_ticket_list"name:"ajax_user_support_ticket_list")]
  864.     public function user_support_ticket_listAction(Request $requestAuthService $authService)
  865.     {
  866.         $get $request->query->all();
  867.         $result = array(
  868.             "draw" => intval($get['draw']),
  869.             "recordsTotal" => 0,
  870.             "recordsFiltered" => 0,
  871.             "data" => array()
  872.         );
  873.         $authService =$authService;
  874.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  875.         $data $this->getDoctrine()->getManager()->getRepository(SupportTicketEntity::class)->ajaxListByUser($get$authService->getUser());
  876.         foreach($data['results'] as $row) {
  877.             $url $this->generateUrl('dashboard_support_ticket_details', array(
  878.                     'id' => base64_encode($row['id'])
  879.             ));
  880.             $action "<a class='action-button-style' href='$url'>Review Ticket</a>" ;
  881.             if($authService->getUser()->getType() == 'Super Admin'){
  882.                 
  883.                 $values = array(
  884.                     $row['id'],
  885.                     $row['name'],
  886.                     $row['email'],
  887.                     $row['title'],
  888.                     $row['message'],
  889.                     $action
  890.                 );
  891.             } else {
  892.                 
  893.                 $values = array(
  894.                     $row['id'],
  895.                     $row['title'],
  896.                     $row['message'],
  897.                     $action
  898.                 );   
  899.             }
  900.             $result['data'][] = $values;
  901.         }
  902.         $result['recordsTotal'] = $data['total'];
  903.         $result['recordsFiltered'] = $data['total'];
  904.         
  905.         return new JsonResponse($result);
  906.     }
  907.     #[Route("/user_notification_lists"name:"ajax_user_notification_lists")]
  908.     public function user_notification_listsAction(Request $requestAuthService $authService)
  909.     {
  910.         $result = array("success" => true);
  911.         if(!$authService->isLoggedIn()){
  912.              
  913.             $result['success'] = false;
  914.             $result['msg'] = 'Opps something went wrong please try again later.';
  915.         } else {
  916.             $em $this->getDoctrine()->getManager();
  917.             $notifications $em->getRepository(NotificationEntity::class)->findBy(['user' => $authService->getUser()->getId()], ['createdAt' => 'DESC']);
  918.             $newNotications $em->getRepository(NotificationEntity::class)->findBy(['user' => $authService->getUser()->getId(), 'status' => 'New']);
  919.             $result['html'] = $this->renderView('Ajax/user_notification_lists.html.twig', ['notifications' => $notifications]);
  920.             $result['ctr'] = count($newNotications);
  921.         }
  922.         
  923.         return new JsonResponse($result);
  924.     }
  925.     #[Route("/user_notification_list"name:"ajax_user_notification_list")]
  926.     public function user_notification_listAction(Request $requestAuthService $authService)
  927.     {
  928.         $get $request->query->all();
  929.         $result = array(
  930.             "draw" => intval($get['draw']),
  931.             "recordsTotal" => 0,
  932.             "recordsFiltered" => 0,
  933.             "data" => array()
  934.         );
  935.         $authService =$authService;
  936.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  937.         $data $this->getDoctrine()->getManager()->getRepository(NotificationEntity::class)->ajaxListByUser($get$authService->getUser());
  938.                
  939.         foreach($data['results'] as $row) {
  940.             $url $this->generateUrl('dashboard_notification_details', array(
  941.                     'id' => base64_encode($row['id'])
  942.             ));
  943.             $action "<a class='action-button-style' href='$url' " . ( $row['status'] != 'New' 'style="color:#858796;"' '') ." >View</a>" ;
  944.             $values = array(
  945.                 $row['type'],
  946.                 $row['message'],
  947.                 $action
  948.             );
  949.             $result['data'][] = $values;
  950.         }
  951.         $result['recordsTotal'] = $data['total'];
  952.         $result['recordsFiltered'] = $data['total'];
  953.         
  954.         return new JsonResponse($result);
  955.     }
  956.       #[Route("/banned_user_list"name:"ajax_banned_user_list")]
  957.     public function banned_user_listAction(Request $requestAuthService $authService)
  958.     {
  959.         $get $request->query->all();
  960.         $result = array(
  961.             "draw" => intval($get['draw']),
  962.             "recordsTotal" => 0,
  963.             "recordsFiltered" => 0,
  964.             "data" => array()
  965.         );
  966.         $authService =$authService;
  967.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  968.         if($authService->getUser()->getType() == 'Super Admin') {
  969.             $data $this->getDoctrine()->getManager()->getRepository(BannedUserEntity::class)->ajax_list($get);
  970.             foreach($data['results'] as $row) {
  971.                 
  972.                 $values = array(
  973.                     $row['name'],
  974.                     $row['email']
  975.                 );
  976.                 $result['data'][] = $values;
  977.             }
  978.             $result['recordsTotal'] = $data['total'];
  979.             $result['recordsFiltered'] = $data['total'];
  980.         }
  981.         return new JsonResponse($result);
  982.     }
  983.     #[Route("/user_autocomplete"name:"user_autocomplete")]
  984.     public function user_autocomplete_suggestions(Request $requestAuthService $authService) {
  985.         $q $request->get('query');
  986.         $result = array(
  987.             'query' => 'descriptions',
  988.             'suggestions' => $this->getDoctrine()->getManager()->getRepository(UserEntity::class)->autocomplete_suggestions($q)
  989.         );
  990.         return new JsonResponse($result);
  991.     }
  992.     #[Route("/transaction_form"name:"ajax_transaction_form")]
  993.     public function transaction_formAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  994.     {
  995.         $result = array();
  996.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  997.         if($request->getMethod() == 'POST'){
  998.             $formData $request->request->get('formData');
  999.             $errors '';
  1000.             if($formData['tokenAmt'] < 1500){
  1001.                 $errors .= 'The minimum amount per transaction is 1,500.' '\n';
  1002.             }
  1003.             if(!in_array(strtoupper($formData['network']), ['BTC' 'LTC''DOGE''ETH'])){
  1004.                 $errors .= 'Opps something went wrong please try again.' '\n';
  1005.             }
  1006.             if(!empty($errors)){
  1007.              
  1008.                 $result['success'] = false;
  1009.                 $result['msg'] = $errors;
  1010.             } else {
  1011.                 $em $this->getDoctrine()->getManager();
  1012.                 $label time() . '-' $this->generateRandomString();
  1013.                 
  1014.                 $walletAddress 'ltc1qmzvkz3j2f75u3wa8lyfghs43xffc83cjvprmtc';
  1015.       
  1016.                 // if($formData['network'] == 'eth'){
  1017.                     
  1018.                 //     $walletAddress = '0x361d637c55752d95339b5b179c534adb2ae542f8';
  1019.                 // } else {
  1020.                 //     $generatedWallet = $blockIoService->generateWallet($formData['network'], $label);
  1021.                 //     $walletAddress = $generatedWallet->data->address;
  1022.                 // }
  1023.                 $networkPriceInUsd $blockIoService->getNetworkPrice($formData['network']);
  1024.                 $tokenUsdValue $this->getParameter('app.token_dollar_value');
  1025.                 $tokenNetworkValue = (float) $tokenUsdValue / (float) $networkPriceInUsd;
  1026.     
  1027.                 $newOrderToken = new UserOrderTokenEntity();
  1028.                 $newOrderToken->setTokenValue($tokenNetworkValue);
  1029.                 $newOrderToken->setTokenAmount($formData['tokenAmt']);
  1030.                 $newOrderToken->setLabel($label);
  1031.                 $newOrderToken->setAddress($walletAddress);
  1032.                 $newOrderToken->setAmount($tokenNetworkValue * (float) $formData['tokenAmt']);
  1033.                 $newOrderToken->setNetwork(strtoupper($formData['network']));
  1034.                 $newOrderToken->setUser($authService->getUser());
  1035.                 $em->persist($newOrderToken);
  1036.                 $em->flush();
  1037.     
  1038.                 $notification = new NotificationEntity();
  1039.                 $notification->setType('Token Order Placed');
  1040.                 $notification->setMessage('Your Token Order  ' .$formData['tokenAmt'] . 'Has Been Received');
  1041.                 $notification->setUser($authService->getUser());
  1042.                 $em->persist($notification);
  1043.                 $em->flush();
  1044.     
  1045.                 $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  1046.     
  1047.                 $result['success'] = true;
  1048.                 $result['token_amount'] = $newOrderToken->getTokenAmount();
  1049.                 $result['bonus_token'] =  $newOrderToken->getTokenAmount() * ( $pb->getBonusPercent() / 100);
  1050.                 $result['view'] = $this->renderView('Ajax/order_preview.html.twig',array(
  1051.                     'network' => $newOrderToken->getNetwork(),
  1052.                     'amount' => $newOrderToken->getAmount(),
  1053.                     'label' => str_replace'-'''$newOrderToken->getLabel()),
  1054.                     'token_amount' => $newOrderToken->getTokenAmount(),
  1055.                     'address' => $newOrderToken->getAddress(),
  1056.                     'bonus_token' => $newOrderToken->getTokenAmount() * ( $pb->getBonusPercent() / 100)
  1057.                 ));
  1058.                 $result['view2'] = $this->renderView('Ajax/order_preview2.html.twig',array(
  1059.                     'network' => $newOrderToken->getNetwork(),
  1060.                     'amount' => $newOrderToken->getAmount(),
  1061.                     'label' => str_replace'-'''$newOrderToken->getLabel()),
  1062.                     'token_amount' => $newOrderToken->getTokenAmount(),
  1063.                     'address' => $newOrderToken->getAddress(),
  1064.                     'bonus_token' => $newOrderToken->getTokenAmount() * ( $pb->getBonusPercent() / 100)
  1065.                 ));
  1066.             }
  1067.         }
  1068.         return new JsonResponse($result);
  1069.     }
  1070.     #[Route("/transaction_details"name:"ajax_transaction_details")]
  1071.     public function transaction_detailsAction(Request $requestAuthService $authService)
  1072.     {
  1073.         $result = array(
  1074.             'success' => true
  1075.         );
  1076.         $authService =$authService;
  1077.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1078.         if($request->getMethod() == 'POST'){
  1079.             $id $request->request->get('id');
  1080.             $em $this->getDoctrine()->getManager();
  1081.             $order $em->getRepository(UserOrderTokenEntity::class)->find($id);
  1082.             $pb $em->getRepository(BonusEntity::class)->findOneBy(array('code' => 'PB'));
  1083.             
  1084.             if(!$order){
  1085.              
  1086.                 $result['success'] = false;
  1087.                 $result['msg'] = 'Something went wrong please try again.';
  1088.             } else {
  1089.                 $result['success'] = true;
  1090.                 $result['view'] = $this->renderView('Ajax/order_preview2.html.twig',array(
  1091.                     'network' => $order->getNetwork(),
  1092.                     'amount' => $order->getAmount(),
  1093.                     'label' => str_replace'-'''$order->getLabel()),
  1094.                     'token_amount' => $order->getTokenAmount(),
  1095.                     'address' => $order->getAddress(),
  1096.                     'bonus_token' => $order->getTokenAmount() * ( $pb->getBonusPercent() / 100),
  1097.                     'status' => $order->getStatus()
  1098.                 ));
  1099.             }      
  1100.         }
  1101.         return new JsonResponse($result);
  1102.     }
  1103.     private function generateRandomString($length 6) {
  1104.        
  1105.         $characters '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1106.         $charactersLength strlen($characters);
  1107.         $randomString '';
  1108.         $em $this->getDoctrine()->getManager();
  1109.         for ($i 0$i $length$i++) {
  1110.             $randomString .= $characters[rand(0$charactersLength 1)];
  1111.         }
  1112.         $orderTokenAddressExists $em->getRepository(UserOrderTokenEntity::class)->findOneBy(array('label' => $randomString));
  1113.         if($orderTokenAddressExists){
  1114.             $this->generateRandomString();
  1115.         }
  1116.         return $randomString;
  1117.     }
  1118.       #[Route("/kyc_application"name:"ajax_kyc_application")]
  1119.     public function kyc_applicationAction(Request $requestAuthService $authService)
  1120.     {
  1121.         $get $request->query->all();
  1122.         $result = array(
  1123.             "draw" => intval($get['draw']),
  1124.             "recordsTotal" => 0,
  1125.             "recordsFiltered" => 0,
  1126.             "data" => array()
  1127.         );
  1128.         $authService =$authService;
  1129.         if(!$authService->isLoggedIn()) return $authService->redirectToLogin();
  1130.         if($authService->getUser()->getType() == 'Super Admin') {
  1131.             $data $this->getDoctrine()->getManager()->getRepository(UserEntity::class)->kyc_application($get);
  1132.             foreach($data['results'] as $row) {
  1133.                 
  1134.                 $values = array(
  1135.                     $row['name'],
  1136.                     $row['birthDate'],
  1137.                     $row['address'],
  1138.                     "<a href='/uploads/file/".urlencode($row['id'])."'>".$row['id']."</a>",
  1139.                     "<a href='/manage/kyc_application_verification?status=confirm&id=".$row['uid']."'>Confirm</a> | <a href='/ajax/kyc_application_verification?status=reject&id=".$row['uid']."'>Reject</a>"                    
  1140.                 );
  1141.                 $result['data'][] = $values;
  1142.             }
  1143.             $result['recordsTotal'] = $data['total'];
  1144.             $result['recordsFiltered'] = $data['total'];
  1145.         }
  1146.         return new JsonResponse($result);
  1147.     }
  1148.           #[Route("/upload_profile_photo"name:"ajax_upload_profile_photo")]
  1149.     public function upload_profile_photoAction(Request $requestAuthService $authService)
  1150.     {
  1151.         $result = array(
  1152.             'success' => false
  1153.         );
  1154.        
  1155.         
  1156.         if(!$authService->isLoggedIn()){
  1157.             
  1158.             $result['msg'] = 'Unauthorized access please contact Administrator';
  1159.         } else {
  1160.         
  1161.             $user $authService->getUser();
  1162.             if($request->getMethod() == 'POST'){
  1163.                 if(isset($_FILES['profile-img']) && !empty($_FILES['profile-img']['tmp_name'])) {
  1164.     
  1165.                     $basename $user->getId() . '-' time() . '.' pathinfo($_FILES['profile-img']['name'], PATHINFO_EXTENSION);
  1166.                     $uploadFile $user->getUploadRootDir() . '/' $baseName;
  1167.     
  1168.                     if(move_uploaded_file($_FILES['profile-img']['tmp_name'], $uploadFile)) {
  1169.                         
  1170.                         $em $this->getDoctrine()->getManager();
  1171.                         $user->setIdFile($_FILES['profile-img']['name']);
  1172.                         $user->setIdFileParse($baseName);
  1173.                         $em->flush();
  1174.                     }
  1175.                     $result['success'] = true;
  1176.                 }
  1177.            }  else {
  1178.     
  1179.                 $result['msg'] = 'Oppps something went wrong please try again';
  1180.            }
  1181.         }
  1182.        
  1183.      
  1184.         return new JsonResponse($result);
  1185.     }
  1186.     #[Route("/country_holder_list"name:"ajax_country_holder_list")]
  1187.     public function countryHolderListAction(Request $requestAuthService $authServiceBlockIoService $blockIoService)
  1188.     {
  1189.         $result = array();
  1190.         if(!$authService->isLoggedIn()){
  1191.             $result['success'] = false;
  1192.             $result['msg'] =  'Unauthorize access please call a system administrator.';
  1193.             return new JsonResponse($result);  
  1194.         } 
  1195.         
  1196.         $em =  $this->getDoctrine()->getManager();
  1197.         $countryHolders $em->getRepository(UserEntity::class)->countryHolders();
  1198.         $result['success'] = true;
  1199.         $result['html'] = $this->renderView('Ajax/country_holder_list.html.twig',array(
  1200.             'tokenSupply' => $this->getParameter('app.token_supply'),
  1201.             'countryHolders' =>     $countryHolders                                                                                                  
  1202.         ));
  1203.         
  1204.         return new JsonResponse($result);
  1205.     }
  1206.     #[Route("/user_wallet_transaction_list"name:"ajax_user_wallet_transaction_list")]
  1207.     public function user_wallet_transaction_listAction(Request $requestAuthService $authServiceSessionInterface $session)
  1208.     {
  1209.         $get $request->query->all();
  1210.         $result = array(
  1211.            'success' => true
  1212.         );
  1213.       $userData $session->get('userData');
  1214.       $data $request->query->all();
  1215.         if(!$authService->isLoggedIn()){
  1216.             return new JsonResponse([
  1217.                 'success' => false,
  1218.                 'message' => 'Unauthorized access please contact a System Administrator.'
  1219.             ]);
  1220.         }
  1221.         $em =  $this->getDoctrine()->getManager();
  1222.         $transactions $em->getRepository(UserEntity::class)->walletTransaction($userData$data);
  1223.         $result['html'] = $this->renderView('Ajax/user_wallet_transaction_list.html.twig', [
  1224.             'transactions' => $transactions
  1225.         ]);
  1226.         
  1227.         return new JsonResponse($result);
  1228.     }
  1229.      #[Route("/dashbaord_user_purchase_meme_coin"name:"ajax_dashbaord_user_purchase_meme_coin")]
  1230.     public function dashbaord_user_purchase_meme_coinAction(Request $requestAuthService $authServiceSessionInterface $session)
  1231.     {
  1232.         $get $request->query->all();
  1233.         $result = array(
  1234.            'success' => true
  1235.         );
  1236.       $userData $session->get('userData');
  1237.       $data $request->query->all();
  1238.         if(!$authService->isLoggedIn()){
  1239.             return new JsonResponse([
  1240.                 'success' => false,
  1241.                 'message' => 'Unauthorized access please contact a System Administrator.'
  1242.             ]);
  1243.         }
  1244.         $em =  $this->getDoctrine()->getManager();
  1245.         if(isset($data['id'])){
  1246.             $memeCoin $em->getRepository(UserMemeCoinEntity::class)->find($data['id']);
  1247.             if(!$memeCoin){
  1248.                 return new JsonResponse([
  1249.                     'success' => false,
  1250.                     'message' => 'Invalid MemeCoin access please contact a System Administrator.'
  1251.                 ]);
  1252.             }
  1253.             $result['html'] = $this->renderView('Ajax/dashboard_user_purchase_meme_coin.html.twig', [
  1254.                 'memeCoin' => $memeCoin
  1255.             ]);
  1256.         }
  1257.         
  1258.         return new JsonResponse($result);
  1259.     }
  1260.        #[Route("/dashboard_user_purchase_meme_coin_confirm"name:"ajax_dashbaord_user_purchase_meme_confirm")]
  1261.     public function dashbaord_user_purchase_meme_confirmAction(Request $requestAuthService $authServiceSessionInterface $session)
  1262.     {
  1263.         $result = array(
  1264.            'success' => true
  1265.         );
  1266.         $user $authService->getUser();    
  1267.       $userData $session->get('userData');
  1268.       $data $request->request->all();
  1269.         if(!$authService->isLoggedIn()){
  1270.             return new JsonResponse([
  1271.                 'success' => false,
  1272.                 'message' => 'Unauthorized access please contact a System Administrator.'
  1273.             ]);
  1274.         }
  1275.         $em =  $this->getDoctrine()->getManager();
  1276.         if(isset($data['id'])){
  1277.             $memeCoin $em->getRepository(UserMemeCoinEntity::class)->find($data['id']);
  1278.             if(!$memeCoin){
  1279.                 return new JsonResponse([
  1280.                     'success' => false,
  1281.                     'message' => 'Invalid MemeCoin access please contact a System Administrator.'
  1282.                 ]);
  1283.             }
  1284.             if(floatval($data['amount']) > $memeCoin->remainingSupply()){
  1285.                   return new JsonResponse([
  1286.                     'success' => false,
  1287.                     'message' => 'Insufficient MemeCoin Supply'
  1288.                 ]);
  1289.             }
  1290.             if((floatval($data['amount']) * floatval($data['basePrice']))  > $user->totalBalance()){
  1291.                   return new JsonResponse([
  1292.                     'success' => false,
  1293.                     'message' => 'Insufficient Xrp Balance'
  1294.                 ]);
  1295.             }
  1296.             $userMemeCoinTransactions = new UserMemeCoinTransactionEntity();
  1297.             $userMemeCoinTransactions->setBuyer($user);
  1298.             $userMemeCoinTransactions->setSeller($memeCoin->getUser());
  1299.             $userMemeCoinTransactions->setAmount(floatval($data['amount']));
  1300.             $userMemeCoinTransactions->setBasePrice(floatval($data['basePrice']));
  1301.             $userMemeCoinTransactions->setSystemFee((floatval($data['amount']) * floatval($data['basePrice'])) * 0.05);
  1302.             $userMemeCoinTransactions->setUserMemeCoin($memeCoin);
  1303.             $em->persist($userMemeCoinTransactions);
  1304.             $em->flush();
  1305.             $result['html'] = $this->renderView('Ajax/dashboard_user_purchase_meme_coin_confirm.html.twig', [
  1306.                 'userMemeCoinTransactions' => $userMemeCoinTransactions
  1307.             ]);
  1308.         }
  1309.         
  1310.         return new JsonResponse($result);
  1311.     }
  1312.     
  1313.     
  1314.     
  1315. }