src/Controller/AjaxController.php line 197

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