src/ApplicationBundle/Modules/Buddybee/Controller/BuddybeePublicController.php line 2540

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Modules\Buddybee\Controller;
  3. use ApplicationBundle\Constants\BuddybeeConstant;
  4. use ApplicationBundle\Constants\GeneralConstant;
  5. use ApplicationBundle\Controller\GenericController;
  6. use ApplicationBundle\Modules\Authentication\Constants\UserConstants; use ApplicationBundle\Modules\Api\Constants\ApiConstants;
  7. use ApplicationBundle\Modules\Buddybee\Buddybee;
  8. use ApplicationBundle\Modules\System\MiscActions;
  9. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  10. use CompanyGroupBundle\Entity\EntityCoursePlanHistory;
  11. use CompanyGroupBundle\Entity\EntityCreateTopic;
  12. use CompanyGroupBundle\Entity\EntityInvoice;
  13. use CompanyGroupBundle\Entity\EntityMeetingSession;
  14. use Ps\PdfBundle\Annotation\Pdf;
  15. use Spatie\CalendarLinks\Link;
  16. use Symfony\Component\HttpFoundation\JsonResponse;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Response;
  19. use Symfony\Component\Routing\Generator\UrlGenerator;
  20. //use Symfony\Bundle\FrameworkBundle\Console\Application;
  21. //use Symfony\Component\Console\Input\ArrayInput;
  22. //use Symfony\Component\Console\Output\NullOutput;
  23. //use DateTime;
  24. class BuddybeePublicController extends GenericController
  25. {
  26.     public function CheckBeeCodeAction(Request $request$beeCode '')
  27.     {
  28.         $em $this->getDoctrine()->getManager('company_group');
  29.         if ($beeCode == '')
  30.             $beeCode $request->query->get('beeCode''');
  31.         if ($beeCode == '')
  32.             $beeCode $request->request->get('beeCode''');
  33.         return new JsonResponse(Buddybee::ProcessBeeCard($em$beeCode));
  34.     }
  35.     public function RefreshEntityMeetingSessionScheduledNotificationAction(Request $request$beeCode '')
  36.     {
  37.         $em $this->getDoctrine()->getManager('company_group');
  38.         Buddybee::refreshEntityMeetingSessionScheduledNotification($em$request->query->get('meetingId'0),
  39.             $this->container->getParameter('notification_enabled'),
  40.             $this->container->getParameter('notification_server'));
  41.         return new JsonResponse(array(
  42.             'success' => true
  43.         ));
  44.     }
  45.     public function CheckPromoCodeAction(Request $request$code '')
  46.     {
  47.         $em $this->getDoctrine()->getManager('company_group');
  48.         if ($code == '')
  49.             $code $request->request->get('code'$request->query->get('code'''));
  50.         $silent $request->request->get('silent'$request->query->get('silent'1));
  51.         $promoCode $em->getRepository('CompanyGroupBundle\\Entity\\PromoCode')
  52.             ->findOneBy(
  53.                 array(
  54.                     'code' => $code
  55.                 )
  56.             );
  57.         $data = array(
  58.             'success' => false,
  59.             'message' => 'Invalid Code'
  60.         );
  61.         $session $request->getSession();
  62.         $claimData MiscActions::ClaimPromoCode($em,
  63.             [
  64.                 'claimFlag' => $request->query->get('claimFlag'$request->request->get('claimFlag'0)),
  65.                 'promoCode' => $code,
  66.                 'orderValue' => $request->query->get('orderValue'$request->request->get('orderValue'0)),
  67.                 'orderCoin' => $request->query->get('orderCoin'$request->request->get('orderCoin'0)),
  68.                 'currency' => $request->query->get('currency'$request->request->get('currency''eur')),
  69.                 'userId' => $request->query->get('userId'$request->request->get('userId'0)),
  70.             ]);
  71.         if ($claimData['data']['success'] == false) {
  72.             if ($session->get('codeHash''') == $code)
  73.                 $session->set('codeHash''');
  74.         }
  75.         $claimData['data']['silent'] = $silent;
  76. //        if ($promoCode) {
  77. //
  78. //            $data = array(
  79. //                'success' => true,
  80. //                'message' => '',
  81. //                'id' => $promoCode->getId(),
  82. //                'code' => $promoCode->getCode(),
  83. //                'promoType' => $promoCode->getPromoType(),
  84. //                'promoValue' => $promoCode->getPromoValue(),
  85. //                'maxDiscountAmount' => $promoCode->getMaxDiscountAmount(),
  86. //                'maxCoinAddition' => $promoCode->getMaxCoinAddition(),
  87. //                'minAmountForApplication' => $promoCode->getMinAmountForApplication(),
  88. //                'minCoinForApplication' => $promoCode->getMinCoinForApplication(),
  89. //                'nextApplicationEachCoinCount' => $promoCode->getNextApplicationEachCoinCount(),
  90. //                'maxUseCount' => $promoCode->getMaxUseCount(),
  91. //                'maxUseCountPerUser' => $promoCode->getMaxUseCountPerUser(),
  92. //                'useCountBalance' => $promoCode->getUseCountBalance(),
  93. //                'useCountBalanceUser' => 0,
  94. //
  95. //                'startsAtTs' => $promoCode->getStartsAtTs(),
  96. //                'expiresAtTs' => $promoCode->getExpiresAtTs(),
  97. //                'perpetual' => $promoCode->getPerpetual(),
  98. //
  99. //
  100. //            );
  101. //
  102. //        }
  103. //        return new JsonResponse($data);
  104.         return new JsonResponse($claimData['data']);
  105.     }
  106.     public function PrintBeeCardAction(Request $request$id)
  107.     {
  108.         $em $this->getDoctrine()->getManager('company_group');
  109. //        $dt = Inventory::GetDrDetails($em, $id, $item_id);
  110.         $repeatCount 1;
  111.         $assignProductId '';
  112.         $queryCondition = [];
  113.         $cardList = [];
  114.         $printFlag $request->request->get('printFlag'$request->query->get('printFlag'0));
  115.         $sendViaMailFlag $request->get('sendViaMailFlag'1);;
  116.         $receiverEmail $request->get('receiverEmail''mozibul.yasser@ourhoneybee.eu');
  117.         $cardCount $request->get('cardCount'1);
  118.         $cardAmount $request->get('cardAmount'0);
  119.         $coinCount $request->get('coinCount'100);
  120.         $currency $request->get('currency''eur');
  121.         $customQrOnly $request->get('customQr'0);
  122.         $customQrUrl $request->get('customQrUrl''');
  123.         $customQrPath $request->get('customQrPath''');
  124.         $customQrDataIndex $request->get('customQrDataIndex''data');
  125.         $customQrDataJson $request->get('customQrDataJson''');
  126.         if ($customQrOnly == 1) {
  127.             return $this->render('@Buddybee/pages/print_bee_card.html.twig',
  128. //        else return $this->render('ApplicationBundle:email/user:buddybee_registration.html.twig',
  129. //        else return $this->render('ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig',
  130.                 array(
  131.                     'page_title' => 'Bee Codes',
  132. //                'export'=>'pdf,print',
  133.                     'data' => [],
  134.                     'customQrUrl' => $customQrUrl,
  135.                     'customQrPath' => $customQrPath,
  136.                     'customQrOnly' => $customQrOnly,
  137.                     'customQrDataJson' => $customQrDataJson,
  138.                     'customQrDataIndex' => $customQrDataIndex,
  139.                     'productList' => [],
  140.                     'repeatCount' => [],
  141. //                'item_id' => $item_id,
  142.                     'labelData' => [],
  143.                     'cardList' => [],
  144.                     'approval_data' => [],
  145.                     'document_log' => [],
  146.                     'document_mark_image' => [],
  147.                     'red' => 0
  148.                 )
  149.             );
  150.         }
  151.         $createIfNeeded $request->get('createIfNeeded'0);
  152.         $rePrintFlag $request->request->has('rePrintFlag') ? $request->request->get('rePrintFlag') : 0;
  153.         $cardIds json_decode($request->get('cardIds'''), true);
  154.         $markAsPrinted $request->request->get('markAsPrinted'$request->query->get('markAsPrinted'0));
  155.         $returnJson $request->request->has('returnJson') ? $request->request->get('returnJson') : 0;
  156.         $physicalOnly $request->get('physicalOnly'0);
  157.         $retailerId $request->get('retailerId'0);
  158.         if (!empty($cardIds))
  159.             $queryCondition['id'] = $cardIds;
  160.         if ($physicalOnly == 1)
  161.             $queryCondition['isForHardCopy'] = 1;
  162.         if ($rePrintFlag == 0)
  163.             $queryCondition['printed'] = [0null];
  164.         $queryCondition['retailerId'] = $retailerId;
  165.         if ($cardAmount != 0$queryCondition['amount'] = $cardAmount;
  166.         if ($coinCount != 0$queryCondition['coinCount'] = $coinCount;
  167.         if ($returnJson == 1)
  168.             $printFlag 0;
  169.         $cards $em->getRepository('CompanyGroupBundle\\Entity\\BeeCode')
  170.             ->findBy(
  171.                 $queryCondition, [], $cardCount
  172.             );
  173.         foreach ($cards as $card) {
  174.             $cardList[] = array(
  175.                 'id' => $card->getId(),
  176.                 'printed' => $card->getPrinted(),
  177.                 'amount' => $card->getAmount(),
  178.                 'coinCount' => $card->getCoinCount(),
  179.                 'pin' => $card->getPin(),
  180.                 'serial' => $card->getSerial(),
  181.             );
  182.         }
  183.         if (($cardCount) > count($cards)) {
  184.             if ($createIfNeeded == 1) {
  185.                 $generateOptions = [
  186.                     'amount' => isset($cpd['amount']) ? $cpd['amount'] : 0,
  187.                     'coinCount' => $coinCount,
  188.                     'cardCount' => (($cardCount) - count($cards)),
  189.                     'serial' => '_AUTO_',
  190.                     'pin' => '_AUTO_',
  191.                     'useCount' => 1,
  192.                     'isForHardCopy' => $physicalOnly == 0,
  193.                     'retailerId' => $retailerId,
  194.                 ];
  195.                 $generatedData MiscActions::GenerateBeeCode($em$generateOptions);
  196.                 foreach ($generatedData['data'] as $cardDt) {
  197.                     $card $cardDt['cardEntityObj'];
  198.                     $cardList[] = array(
  199.                         'id' => $card->getId(),
  200.                         'printed' => $card->getPrinted(),
  201.                         'amount' => $card->getAmount(),
  202.                         'coinCount' => $card->getCoinCount(),
  203.                         'pin' => $card->getPin(),
  204.                         'serial' => $card->getSerial(),
  205.                     );
  206.                 }
  207.             }
  208.         }
  209.         $companyId $this->getLoggedUserCompanyId($request);
  210.         if ($request->query->has('repeatCount'))
  211.             $repeatCount $request->query->get('repeatCount');
  212.         if ($request->request->has('print_selection_type'))
  213.             $print_selection_type $request->request->get('print_selection_type');
  214.         if ($request->request->has('print_selection_string'))
  215.             $print_selection_string $request->request->get('print_selection_string');
  216.         if ($request->request->has('productByCodeIds'))
  217.             $productByCodeIds json_decode($request->request->get('productByCodeIds'), true);
  218.         if ($request->request->has('formatId'))
  219.             $assignLabelFormatId $request->request->get('formatId');
  220.         if ($printFlag == 0) {
  221.         }
  222.         if ($sendViaMailFlag == 1) {
  223.             if (GeneralConstant::EMAIL_ENABLED == 1) {
  224.                 $bodyHtml '';
  225.                 $bodyTemplate 'ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig';
  226.                 $bodyData = array(
  227.                     'cardList' => $cardList,
  228. //                        'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
  229. //                        'email' => $userName,
  230. //                        'password' => $newApplicant->getPassword(),
  231.                 );
  232.                 $attachments = [];
  233.                 $forwardToMailAddress $receiverEmail;
  234. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  235.                 $new_mail $this->get('mail_module');
  236.                 $new_mail->sendMyMail(array(
  237.                     'senderHash' => '_CUSTOM_',
  238.                     //                        'senderHash'=>'_CUSTOM_',
  239.                     'forwardToMailAddress' => $forwardToMailAddress,
  240.                     'subject' => 'Digital Bee Card Delivery',
  241. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  242.                     'attachments' => $attachments,
  243.                     'toAddress' => $forwardToMailAddress,
  244.                     'fromAddress' => 'delivery@buddybee.eu',
  245.                     'userName' => 'delivery@buddybee.eu',
  246.                     'password' => 'Honeybee@0112',
  247.                     'smtpServer' => 'smtp.hostinger.com',
  248.                     'smtpPort' => 465,
  249. //                        'encryptionMethod' => 'tls',
  250.                     'encryptionMethod' => 'ssl',
  251. //                            'emailBody' => $bodyHtml,
  252.                     'mailTemplate' => $bodyTemplate,
  253.                     'templateData' => $bodyData,
  254. //                        'embedCompanyImage' => 1,
  255. //                        'companyId' => $companyId,
  256. //                        'companyImagePath' => $company_data->getImage()
  257.                 ));
  258.                 foreach ($cards as $card) {
  259.                     $card->setPrinted(1);
  260.                 }
  261.                 $em->flush();
  262.             }
  263.             return new JsonResponse(
  264.                 array(
  265.                     'success' => true
  266.                 )
  267.             );
  268.         }
  269.         $productByCodeData = [];
  270.         $productList = [];
  271.         $productIds = [];
  272.         $labelData = [
  273.             'formatId' => 0
  274.         ];
  275.         $formatId 0;
  276. //        $company_data = Company::getCompanyData($em, 1);
  277.         $document_mark = array(
  278.             'original' => '/images/Original-Stamp-PNG-Picture.png',
  279.             'copy' => ''
  280.         );
  281.         $dt $productByCodeData;
  282.         if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
  283.             $html $this->renderView('@Inventory/pages/print/print_label.html.twig',
  284.                 array(
  285.                     //full array here
  286.                     'pdf' => true,
  287.                     'page_title' => 'Device Labels',
  288.                     'export' => 'print',
  289.                     'repeatCount' => $repeatCount,
  290.                     'labelData' => $labelData,
  291. //                    'brandList' => Inventory::GetBrandList($em, $companyId),
  292. //                    'item_id' => $item_id,
  293.                     'data' => $dt,
  294.                     'productList' => $productList,
  295.                     'approval_data' => [],
  296.                     'document_log' => [],
  297.                     'document_mark_image' => $document_mark['original'],
  298.                     'red' => 0
  299.                 )
  300.             );
  301.             $pdf_response $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
  302. //                'orientation' => 'landscape',
  303.                 'enable-javascript' => true,
  304. //                'javascript-delay' => 1000,
  305.                 'no-stop-slow-scripts' => false,
  306.                 'no-background' => false,
  307.                 'lowquality' => false,
  308.                 'encoding' => 'utf-8',
  309. //            'images' => true,
  310. //            'cookie' => array(),
  311.                 'dpi' => 300,
  312.                 'image-dpi' => 300,
  313. //                'enable-external-links' => true,
  314. //                'enable-internal-links' => true
  315.             ));
  316.             return new Response(
  317.                 $pdf_response,
  318.                 200,
  319.                 array(
  320.                     'Content-Type' => 'application/pdf',
  321.                     'Content-Disposition' => 'attachment; filename="device_labels.pdf"'
  322.                 )
  323.             );
  324.         }
  325.         $url $this->generateUrl(
  326.             'print_label'
  327.         );
  328.         if ($markAsPrinted == 1) {
  329.             foreach ($cards as $card) {
  330.                 $card->setPrinted(1);
  331.             }
  332.             $em->flush();
  333.         }
  334.         if ($returnJson == && $printFlag == 0) {
  335. //                    $dr = $em->getRepository('ApplicationBundle\\Entity\\DeliveryReceipt')->findBy(
  336. //                        array(
  337. //                            'salesOrderId' => $orderId, ///material
  338. //
  339. //                        )
  340. //                    );
  341.             return new JsonResponse(array(
  342.                 'success' => true,
  343.                 'cardList' => $cardList
  344. //                        'documentHash' => $order->getDocumentHash(),
  345. //                'documentId' => $receiptId,
  346. //                'documentIdPadded' => str_pad($receiptId, 8, '0', STR_PAD_LEFT),
  347. //
  348. //                'viewUrl' => $url . "/" . $receiptId,
  349.             ));
  350.         } else return $this->render('@Buddybee/pages/print_bee_card.html.twig',
  351. //        else return $this->render('ApplicationBundle:email/user:buddybee_registration.html.twig',
  352. //        else return $this->render('ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig',
  353.             array(
  354.                 'page_title' => 'Bee Codes',
  355. //                'export'=>'pdf,print',
  356.                 'data' => $dt,
  357.                 'customQrOnly' => $customQrOnly,
  358.                 'productList' => $productList,
  359.                 'repeatCount' => $repeatCount,
  360. //                'item_id' => $item_id,
  361.                 'labelData' => $labelData,
  362.                 'cardList' => $cardList,
  363.                 'approval_data' => [],
  364.                 'document_log' => [],
  365.                 'document_mark_image' => $document_mark['original'],
  366.                 'red' => 0
  367.             )
  368.         );
  369.     }
  370.     public function MakePaymentOfEntityInvoiceAction(Request $request$encData '')
  371.     {
  372.         $em $this->getDoctrine()->getManager('company_group');
  373.         $em_goc $em;
  374.         $invoiceId 0;
  375.         $autoRedirect 1;
  376.         $redirectUrl '';
  377.         $meetingId 0;
  378.         $triggerMiddlePage 0;
  379.         $session $request->getSession();
  380.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  381.         $refundSuccess 0;
  382.         $errorMsg '';
  383.         $errorCode '';
  384.         if ($encData != '') {
  385.             $invoiceId $encData;
  386.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  387.             if (isset($encryptedData['invoiceId']))
  388.                 $invoiceId $encryptedData['invoiceId'];
  389.             if (isset($encryptedData['triggerMiddlePage']))
  390.                 $triggerMiddlePage $encryptedData['triggerMiddlePage'];
  391.             if (isset($encryptedData['autoRedirect']))
  392.                 $autoRedirect $encryptedData['autoRedirect'];
  393.         } else {
  394.             $invoiceId $request->request->get('invoiceId'$request->query->get('invoiceId'0));
  395.             $triggerMiddlePage $request->request->get('triggerMiddlePage'$request->query->get('triggerMiddlePage'0));
  396.             $meetingId 0;
  397.             $autoRedirect $request->query->get('autoRedirect'1);
  398.             $redirectUrl '';
  399.         }
  400.         $meetingId $request->request->get('meetingId'$request->query->get('meetingId'0));
  401.         $actionDone 0;
  402.         if ($meetingId != 0) {
  403.             $dt Buddybee::ConfirmAnyMeetingSessionIfPossible($em0$meetingIdfalse,
  404.                 $this->container->getParameter('notification_enabled'),
  405.                 $this->container->getParameter('notification_server'));
  406.             if ($invoiceId == && $dt['success'] == true) {
  407.                 $actionDone 1;
  408.                 return new JsonResponse(array(
  409.                     'clientSecret' => 0,
  410.                     'actionDone' => $actionDone,
  411.                     'id' => 0,
  412.                     'proceedToCheckout' => 0
  413.                 ));
  414.             }
  415.         }
  416. //        $invoiceId = $request->request->get('meetingId', $request->query->get('meetingId', 0));
  417.         $output = [
  418.             'clientSecret' => 0,
  419.             'id' => 0,
  420.             'proceedToCheckout' => 0
  421.         ];
  422.         if ($invoiceId != 0) {
  423.             $gatewayInvoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->findOneBy(
  424.                 array(
  425.                     'Id' => $invoiceId,
  426.                     'isProcessed' => [0]
  427.                 ));
  428.         } else {
  429.             $gatewayInvoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->findOneBy(
  430.                 array(
  431.                     'meetingId' => $meetingId,
  432.                     'isProcessed' => [0]
  433.                 ));
  434.         }
  435.         if ($gatewayInvoice)
  436.             $invoiceId $gatewayInvoice->getId();
  437.         $invoiceSessionCount 0;
  438.         $payableAmount 0;
  439.         $imageBySessionCount = [
  440.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  441.             100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  442.             200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  443.             300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  444.             400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  445.             500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  446.             600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  447.             700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  448.             800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  449.             900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  450.             1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  451.             1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  452.             1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  453.             1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  454.             1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  455.             1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  456.             1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  457.             1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  458.             1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  459.             1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  460.             2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  461.             2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  462.             2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  463.             2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  464.             2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  465.             2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  466.             2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  467.             2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  468.             2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  469.             2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  470.             3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  471.             3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  472.             3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  473.             3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  474.             3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  475.             3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  476.             3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  477.             3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  478.         ];
  479.         if ($gatewayInvoice) {
  480.             $gatewayProductData json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
  481.             if ($gatewayProductData == null$gatewayProductData = [];
  482.             $gatewayAmount number_format($gatewayInvoice->getGateWayBillamount(), 2'.''');
  483.             $invoiceSessionCount $gatewayInvoice->getSessionCount();
  484.             $currencyForGateway $gatewayInvoice->getAmountCurrency();
  485.             $gatewayAmount round($gatewayAmount2);
  486.             if (empty($gatewayProductData))
  487.                 $gatewayProductData = [
  488.                     [
  489.                         'price_data' => [
  490.                             'currency' => 'eur',
  491.                             'unit_amount' => $gatewayAmount != ? (100 $gatewayAmount) : 200000,
  492.                             'product_data' => [
  493. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  494.                                 'name' => 'Bee Coins',
  495. //                                'images' => [$imageBySessionCount[$invoiceSessionCount]],
  496.                                 'images' => [$imageBySessionCount[0]],
  497.                             ],
  498.                         ],
  499.                         'quantity' => 1,
  500.                     ]
  501.                 ];
  502.             $productDescStr '';
  503.             $productDescArr = [];
  504.             foreach ($gatewayProductData as $gpd) {
  505.                 $productDescArr[] = $gpd['price_data']['product_data']['name'];
  506.             }
  507.             $productDescStr implode(','$productDescArr);
  508.             $paymentGatewayFromInvoice $gatewayInvoice->getAmountTransferGateWayHash();
  509.             if ($paymentGatewayFromInvoice == 'stripe') {
  510.                 $stripe = new \Stripe\Stripe();
  511.                 \Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  512.                 $stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  513.                 {
  514.                     if ($request->query->has('meetingSessionId'))
  515.                         $id $request->query->get('meetingSessionId');
  516.                 }
  517.                 $paymentIntent = [
  518.                     "id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
  519.                     "object" => "payment_intent",
  520.                     "amount" => 3000,
  521.                     "amount_capturable" => 0,
  522.                     "amount_received" => 0,
  523.                     "application" => null,
  524.                     "application_fee_amount" => null,
  525.                     "canceled_at" => null,
  526.                     "cancellation_reason" => null,
  527.                     "capture_method" => "automatic",
  528.                     "charges" => [
  529.                         "object" => "list",
  530.                         "data" => [],
  531.                         "has_more" => false,
  532.                         "url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
  533.                     ],
  534.                     "client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
  535.                     "confirmation_method" => "automatic",
  536.                     "created" => 1546523966,
  537.                     "currency" => $currencyForGateway,
  538.                     "customer" => null,
  539.                     "description" => null,
  540.                     "invoice" => null,
  541.                     "last_payment_error" => null,
  542.                     "livemode" => false,
  543.                     "metadata" => [],
  544.                     "next_action" => null,
  545.                     "on_behalf_of" => null,
  546.                     "payment_method" => null,
  547.                     "payment_method_options" => [],
  548.                     "payment_method_types" => [
  549.                         "card"
  550.                     ],
  551.                     "receipt_email" => null,
  552.                     "review" => null,
  553.                     "setup_future_usage" => null,
  554.                     "shipping" => null,
  555.                     "statement_descriptor" => null,
  556.                     "statement_descriptor_suffix" => null,
  557.                     "status" => "requires_payment_method",
  558.                     "transfer_data" => null,
  559.                     "transfer_group" => null
  560.                 ];
  561.                 $checkout_session = \Stripe\Checkout\Session::create([
  562.                     'payment_method_types' => ['card'],
  563.                     'line_items' => $gatewayProductData,
  564.                     'mode' => 'payment',
  565.                     'success_url' => $this->generateUrl(
  566.                         'payment_gateway_success',
  567.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  568.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  569.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  570.                     ),
  571.                     'cancel_url' => $this->generateUrl(
  572.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  573.                     ),
  574.                 ]);
  575.                 $output = [
  576.                     'clientSecret' => $paymentIntent['client_secret'],
  577.                     'id' => $checkout_session->id,
  578.                     'paymentGateway' => $paymentGatewayFromInvoice,
  579.                     'proceedToCheckout' => 1
  580.                 ];
  581. //                return new JsonResponse($output);
  582.             }
  583.             if ($paymentGatewayFromInvoice == 'aamarpay') {
  584.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  585.                 $url $sandBoxMode == 'https://sandbox.aamarpay.com/request.php' 'https://secure.aamarpay.com/request.php';
  586.                 $fields = array(
  587. //                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  588.                     'store_id' => $sandBoxMode == 'aamarpaytest' 'buddybee'//store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  589.                     'amount' => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''), //transaction amount
  590.                     'payment_type' => 'VISA'//no need to change
  591.                     'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  592.                     'tran_id' => 'BEI' str_pad($gatewayInvoice->getBillerId(), 3'0'STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5'0'STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4'0'STR_PAD_LEFT), //transaction id must be unique from your end
  593.                     'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  594.                     'cus_email' => $studentDetails->getEmail(), //customer email address
  595.                     'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  596.                     'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  597.                     'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  598.                     'cus_state' => $studentDetails->getCurrAddrState(),  //state
  599.                     'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  600.                     'cus_country' => 'Bangladesh',  //country
  601.                     'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  602.                     'cus_fax' => '',  //fax
  603.                     'ship_name' => ''//ship name
  604.                     'ship_add1' => '',  //ship address
  605.                     'ship_add2' => '',
  606.                     'ship_city' => '',
  607.                     'ship_state' => '',
  608.                     'ship_postcode' => '',
  609.                     'ship_country' => 'Bangladesh',
  610.                     'desc' => $productDescStr,
  611.                     'success_url' => $this->generateUrl(
  612.                         'payment_gateway_success',
  613.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  614.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  615.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  616.                     ),
  617.                     'fail_url' => $this->generateUrl(
  618.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  619.                     ),
  620.                     'cancel_url' => $this->generateUrl(
  621.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  622.                     ),
  623. //                    'opt_a' => 'Reshad',  //optional paramter
  624. //                    'opt_b' => 'Akil',
  625. //                    'opt_c' => 'Liza',
  626. //                    'opt_d' => 'Sohel',
  627. //                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  628.                     'signature_key' => $sandBoxMode == 'dbb74894e82415a2f7ff0ec3a97e4183' 'b7304a40e21fe15af3be9a948307f524'  //live
  629.                 ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  630.                 $fields_string http_build_query($fields);
  631.                 $ch curl_init();
  632.                 curl_setopt($chCURLOPT_VERBOSEtrue);
  633.                 curl_setopt($chCURLOPT_URL$url);
  634.                 curl_setopt($chCURLOPT_POSTFIELDS$fields_string);
  635.                 curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  636.                 curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  637.                 $url_forward str_replace('"'''stripslashes(curl_exec($ch)));
  638.                 curl_close($ch);
  639. //                $this->redirect_to_merchant($url_forward);
  640.                 $output = [
  641. //                    'redirectUrl' => 'https://sandbox.aamarpay.com/'.$url_forward, //keeping it off temporarily
  642.                     'redirectUrl' => ($sandBoxMode == 'https://sandbox.aamarpay.com/' 'https://secure.aamarpay.com/') . $url_forward//keeping it off temporarily
  643. //                    'fields'=>$fields,
  644. //                    'fields_string'=>$fields_string,
  645. //                    'redirectUrl' => $this->generateUrl(
  646. //                        'payment_gateway_success',
  647. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  648. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  649. //                        ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  650. //                    ),
  651.                     'paymentGateway' => $paymentGatewayFromInvoice,
  652.                     'proceedToCheckout' => 1
  653.                 ];
  654. //                return new JsonResponse($output);
  655.             } else if ($paymentGatewayFromInvoice == 'bkash') {
  656.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  657.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  658.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  659.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  660.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  661.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  662.                 $request_data = array(
  663.                     'app_key' => $app_key_value,
  664.                     'app_secret' => $app_secret_value
  665.                 );
  666.                 $url curl_init($baseUrl '/tokenized/checkout/token/grant');
  667.                 $request_data_json json_encode($request_data);
  668.                 $header = array(
  669.                     'Content-Type:application/json',
  670.                     'username:' $username_value,
  671.                     'password:' $password_value
  672.                 );
  673.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  674.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  675.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  676.                 curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  677.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  678.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  679.                 $tokenData json_decode(curl_exec($url), true);
  680.                 curl_close($url);
  681.                 $id_token $tokenData['id_token'];
  682.                 $goToBkashPage 0;
  683.                 if ($tokenData['statusCode'] == '0000') {
  684.                     $auth $id_token;
  685.                     $requestbody = array(
  686.                         "mode" => "0011",
  687. //                        "payerReference" => "",
  688.                         "payerReference" => $gatewayInvoice->getInvoiceDateTs(),
  689.                         "callbackURL" => $this->generateUrl(
  690.                             'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
  691.                         ),
  692. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  693.                         "amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  694.                         "currency" => "BDT",
  695.                         "intent" => "sale",
  696.                         "merchantInvoiceNumber" => $invoiceId
  697.                     );
  698.                     $url curl_init($baseUrl '/tokenized/checkout/create');
  699.                     $requestbodyJson json_encode($requestbody);
  700.                     $header = array(
  701.                         'Content-Type:application/json',
  702.                         'Authorization:' $auth,
  703.                         'X-APP-Key:' $app_key_value
  704.                     );
  705.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  706.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  707.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  708.                     curl_setopt($urlCURLOPT_POSTFIELDS$requestbodyJson);
  709.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  710.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  711.                     $resultdata curl_exec($url);
  712.                     curl_close($url);
  713. //                    return new JsonResponse($resultdata);
  714.                     $obj json_decode($resultdatatrue);
  715.                     $goToBkashPage 1;
  716.                     $justNow = new \DateTime();
  717.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  718.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  719.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  720.                     $gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
  721.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  722.                     $em->flush();
  723.                     $output = [
  724.                         'redirectUrl' => $obj['bkashURL'],
  725.                         'paymentGateway' => $paymentGatewayFromInvoice,
  726.                         'proceedToCheckout' => $goToBkashPage,
  727.                         'tokenData' => $tokenData,
  728.                         'obj' => $obj,
  729.                         'id_token' => $tokenData['id_token'],
  730.                     ];
  731.                 }
  732. //                $fields = array(
  733. //
  734. //                    "mode" => "0011",
  735. //                    "payerReference" => "01723888888",
  736. //                    "callbackURL" => $this->generateUrl(
  737. //                        'payment_gateway_success',
  738. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  739. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  740. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  741. //                    ),
  742. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  743. //                    "amount" => $gatewayInvoice->getGateWayBillamount(),
  744. //                    "currency" => "BDT",
  745. //                    "intent" => "sale",
  746. //                    "merchantInvoiceNumber" => 'BEI' . str_pad($gatewayInvoice->getBillerId(), 3, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4, '0', STR_PAD_LEFT)
  747. //
  748. //                );
  749. //                $fields = array(
  750. ////                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  751. //                    'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  752. //                    'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  753. //                    'payment_type' => 'VISA', //no need to change
  754. //                    'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  755. //                    'tran_id' => 'BEI' . str_pad($gatewayInvoice->getBillerId(), 3, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4, '0', STR_PAD_LEFT), //transaction id must be unique from your end
  756. //                    'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(),  //customer name
  757. //                    'cus_email' => $studentDetails->getEmail(), //customer email address
  758. //                    'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  759. //                    'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  760. //                    'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  761. //                    'cus_state' => $studentDetails->getCurrAddrState(),  //state
  762. //                    'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  763. //                    'cus_country' => 'Bangladesh',  //country
  764. //                    'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
  765. //                    'cus_fax' => '',  //fax
  766. //                    'ship_name' => '', //ship name
  767. //                    'ship_add1' => '',  //ship address
  768. //                    'ship_add2' => '',
  769. //                    'ship_city' => '',
  770. //                    'ship_state' => '',
  771. //                    'ship_postcode' => '',
  772. //                    'ship_country' => 'Bangladesh',
  773. //                    'desc' => $productDescStr,
  774. //                    'success_url' => $this->generateUrl(
  775. //                        'payment_gateway_success',
  776. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  777. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  778. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  779. //                    ),
  780. //                    'fail_url' => $this->generateUrl(
  781. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  782. //                    ),
  783. //                    'cancel_url' => $this->generateUrl(
  784. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  785. //                    ),
  786. ////                    'opt_a' => 'Reshad',  //optional paramter
  787. ////                    'opt_b' => 'Akil',
  788. ////                    'opt_c' => 'Liza',
  789. ////                    'opt_d' => 'Sohel',
  790. ////                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  791. //                    'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524'  //live
  792. //
  793. //                ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  794. //
  795. //                $fields_string = http_build_query($fields);
  796. //
  797. //                $ch = curl_init();
  798. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  799. //                curl_setopt($ch, CURLOPT_URL, $url);
  800. //
  801. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  802. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  803. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  804. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  805. //                curl_close($ch);
  806. //                $this->redirect_to_merchant($url_forward);
  807.             }
  808.         }
  809.         if ($triggerMiddlePage == 1) return $this->render('@Buddybee/pages/makePaymentOfEntityInvoiceLandingPage.html.twig', array(
  810.             'page_title' => 'Invoice Payment',
  811.             'data' => $output,
  812.         ));
  813.         else
  814.             return new JsonResponse($output);
  815.     }
  816.     public function TriggerLoginForBookMeetingAction(Request $request$encData '')
  817.     {
  818.         $em_goc $this->getDoctrine()->getManager('company_group');
  819.         $session $request->getSession();
  820.         $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  821.         $token $request->request->get('token'$session->get('token'''));
  822.         if ($token != '')
  823.             MiscActions::DeleteToken($em_goc$token);
  824.         $session->clear();
  825.         $session->set('CLEARLOGIN'1);
  826.         if (isset($encryptedData['LAST_REQUEST_URI_BEFORE_LOGIN']))
  827.             $session->set('LAST_REQUEST_URI_BEFORE_LOGIN'$encryptedData['LAST_REQUEST_URI_BEFORE_LOGIN']);
  828. //        $request->headers->setCookie(Cookie::create('CLEARLOGINCOOKIE', 1
  829. //            )
  830. //
  831. //        );
  832.         return $this->redirectToRoute('user_login');
  833.     }
  834.     public function RefundEntityInvoiceAction(Request $request$encData '')
  835.     {
  836.         $em $this->getDoctrine()->getManager('company_group');
  837.         $invoiceId 0;
  838.         $currIsProcessedFlagValue '_UNSET_';
  839.         $session $request->getSession();
  840.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  841.         $paymentId $request->query->get('paymentID'0);
  842.         $status $request->query->get('status'0);
  843.         $refundSuccess 0;
  844.         $errorMsg '';
  845.         $errorCode '';
  846.         if ($encData != '') {
  847.             $invoiceId $encData;
  848.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  849.             if (isset($encryptedData['invoiceId']))
  850.                 $invoiceId $encryptedData['invoiceId'];
  851.             if (isset($encryptedData['autoRedirect']))
  852.                 $autoRedirect $encryptedData['autoRedirect'];
  853.         } else {
  854.             $invoiceId $request->request->get('invoiceId'$request->query->get('invoiceId'0));
  855.             $meetingId 0;
  856.             $autoRedirect $request->query->get('autoRedirect'1);
  857.             $redirectUrl '';
  858.         }
  859.         $gatewayInvoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->findOneBy(
  860.             array(
  861.                 'Id' => $invoiceId,
  862.                 'isProcessed' => [1]
  863.             ));
  864.         if ($gatewayInvoice) {
  865.             $gatewayInvoice->setIsProcessed(3); //pending settlement
  866.             $currIsProcessedFlagValue $gatewayInvoice->getIsProcessed();
  867.             $em->flush();
  868.             if ($gatewayInvoice->getAmountTransferGateWayHash() == 'bkash') {
  869.                 $invoiceId $gatewayInvoice->getId();
  870.                 $paymentID $gatewayInvoice->getGatewayPaymentId();
  871.                 $trxID $gatewayInvoice->getGatewayTransId();
  872.                 $justNow = new \DateTime();
  873.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  874.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  875.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  876.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  877.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  878.                 $justNowTs $justNow->format('U');
  879.                 if ($gatewayInvoice->getGatewayIdTokenExpireTs() <= $justNowTs) {
  880.                     $refresh_token $gatewayInvoice->getGatewayIdRefreshToken();
  881.                     $request_data = array(
  882.                         'app_key' => $app_key_value,
  883.                         'app_secret' => $app_secret_value,
  884.                         'refresh_token' => $refresh_token
  885.                     );
  886.                     $url curl_init($baseUrl '/tokenized/checkout/token/refresh');
  887.                     $request_data_json json_encode($request_data);
  888.                     $header = array(
  889.                         'Content-Type:application/json',
  890.                         'username:' $username_value,
  891.                         'password:' $password_value
  892.                     );
  893.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  894.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  895.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  896.                     curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  897.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  898.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  899.                     $tokenData json_decode(curl_exec($url), true);
  900.                     curl_close($url);
  901.                     $justNow = new \DateTime();
  902.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  903.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  904.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  905.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  906.                     $em->flush();
  907.                 }
  908.                 $auth $gatewayInvoice->getGatewayIdToken();;
  909.                 $post_token = array(
  910.                     'paymentID' => $paymentID,
  911.                     'trxID' => $trxID,
  912.                     'reason' => 'Full Refund Policy',
  913.                     'sku' => 'RSTR',
  914.                     'amount' => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  915.                 );
  916.                 $url curl_init($baseUrl '/tokenized/checkout/payment/refund');
  917.                 $posttoken json_encode($post_token);
  918.                 $header = array(
  919.                     'Content-Type:application/json',
  920.                     'Authorization:' $auth,
  921.                     'X-APP-Key:' $app_key_value
  922.                 );
  923.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  924.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  925.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  926.                 curl_setopt($urlCURLOPT_POSTFIELDS$posttoken);
  927.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  928.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  929.                 $resultdata curl_exec($url);
  930.                 curl_close($url);
  931.                 $obj json_decode($resultdatatrue);
  932. //                return new JsonResponse($obj);
  933.                 if (isset($obj['completedTime']))
  934.                     $refundSuccess 1;
  935.                 else if (isset($obj['errorCode'])) {
  936.                     $refundSuccess 0;
  937.                     $errorCode $obj['errorCode'];
  938.                     $errorMsg $obj['errorMessage'];
  939.                 }
  940. //                    $gatewayInvoice->setGatewayTransId($obj['trxID']);
  941.                 $em->flush();
  942.             }
  943.             if ($refundSuccess == 1) {
  944.                 Buddybee::RefundEntityInvoice($em$invoiceId);
  945.                 $currIsProcessedFlagValue 4;
  946.             }
  947.         } else {
  948.         }
  949.         MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  950.         return new JsonResponse(
  951.             array(
  952.                 'success' => $refundSuccess,
  953.                 'errorCode' => $errorCode,
  954.                 'isProcessed' => $currIsProcessedFlagValue,
  955.                 'errorMsg' => $errorMsg,
  956.             )
  957.         );
  958.     }
  959.     public function ViewEntityInvoiceAction(Request $request$encData '')
  960.     {
  961.         $em $this->getDoctrine()->getManager('company_group');
  962.         $invoiceId 0;
  963.         $autoRedirect 1;
  964.         $redirectUrl '';
  965.         $meetingId 0;
  966.         $invoice null;
  967.         if ($encData != '') {
  968.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  969.             $invoiceId $encData;
  970.             if (isset($encryptedData['invoiceId']))
  971.                 $invoiceId $encryptedData['invoiceId'];
  972.             if (isset($encryptedData['autoRedirect']))
  973.                 $autoRedirect $encryptedData['autoRedirect'];
  974.         } else {
  975.             $invoiceId $request->query->get('invoiceId'0);
  976.             $meetingId 0;
  977.             $autoRedirect $request->query->get('autoRedirect'1);
  978.             $redirectUrl '';
  979.         }
  980. //    $invoiceList = [];
  981.         $billerDetails = [];
  982.         $billToDetails = [];
  983.         if ($invoiceId != 0) {
  984.             $invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  985.                 ->findOneBy(
  986.                     array(
  987.                         'Id' => $invoiceId,
  988.                     )
  989.                 );
  990.             if ($invoice) {
  991.                 $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  992.                     ->findOneBy(
  993.                         array(
  994.                             'applicantId' => $invoice->getBillerId(),
  995.                         )
  996.                     );
  997.                 $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  998.                     ->findOneBy(
  999.                         array(
  1000.                             'applicantId' => $invoice->getBillToId(),
  1001.                         )
  1002.                     );
  1003.             }
  1004. //            foreach ($invoice as data) {
  1005. //                $invoiceData = array(
  1006. //                    'id' => data->getStudentId(),
  1007. //
  1008. //                );
  1009. //                $invoiceList = $invoiceData;
  1010. //            }
  1011.         }
  1012. //        $student= [];
  1013. //        $studentDetails = $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1014. //            ->findBy(
  1015. //                array(
  1016. //                    'applicantId' => $invoiceId->getStudentId(),
  1017. //
  1018. //                )
  1019. //            );
  1020. //
  1021. //
  1022. //
  1023. //        foreach ($studentDetails as $studentDetail) {
  1024. //            $studentData = array(
  1025. //                'firstName' => $studentDetail->getFirstName(),
  1026. //                'lasttName' => $studentDetail->getLastName(),
  1027. //
  1028. //            );
  1029. //            $student = $studentData;
  1030. //        }
  1031.         if ($request->query->get('sendMail'0) == && GeneralConstant::EMAIL_ENABLED == 1) {
  1032.             $billerDetails = [];
  1033.             $billToDetails = [];
  1034.             if ($invoice) {
  1035.                 $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1036.                     ->findOneBy(
  1037.                         array(
  1038.                             'applicantId' => $invoice->getBillerId(),
  1039.                         )
  1040.                     );
  1041.                 $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1042.                     ->findOneBy(
  1043.                         array(
  1044.                             'applicantId' => $invoice->getBillToId(),
  1045.                         )
  1046.                     );
  1047.                 $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1048.                 $bodyData = array(
  1049.                     'page_title' => 'Invoice',
  1050. //            'studentDetails' => $student,
  1051.                     'billerDetails' => $billerDetails,
  1052.                     'billToDetails' => $billToDetails,
  1053.                     'invoice' => $invoice,
  1054.                     'currencyList' => BuddybeeConstant::$currency_List,
  1055.                     'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1056.                 );
  1057.                 $attachments = [];
  1058.                 $forwardToMailAddress $billToDetails->getOAuthEmail();
  1059. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1060.                 $new_mail $this->get('mail_module');
  1061.                 $new_mail->sendMyMail(array(
  1062.                     'senderHash' => '_CUSTOM_',
  1063.                     //                        'senderHash'=>'_CUSTOM_',
  1064.                     'forwardToMailAddress' => $forwardToMailAddress,
  1065.                     'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  1066. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1067.                     'attachments' => $attachments,
  1068.                     'toAddress' => $forwardToMailAddress,
  1069.                     'fromAddress' => 'no-reply@buddybee.eu',
  1070.                     'userName' => 'no-reply@buddybee.eu',
  1071.                     'password' => 'Honeybee@0112',
  1072.                     'smtpServer' => 'smtp.hostinger.com',
  1073.                     'smtpPort' => 465,
  1074. //                            'emailBody' => $bodyHtml,
  1075.                     'mailTemplate' => $bodyTemplate,
  1076.                     'templateData' => $bodyData,
  1077.                     'embedCompanyImage' => 0,
  1078.                     'companyId' => 0,
  1079.                     'companyImagePath' => ''
  1080. //                        'embedCompanyImage' => 1,
  1081. //                        'companyId' => $companyId,
  1082. //                        'companyImagePath' => $company_data->getImage()
  1083.                 ));
  1084.             }
  1085.         }
  1086.         if ($invoice) {
  1087.         } else {
  1088.             return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  1089.                 'page_title' => '404 Not Found',
  1090.             ));
  1091.         }
  1092.         return $this->render('ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig', array(
  1093.             'page_title' => 'Invoice',
  1094. //            'studentDetails' => $student,
  1095.             'billerDetails' => $billerDetails,
  1096.             'billToDetails' => $billToDetails,
  1097.             'invoice' => $invoice,
  1098.             'currencyList' => BuddybeeConstant::$currency_List,
  1099.             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1100.         ));
  1101.     }
  1102.     public function ConfirmBuddybeeMeetingAction(Request $request$encData '')
  1103.     {
  1104.         $em $this->getDoctrine()->getManager('company_group');
  1105.         $invoiceId 0;
  1106.         $autoRedirect 1;
  1107.         $redirectUrl '';
  1108.         $meetingId 0;
  1109.         $studentId 0;
  1110.         $consultantId 0;
  1111.         $confirmBookingPaymentWise '_UNCHANGED_';
  1112.         $confirmedByStudent '_UNCHANGED_';
  1113.         $confirmedByConsultant '_UNCHANGED_';
  1114.         if ($encData != '') {
  1115.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  1116.             if (isset($encryptedData['meetingId'])) $meetingId $encryptedData['meetingId'];
  1117.             if (isset($encryptedData['studentId'])) $studentId $encryptedData['studentId'];
  1118.             if (isset($encryptedData['consultantId'])) $consultantId $encryptedData['consultantId'];
  1119.             if (isset($encryptedData['confirmBookingPaymentWise'])) $confirmBookingPaymentWise $encryptedData['confirmBookingPaymentWise'];
  1120.             if (isset($encryptedData['confirmedByConsultant'])) $confirmedByConsultant $encryptedData['confirmedByConsultant'];
  1121.             if (isset($encryptedData['confirmedByStudent'])) $confirmedByStudent $encryptedData['confirmedByStudent'];
  1122.         } else {
  1123.             $meetingId $request->request->get('meetingId'$request->query->get('meetingId'0));
  1124.             $consultantId $request->request->get('consultantId'$request->query->get('consultantId'0));
  1125.             $studentId $request->request->get('studentId'$request->query->get('studentId'0));
  1126.             $confirmBookingPaymentWise $request->request->get('confirmBookingPaymentWise'$request->query->get('confirmBookingPaymentWise''_UNCHANGED_'));
  1127.             $confirmedByStudent $request->request->get('confirmedByStudent'$request->query->get('confirmedByStudent''_UNCHANGED_'));
  1128.             $confirmedByConsultant $request->request->get('confirmedByConsultant'$request->query->get('confirmedByConsultant''_UNCHANGED_'));
  1129.         }
  1130.         if ($meetingId != 0) {
  1131.             if ($confirmBookingPaymentWise == 1) {
  1132.                 Buddybee::ConfirmAnyMeetingSessionIfPossible($em$studentId$meetingId);
  1133.             }
  1134.             Buddybee::ModifyConfirmationInfo($em$meetingId$confirmedByStudent$confirmedByConsultant);
  1135.         } else {
  1136.             if ($confirmBookingPaymentWise == 1) {
  1137.                 Buddybee::ConfirmAnyMeetingSessionIfPossible($em$studentId$meetingId);
  1138.             }
  1139.         }
  1140.         return new JsonResponse(
  1141.             array(
  1142.                 'success' => true
  1143.             )
  1144.         );
  1145.     }
  1146.     public function BuddyBeeAdminReportTestAction(Request $request$encData '')
  1147.     {
  1148.         $toPrint "";
  1149.         $gocList = [];
  1150.         $now = new \DateTime();
  1151.         $now->setTimezone(new \DateTimeZone('+0000'));
  1152.         $yday = new \DateTime();
  1153.         $yday->modify('-1 day');
  1154.         $yday->setTimezone(new \DateTimeZone('+0000'));
  1155.         $currDate_YMD $now->format('Y-m-d H:i:s');
  1156.         $yday_start_YMD $yday->format('Y-m-d 00:00:00');
  1157.         $yday_YMD $yday->format('Y-m-d 23:59:59');
  1158.         $currDateTs $now->format('U');
  1159.         $gocList = [];
  1160.         $dayOfMonth = new \DateTime();
  1161.         $dayOfMonth->modify('-30 day');
  1162.         $firstDayOfMonth_YMD $dayOfMonth->format('Y-m-d 00:00:00');
  1163.         $lastWeek = new \DateTime();
  1164.         $lastWeek->modify('-6 day');
  1165.         $lasstWeek_YMD $lastWeek->format('Y-m-d 00:00:00');
  1166.         $cgem $this->getDoctrine()->getManager('company_group');
  1167.         $currDate = new \DateTime();
  1168.         $currDateTs $currDate->format('U');
  1169.         $toDeleteIdList = [];
  1170. //                $toPrint.="\nSearching $gocDbName Now..";
  1171.         //check if there are flags the flags and set them in enti
  1172.         $reportData = array(
  1173.             'newUser' => 0,
  1174.             'totalUser' => 0,
  1175.             'newInvoicePurchasePaid' => 0,
  1176.             'totalInvoicePurchasePaid' => 0,
  1177.             'newCoinPurchased' => 0,
  1178.             'totalCoinPurchased' => 0,
  1179.             'newPaidBookings' => 0,
  1180.             'totalPaidBookings' => 0,
  1181.             'dateStr' => $currDate->format('F d, Y'),
  1182.             'monthWiseUser' => 0,
  1183.             'lastWeek' => 0,
  1184.             'monthlyInvoicePurchasePaid' => 0,
  1185.             'weeklyInvoicePurchasePaid' => 0,
  1186.             'monthlyPaidBookings' => 0,
  1187.             'weeklyPaidBookings' => 0,
  1188.             'monthlyCoinPurchased' => 0,
  1189.             'weeklyCoinPurchased' => 0,
  1190.             'newLead' => 0,
  1191.             'weeklyLead' => 0,
  1192.             'monthlyLead' => 0,
  1193.             'totalLead' => 0
  1194.         );
  1195.         //get
  1196.         $reportData['newUser'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1197.             ->createQueryBuilder('m')
  1198.             ->select("count(m)")
  1199.             ->where("m.accountStatus = 1")
  1200.             ->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
  1201.             ->andWhere("m.isConsultant <> 1")
  1202.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1203.             ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
  1204.             ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
  1205.             ->setParameter('yday_start_YMD'$yday_start_YMD)
  1206.             ->setParameter('yday_YMD'$yday_YMD)
  1207.             ->getQuery()
  1208.             ->getSingleScalarResult();
  1209.         $reportData['monthWiseUser'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1210.             ->createQueryBuilder('m')
  1211.             ->select("count(m)")
  1212.             ->where("m.accountStatus = 1")
  1213.             ->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
  1214.             ->andWhere("m.isConsultant <> 1")
  1215.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1216. //            ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
  1217. //            ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
  1218.             ->andWhere('m.actualRegistrationAt BETWEEN :firstDayOfThisMonth AND :currentDate')
  1219.             ->setParameter('firstDayOfThisMonth'$firstDayOfMonth_YMD)
  1220.             ->setParameter('currentDate'$currDate_YMD)
  1221.             ->getQuery()
  1222.             ->getSingleScalarResult();
  1223.         $reportData['lastWeek'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1224.             ->createQueryBuilder('m')
  1225.             ->select("count(m)")
  1226.             ->where("m.accountStatus = 1")
  1227.             ->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
  1228.             ->andWhere("m.isConsultant <> 1")
  1229.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1230. //            ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
  1231. //            ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
  1232.             ->andWhere('m.actualRegistrationAt BETWEEN :lastWeek AND :currentDate')
  1233.             ->setParameter('lastWeek'$lasstWeek_YMD)
  1234.             ->setParameter('currentDate'$currDate_YMD)
  1235.             ->getQuery()
  1236.             ->getSingleScalarResult();
  1237.         $reportData['totalUser'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1238.             ->createQueryBuilder('m')
  1239.             ->select("count(m)")
  1240.             ->where("m.accountStatus = 1")
  1241.             ->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
  1242.             ->andWhere("m.isConsultant <> 1")
  1243.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1244. //            ->andWhere("m.createdAt >= :yday_start_YMD " )
  1245. //            ->andWhere("m.createdAt <= :yday_YMD " )
  1246. //            ->setParameter('yday_start_YMD', $yday_start_YMD)
  1247. //            ->setParameter('yday_YMD', $yday_YMD)
  1248.             ->getQuery()
  1249.             ->getSingleScalarResult();
  1250.         $reportData['newInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1251.             ->createQueryBuilder('m')
  1252.             ->select("count(m)")
  1253.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1254.             ->andWhere("m.invoiceType = 1")
  1255.             ->andWhere("m.createdAt >= :yday_start_YMD ")
  1256.             ->andWhere("m.createdAt <= :yday_YMD ")
  1257.             ->setParameter('yday_start_YMD'$yday_start_YMD)
  1258.             ->setParameter('yday_YMD'$yday_YMD)
  1259.             ->getQuery()
  1260.             ->getSingleScalarResult();
  1261.         $reportData['monthlyInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1262.             ->createQueryBuilder('m')
  1263.             ->select("count(m)")
  1264.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1265.             ->andWhere("m.invoiceType = 1")
  1266.             ->andWhere('m.createdAt BETWEEN :firstDayOfThisMonth AND :currentDate')
  1267.             ->setParameter('firstDayOfThisMonth'$firstDayOfMonth_YMD)
  1268.             ->setParameter('currentDate'$currDate_YMD)
  1269.             ->getQuery()
  1270.             ->getSingleScalarResult();
  1271.         $reportData['weeklyInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1272.             ->createQueryBuilder('m')
  1273.             ->select("count(m)")
  1274.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1275.             ->andWhere("m.invoiceType = 1")
  1276.             ->andWhere('m.createdAt BETWEEN :lastWeek AND :currentDate')
  1277.             ->setParameter('lastWeek'$lasstWeek_YMD)
  1278.             ->setParameter('currentDate'$currDate_YMD)
  1279.             ->getQuery()
  1280.             ->getSingleScalarResult();
  1281.         $reportData['totalInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1282.             ->createQueryBuilder('m')
  1283.             ->select("count(m)")
  1284.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1285.             ->andWhere("m.invoiceType = 1")
  1286. //            ->andWhere("m.createdAt >= :yday_start_YMD " )
  1287. //            ->andWhere("m.createdAt <= :yday_YMD " )
  1288. //            ->setParameter('yday_start_YMD', $yday_start_YMD)
  1289. //            ->setParameter('yday_YMD', $yday_YMD)
  1290.             ->getQuery()
  1291.             ->getSingleScalarResult();
  1292.         $reportData['newPaidBookings'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  1293.             ->createQueryBuilder('m')
  1294.             ->select("count(m)")
  1295.             ->where("m.isPaidFull = 1")
  1296.             ->andWhere("m.updatedAt >= :yday_start_YMD ")
  1297.             ->andWhere("m.updatedAt <= :yday_YMD ")
  1298.             ->setParameter('yday_start_YMD'$yday_start_YMD)
  1299.             ->setParameter('yday_YMD'$yday_YMD)
  1300.             ->getQuery()
  1301.             ->getSingleScalarResult();
  1302.         $reportData['monthlyPaidBookings'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  1303.             ->createQueryBuilder('m')
  1304.             ->select("count(m)")
  1305.             ->where("m.isPaidFull = 1")
  1306.             ->andWhere('m.updatedAt BETWEEN :firstDayOfThisMonth AND :currentDate')
  1307.             ->setParameter('firstDayOfThisMonth'$firstDayOfMonth_YMD)
  1308.             ->setParameter('currentDate'$currDate_YMD)
  1309.             ->getQuery()
  1310.             ->getSingleScalarResult();
  1311.         $reportData['weeklyPaidBookings'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  1312.             ->createQueryBuilder('m')
  1313.             ->select("count(m)")
  1314.             ->where("m.isPaidFull = 1")
  1315.             ->andWhere('m.updatedAt BETWEEN :lastWeek AND :currentDate')
  1316.             ->setParameter('lastWeek'$lasstWeek_YMD)
  1317.             ->setParameter('currentDate'$currDate_YMD)
  1318.             ->getQuery()
  1319.             ->getSingleScalarResult();
  1320.         $reportData['totalPaidBookings'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  1321.             ->createQueryBuilder('m')
  1322.             ->select("count(m)")
  1323.             ->where("m.isPaidFull = 1")
  1324. //            ->andWhere("m.updatedAt >= :yday_start_YMD " )
  1325. //            ->andWhere("m.updatedAt <= :yday_YMD " )
  1326. //            ->setParameter('yday_start_YMD', $yday_start_YMD)
  1327. //            ->setParameter('yday_YMD', $yday_YMD)
  1328.             ->getQuery()
  1329.             ->getSingleScalarResult();
  1330.         $reportData['newCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1331.             ->createQueryBuilder('m')
  1332.             ->select("sum(m.sessionCount)")
  1333.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1334.             ->andWhere("m.createdAt >= :yday_start_YMD ")
  1335.             ->andWhere("m.createdAt <= :yday_YMD ")
  1336.             ->setParameter('yday_start_YMD'$yday_start_YMD)
  1337.             ->setParameter('yday_YMD'$yday_YMD)
  1338.             ->getQuery()
  1339.             ->getSingleScalarResult();
  1340.         $reportData['monthlyCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1341.             ->createQueryBuilder('m')
  1342.             ->select("sum(m.sessionCount)")
  1343.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1344.             ->andWhere('m.createdAt BETWEEN :firstDayOfThisMonth AND :currentDate')
  1345.             ->setParameter('firstDayOfThisMonth'$firstDayOfMonth_YMD)
  1346.             ->setParameter('currentDate'$currDate_YMD)
  1347.             ->getQuery()
  1348.             ->getSingleScalarResult();
  1349.         $reportData['weeklyCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1350.             ->createQueryBuilder('m')
  1351.             ->select("sum(m.sessionCount)")
  1352.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1353.             ->andWhere('m.createdAt BETWEEN :lastWeek AND :currentDate')
  1354.             ->setParameter('lastWeek'$lasstWeek_YMD)
  1355.             ->setParameter('currentDate'$currDate_YMD)
  1356.             ->getQuery()
  1357.             ->getSingleScalarResult();
  1358.         $reportData['totalCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1359.             ->createQueryBuilder('m')
  1360.             ->select("sum(m.sessionCount)")
  1361.             ->where("m.stage = " BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED)
  1362. //            ->andWhere("m.createdAt >= :yday_start_YMD " )
  1363. //            ->andWhere("m.createdAt <= :yday_YMD " )
  1364. //            ->setParameter('yday_start_YMD', $yday_start_YMD)
  1365. //            ->setParameter('yday_YMD', $yday_YMD)
  1366.             ->getQuery()
  1367.             ->getSingleScalarResult();
  1368.         $reportData['newlead'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1369.             ->createQueryBuilder('m')
  1370.             ->select("count(m)")
  1371.             ->where("m.accountStatus = 1")
  1372.             ->andWhere("(m.isTemporaryEntry = 1 )")
  1373.             ->andWhere("m.isConsultant <> 1")
  1374.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1375.             ->andWhere("m.createdAt >= :yday_start_YMD ")
  1376.             ->andWhere("m.createdAt <= :yday_YMD ")
  1377.             ->setParameter('yday_start_YMD'$yday_start_YMD)
  1378.             ->setParameter('yday_YMD'$yday_YMD)
  1379.             ->getQuery()
  1380.             ->getSingleScalarResult();
  1381.         $reportData['monthlyLead'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1382.             ->createQueryBuilder('m')
  1383.             ->select("count(m)")
  1384.             ->where("m.accountStatus = 1")
  1385.             ->andWhere("(m.isTemporaryEntry = 1)")
  1386.             ->andWhere("m.isConsultant <> 1")
  1387.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1388. //            ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
  1389. //            ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
  1390.             ->andWhere('m.createdAt BETWEEN :firstDayOfThisMonth AND :currentDate')
  1391.             ->setParameter('firstDayOfThisMonth'$firstDayOfMonth_YMD)
  1392.             ->setParameter('currentDate'$currDate_YMD)
  1393.             ->getQuery()
  1394.             ->getSingleScalarResult();
  1395.         $reportData['weeklyLead'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1396.             ->createQueryBuilder('m')
  1397.             ->select("count(m)")
  1398.             ->where("m.accountStatus = 1")
  1399.             ->andWhere("(m.isTemporaryEntry = 1)")
  1400.             ->andWhere("m.isConsultant <> 1")
  1401.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1402. //            ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
  1403. //            ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
  1404.             ->andWhere('m.createdAt BETWEEN :lastWeek AND :currentDate')
  1405.             ->setParameter('lastWeek'$lasstWeek_YMD)
  1406.             ->setParameter('currentDate'$currDate_YMD)
  1407.             ->getQuery()
  1408.             ->getSingleScalarResult();
  1409.         $reportData['totalLead'] = $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1410.             ->createQueryBuilder('m')
  1411.             ->select("count(m)")
  1412.             ->where("m.accountStatus = 1")
  1413.             ->andWhere("(m.isTemporaryEntry = 1)")
  1414.             ->andWhere("m.isConsultant <> 1")
  1415.             ->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
  1416. //            ->andWhere("m.createdAt >= :yday_start_YMD " )
  1417. //            ->andWhere("m.createdAt <= :yday_YMD " )
  1418. //            ->setParameter('yday_start_YMD', $yday_start_YMD)
  1419. //            ->setParameter('yday_YMD', $yday_YMD)
  1420.             ->getQuery()
  1421.             ->getSingleScalarResult();
  1422.         $adminList $cgem->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1423.             ->createQueryBuilder('m')
  1424. //            ->select("m")
  1425. //            ->where("m.accountStatus = 1" )
  1426.             ->where("m.isAdmin >= 1")
  1427. //            ->andWhere("m.createdAt >= :yday_start_YMD " )
  1428. //            ->andWhere("m.createdAt <= :yday_YMD " )
  1429. //            ->setParameter('yday_start_YMD', $yday_start_YMD)
  1430. //            ->setParameter('yday_YMD', $yday_YMD)
  1431.             ->getQuery()
  1432.             ->getResult();
  1433.         $emailAddresses = [];
  1434. //        $emailAddresses=['eco.buet@gmail.com'];
  1435.         foreach ($adminList as $a) {
  1436.             $emailAddresses[] = $a->getOAuthEmail();
  1437.         }
  1438.         $data $reportData;
  1439.         $attachments = []; //for now only general mails
  1440.         $bodyTemplate 'ApplicationBundle:email/templates:dailyUserReportBuddyBee.html.twig';
  1441.         $bodyData $data;
  1442. //                        $companyId=$schedule->getCompanyId();
  1443. //                        $companyData=Company::getCompanyData($this->em, $companyId);
  1444.         return $this->render($bodyTemplate$bodyData);
  1445.         return $toPrint;
  1446.     }
  1447.     public function UpdateCoursePlanForMeetingAction(Request $request$encData '')
  1448.     {
  1449.         $em $this->getDoctrine()->getManager('company_group');
  1450.         $meetingId $request->request->get('meetingId'$request->query->get('meetingId'0));
  1451.         $topicId $request->request->get('topicId'$request->query->get('topicId'0));
  1452.         $consultantId $request->request->get('consultantId'$request->query->get('consultantId'0));
  1453.         $studentId $request->request->get('studentId'$request->query->get('studentId'0));
  1454.         $action $request->request->get('action'$request->query->get('action''_REPLACE_'));
  1455.         $coursePlanHistoryForThisUserAndTopic $request->request->get('data'$request->query->get('data', []));
  1456.         $enableForThisUserAndTopic $request->request->get('enableData'$request->query->get('enableData', []));
  1457.         $entry $em->getRepository('CompanyGroupBundle\\Entity\\EntityCoursePlanHistory')
  1458.             ->findOneBy(
  1459.                 array(
  1460.                     'studentId' => $studentId,
  1461.                     'topicId' => $topicId,
  1462.                 )
  1463.             );
  1464.         if (!$entry)
  1465.             $entry = new EntityCoursePlanHistory();
  1466.         $meetingIds json_decode($entry->getMeetingIds(), true);
  1467.         if ($meetingIds == null$meetingIds = [];
  1468.         if (!in_array($meetingId$meetingIds))
  1469.             $meetingIds[] = $meetingId;
  1470.         $entry->setStudentId($studentId);
  1471.         $entry->setTopicId($topicId);
  1472.         $entry->setMeetingIds(json_encode($meetingIds));
  1473.         if ($action == '_REPLACE_')
  1474.             $entry->setData(json_encode($coursePlanHistoryForThisUserAndTopic));
  1475.         if ($action == '_MODIFY_ENABLED_') {
  1476.             $coursePlanHistoryForThisUserAndTopic json_decode($entry->getData(), true);
  1477.             if ($coursePlanHistoryForThisUserAndTopic == null$coursePlanHistoryForThisUserAndTopic = [];
  1478.             foreach ($enableForThisUserAndTopic as $enableData) {
  1479.                 if (!isset($coursePlanHistoryForThisUserAndTopic[$enableData['sessionId']]))
  1480.                     $coursePlanHistoryForThisUserAndTopic[$enableData['sessionId']] = array(
  1481.                         'enabled' => 0,
  1482.                         'isOpen' => 0,
  1483.                         'subjects' => []
  1484.                     );
  1485.                 $coursePlanHistoryForThisUserAndTopic[$enableData['sessionId']]['enabled'] = $enableData['isEnabled'];
  1486.             }
  1487.             $entry->setData(json_encode($coursePlanHistoryForThisUserAndTopic));
  1488.         }
  1489.         $em->persist($entry);
  1490.         $em->flush();
  1491.         return new JsonResponse(
  1492.             array(
  1493.                 'success' => true
  1494.             )
  1495.         );
  1496.     }
  1497.     public function PaymentGatewaySuccessAction(Request $request$encData '')
  1498.     {
  1499.         $em $this->getDoctrine()->getManager('company_group');
  1500.         $invoiceId 0;
  1501.         $autoRedirect 1;
  1502.         $redirectUrl '';
  1503.         $meetingId 0;
  1504.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  1505.         if($systemType=='_CENTRAL_') {
  1506.             if ($encData != '') {
  1507.                 $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  1508.                 if (isset($encryptedData['invoiceId']))
  1509.                     $invoiceId $encryptedData['invoiceId'];
  1510.                 if (isset($encryptedData['autoRedirect']))
  1511.                     $autoRedirect $encryptedData['autoRedirect'];
  1512.             } else {
  1513.                 $invoiceId $request->query->get('invoiceId'0);
  1514.                 $meetingId 0;
  1515.                 $autoRedirect $request->query->get('autoRedirect'1);
  1516.                 $redirectUrl '';
  1517.             }
  1518.             if ($invoiceId != 0) {
  1519.                 $retData Buddybee::ProcessEntityInvoice($em$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  1520.                     $this->container->getParameter('notification_enabled'),
  1521.                     $this->container->getParameter('notification_server')
  1522.                 );
  1523.                 if ($retData['sendCards'] == 1) {
  1524.                     $cardList = array();
  1525.                     $cards $em->getRepository('CompanyGroupBundle\\Entity\\BeeCode')
  1526.                         ->findBy(
  1527.                             array(
  1528.                                 'id' => $retData['cardIds']
  1529.                             )
  1530.                         );
  1531.                     foreach ($cards as $card) {
  1532.                         $cardList[] = array(
  1533.                             'id' => $card->getId(),
  1534.                             'printed' => $card->getPrinted(),
  1535.                             'amount' => $card->getAmount(),
  1536.                             'coinCount' => $card->getCoinCount(),
  1537.                             'pin' => $card->getPin(),
  1538.                             'serial' => $card->getSerial(),
  1539.                         );
  1540.                     }
  1541.                     $receiverEmail $retData['receiverEmail'];
  1542.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1543.                         $bodyHtml '';
  1544.                         $bodyTemplate 'ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig';
  1545.                         $bodyData = array(
  1546.                             'cardList' => $cardList,
  1547. //                        'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
  1548. //                        'email' => $userName,
  1549. //                        'password' => $newApplicant->getPassword(),
  1550.                         );
  1551.                         $attachments = [];
  1552.                         $forwardToMailAddress $receiverEmail;
  1553. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1554.                         $new_mail $this->get('mail_module');
  1555.                         $new_mail->sendMyMail(array(
  1556.                             'senderHash' => '_CUSTOM_',
  1557.                             //                        'senderHash'=>'_CUSTOM_',
  1558.                             'forwardToMailAddress' => $forwardToMailAddress,
  1559.                             'subject' => 'Digital Bee Card Delivery',
  1560. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1561.                             'attachments' => $attachments,
  1562.                             'toAddress' => $forwardToMailAddress,
  1563.                             'fromAddress' => 'delivery@buddybee.eu',
  1564.                             'userName' => 'delivery@buddybee.eu',
  1565.                             'password' => 'Honeybee@0112',
  1566.                             'smtpServer' => 'smtp.hostinger.com',
  1567.                             'smtpPort' => 465,
  1568. //                        'encryptionMethod' => 'tls',
  1569.                             'encryptionMethod' => 'ssl',
  1570. //                            'emailBody' => $bodyHtml,
  1571.                             'mailTemplate' => $bodyTemplate,
  1572.                             'templateData' => $bodyData,
  1573. //                        'embedCompanyImage' => 1,
  1574. //                        'companyId' => $companyId,
  1575. //                        'companyImagePath' => $company_data->getImage()
  1576.                         ));
  1577.                         foreach ($cards as $card) {
  1578.                             $card->setPrinted(1);
  1579.                         }
  1580.                         $em->flush();
  1581.                     }
  1582.                     return new JsonResponse(
  1583.                         array(
  1584.                             'success' => true
  1585.                         )
  1586.                     );
  1587.                 }
  1588.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  1589.                 $meetingId $retData['meetingId'];
  1590.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  1591.                     $billerDetails = [];
  1592.                     $billToDetails = [];
  1593.                     $invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1594.                         ->findOneBy(
  1595.                             array(
  1596.                                 'Id' => $invoiceId,
  1597.                             )
  1598.                         );;
  1599.                     if ($invoice) {
  1600.                         $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1601.                             ->findOneBy(
  1602.                                 array(
  1603.                                     'applicantId' => $invoice->getBillerId(),
  1604.                                 )
  1605.                             );
  1606.                         $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1607.                             ->findOneBy(
  1608.                                 array(
  1609.                                     'applicantId' => $invoice->getBillToId(),
  1610.                                 )
  1611.                             );
  1612.                     }
  1613.                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1614.                     $bodyData = array(
  1615.                         'page_title' => 'Invoice',
  1616. //            'studentDetails' => $student,
  1617.                         'billerDetails' => $billerDetails,
  1618.                         'billToDetails' => $billToDetails,
  1619.                         'invoice' => $invoice,
  1620.                         'currencyList' => BuddybeeConstant::$currency_List,
  1621.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1622.                     );
  1623.                     $attachments = [];
  1624.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  1625. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1626.                     $new_mail $this->get('mail_module');
  1627.                     $new_mail->sendMyMail(array(
  1628.                         'senderHash' => '_CUSTOM_',
  1629.                         //                        'senderHash'=>'_CUSTOM_',
  1630.                         'forwardToMailAddress' => $forwardToMailAddress,
  1631.                         'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  1632. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1633.                         'attachments' => $attachments,
  1634.                         'toAddress' => $forwardToMailAddress,
  1635.                         'fromAddress' => 'no-reply@buddybee.eu',
  1636.                         'userName' => 'no-reply@buddybee.eu',
  1637.                         'password' => 'Honeybee@0112',
  1638.                         'smtpServer' => 'smtp.hostinger.com',
  1639.                         'smtpPort' => 465,
  1640. //                            'emailBody' => $bodyHtml,
  1641.                         'mailTemplate' => $bodyTemplate,
  1642.                         'templateData' => $bodyData,
  1643.                         'embedCompanyImage' => 0,
  1644.                         'companyId' => 0,
  1645.                         'companyImagePath' => ''
  1646. //                        'embedCompanyImage' => 1,
  1647. //                        'companyId' => $companyId,
  1648. //                        'companyImagePath' => $company_data->getImage()
  1649.                     ));
  1650.                 }
  1651. //
  1652.                 if ($meetingId != 0) {
  1653.                     $url $this->generateUrl(
  1654.                         'consultancy_session'
  1655.                     );
  1656. //                if($request->query->get('autoRedirect',1))
  1657. //                    return $this->redirect($url . '/' . $meetingId);
  1658.                     $redirectUrl $url '/' $meetingId;
  1659.                 } else {
  1660.                     $url $this->generateUrl(
  1661.                         'buddybee_dashboard'
  1662.                     );
  1663. //                if($request->query->get('autoRedirect',1))
  1664. //                    return $this->redirect($url);
  1665.                     $redirectUrl $url;
  1666.                 }
  1667.             }
  1668.             return $this->render('ApplicationBundle:pages/stripe:success.html.twig', array(
  1669.                 'page_title' => 'Success',
  1670.                 'meetingId' => $meetingId,
  1671.                 'autoRedirect' => $autoRedirect,
  1672.                 'redirectUrl' => $redirectUrl,
  1673.             ));
  1674.         }
  1675.         else if($systemType=='_BUDDYBEE_') {
  1676.             if ($encData != '') {
  1677.                 $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  1678.                 if (isset($encryptedData['invoiceId']))
  1679.                     $invoiceId $encryptedData['invoiceId'];
  1680.                 if (isset($encryptedData['autoRedirect']))
  1681.                     $autoRedirect $encryptedData['autoRedirect'];
  1682.             } else {
  1683.                 $invoiceId $request->query->get('invoiceId'0);
  1684.                 $meetingId 0;
  1685.                 $autoRedirect $request->query->get('autoRedirect'1);
  1686.                 $redirectUrl '';
  1687.             }
  1688.             if ($invoiceId != 0) {
  1689.                 $retData Buddybee::ProcessEntityInvoice($em$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  1690.                     $this->container->getParameter('notification_enabled'),
  1691.                     $this->container->getParameter('notification_server')
  1692.                 );
  1693.                 if ($retData['sendCards'] == 1) {
  1694.                     $cardList = array();
  1695.                     $cards $em->getRepository('CompanyGroupBundle\\Entity\\BeeCode')
  1696.                         ->findBy(
  1697.                             array(
  1698.                                 'id' => $retData['cardIds']
  1699.                             )
  1700.                         );
  1701.                     foreach ($cards as $card) {
  1702.                         $cardList[] = array(
  1703.                             'id' => $card->getId(),
  1704.                             'printed' => $card->getPrinted(),
  1705.                             'amount' => $card->getAmount(),
  1706.                             'coinCount' => $card->getCoinCount(),
  1707.                             'pin' => $card->getPin(),
  1708.                             'serial' => $card->getSerial(),
  1709.                         );
  1710.                     }
  1711.                     $receiverEmail $retData['receiverEmail'];
  1712.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1713.                         $bodyHtml '';
  1714.                         $bodyTemplate 'ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig';
  1715.                         $bodyData = array(
  1716.                             'cardList' => $cardList,
  1717. //                        'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
  1718. //                        'email' => $userName,
  1719. //                        'password' => $newApplicant->getPassword(),
  1720.                         );
  1721.                         $attachments = [];
  1722.                         $forwardToMailAddress $receiverEmail;
  1723. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1724.                         $new_mail $this->get('mail_module');
  1725.                         $new_mail->sendMyMail(array(
  1726.                             'senderHash' => '_CUSTOM_',
  1727.                             //                        'senderHash'=>'_CUSTOM_',
  1728.                             'forwardToMailAddress' => $forwardToMailAddress,
  1729.                             'subject' => 'Digital Bee Card Delivery',
  1730. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1731.                             'attachments' => $attachments,
  1732.                             'toAddress' => $forwardToMailAddress,
  1733.                             'fromAddress' => 'delivery@buddybee.eu',
  1734.                             'userName' => 'delivery@buddybee.eu',
  1735.                             'password' => 'Honeybee@0112',
  1736.                             'smtpServer' => 'smtp.hostinger.com',
  1737.                             'smtpPort' => 465,
  1738. //                        'encryptionMethod' => 'tls',
  1739.                             'encryptionMethod' => 'ssl',
  1740. //                            'emailBody' => $bodyHtml,
  1741.                             'mailTemplate' => $bodyTemplate,
  1742.                             'templateData' => $bodyData,
  1743. //                        'embedCompanyImage' => 1,
  1744. //                        'companyId' => $companyId,
  1745. //                        'companyImagePath' => $company_data->getImage()
  1746.                         ));
  1747.                         foreach ($cards as $card) {
  1748.                             $card->setPrinted(1);
  1749.                         }
  1750.                         $em->flush();
  1751.                     }
  1752.                     return new JsonResponse(
  1753.                         array(
  1754.                             'success' => true
  1755.                         )
  1756.                     );
  1757.                 }
  1758.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  1759.                 $meetingId $retData['meetingId'];
  1760.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  1761.                     $billerDetails = [];
  1762.                     $billToDetails = [];
  1763.                     $invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  1764.                         ->findOneBy(
  1765.                             array(
  1766.                                 'Id' => $invoiceId,
  1767.                             )
  1768.                         );;
  1769.                     if ($invoice) {
  1770.                         $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1771.                             ->findOneBy(
  1772.                                 array(
  1773.                                     'applicantId' => $invoice->getBillerId(),
  1774.                                 )
  1775.                             );
  1776.                         $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1777.                             ->findOneBy(
  1778.                                 array(
  1779.                                     'applicantId' => $invoice->getBillToId(),
  1780.                                 )
  1781.                             );
  1782.                     }
  1783.                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  1784.                     $bodyData = array(
  1785.                         'page_title' => 'Invoice',
  1786. //            'studentDetails' => $student,
  1787.                         'billerDetails' => $billerDetails,
  1788.                         'billToDetails' => $billToDetails,
  1789.                         'invoice' => $invoice,
  1790.                         'currencyList' => BuddybeeConstant::$currency_List,
  1791.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  1792.                     );
  1793.                     $attachments = [];
  1794.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  1795. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1796.                     $new_mail $this->get('mail_module');
  1797.                     $new_mail->sendMyMail(array(
  1798.                         'senderHash' => '_CUSTOM_',
  1799.                         //                        'senderHash'=>'_CUSTOM_',
  1800.                         'forwardToMailAddress' => $forwardToMailAddress,
  1801.                         'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  1802. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1803.                         'attachments' => $attachments,
  1804.                         'toAddress' => $forwardToMailAddress,
  1805.                         'fromAddress' => 'no-reply@buddybee.eu',
  1806.                         'userName' => 'no-reply@buddybee.eu',
  1807.                         'password' => 'Honeybee@0112',
  1808.                         'smtpServer' => 'smtp.hostinger.com',
  1809.                         'smtpPort' => 465,
  1810. //                            'emailBody' => $bodyHtml,
  1811.                         'mailTemplate' => $bodyTemplate,
  1812.                         'templateData' => $bodyData,
  1813.                         'embedCompanyImage' => 0,
  1814.                         'companyId' => 0,
  1815.                         'companyImagePath' => ''
  1816. //                        'embedCompanyImage' => 1,
  1817. //                        'companyId' => $companyId,
  1818. //                        'companyImagePath' => $company_data->getImage()
  1819.                     ));
  1820.                 }
  1821. //
  1822.                 if ($meetingId != 0) {
  1823.                     $url $this->generateUrl(
  1824.                         'consultancy_session'
  1825.                     );
  1826. //                if($request->query->get('autoRedirect',1))
  1827. //                    return $this->redirect($url . '/' . $meetingId);
  1828.                     $redirectUrl $url '/' $meetingId;
  1829.                 } else {
  1830.                     $url $this->generateUrl(
  1831.                         'buddybee_dashboard'
  1832.                     );
  1833. //                if($request->query->get('autoRedirect',1))
  1834. //                    return $this->redirect($url);
  1835.                     $redirectUrl $url;
  1836.                 }
  1837.             }
  1838.             return $this->render('ApplicationBundle:pages/stripe:success.html.twig', array(
  1839.                 'page_title' => 'Success',
  1840.                 'meetingId' => $meetingId,
  1841.                 'autoRedirect' => $autoRedirect,
  1842.                 'redirectUrl' => $redirectUrl,
  1843.             ));
  1844.         }
  1845.     }
  1846.     public function BkashCallbackAction(Request $request$encData '')
  1847.     {
  1848.         $em $this->getDoctrine()->getManager('company_group');
  1849.         $invoiceId 0;
  1850.         $session $request->getSession();
  1851.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  1852.         $paymentId $request->query->get('paymentID'0);
  1853.         $status $request->query->get('status'0);
  1854.         if ($status == 'success') {
  1855.             $paymentID $paymentId;
  1856.             $gatewayInvoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->findOneBy(
  1857.                 array(
  1858.                     'gatewayPaymentId' => $paymentId,
  1859.                     'isProcessed' => [02]
  1860.                 ));
  1861.             if ($gatewayInvoice) {
  1862.                 $invoiceId $gatewayInvoice->getId();
  1863.                 $justNow = new \DateTime();
  1864.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  1865.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  1866.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  1867.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  1868.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  1869.                 $justNowTs $justNow->format('U');
  1870.                 if ($gatewayInvoice->getGatewayIdTokenExpireTs() <= $justNowTs) {
  1871.                     $refresh_token $gatewayInvoice->getGatewayIdRefreshToken();
  1872.                     $request_data = array(
  1873.                         'app_key' => $app_key_value,
  1874.                         'app_secret' => $app_secret_value,
  1875.                         'refresh_token' => $refresh_token
  1876.                     );
  1877.                     $url curl_init($baseUrl '/tokenized/checkout/token/refresh');
  1878.                     $request_data_json json_encode($request_data);
  1879.                     $header = array(
  1880.                         'Content-Type:application/json',
  1881.                         'username:' $username_value,
  1882.                         'password:' $password_value
  1883.                     );
  1884.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  1885.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  1886.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  1887.                     curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  1888.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  1889.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  1890.                     $tokenData json_decode(curl_exec($url), true);
  1891.                     curl_close($url);
  1892.                     $justNow = new \DateTime();
  1893.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  1894.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  1895.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  1896.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  1897.                     $em->flush();
  1898.                 }
  1899.                 $auth $gatewayInvoice->getGatewayIdToken();;
  1900.                 $post_token = array(
  1901.                     'paymentID' => $paymentID
  1902.                 );
  1903. //                $url = curl_init();
  1904.                 $url curl_init($baseUrl '/tokenized/checkout/execute');
  1905.                 $posttoken json_encode($post_token);
  1906.                 $header = array(
  1907.                     'Content-Type:application/json',
  1908.                     'Authorization:' $auth,
  1909.                     'X-APP-Key:' $app_key_value
  1910.                 );
  1911. //                curl_setopt_array($url, array(
  1912. //                    CURLOPT_HTTPHEADER => $header,
  1913. //                    CURLOPT_RETURNTRANSFER => 1,
  1914. //                    CURLOPT_URL => $baseUrl . '/tokenized/checkout/execute',
  1915. //
  1916. //                    CURLOPT_FOLLOWLOCATION => 1,
  1917. //                    CURLOPT_POST => 1,
  1918. //                    CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
  1919. //                    CURLOPT_POSTFIELDS => http_build_query($post_token)
  1920. //                ));
  1921.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  1922.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  1923.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  1924.                 curl_setopt($urlCURLOPT_POSTFIELDS$posttoken);
  1925.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  1926.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  1927.                 $resultdata curl_exec($url);
  1928.                 curl_close($url);
  1929.                 $obj json_decode($resultdatatrue);
  1930. //                return new JsonResponse(array(
  1931. //                    'obj' => $obj,
  1932. //                    'url' => $baseUrl . '/tokenized/checkout/execute',
  1933. //                    'header' => $header,
  1934. //                    'paymentID' => $paymentID,
  1935. //                    'posttoken' => $posttoken,
  1936. //                ));
  1937. //                                return new JsonResponse($obj);
  1938.                 if (isset($obj['statusCode'])) {
  1939.                     if ($obj['statusCode'] == '0000') {
  1940.                         $gatewayInvoice->setGatewayTransId($obj['trxID']);
  1941.                         $em->flush();
  1942.                         return $this->redirectToRoute("payment_gateway_success", ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  1943.                             'invoiceId' => $invoiceId'autoRedirect' => 1
  1944.                         ))),
  1945.                             'hbeeSessionToken' => $session->get('token'0)]);
  1946.                     } else {
  1947.                         return $this->redirectToRoute("payment_gateway_cancel", [
  1948.                             'msg' => isset($obj['statusMessage']) ? $obj['statusMessage'] : (isset($obj['errorMessage']) ? $obj['errorMessage'] : 'Payment Failed')
  1949.                         ]);
  1950.                     }
  1951.                 }
  1952.             } else {
  1953.                 return $this->redirectToRoute("payment_gateway_cancel", [
  1954.                     'msg' => isset($obj['statusMessage']) ? $obj['statusMessage'] : (isset($obj['errorMessage']) ? $obj['errorMessage'] : 'Payment Failed')
  1955.                 ]);
  1956.             }
  1957.         } else {
  1958.             return $this->redirectToRoute("payment_gateway_cancel", [
  1959.                 'msg' => isset($obj['statusMessage']) ? $obj['statusMessage'] : (isset($obj['errorMessage']) ? $obj['errorMessage'] : 'The Payment was unsuccessful')
  1960.             ]);
  1961.         }
  1962.     }
  1963.     public function PaymentGatewayCancelAction(Request $request$msg 'The Payment was unsuccessful'$encData '')
  1964.     {
  1965.         $em $this->getDoctrine()->getManager('company_group');
  1966. //        $consultantDetail = $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(array());
  1967.         $session $request->getSession();
  1968.         if ($msg == '')
  1969.             $msg $request->query->get('msg'$request->request->get('msg''The Payment was unsuccessful'));
  1970.         return $this->render('ApplicationBundle:pages/stripe:cancel.html.twig', array(
  1971.             'page_title' => 'Success',
  1972.             'msg' => $msg,
  1973.         ));
  1974.     }
  1975.     public function ConsultancyHomePageAction(Request $request)
  1976.     {
  1977. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  1978. //            'page_title' => 'BuddyBee Home',
  1979. //        ));
  1980.         $session $request->getSession();
  1981.         $em_goc $this->getDoctrine()->getManager('company_group');
  1982.         if ($request->query->has('convertToAdmin')) {
  1983.             $session $request->getSession();
  1984.             MiscActions::ConvertCurrentUserToAdmin($em_goc$session);
  1985.         }
  1986.         if($session->get(UserConstants::USER_ID,0) !=0) {
  1987.             if ($session->get('buddybeeAdminLevel'0) > 1)
  1988.                 return $this->redirectToRoute("buddybee_admin_dashboard", [
  1989.                 ]);
  1990.             elseif ($session->get('isConsultant') == 1)
  1991.                 return $this->redirectToRoute("consultant_dashboard", [
  1992.                 ]);
  1993.             else
  1994.                 return $this->redirectToRoute("student_dashboard", [
  1995.                 ]);
  1996.         }
  1997.         else return $this->render('@Buddybee/pages/consultancyHomePageNew.html.twig', array(
  1998.             'page_title' => 'BuddyBee Home',
  1999.         ));
  2000.     }
  2001.     public function BuddyBeePrivacyPolicyAction()
  2002.     {
  2003. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  2004. //            'page_title' => 'BuddyBee Home',
  2005. //        ));
  2006.         return $this->render('@Buddybee/pages/privacy_policy.html.twig', array(
  2007.             'page_title' => 'Privacy Policy',
  2008.         ));
  2009.     }
  2010.     public function PrivacyPolicyAction()
  2011.     {
  2012. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  2013. //            'page_title' => 'BuddyBee Home',
  2014. //        ));
  2015.         return $this->render('ApplicationBundle:pages/central:privacy_policy.html.twig', array(
  2016.             'page_title' => 'Privacy Policy',
  2017.         ));
  2018.     }
  2019.     public function BuddyBeeTermsOfServiceAction()
  2020.     {
  2021. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  2022. //            'page_title' => 'BuddyBee Home',
  2023. //        ));
  2024.         return $this->render('@Buddybee/pages/terms_of_use.html.twig', array(
  2025.             'page_title' => 'Terms of Service',
  2026.         ));
  2027.     }
  2028.     public function BuddyBeeRefundPolicyAction()
  2029.     {
  2030. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  2031. //            'page_title' => 'BuddyBee Home',
  2032. //        ));
  2033.         return $this->render('@Buddybee/pages/refund_policy.html.twig', array(
  2034.             'page_title' => 'Refund Policy',
  2035.         ));
  2036.     }
  2037.     public function BuddyBeeCancellationPolicyAction()
  2038.     {
  2039. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  2040. //            'page_title' => 'BuddyBee Home',
  2041. //        ));
  2042.         return $this->render('@Buddybee/pages/cancellation_policy.html.twig', array(
  2043.             'page_title' => 'Cancellation Policy',
  2044.         ));
  2045.     }
  2046.     public function ConsultancySearchPageAction(Request $request$ref '')
  2047.     {
  2048.         $em_goc $this->getDoctrine()->getManager('company_group');
  2049.         $topicId $request->query->get('topicId'0);
  2050. //        $qb = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  2051. //            ->createQueryBuilder('m')
  2052. //            ->where("(m.isConsultant = 1 )")
  2053. //            ->andwhere("m.topicMarker like '%_country_%' or m.topicMarker like '%_university_%'");
  2054. //
  2055. //            $qb->andwhere("m.preferredTopicIdsAsConsultant like '%[%' or m.topicMarker like '%_university_%'");
  2056. //        $consultant = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findAll();
  2057.         if ($ref == '_ADMIN_') {
  2058.             $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')
  2059.                 ->createQueryBuilder('m')
  2060.                 ->where("(m.isEvent = 0 or m.isEvent IS NULL   )")
  2061.                 ->andwhere("m.topicMarker like '%_support_%' or m.topicMarker like '%_report_to_admin_%'")
  2062.                 ->andwhere("m.consultancyEnabled =1")
  2063. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  2064. //            ->setParameter('endAt', $endDate->format('U '))
  2065. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  2066.                 ->getQuery()
  2067.                 ->setMaxResults(100)
  2068.                 ->getResult();
  2069.         } else {
  2070.             $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')
  2071.                 ->createQueryBuilder('m')
  2072.                 ->where("(m.isEvent = 0 or m.isEvent IS NULL   )")
  2073.                 ->andwhere("m.topicMarker like '%_country_%' or m.topicMarker like '%_university_%'")
  2074.                 ->andwhere("m.consultancyEnabled =1")
  2075. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  2076. //            ->setParameter('endAt', $endDate->format('U '))
  2077. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  2078.                 ->getQuery()
  2079.                 ->setMaxResults(100)
  2080.                 ->getResult();
  2081.         }
  2082.         if ($request->isMethod('POST') && $request->request->has('returnJson')) {
  2083.             $listData Buddybee::GetConsultantListForAjax($em_goc$request->isMethod('POST') ? 'POST' 'GET'$request->request);
  2084.             if ($request->query->has('dataTableQry')) {
  2085.                 return new JsonResponse(
  2086.                     $listData
  2087.                 );
  2088.             }
  2089.         }
  2090.         return $this->render('@Buddybee/pages/consultancySearchPage.html.twig', array(
  2091.             'page_title' => $ref == '_ADMIN_' 'Meet Admins' 'Find Consultant',
  2092.             'ref' => $ref,
  2093. //            'page_title' => 'Find Consultant',
  2094. //            'consultant' => $consultant,
  2095.             'topic' => $topic,
  2096.             'topicId' => $topicId,
  2097.         ));
  2098.     }
  2099.     public function EventListPageAction(Request $request)
  2100.     {
  2101.         $em_goc $this->getDoctrine()->getManager('company_group');
  2102.         $topicId $request->query->get('topicId'0);
  2103.         $session $request->getSession();
  2104. //        $qb = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  2105. //            ->createQueryBuilder('m')
  2106. //            ->where("(m.isConsultant = 1 )")
  2107. //            ->andwhere("m.topicMarker like '%_country_%' or m.topicMarker like '%_university_%'");
  2108. //
  2109. //            $qb->andwhere("m.preferredTopicIdsAsConsultant like '%[%' or m.topicMarker like '%_university_%'");
  2110.         $userId $session->get(UserConstants::USER_ID0);
  2111.         $applicantDetails $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2112.             array(
  2113.                 'applicantId' => $userId
  2114.             )
  2115.         );
  2116.         $followingEventIds = [];
  2117.         $attendingEventIds = [];
  2118.         $skipEventIds = [];
  2119.         if ($applicantDetails) {
  2120.             $followingEventIds json_decode($applicantDetails->getFollowingEventIds(), true);
  2121.             $attendingEventIds json_decode($applicantDetails->getAttendingEventIds(), true);
  2122.             $skipEventIds json_decode($applicantDetails->getSkipEventIds(), true);
  2123.             if ($followingEventIds == null$followingEventIds = [];
  2124.             if ($attendingEventIds == null$attendingEventIds = [];
  2125.             if ($skipEventIds == null$skipEventIds = [];
  2126.         }
  2127.         return $this->render('@Buddybee/pages/event_list_page.html.twig', array(
  2128.             'page_title' => 'Event List',
  2129.             'applicantId' => $userId,
  2130.             'followingEventIds' => $followingEventIds,
  2131.             'attendingEventIds' => $attendingEventIds,
  2132.             'skipEventIds' => $skipEventIds,
  2133.         ));
  2134.     }
  2135.     public function ConsultancyServicesPageAction(Request $request)
  2136.     {
  2137.         $em_goc $this->getDoctrine()->getManager('company_group');
  2138.         $service_list = [
  2139.             ['text' => 'One by one counselling''image' => '/images/service_icons/service_1.png'],
  2140.             ['text' => 'University Application''image' => '/images/service_icons/service_2.png'],
  2141.             ['text' => 'Offer letter''image' => '/images/service_icons/service_3.png'],
  2142.             ['text' => 'Scholarship Guidance''image' => '/images/service_icons/service_4.png'],
  2143.             ['text' => 'University Interview Arrangements''image' => '/images/service_icons/service_5.png'],
  2144.             ['text' => 'Air ticketing''image' => '/images/service_icons/service_6.png'],
  2145.             ['text' => 'Visa Guidance and Application''image' => '/images/service_icons/service_7.png'],
  2146.             ['text' => 'Overseas Networking''image' => '/images/service_icons/service_8.png'],
  2147.             ['text' => 'Passport and Others Documentation including deadline''image' => '/images/service_icons/service_9.png'],
  2148.             ['text' => 'Banking Guidance(EBL,MTB and CITY Bank are our values partners''image' => '/images/service_icons/service_10.png'],
  2149.             ['text' => 'Visa Extension(if required,while you are in abroad''image' => '/images/service_icons/service_11.png'],
  2150.             ['text' => 'Work Permit Guidance''image' => '/images/service_icons/service_12.png'],
  2151.             ['text' => 'Language Courses''image' => '/images/service_icons/service_13.png'],
  2152.             ['text' => 'Course selection''image' => '/images/service_icons/service_14.png'],
  2153.             ['text' => 'Accomodation Guidance''image' => '/images/service_icons/service_15.png'],
  2154.             ['text' => 'ETC''image' => '/images/service_icons/service_16.png'],
  2155.         ];
  2156.         return $this->render('@Buddybee/pages/consultancy_services.html.twig', array(
  2157.             'page_title' => 'Our Services',
  2158.             'service_list' => $service_list,
  2159.         ));
  2160.     }
  2161.     public function ConsultantProfileAction(Request $request$id)
  2162.     {
  2163.         $em $this->getDoctrine()->getManager();
  2164.         //$topic = $em->getRepository('ApplicationBundle\\Entity\\ConsultancyTopic')->findAll();
  2165.         $em_goc $this->getDoctrine()->getManager('company_group');
  2166.         $session $request->getSession();
  2167.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  2168. //        $review = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityReview')->findBy(
  2169. //            array(
  2170. //                'consultantId' => $id
  2171. //            )
  2172. //        );
  2173.         $review = [];
  2174.         $autoSelectTopicId $request->query->get('topicId'0);
  2175. //        foreach($review )
  2176. //        $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findOneBy(array(
  2177. //            'consultantId' => $id
  2178. //        ));
  2179.         $lifetimeCoinsBalanceUser 0;
  2180.         $applicantId $request->request->get('applicantId'$request->query->get('applicantId'$session->get(UserConstants::USER_ID)));
  2181.         $meetingStartDtUTCZONE = new \DateTime();
  2182.         $from = clone $meetingStartDtUTCZONE;
  2183.         $to = new \DateTime('@' . ((60 20) + $meetingStartDtUTCZONE->format('U')));
  2184.         $calLink Link::create('Consultancy Session on Buddybee on :LOL'$from$to)
  2185.             ->description('Consultancy Session on Buddybee on  ')
  2186.             ->address('Online');
  2187.         if ($applicantId != 0) {
  2188.             $applicant $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  2189.                 ->findOneBy(
  2190.                     array(//                    'targetId'=>$request->request->get('targetId',0)
  2191.                         'applicantId' => $applicantId
  2192.                     )
  2193.                 );
  2194.             if ($applicant) {
  2195.                 $lifetimeCoinsBalanceUser = ($applicant->getSessionCountBalance()) + ($applicant->getTotalSessionUsed());
  2196.             }
  2197.         }
  2198. //        if ($consultantDetails) {
  2199. //            if ($session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL, 0) < 10) {
  2200. //                if ($consultantDetails->getApplicantId() == $session->get(UserConstants::USER_ID, 0) || $consultantDetails->getAssignedSalesPersonId() == $session->get(UserConstants::USER_ID, -1) || $consultantDetails->getAssignedSalesPersonId() == null) {
  2201. //
  2202. //                } else {
  2203. //                    return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  2204. //                        'page_title' => '404 Not Found',
  2205. //
  2206. //                    ));
  2207. //                }
  2208. //
  2209. //            } else {
  2210. //
  2211. //            }
  2212. //        } else
  2213. //            return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  2214. //                'page_title' => '404 Not Found',
  2215. //
  2216. //            ));
  2217.         return $this->render('@Buddybee/pages/consultantProfile.html.twig', array(
  2218.             'page_title' => 'Consultant Profile',
  2219.             'og_title' => 'Meet ' $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname() . ' on BuddyBee',
  2220.             'og_description' => $consultantDetails->getSummaryText(),
  2221. //            'og_description' => $consultantDetails->getFirstname().' '.$consultantDetails->getLastname() .' is one of the finest consultant on buddybee to help you with ' ,
  2222.             'og_image' => $consultantDetails->getImage(),
  2223.             'consultantDetails' => $consultantDetails,
  2224.             'calLinkText' => $calLink->google(),
  2225.             'education' => json_decode($consultantDetails->getEducationData(), true),
  2226.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  2227.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  2228.             'autoSelectTopicId' => $autoSelectTopicId,
  2229.             'lifetimeCoinsBalanceUser' => $lifetimeCoinsBalanceUser,
  2230. //            'schedule' => $consultantSchedule,
  2231. //            'timeSchedule' => $consultantSchedule != null ? json_decode($consultantSchedule->getTimeSchedule(), true) : [],
  2232.             'review' => $review
  2233.         ));
  2234.     }
  2235.     public function StudentProfileAction(Request $request$id)
  2236.     {
  2237.         $em $this->getDoctrine()->getManager();
  2238.         //$topic = $em->getRepository('ApplicationBundle\\Entity\\ConsultancyTopic')->findAll();
  2239.         $em_goc $this->getDoctrine()->getManager('company_group');
  2240.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
  2241. //        $review = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityReview')->findBy(
  2242. //            array(
  2243. //                'consultantId' => $id
  2244. //            )
  2245. //        );
  2246.         $review = [];
  2247.         $autoSelectTopicId $request->query->get('topicId'0);
  2248. //        foreach($review )
  2249. //        $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findOneBy(array(
  2250. //            'consultantId' => $id
  2251. //        ));
  2252.         $session $request->getSession();
  2253.         if ($consultantDetails ) {
  2254.             if ($session->get(UserConstants::USER_ID0) != 0  && $session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL0) < 10 && $session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL0) >1) {
  2255.                 if ($consultantDetails->getApplicantId() == $session->get(UserConstants::USER_ID0) || $consultantDetails->getAssignedSalesRepresentativeId() == $session->get(UserConstants::USER_ID, -1) || $consultantDetails->getAssignedSalesRepresentativeId() == null) {
  2256.                 } else {
  2257.                     return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  2258.                         'page_title' => '404 Not Found',
  2259.                     ));
  2260.                 }
  2261.             } else {
  2262.             }
  2263.         } else
  2264.             return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  2265.                 'page_title' => '404 Not Found',
  2266.             ));
  2267.         return $this->render('@Buddybee/pages/studentProfile.html.twig', array(
  2268.             'page_title' => 'Student Profile',
  2269.             'og_title' => 'Meet ' $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname() . ' on BuddyBee',
  2270.             'og_description' => $consultantDetails->getSummaryText(),
  2271. //            'og_description' => $consultantDetails->getFirstname().' '.$consultantDetails->getLastname() .' is one of the finest consultant on buddybee to help you with ' ,
  2272.             'og_image' => $consultantDetails->getImage(),
  2273.             'consultantDetails' => $consultantDetails,
  2274.             'education' => json_decode($consultantDetails->getEducationData(), true),
  2275.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  2276.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  2277.             'autoSelectTopicId' => 0,
  2278. //            'schedule' => $consultantSchedule,
  2279. //            'timeSchedule' => $consultantSchedule != null ? json_decode($consultantSchedule->getTimeSchedule(), true) : [],
  2280.             'review' => $review
  2281.         ));
  2282.     }
  2283.     public function getTopicSessionAction($id)
  2284.     {
  2285.         $em $this->getDoctrine()->getManager('company_group');
  2286.         $topic $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->find($id);
  2287.         $sessions json_decode($topic->getSessionData(), true);
  2288.         if ($sessions == null)
  2289.             $sessions = [];
  2290.         $sessionsArray = [];
  2291.         $sessionNames BuddybeeConstant::$sessionName;
  2292.         foreach ($sessions as $key => $s) {
  2293.             $sessionsArray[] = array(
  2294.                 'value' => $s['sessionId'],
  2295.                 'id' => $s['sessionId'],
  2296.                 'text' => (isset($sessionNames[$s['sessionId']]) ? $sessionNames[$s['sessionId']] : '') . ' - ' . (isset($s['sessionYear']) ? $s['sessionYear'] : ''),
  2297.                 'name' => (isset($sessionNames[$s['sessionId']]) ? $sessionNames[$s['sessionId']] : '') . ' - ' . (isset($s['sessionYear']) ? $s['sessionYear'] : ''),
  2298.             );
  2299.         }
  2300.         return new JsonResponse(
  2301.             array(
  2302.                 'success' => true,
  2303.                 'sessions' => $sessions,
  2304.                 'sessionsArray' => $sessionsArray
  2305.             )
  2306.         );
  2307.     }
  2308.     public function getConsultantSchedulesAction(Request $request)
  2309.     {
  2310.         $em $this->getDoctrine()->getManager('company_group');
  2311.         if ($request->request->get('consultantId''') == '')
  2312.             return new JsonResponse(
  2313.                 array(
  2314.                     'success' => false,
  2315.                     'data' => [],
  2316.                     'reloadCalendar' => $request->request->get('reloadCalendar'0),
  2317.                     'msg' => 'No Schedule available',
  2318.                 )
  2319.             );
  2320.         $data MiscActions::GetConsultantSchedules($em,
  2321.             $request->request->get('consultantId'''),
  2322.             $request->request->get('startDateStr'''),
  2323.             $request->request->get('endDateStr'''),
  2324.             $request->request->get('durationMin'90),
  2325.             $request->request->get('options', [])
  2326.         );
  2327.         if (!empty($data['scheduleList']))
  2328.             return new JsonResponse(
  2329.                 array(
  2330.                     'success' => true,
  2331.                     'data' => $data,
  2332.                     'hbeeErrorCode' => '',
  2333.                     'reloadCalendar' => $request->request->get('reloadCalendar'0),
  2334.                     'msg' => '',
  2335.                 )
  2336.             );
  2337.         else
  2338.             return new JsonResponse(
  2339.                 array(
  2340.                     'success' => false,
  2341.                     'hbeeErrorCode' => BuddybeeConstant::ERROR_NO_SCHEDULE_FOUND,
  2342.                     'data' => $data,
  2343.                     'reloadCalendar' => $request->request->get('reloadCalendar'0),
  2344.                     'msg' => 'No Schedule available',
  2345.                 )
  2346.             );
  2347.     }
  2348.     public function RescheduleConsultancySessionAction(Request $request)
  2349.     {
  2350.         $em $this->getDoctrine()->getManager('company_group');
  2351.         $data Buddybee::ReScheduleConsultancySchedule($em,
  2352.             $request->request->get('redeemOnly'0),
  2353.             $request->request->get('meetingId'0),
  2354.             $request->request->get('consultantId'0),
  2355.             $request->request->get('studentId'0),
  2356.             $request->request->get('startDateTs'''),
  2357.             $request->request->get('consumedSessionCount''_UNCHANGED_'),
  2358.             $request->request->get('options', []),
  2359.             $this->container->getParameter('notification_enabled'),
  2360.             $this->container->getParameter('notification_server')
  2361.         );
  2362.         return new JsonResponse($data);
  2363.     }
  2364.     public function ConfirmConsultancySessionAction(Request $request)
  2365.     {
  2366.         $em $this->getDoctrine()->getManager('company_group');
  2367.         $data MiscActions::ConfirmConsultancySchedule($em,
  2368.             $request->request->get('confirmStatus'0),
  2369.             $request->request->get('meetingId'0),
  2370.             $request->request->get('consultantId'0),
  2371.             $request->request->get('studentId'0),
  2372.             $request->request->get('confirmType''_CONSULTANT_'),
  2373.             $request->request->get('redeemAction'0)
  2374.         );
  2375.         return new JsonResponse($data);
  2376.     }
  2377.     public function ModifyDocumentEvaluationStatusAction(Request $request)
  2378.     {
  2379.         $em $this->getDoctrine()->getManager('company_group');
  2380.         $data MiscActions::ModifyDocumentStatus(
  2381.             $em,
  2382.             $request->request->get('applicantId'0),
  2383.             $request->request->get('feedbackDocumentId'0),
  2384.             $request->request->get('docStatusTag'1),
  2385.             $request->request->get('topicId'0),
  2386.             $request->request->get('docComment''')
  2387.         );
  2388.         return new JsonResponse(
  2389.             array(
  2390.                 'success' => $data,
  2391.                 'docId' => $request->request->get('feedbackDocumentId'0),
  2392.                 'docStatusTag' => $request->request->get('docStatusTag'0),
  2393.                 'docComment' => $request->request->get('docComment'0),
  2394.             )
  2395.         );
  2396.     }
  2397.     public function AddBeeCardTemporaryBookingAction(Request $request)
  2398.     {
  2399.         $em $this->getDoctrine()->getManager('company_group');
  2400.         $data MiscActions::AddBeeCardTemporaryBooking(
  2401.             $em,
  2402.             $request->request->get('cardIds', []),
  2403.             $request->request->get('cardOptionsByCoinCount', [
  2404. //            100=>['coinCount'=>100, 'qty'=>9]
  2405.             ]),
  2406.             $request->request->get('retailerId'0),
  2407.             $request->request->get('applicantId'0),
  2408.             $request->request->get('createIfNeeded'0)
  2409.         );
  2410.         return new JsonResponse($data);
  2411.     }
  2412.     public function AddConsultancySessionTemporaryBookingAction(Request $request)
  2413.     {
  2414.         $em $this->getDoctrine()->getManager('company_group');
  2415.         $data MiscActions::AddTemporaryBooking(
  2416.             $em,
  2417.             $request->request->get('topicId'''),
  2418.             $request->request->get('scheduledTimeTs'''),
  2419.             $request->request->get('consultantId'0),
  2420.             $request->request->get('studentId'0),
  2421.             $request->request->get('duration'90),
  2422.             $request->request->get('forcedScheduleDt''')
  2423.         );
  2424.         if ($data)
  2425.             return new JsonResponse(
  2426.                 array(
  2427.                     'success' => true,
  2428.                     'data' => $data,
  2429.                     'scheduledTimeTs' => $data['ts'],
  2430.                 )
  2431.             );
  2432.         else
  2433.             return new JsonResponse(
  2434.                 array(
  2435.                     'success' => false,
  2436.                     'data' => $data,
  2437.                     'scheduledTimeTs' => 0,
  2438.                 )
  2439.             );
  2440.     }
  2441.     public function AddEntityTicketAction(Request $request$id 0)
  2442.     {
  2443.         $em $this->getDoctrine()->getManager('company_group');
  2444.         $options = array(
  2445.             'title' => $request->request->get('title''<no title>'),
  2446.             'ticketBody' => $request->request->get('ticketBody''<no body>'),
  2447.             'replyTo' => $request->request->get('replyTo'null),
  2448.             'ticketMarkerHash' => $request->request->get('ticketMarkerHash'''),
  2449.             'email' => $request->request->get('email'''),
  2450.             'phone' => $request->request->get('phone'''),
  2451.             'name' => $request->request->get('name'''),
  2452.             'preferredContactMethod' => $request->request->get('preferredContactMethod'1),
  2453.             'ticketAssignedDate' => $request->request->get('ticketAssignedDate'''),
  2454.             'userId' => $request->request->get('userId'0),
  2455.             'type' => $request->request->get('type'90),
  2456.             'entity' => $request->request->get('entity'''),
  2457.             'entityId' => $request->request->get('entityId'''),
  2458.             'meetingId' => $request->request->get('meetingId'0),
  2459.             'applicantId' => $request->request->get('applicantId'0),
  2460.             'expired' => $request->request->get('expired'0),
  2461.             'urgency' => $request->request->get('urgency'1),
  2462.             'attachments' => $request->request->get('attachments', []),
  2463.         );
  2464.         $generatedData MiscActions::GenerateEntityTicket($em$options$request);
  2465.         $cardList $generatedData['data'];
  2466.         return new JsonResponse($generatedData);
  2467.     }
  2468.     public function AddInfoFromChatbotAction(Request $request$queryStr '')
  2469.     {
  2470.         $em_goc $this->getDoctrine()->getManager('company_group');
  2471.         $session $request->getSession();
  2472.         $thisUserId 3;
  2473.         $data = array(
  2474.             'success' => false,
  2475.             'id' => 0
  2476.         );
  2477.         if ($request->isMethod('POST')) {
  2478.             ///super login
  2479.             $todayDt = new \DateTime();
  2480. //            $mp='_eco_';
  2481.             $mp $todayDt->format('ym');
  2482.             if ($request->request->get('password') == $mp)
  2483.                 $skipPassword 1;
  2484.             $signUpUserType UserConstants::USER_TYPE_APPLICANT;
  2485.             $pendingInitialCommunication 1;
  2486.             $immediateFollowUpFlag 1;
  2487.             $fbUniqueId $request->request->get('id'$request->query->get('fbUniqueId'''));
  2488.             $preferredCountryId $request->request->get('preferredCountryId'$request->query->get('preferredCountryId'''));
  2489.             $preferredCountryCode $request->request->get('preferredCountryCode'$request->query->get('preferredCountryCode'''));
  2490.             $importantCommTags $request->request->get('importantCommTags'$request->query->get('importantCommTags'''));
  2491.             $applicantSpecificNote $request->request->get('applicantSpecificNote'$request->query->get('applicantSpecificNote'''));
  2492.             $educationText $request->request->get('educationText'$request->query->get('educationText'''));
  2493.             $email $request->request->get('email'$request->query->get('email'''));
  2494.             $phone $request->request->get('phone'$request->query->get('phone'''));
  2495.             $userName $request->request->get('userName'$request->query->get('userName'''));
  2496.             $optInEmail $request->request->get('optin_email'$request->query->get('optin_email'''));
  2497.             $optInPhone $request->request->get('optin_phone'$request->query->get('optin_phone'''));
  2498.             $first_name $request->request->get('first_name'$request->query->get('first_name'''));
  2499.             $last_name $request->request->get('last_name'$request->query->get('last_name'''));
  2500.             $password $request->request->get('password'MiscActions::GenerateRandomCrypto('PSS' microtime(true)));
  2501.             $sendWelcomeEmail $request->request->get('sendWelcomeEmail'0);
  2502.             $isTemporary $request->request->get('isTemporary'1);
  2503.             if ($signUpUserType == UserConstants::USER_TYPE_APPLICANT) {
  2504.                 $oAuthEmail $email;
  2505.                 $oAuthData = [
  2506.                     'email' => $email,
  2507.                     'phone' => $phone,
  2508.                     'uniqueId' => '',
  2509.                     'image' => '',
  2510.                     'emailVerified' => '',
  2511.                     'name' => $first_name ' ' $last_name,
  2512.                     'type' => '0',
  2513.                     'token' => '',
  2514.                 ];
  2515.                 $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2516.                     [
  2517.                         'fbUniqueId' => $fbUniqueId == '' '_THIS_WILL_NEVER_MATCH_' $fbUniqueId,
  2518.                     ]
  2519.                 );
  2520.                 if (!$isApplicantExist)
  2521.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2522.                         [
  2523.                             'email' => $oAuthEmail == '' '_THIS_WILL_NEVER_MATCH_' $oAuthEmail
  2524.                         ]
  2525.                     );
  2526.                 if (!$isApplicantExist)
  2527.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2528.                         [
  2529.                             'email' => $oAuthEmail == '' '_THIS_WILL_NEVER_MATCH_' $oAuthEmail
  2530.                         ]
  2531.                     );
  2532.                 if (!$isApplicantExist)
  2533.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2534.                         [
  2535.                             'username' => $userName == '' '_THIS_WILL_NEVER_MATCH_' $userName
  2536.                         ]
  2537.                     );
  2538.                 if (!$isApplicantExist)
  2539.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2540.                         [
  2541.                             'phone' => $phone == '' '_THIS_WILL_NEVER_MATCH_' $phone
  2542.                         ]
  2543.                     );
  2544.                 if (!$isApplicantExist && $queryStr != '') {
  2545.                     if (strpos($queryStr'@') != false) {
  2546. //                        System::log_it($this->container->getParameter('kernel.root_dir'), $queryStr.' WXISTS',
  2547. //                            'chatbot_log_test', 0); //last er 1 is append
  2548.                         $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2549.                             [
  2550.                                 'email' => $queryStr == '' '_THIS_WILL_NEVER_MATCH_' $queryStr
  2551.                             ]
  2552.                         );
  2553.                         if ($isApplicantExist)
  2554.                             $email $queryStr;
  2555.                     } else {
  2556.                         $sqtr $queryStr;
  2557.                         $sqtr str_ireplace([' ''+''-'], ''$sqtr);
  2558.                         if (is_numeric($sqtr)) {
  2559.                             $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  2560.                                 [
  2561.                                     'phone' => $sqtr == '' '_THIS_WILL_NEVER_MATCH_' $sqtr
  2562.                                 ]
  2563.                             );
  2564.                         }
  2565.                     }
  2566.                 }
  2567.                 if ($queryStr != '') {
  2568.                     if (strpos($queryStr'@') !== false && $email == '') {
  2569.                         $email $queryStr;
  2570.                     } else {
  2571.                         $sqtr $queryStr;
  2572.                         $sqtr str_ireplace([' ''+''-'], ''$sqtr);
  2573.                         if (is_numeric($sqtr) && $phone == '') {
  2574.                             $phone $queryStr;
  2575.                         }
  2576.                     }
  2577.                 }
  2578.                 $oAuthEmail $email;
  2579.                 $newApplicant null;
  2580.                 if ($isApplicantExist) {
  2581.                     $newApplicant $isApplicantExist;
  2582.                 } else if ($phone != '' || $fbUniqueId != '' || $email != '') {
  2583.                     $newApplicant = new EntityApplicantDetails();
  2584.                 }
  2585.                 $img $oAuthData['image'];
  2586.                 if ($newApplicant) {
  2587.                     if ($isApplicantExist) {
  2588.                     } else {
  2589.                         $newApplicant->setLeadCreatedById($thisUserId);    ///9999 =chatbot
  2590. //                        $newApplicant->setEmail($email);
  2591.                         $newApplicant->setAssignedSalesRepresentativeId(null);
  2592.                         $newApplicant->setIsEmailVerified(0);
  2593.                         $newApplicant->setIsPhoneVerified(0);
  2594.                         $newApplicant->setAccountStatus(1);
  2595.                         $newApplicant->setPendingInitialCommunication($pendingInitialCommunication);
  2596.                         $newApplicant->setImmediateFollowUpFlag($immediateFollowUpFlag);
  2597.                         $salt uniqid(mt_rand());
  2598.                         $newApplicant->setSalt($salt);
  2599.                         $newApplicant->setTempPassword($password);
  2600.                         $newApplicant->setTriggerResetPassword(1);
  2601.                         //salt will be username
  2602. //                $this->container->get('sha256salted_encoder')->isPasswordValid($user->getPassword(), $request->request->get('password'), $user->getSalt())
  2603.                         $encodedPassword $this->container->get('sha256salted_encoder')->encodePassword($password$salt);
  2604.                         $newApplicant->setPassword($encodedPassword);
  2605.                         $newApplicant->setImage($img);
  2606.                         $newApplicant->setIsConsultant(0);
  2607.                         $newApplicant->setIsTemporaryEntry($isTemporary);
  2608.                         $newApplicant->setActualRegistrationAt($isTemporary == null : new \DateTime());
  2609.                         $newApplicant->setApplyForConsultant(0);
  2610.                         $newApplicant->setPendingInitialCommunication($pendingInitialCommunication);
  2611.                         $newApplicant->setImmediateFollowUpFlag($immediateFollowUpFlag);
  2612.                     }
  2613.                     if ($img != ''$newApplicant->setImage($img);
  2614.                     if ($userName != ''$newApplicant->setUserName($userName);
  2615.                     if ($email != ''$newApplicant->setEmail($email);
  2616.                     if ($first_name != ''$newApplicant->setFirstname($first_name);
  2617.                     if ($last_name != ''$newApplicant->setLastname($last_name);
  2618.                     if ($oAuthEmail != ''$newApplicant->setOAuthEmail($oAuthEmail);
  2619.                     if ($phone != ''$newApplicant->setPhone($phone);
  2620.                     if ($fbUniqueId != ''$newApplicant->setFbUniqueId($fbUniqueId);
  2621.                     if ($preferredCountryId != '') {
  2622.                         $currIds json_decode($newApplicant->getPreferredCountryIdsAsStudent(), true);
  2623.                         if ($currIds == null$currIds = [];
  2624.                         $currIds[] = $preferredCountryId;
  2625.                         $newApplicant->setPreferredCountryIdsAsStudent(json_encode($currIds));
  2626.                     }
  2627.                     if ($preferredCountryCode != '') {
  2628.                         $preferredCountry $em_goc->getRepository("CompanyGroupBundle\\Entity\\EntityCountries")->findOneBy(array(
  2629.                             'code' => $preferredCountryCode,
  2630.                         ));
  2631.                         if ($preferredCountry) {
  2632.                             $preferredCountryId $preferredCountry->getCountryId();
  2633.                             $currIds json_decode($newApplicant->getPreferredCountryIdsAsStudent(), true);
  2634.                             if ($currIds == null$currIds = [];
  2635.                             $currIds[] = $preferredCountryId;
  2636.                             $newApplicant->setPreferredCountryIdsAsStudent(json_encode($currIds));
  2637.                         }
  2638.                     }
  2639.                     if ($importantCommTags != '') {
  2640.                         if ($newApplicant->getImportantCommTags() == '' || $newApplicant->getImportantCommTags() == null)
  2641.                             $newApplicant->setImportantCommTags($importantCommTags);
  2642.                         else
  2643.                             $newApplicant->setImportantCommTags($newApplicant->getImportantCommTags() . ',' $importantCommTags);
  2644.                     }
  2645.                     if ($applicantSpecificNote != '') {
  2646.                         $newApplicant->setApplicantSpecificNote($applicantSpecificNote);
  2647.                     }
  2648.                     if ($educationText != '') {
  2649.                         $newApplicant->setEducationText($educationText);
  2650.                     }
  2651. //                $userName = explode('@', $email)[0];
  2652.                     //now check if same username exists
  2653.                     $username_already_exist 0;
  2654.                     $em_goc->persist($newApplicant);
  2655.                     $em_goc->flush();
  2656.                     if (GeneralConstant::EMAIL_ENABLED == && $sendWelcomeEmail == 1) {
  2657.                         $bodyHtml '';
  2658.                         $bodyTemplate 'ApplicationBundle:email/templates:buddybeeRegistrationComplete.html.twig';
  2659.                         $bodyData = array(
  2660.                             'name' => $newApplicant->getFirstname() . ' ' $newApplicant->getLastname(),
  2661.                             'email' => $userName,
  2662.                             'showPassword' => 1,
  2663.                             'password' => $password,
  2664.                         );
  2665.                         $attachments = [];
  2666.                         $forwardToMailAddress $newApplicant->getOAuthEmail();
  2667. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  2668.                         $new_mail $this->get('mail_module');
  2669.                         $new_mail->sendMyMail(array(
  2670.                             'senderHash' => '_CUSTOM_',
  2671.                             //                        'senderHash'=>'_CUSTOM_',
  2672.                             'forwardToMailAddress' => $forwardToMailAddress,
  2673.                             'subject' => 'Welcome to BuddyBee ',
  2674. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  2675.                             'attachments' => $attachments,
  2676.                             'toAddress' => $forwardToMailAddress,
  2677.                             'fromAddress' => 'registration@buddybee.eu',
  2678.                             'userName' => 'registration@buddybee.eu',
  2679.                             'password' => 'Y41dh8g0112',
  2680.                             'smtpServer' => 'smtp.hostinger.com',
  2681.                             'smtpPort' => 465,
  2682. //                            'emailBody' => $bodyHtml,
  2683.                             'mailTemplate' => $bodyTemplate,
  2684.                             'templateData' => $bodyData,
  2685. //                        'embedCompanyImage' => 1,
  2686. //                        'companyId' => $companyId,
  2687. //                        'companyImagePath' => $company_data->getImage()
  2688.                         ));
  2689.                     }
  2690.                     return new JsonResponse(array(
  2691.                         'success' => true,
  2692.                         'successStr' => 'Account Created Successfully',
  2693.                         'name' => $newApplicant->getFirstname() . ' ' $newApplicant->getLastname(),
  2694.                         'applicantId' => $newApplicant->getApplicantId(),
  2695. //                        'oAuthData' => $oAuthData,
  2696.                     ));
  2697.                 }
  2698.             }
  2699.         }
  2700.         return new JsonResponse(
  2701.             $data
  2702.         );
  2703.     }
  2704.     public function JitsiBrandingEndpointAction(Request $request$id 0)
  2705.     {
  2706.         return new JsonResponse(array(
  2707.             'backgroundImageUrl' => 'https://buddybee.eu/buddybee_assets/images/jitsi_background.jpg',
  2708.             'logoImageUrl' => 'https://buddybee.eu/buddybee_assets/images/menu_logo_small.png',
  2709.             // Overwrite for pool of background images for avatars
  2710. //        'avatarBackgrounds' => ['url(https://example.com/avatar-background-1.png)', '#FFF'],
  2711.             // The lobby/prejoin screen background
  2712. //        'premeetingBackground' => 'url(https://example.com/premeeting-background.png)',
  2713.             // A list of images that can be used as video backgrounds.
  2714.             // When this field is present, the default images will be replaced with those provided.
  2715.             'virtualBackgrounds' => ['https://buddybee.eu/buddybee_assets/images/jitsi_background.jpg'],
  2716.         ));
  2717.     }
  2718.     public function CheckoutPageAction(Request $request$encData '')
  2719.     {
  2720.         $em $this->getDoctrine()->getManager('company_group');
  2721.         $em_goc $this->getDoctrine()->getManager('company_group');
  2722.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  2723.         $invoiceId $request->request->get('invoiceId'$request->query->get('invoiceId'0));
  2724.         if ($encData != "") {
  2725.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  2726.             if ($encryptedData == null$encryptedData = [];
  2727.             if (isset($encryptedData['invoiceId'])) $invoiceId $encryptedData['invoiceId'];
  2728.         }
  2729.         $session $request->getSession();
  2730.         $currencyForGateway 'eur';
  2731.         $gatewayInvoice null;
  2732.         if ($invoiceId != 0)
  2733.             $gatewayInvoice $em->getRepository(EntityInvoice::class)->find($invoiceId);
  2734.         $paymentGateway $request->request->get('paymentGateway''stripe'); //aamarpay,bkash
  2735.         $paymentType $request->request->get('paymentType''credit');
  2736.         $retailerId $request->request->get('retailerId'0);
  2737.         if ($request->query->has('currency'))
  2738.             $currencyForGateway $request->query->get('currency');
  2739.         else
  2740.             $currencyForGateway $request->request->get('currency''eur');
  2741.         {
  2742.             if ($request->query->has('meetingSessionId'))
  2743.                 $id $request->query->get('meetingSessionId');
  2744.         }
  2745.         $currentUserBalance 0;
  2746.         $currentUserCoinBalance 0;
  2747.         $gatewayAmount 0;
  2748.         $redeemedAmount 0;
  2749.         $redeemedSessionCount 0;
  2750.         $toConsumeSessionCount 0;
  2751.         $invoiceSessionCount 0;
  2752.         $payableAmount 0;
  2753.         $promoClaimedAmount 0;
  2754.         $promoCodeId 0;
  2755.         $promoClaimedSession 0;
  2756.         $bookingExpireTime null;
  2757.         $bookingExpireTs 0;
  2758.         $imageBySessionCount = [
  2759.             => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2760.             100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2761.             200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2762.             300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2763.             400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2764.             500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2765.             600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2766.             700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2767.             800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2768.             900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2769.             1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2770.             1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2771.             1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2772.             1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2773.             1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2774.             1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2775.             1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2776.             1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2777.             1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2778.             1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2779.             2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2780.             2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2781.             2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2782.             2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2783.             2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2784.             2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2785.             2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2786.             2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2787.             2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2788.             2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2789.             3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2790.             3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2791.             3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2792.             3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2793.             3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2794.             3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2795.             3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2796.             3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
  2797.         ];
  2798.         if (!$gatewayInvoice) {
  2799.             if ($request->isMethod('POST')) {
  2800.                 $totalAmount 0;
  2801.                 $totalSessionCount 0;
  2802.                 $consumedAmount 0;
  2803.                 $consumedSessionCount 0;
  2804.                 $bookedById 0;
  2805.                 $bookingRefererId 0;
  2806.                 if ($session->get(UserConstants::USER_ID)) {
  2807.                     $bookedById $session->get(UserConstants::USER_ID);
  2808.                     $bookingRefererId 0;
  2809.                     $toConsumeSessionCount $request->request->get('meetingSessionConsumeCount'0);
  2810.                     $invoiceSessionCount * ($request->request->get('sessionCount'0) == '' $request->request->get('sessionCount'0));
  2811.                     //1st do the necessary
  2812.                     $extMeeting null;
  2813.                     $meetingSessionId 0;
  2814.                     if ($request->request->has('purchasePackage')) {
  2815.                         //1. check if any bee card if yes try to claim it , modify current balance then
  2816.                         $beeCodeSerial $request->request->get('beeCodeSerial''');
  2817.                         $promoCode $request->request->get('promoCode''');
  2818.                         $beeCodePin $request->request->get('beeCodePin''');
  2819.                         $userId $request->request->get('userId'$session->get(UserConstants::USER_ID));
  2820.                         $studentDetails null;
  2821.                         $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  2822.                         if ($studentDetails) {
  2823.                             $currentUserBalance $studentDetails->getAccountBalance();
  2824.                         }
  2825.                         if ($beeCodeSerial != '' && $beeCodePin != '') {
  2826.                             $claimData MiscActions::ClaimBeeCode($em,
  2827.                                 [
  2828.                                     'claimFlag' => 1,
  2829.                                     'pin' => $beeCodePin,
  2830.                                     'serial' => $beeCodeSerial,
  2831.                                     'userId' => $userId,
  2832.                                 ]);
  2833.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  2834.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  2835.                                 $claimData['newCoinBalance'] = $session->get('BUDDYBEE_COIN_BALANCE');
  2836.                                 $claimData['newBalance'] = $session->get('BUDDYBEE_BALANCE');
  2837.                             }
  2838.                             $redeemedAmount $claimData['data']['claimedAmount'];
  2839.                             $redeemedSessionCount $claimData['data']['claimedCoin'];
  2840.                         } else
  2841.                             if ($userId == $session->get(UserConstants::USER_ID)) {
  2842.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  2843.                             }
  2844.                         $payableAmount round($request->request->get('payableAmount'0), 0);
  2845.                         $totalAmountWoDiscount round($request->request->get('totalAmountWoDiscount'0), 0);
  2846.                         //now claim and process promocode
  2847.                         if ($promoCode != '') {
  2848.                             $claimData MiscActions::ClaimPromoCode($em,
  2849.                                 [
  2850.                                     'claimFlag' => 1,
  2851.                                     'promoCode' => $promoCode,
  2852.                                     'decryptedPromoCodeData' => json_decode($this->get('url_encryptor')->decrypt($promoCode), true),
  2853.                                     'orderValue' => $totalAmountWoDiscount,
  2854.                                     'currency' => $currencyForGateway,
  2855.                                     'orderCoin' => $invoiceSessionCount,
  2856.                                     'userId' => $userId,
  2857.                                 ]);
  2858.                             $promoClaimedAmount 0;
  2859. //                            $promoClaimedAmount = $claimData['data']['claimedAmount']*(BuddybeeConstant::$convMultFromTo['eur'][$currencyForGateway]);
  2860.                             $promoCodeId $claimData['promoCodeId'];
  2861.                             $promoClaimedSession $claimData['data']['claimedCoin'];
  2862.                         }
  2863.                         if ($userId == $session->get(UserConstants::USER_ID)) {
  2864.                             MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  2865.                             $currentUserBalance $session->get('BUDDYBEE_BALANCE');
  2866.                             $currentUserCoinBalance $session->get('BUDDYBEE_COIN_BALANCE');
  2867.                         } else {
  2868.                             if ($bookingRefererId == 0)
  2869.                                 $bookingRefererId $session->get(UserConstants::USER_ID);
  2870.                             $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
  2871.                             if ($studentDetails) {
  2872.                                 $currentUserBalance $studentDetails->getAccountBalance();
  2873.                                 $currentUserCoinBalance $studentDetails->getSessionCountBalance();
  2874.                                 if ($bookingRefererId != $userId && $bookingRefererId != 0) {
  2875.                                     $bookingReferer $em_goc->getRepository(EntityApplicantDetails::class)->find($bookingRefererId);
  2876.                                     if ($bookingReferer)
  2877.                                         if ($bookingReferer->getIsAdmin()) {
  2878.                                             $studentDetails->setAssignedSalesRepresentativeId($bookingRefererId);
  2879.                                             $em_goc->flush();
  2880.                                         }
  2881.                                 }
  2882.                             }
  2883.                         }
  2884.                         //2. check if any promo code  if yes add it to promo discount
  2885.                         //3. check if scheule is still temporarily booked if not return that you cannot book it
  2886.                         Buddybee::ExpireAnyMeetingSessionIfNeeded($em);
  2887.                         Buddybee::ExpireAnyEntityInvoiceIfNeeded($em);
  2888.                         if ($request->request->get('autoAssignMeetingSession'0) == 1
  2889.                             && $request->request->get('consultancyScheduleId'0) != 0
  2890.                             && $request->request->get('consultancyScheduleId'0) != ''
  2891.                         ) {
  2892.                             //1st check if a meeting session exxists with same TS, student id , consultant id
  2893.                             $scheduledStartTime = new \DateTime('@' $request->request->get('consultancyScheduleId'''));
  2894.                             $extMeeting $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  2895.                                 ->findOneBy(
  2896.                                     array(
  2897.                                         'scheduledTimeTs' => $scheduledStartTime->format('U'),
  2898.                                         'consultantId' => $request->request->get('consultantId'0),
  2899.                                         'studentId' => $request->request->get('studentId'0),
  2900.                                         'durationAllowedMin' => $request->request->get('meetingSessionScheduledDuration'BuddybeeConstant::PER_SESSION_MINUTE),
  2901.                                     )
  2902.                                 );
  2903.                             if ($extMeeting) {
  2904.                                 $new $extMeeting;
  2905.                                 $meetingSessionId $new->getSessionId();
  2906.                                 $periodMarker $scheduledStartTime->format('Ym');
  2907.                             } else {
  2908.                                 $scheduleValidity MiscActions::CheckIfScheduleCanBeConfirmed(
  2909.                                     $em,
  2910.                                     $request->request->get('consultantId'0),
  2911.                                     $request->request->get('studentId'0),
  2912.                                     $scheduledStartTime->format('U'),
  2913.                                     $request->request->get('meetingSessionScheduledDuration'BuddybeeConstant::PER_SESSION_MINUTE),
  2914.                                     1
  2915.                                 );
  2916.                                 if (!$scheduleValidity) {
  2917.                                     $url $this->generateUrl(
  2918.                                         'consultant_profile'
  2919.                                     );
  2920.                                     $output = [
  2921.                                         'proceedToCheckout' => 0,
  2922.                                         'message' => 'Session Booking Expired or not Found!',
  2923.                                         'errorFlag' => 1,
  2924.                                         'redirectUrl' => $url '/' $request->request->get('consultantId'0)
  2925.                                     ];
  2926.                                     return new JsonResponse($output);
  2927.                                 }
  2928.                                 $new = new EntityMeetingSession();
  2929.                                 $new->setTopicId($request->request->get('consultancyTopic'0));
  2930.                                 $new->setConsultantId($request->request->get('consultantId'0));
  2931.                                 $new->setStudentId($request->request->get('studentId'0));
  2932.                                 $consultancyTopic $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic'0));
  2933.                                 $new->setMeetingType($consultancyTopic $consultancyTopic->getMeetingType() : 0);
  2934.                                 $new->setConsultantCanUpload($consultancyTopic $consultancyTopic->getConsultantCanUpload() : 0);
  2935.                                 $scheduledEndTime = new \DateTime($request->request->get('scheduledTime'''));
  2936.                                 $scheduledEndTime $scheduledEndTime->modify('+' $request->request->get('meetingSessionScheduledDuration'30) . ' minute');
  2937.                                 //$new->setScheduledTime($request->request->get('setScheduledTime'));
  2938.                                 $new->setScheduledTime($scheduledStartTime);
  2939.                                 $new->setDurationAllowedMin($request->request->get('meetingSessionScheduledDuration'30));
  2940.                                 $new->setDurationLeftMin($request->request->get('meetingSessionScheduledDuration'30));
  2941.                                 $new->setSessionExpireDate($scheduledEndTime);
  2942.                                 $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  2943.                                 $new->setEquivalentSessionCount($request->request->get('meetingSessionConsumeCount'0));
  2944.                                 $new->setMeetingSpecificNote($request->request->get('meetingSpecificNote'''));
  2945.                                 $new->setUsableSessionCount($request->request->get('meetingSessionConsumeCount'0));
  2946.                                 $new->setRedeemSessionCount($request->request->get('meetingSessionConsumeCount'0));
  2947.                                 $new->setMeetingActionFlag(0);// no action waiting for meeting
  2948.                                 $new->setScheduledTime($scheduledStartTime);
  2949.                                 $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  2950.                                 $new->setPayableAmount($request->request->get('payableAmount'0));
  2951.                                 $new->setDueAmount($request->request->get('dueAmount'0));
  2952.                                 //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  2953.                                 //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  2954.                                 $new->setPackageName(($request->request->get('packageName''')));
  2955.                                 $new->setPcakageDetails(($request->request->get('packageData''')));
  2956.                                 $new->setScheduleId(($request->request->get('consultancyScheduleId'0)));
  2957.                                 $currentUnixTime = new \DateTime();
  2958.                                 $currentUnixTimeStamp $currentUnixTime->format('U');
  2959.                                 $studentId $request->request->get('studentId'0);
  2960.                                 $consultantId $request->request->get('consultantId'0);
  2961.                                 $new->setMeetingRoomId(str_pad($consultantId4STR_PAD_LEFT) . $currentUnixTimeStamp str_pad($studentId4STR_PAD_LEFT));
  2962.                                 $new->setSessionValue(($request->request->get('sessionValue'0)));
  2963. //                        $new->setIsPayment(0);
  2964.                                 $new->setConsultantIsPaidFull(0);
  2965.                                 if ($bookingExpireTs == 0) {
  2966.                                     $bookingExpireTime = new \DateTime();
  2967.                                     $currTime = new \DateTime();
  2968.                                     $currTimeTs $currTime->format('U');
  2969.                                     $bookingExpireTs = ($scheduledStartTime->format('U')) - (24 3600);
  2970.                                     if ($bookingExpireTs $currTimeTs) {
  2971.                                         if (($scheduledStartTime->format('U')) - $currTimeTs > (12 3600))
  2972.                                             $bookingExpireTs = ($scheduledStartTime->format('U')) - (3600);
  2973.                                         else
  2974.                                             $bookingExpireTs = ($scheduledStartTime->format('U'));
  2975.                                     }
  2976. //                                    $bookingExpireTs = $bookingExpireTime->format('U');
  2977.                                 }
  2978.                                 $new->setPaidSessionCount(0);
  2979.                                 $new->setBookedById($bookedById);
  2980.                                 $new->setBookingRefererId($bookingRefererId);
  2981.                                 $new->setDueSessionCount($request->request->get('meetingSessionConsumeCount'0));
  2982.                                 $new->setExpireIfUnpaidTs($bookingExpireTs);
  2983.                                 $new->setBookingExpireTs($bookingExpireTs);
  2984.                                 $new->setConfirmationExpireTs($bookingExpireTs);
  2985.                                 $new->setIsPaidFull(0);
  2986.                                 $new->setIsExpired(0);
  2987.                                 $em_goc->persist($new);
  2988.                                 $em_goc->flush();
  2989.                                 $meetingSessionId $new->getSessionId();
  2990.                                 $periodMarker $scheduledStartTime->format('Ym');
  2991.                                 MiscActions::UpdateSchedulingRestrictions($em_goc$consultantId$periodMarker, (($request->request->get('meetingSessionScheduledDuration'30)) / 60), -(($request->request->get('meetingSessionScheduledDuration'30)) / 60));
  2992.                             }
  2993.                         }
  2994.                         //4. if after all this stages passed then calcualte gateway payable
  2995.                         if ($request->request->get('isRecharge'0) == 1) {
  2996.                             if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  2997.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  2998.                                 $gatewayAmount 0;
  2999.                             } else
  3000.                                 $gatewayAmount $payableAmount - ($redeemedAmount $promoClaimedAmount);
  3001.                         } else {
  3002.                             if ($toConsumeSessionCount <= $currentUserCoinBalance && $invoiceSessionCount <= $toConsumeSessionCount) {
  3003.                                 $payableAmount 0;
  3004.                                 $gatewayAmount 0;
  3005.                             } else if (($redeemedAmount $promoClaimedAmount) >= $payableAmount) {
  3006.                                 $payableAmount = ($redeemedAmount $promoClaimedAmount);
  3007.                                 $gatewayAmount 0;
  3008.                             } else
  3009.                                 $gatewayAmount $payableAmount <= ($currentUserBalance + ($redeemedAmount $promoClaimedAmount)) ? : ($payableAmount $currentUserBalance - ($redeemedAmount $promoClaimedAmount));
  3010.                         }
  3011.                         $gatewayAmount round($gatewayAmount2);
  3012.                         $dueAmount round($request->request->get('dueAmount'$payableAmount), 0);
  3013.                         if ($request->request->has('gatewayProductData'))
  3014.                             $gatewayProductData $request->request->get('gatewayProductData');
  3015.                         $gatewayProductData = [[
  3016.                             'price_data' => [
  3017.                                 'currency' => $currencyForGateway,
  3018.                                 'unit_amount' => $gatewayAmount != ? ((100 $gatewayAmount) / ($invoiceSessionCount != $invoiceSessionCount 1)) : 200000,
  3019.                                 'product_data' => [
  3020. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  3021.                                     'name' => 'Bee Coins',
  3022.                                     'images' => [$imageBySessionCount[0]],
  3023.                                 ],
  3024.                             ],
  3025.                             'quantity' => $invoiceSessionCount != $invoiceSessionCount 1,
  3026.                         ]];
  3027.                         $new_invoice null;
  3028.                         if ($extMeeting) {
  3029.                             $new_invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  3030.                                 ->findOneBy(
  3031.                                     array(
  3032.                                         'invoiceType' => $request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_BUDDYBEE),
  3033.                                         'meetingId' => $extMeeting->getSessionId(),
  3034.                                     )
  3035.                                 );
  3036.                         }
  3037.                         if ($new_invoice) {
  3038.                         } else {
  3039.                             $new_invoice = new EntityInvoice();
  3040.                             $invoiceDate = new \DateTime();
  3041.                             $new_invoice->setInvoiceDate($invoiceDate);
  3042.                             $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  3043.                             $new_invoice->setStudentId($userId);
  3044.                             $new_invoice->setBillerId($retailerId == $retailerId);
  3045.                             $new_invoice->setRetailerId($retailerId);
  3046.                             $new_invoice->setBillToId($userId);
  3047.                             $new_invoice->setAmountTransferGateWayHash($paymentGateway);
  3048.                             $new_invoice->setAmountCurrency($currencyForGateway);
  3049.                             $cardIds $request->request->get('cardIds', []);
  3050.                             $new_invoice->setMeetingId($meetingSessionId);
  3051.                             $new_invoice->setGatewayBillAmount($gatewayAmount);
  3052.                             $new_invoice->setRedeemedAmount($redeemedAmount);
  3053.                             $new_invoice->setPromoDiscountAmount($promoClaimedAmount);
  3054.                             $new_invoice->setPromoCodeId($promoCodeId);
  3055.                             $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  3056.                             $new_invoice->setPaidAmount($payableAmount $dueAmount);
  3057.                             $new_invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
  3058.                             $new_invoice->setDueAmount($dueAmount);
  3059.                             $new_invoice->setInvoiceType($request->request->get('invoiceType'BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_BUDDYBEE));
  3060.                             $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  3061.                             $new_invoice->setCardIds(json_encode($cardIds));
  3062.                             $new_invoice->setAmountType($request->request->get('amountType'1));
  3063.                             $new_invoice->setAmount($payableAmount);
  3064.                             $new_invoice->setConsumeAmount($payableAmount);
  3065.                             $new_invoice->setSessionCount($invoiceSessionCount);
  3066.                             $new_invoice->setConsumeSessionCount($toConsumeSessionCount);
  3067.                             $new_invoice->setIsPaidfull(0);
  3068.                             $new_invoice->setIsProcessed(0);
  3069.                             $new_invoice->setApplicantId($userId);
  3070.                             $new_invoice->setBookedById($bookedById);
  3071.                             $new_invoice->setBookingRefererId($bookingRefererId);
  3072.                             $new_invoice->setIsRecharge($request->request->get('isRecharge'0));
  3073.                             $new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting'0));
  3074.                             $new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting'0));
  3075.                             $new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards'0));
  3076.                             $new_invoice->setIsPayment(0); //0 means receive
  3077.                             $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  3078.                             $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED); //0 means receive
  3079.                             if ($bookingExpireTs == 0) {
  3080.                                 $bookingExpireTime = new \DateTime();
  3081.                                 $bookingExpireTime->modify('+30 day');
  3082.                                 $bookingExpireTs $bookingExpireTime->format('U');
  3083.                             }
  3084.                             $new_invoice->setExpireIfUnpaidTs($bookingExpireTs);
  3085.                             $new_invoice->setBookingExpireTs($bookingExpireTs);
  3086.                             $new_invoice->setConfirmationExpireTs($bookingExpireTs);
  3087. //            $new_invoice->setStatus($request->request->get(0));
  3088.                             $em_goc->persist($new_invoice);
  3089.                             $em_goc->flush();
  3090.                         }
  3091.                         $invoiceId $new_invoice->getId();
  3092.                         $gatewayInvoice $new_invoice;
  3093.                         if ($request->request->get('isRecharge'0) == 1) {
  3094.                         } else {
  3095.                             if ($gatewayAmount <= 0) {
  3096.                                 $meetingId 0;
  3097.                                 if ($invoiceId != 0) {
  3098.                                     $retData =  Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],$this->container->getParameter('kernel.root_dir'),  false,
  3099.                                         $this->container->getParameter('notification_enabled'),
  3100.                                         $this->container->getParameter('notification_server')
  3101.                                     );
  3102.                                     $meetingId $retData['meetingId'];
  3103.                                 }
  3104.                                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  3105.                                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  3106.                                     $billerDetails = [];
  3107.                                     $billToDetails = [];
  3108.                                     $invoice $gatewayInvoice;
  3109.                                     if ($invoice) {
  3110.                                         $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3111.                                             ->findOneBy(
  3112.                                                 array(
  3113.                                                     'applicantId' => $invoice->getBillerId(),
  3114.                                                 )
  3115.                                             );
  3116.                                         $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3117.                                             ->findOneBy(
  3118.                                                 array(
  3119.                                                     'applicantId' => $invoice->getBillToId(),
  3120.                                                 )
  3121.                                             );
  3122.                                     }
  3123.                                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  3124.                                     $bodyData = array(
  3125.                                         'page_title' => 'Invoice',
  3126. //            'studentDetails' => $student,
  3127.                                         'billerDetails' => $billerDetails,
  3128.                                         'billToDetails' => $billToDetails,
  3129.                                         'invoice' => $invoice,
  3130.                                         'currencyList' => BuddybeeConstant::$currency_List,
  3131.                                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  3132.                                     );
  3133.                                     $attachments = [];
  3134.                                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  3135. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3136.                                     $new_mail $this->get('mail_module');
  3137.                                     $new_mail->sendMyMail(array(
  3138.                                         'senderHash' => '_CUSTOM_',
  3139.                                         //                        'senderHash'=>'_CUSTOM_',
  3140.                                         'forwardToMailAddress' => $forwardToMailAddress,
  3141.                                         'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  3142. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  3143.                                         'attachments' => $attachments,
  3144.                                         'toAddress' => $forwardToMailAddress,
  3145.                                         'fromAddress' => 'no-reply@buddybee.eu',
  3146.                                         'userName' => 'no-reply@buddybee.eu',
  3147.                                         'password' => 'Honeybee@0112',
  3148.                                         'smtpServer' => 'smtp.hostinger.com',
  3149.                                         'smtpPort' => 465,
  3150. //                            'emailBody' => $bodyHtml,
  3151.                                         'mailTemplate' => $bodyTemplate,
  3152.                                         'templateData' => $bodyData,
  3153.                                         'embedCompanyImage' => 0,
  3154.                                         'companyId' => 0,
  3155.                                         'companyImagePath' => ''
  3156. //                        'embedCompanyImage' => 1,
  3157. //                        'companyId' => $companyId,
  3158. //                        'companyImagePath' => $company_data->getImage()
  3159.                                     ));
  3160.                                 }
  3161.                                 if ($meetingId != 0) {
  3162.                                     $url $this->generateUrl(
  3163.                                         'consultancy_session'
  3164.                                     );
  3165.                                     $output = [
  3166.                                         'invoiceId' => $gatewayInvoice->getId(),
  3167.                                         'meetingId' => $meetingId,
  3168.                                         'proceedToCheckout' => 0,
  3169.                                         'redirectUrl' => $url '/' $meetingId
  3170.                                     ];
  3171.                                 } else {
  3172.                                     $url $this->generateUrl(
  3173.                                         'buddybee_dashboard'
  3174.                                     );
  3175.                                     $output = [
  3176.                                         'invoiceId' => $gatewayInvoice->getId(),
  3177.                                         'meetingId' => 0,
  3178.                                         'proceedToCheckout' => 0,
  3179.                                         'redirectUrl' => $url
  3180.                                     ];
  3181.                                 }
  3182.                                 return new JsonResponse($output);
  3183. //                return $this->redirect($url);
  3184.                             } else {
  3185.                             }
  3186. //                $url = $this->generateUrl(
  3187. //                    'checkout_page'
  3188. //                );
  3189. //
  3190. //                return $this->redirect($url."?meetingSessionId=".$new->getSessionId().'&invoiceId='.$invoiceId);
  3191.                         }
  3192.                     }
  3193.                 } else {
  3194.                     $url $this->generateUrl(
  3195.                         'applicant_login'
  3196.                     );
  3197.                     $session->set('LAST_REQUEST_URI_BEFORE_LOGIN'$this->generateUrl(
  3198.                         'pricing_plan_page', [
  3199.                         'autoRedirected' => 1
  3200.                     ],
  3201.                         UrlGenerator::ABSOLUTE_URL
  3202.                     ));
  3203.                     $output = [
  3204.                         'proceedToCheckout' => 0,
  3205.                         'redirectUrl' => $url,
  3206.                         'clearLs' => 0
  3207.                     ];
  3208.                     return new JsonResponse($output);
  3209.                 }
  3210.                 //now proceed to checkout page if the user has lower balance or recharging
  3211.                 //$invoiceDetails = $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->
  3212.             }
  3213.         }
  3214.         if ($gatewayInvoice) {
  3215.             $gatewayProductData json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
  3216.             if ($gatewayProductData == null$gatewayProductData = [];
  3217.             if (empty($gatewayProductData))
  3218.                 $gatewayProductData = [
  3219.                     [
  3220.                         'price_data' => [
  3221.                             'currency' => 'eur',
  3222.                             'unit_amount' => $gatewayAmount != ? (100 $gatewayAmount) : 200000,
  3223.                             'product_data' => [
  3224. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  3225.                                 'name' => 'Bee Coins',
  3226.                                 'images' => [$imageBySessionCount[0]],
  3227.                             ],
  3228.                         ],
  3229.                         'quantity' => 1,
  3230.                     ]
  3231.                 ];
  3232.             $productDescStr '';
  3233.             $productDescArr = [];
  3234.             foreach ($gatewayProductData as $gpd) {
  3235.                 $productDescArr[] = $gpd['price_data']['product_data']['name'];
  3236.             }
  3237.             $productDescStr implode(','$productDescArr);
  3238.             $paymentGatewayFromInvoice $gatewayInvoice->getAmountTransferGateWayHash();
  3239.             if ($paymentGateway == null$paymentGatewayFromInvoice 'stripe';
  3240.             if ($paymentGatewayFromInvoice == 'stripe' || $paymentGatewayFromInvoice == 'aamarpay' || $paymentGatewayFromInvoice == 'bkash') {
  3241.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  3242.                     $billerDetails = [];
  3243.                     $billToDetails = [];
  3244.                     $invoice $gatewayInvoice;
  3245.                     if ($invoice) {
  3246.                         $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3247.                             ->findOneBy(
  3248.                                 array(
  3249.                                     'applicantId' => $invoice->getBillerId(),
  3250.                                 )
  3251.                             );
  3252.                         $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3253.                             ->findOneBy(
  3254.                                 array(
  3255.                                     'applicantId' => $invoice->getBillToId(),
  3256.                                 )
  3257.                             );
  3258.                     }
  3259.                     $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  3260.                     $bodyData = array(
  3261.                         'page_title' => 'Invoice',
  3262. //            'studentDetails' => $student,
  3263.                         'billerDetails' => $billerDetails,
  3264.                         'billToDetails' => $billToDetails,
  3265.                         'invoice' => $invoice,
  3266.                         'currencyList' => BuddybeeConstant::$currency_List,
  3267.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  3268.                     );
  3269.                     $attachments = [];
  3270.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  3271. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3272.                     $new_mail $this->get('mail_module');
  3273.                     $new_mail->sendMyMail(array(
  3274.                         'senderHash' => '_CUSTOM_',
  3275.                         //                        'senderHash'=>'_CUSTOM_',
  3276.                         'forwardToMailAddress' => $forwardToMailAddress,
  3277.                         'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  3278. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  3279.                         'attachments' => $attachments,
  3280.                         'toAddress' => $forwardToMailAddress,
  3281.                         'fromAddress' => 'no-reply@buddybee.eu',
  3282.                         'userName' => 'no-reply@buddybee.eu',
  3283.                         'password' => 'Honeybee@0112',
  3284.                         'smtpServer' => 'smtp.hostinger.com',
  3285.                         'smtpPort' => 465,
  3286. //                            'emailBody' => $bodyHtml,
  3287.                         'mailTemplate' => $bodyTemplate,
  3288.                         'templateData' => $bodyData,
  3289.                         'embedCompanyImage' => 0,
  3290.                         'companyId' => 0,
  3291.                         'companyImagePath' => ''
  3292. //                        'embedCompanyImage' => 1,
  3293. //                        'companyId' => $companyId,
  3294. //                        'companyImagePath' => $company_data->getImage()
  3295.                     ));
  3296.                 }
  3297.             }
  3298.             if ($paymentGatewayFromInvoice == 'stripe') {
  3299.                 $stripe = new \Stripe\Stripe();
  3300.                 \Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  3301.                 $stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
  3302.                 {
  3303.                     if ($request->query->has('meetingSessionId'))
  3304.                         $id $request->query->get('meetingSessionId');
  3305.                 }
  3306.                 $paymentIntent = [
  3307.                     "id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
  3308.                     "object" => "payment_intent",
  3309.                     "amount" => 3000,
  3310.                     "amount_capturable" => 0,
  3311.                     "amount_received" => 0,
  3312.                     "application" => null,
  3313.                     "application_fee_amount" => null,
  3314.                     "canceled_at" => null,
  3315.                     "cancellation_reason" => null,
  3316.                     "capture_method" => "automatic",
  3317.                     "charges" => [
  3318.                         "object" => "list",
  3319.                         "data" => [],
  3320.                         "has_more" => false,
  3321.                         "url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
  3322.                     ],
  3323.                     "client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
  3324.                     "confirmation_method" => "automatic",
  3325.                     "created" => 1546523966,
  3326.                     "currency" => $currencyForGateway,
  3327.                     "customer" => null,
  3328.                     "description" => null,
  3329.                     "invoice" => null,
  3330.                     "last_payment_error" => null,
  3331.                     "livemode" => false,
  3332.                     "metadata" => [],
  3333.                     "next_action" => null,
  3334.                     "on_behalf_of" => null,
  3335.                     "payment_method" => null,
  3336.                     "payment_method_options" => [],
  3337.                     "payment_method_types" => [
  3338.                         "card"
  3339.                     ],
  3340.                     "receipt_email" => null,
  3341.                     "review" => null,
  3342.                     "setup_future_usage" => null,
  3343.                     "shipping" => null,
  3344.                     "statement_descriptor" => null,
  3345.                     "statement_descriptor_suffix" => null,
  3346.                     "status" => "requires_payment_method",
  3347.                     "transfer_data" => null,
  3348.                     "transfer_group" => null
  3349.                 ];
  3350.                 $checkout_session = \Stripe\Checkout\Session::create([
  3351.                     'payment_method_types' => ['card'],
  3352.                     'line_items' => $gatewayProductData,
  3353.                     'mode' => 'payment',
  3354.                     'success_url' => $this->generateUrl(
  3355.                         'payment_gateway_success',
  3356.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  3357.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  3358.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  3359.                     ),
  3360.                     'cancel_url' => $this->generateUrl(
  3361.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  3362.                     ),
  3363.                 ]);
  3364.                 $output = [
  3365.                     'clientSecret' => $paymentIntent['client_secret'],
  3366.                     'id' => $checkout_session->id,
  3367.                     'paymentGateway' => $paymentGatewayFromInvoice,
  3368.                     'proceedToCheckout' => 1
  3369.                 ];
  3370.                 return new JsonResponse($output);
  3371.             }
  3372.             if ($paymentGatewayFromInvoice == 'aamarpay') {
  3373.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  3374.                 $url $sandBoxMode == 'https://sandbox.aamarpay.com/request.php' 'https://secure.aamarpay.com/request.php';
  3375.                 $fields = array(
  3376. //                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  3377.                     'store_id' => $sandBoxMode == 'aamarpaytest' 'buddybee'//store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  3378.                     'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
  3379.                     'payment_type' => 'VISA'//no need to change
  3380.                     'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  3381.                     'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
  3382.                     'cus_name' => $studentDetails->getFirstname() . ' ' $studentDetails->getLastName(),  //customer name
  3383.                     'cus_email' => $studentDetails->getEmail(), //customer email address
  3384.                     'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  3385.                     'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  3386.                     'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  3387.                     'cus_state' => $studentDetails->getCurrAddrState(),  //state
  3388.                     'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  3389.                     'cus_country' => 'Bangladesh',  //country
  3390.                     'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' $studentDetails->getPhone(), //customer phone number
  3391.                     'cus_fax' => '',  //fax
  3392.                     'ship_name' => ''//ship name
  3393.                     'ship_add1' => '',  //ship address
  3394.                     'ship_add2' => '',
  3395.                     'ship_city' => '',
  3396.                     'ship_state' => '',
  3397.                     'ship_postcode' => '',
  3398.                     'ship_country' => 'Bangladesh',
  3399.                     'desc' => $productDescStr,
  3400.                     'success_url' => $this->generateUrl(
  3401.                         'payment_gateway_success',
  3402.                         ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  3403.                             'invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1)
  3404.                         ))), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  3405.                     ),
  3406.                     'fail_url' => $this->generateUrl(
  3407.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  3408.                     ),
  3409.                     'cancel_url' => $this->generateUrl(
  3410.                         'payment_gateway_cancel', ['invoiceId' => $invoiceId'autoRedirect' => $request->request->get('autoRedirect'1), 'hbeeSessionToken' => $session->get('token'0)], UrlGenerator::ABSOLUTE_URL
  3411.                     ),
  3412. //                    'opt_a' => 'Reshad',  //optional paramter
  3413. //                    'opt_b' => 'Akil',
  3414. //                    'opt_c' => 'Liza',
  3415. //                    'opt_d' => 'Sohel',
  3416. //                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  3417.                     'signature_key' => $sandBoxMode == 'dbb74894e82415a2f7ff0ec3a97e4183' 'b7304a40e21fe15af3be9a948307f524'  //live
  3418.                 ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  3419.                 $fields_string http_build_query($fields);
  3420.                 $ch curl_init();
  3421.                 curl_setopt($chCURLOPT_VERBOSEtrue);
  3422.                 curl_setopt($chCURLOPT_URL$url);
  3423.                 curl_setopt($chCURLOPT_POSTFIELDS$fields_string);
  3424.                 curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  3425.                 curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  3426.                 $url_forward str_replace('"'''stripslashes(curl_exec($ch)));
  3427.                 curl_close($ch);
  3428. //                $this->redirect_to_merchant($url_forward);
  3429.                 $output = [
  3430. //                    'redirectUrl' => 'https://sandbox.aamarpay.com/'.$url_forward, //keeping it off temporarily
  3431.                     'redirectUrl' => ($sandBoxMode == 'https://sandbox.aamarpay.com/' 'https://secure.aamarpay.com/') . $url_forward//keeping it off temporarily
  3432. //                    'fields'=>$fields,
  3433. //                    'fields_string'=>$fields_string,
  3434. //                    'redirectUrl' => $this->generateUrl(
  3435. //                        'payment_gateway_success',
  3436. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  3437. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  3438. //                        ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  3439. //                    ),
  3440.                     'paymentGateway' => $paymentGatewayFromInvoice,
  3441.                     'proceedToCheckout' => 1
  3442.                 ];
  3443.                 return new JsonResponse($output);
  3444.             } else if ($paymentGatewayFromInvoice == 'bkash') {
  3445.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
  3446.                 $baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' 'https://tokenized.pay.bka.sh/v1.2.0-beta';
  3447.                 $username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' '01891962953';
  3448.                 $password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' ',a&kPV4deq&';
  3449.                 $app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' '2ueVHdwz5gH3nxx7xn8wotlztc';
  3450.                 $app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
  3451.                 $request_data = array(
  3452.                     'app_key' => $app_key_value,
  3453.                     'app_secret' => $app_secret_value
  3454.                 );
  3455.                 $url curl_init($baseUrl '/tokenized/checkout/token/grant');
  3456.                 $request_data_json json_encode($request_data);
  3457.                 $header = array(
  3458.                     'Content-Type:application/json',
  3459.                     'username:' $username_value,
  3460.                     'password:' $password_value
  3461.                 );
  3462.                 curl_setopt($urlCURLOPT_HTTPHEADER$header);
  3463.                 curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  3464.                 curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  3465.                 curl_setopt($urlCURLOPT_POSTFIELDS$request_data_json);
  3466.                 curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  3467.                 curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  3468.                 $tokenData json_decode(curl_exec($url), true);
  3469.                 curl_close($url);
  3470.                 $id_token $tokenData['id_token'];
  3471.                 $goToBkashPage 0;
  3472.                 if ($tokenData['statusCode'] == '0000') {
  3473.                     $auth $id_token;
  3474.                     $requestbody = array(
  3475.                         "mode" => "0011",
  3476. //                        "payerReference" => "01723888888",
  3477.                         "payerReference" => $invoiceDate->format('U'),
  3478.                         "callbackURL" => $this->generateUrl(
  3479.                             'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
  3480.                         ),
  3481. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  3482.                         "amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2'.'''),
  3483.                         "currency" => "BDT",
  3484.                         "intent" => "sale",
  3485.                         "merchantInvoiceNumber" => $invoiceId
  3486.                     );
  3487.                     $url curl_init($baseUrl '/tokenized/checkout/create');
  3488.                     $requestbodyJson json_encode($requestbody);
  3489.                     $header = array(
  3490.                         'Content-Type:application/json',
  3491.                         'Authorization:' $auth,
  3492.                         'X-APP-Key:' $app_key_value
  3493.                     );
  3494.                     curl_setopt($urlCURLOPT_HTTPHEADER$header);
  3495.                     curl_setopt($urlCURLOPT_CUSTOMREQUEST"POST");
  3496.                     curl_setopt($urlCURLOPT_RETURNTRANSFERtrue);
  3497.                     curl_setopt($urlCURLOPT_POSTFIELDS$requestbodyJson);
  3498.                     curl_setopt($urlCURLOPT_FOLLOWLOCATION1);
  3499.                     curl_setopt($urlCURLOPT_IPRESOLVECURL_IPRESOLVE_V4);
  3500.                     $resultdata curl_exec($url);
  3501.                     curl_close($url);
  3502. //                    echo $resultdata;
  3503.                     $obj json_decode($resultdatatrue);
  3504.                     $goToBkashPage 1;
  3505.                     $justNow = new \DateTime();
  3506.                     $justNow->modify('+' $tokenData['expires_in'] . ' second');
  3507.                     $gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
  3508.                     $gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
  3509.                     $gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
  3510.                     $gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
  3511.                     $em->flush();
  3512.                     $output = [
  3513.                         'redirectUrl' => $obj['bkashURL'],
  3514.                         'paymentGateway' => $paymentGatewayFromInvoice,
  3515.                         'proceedToCheckout' => $goToBkashPage,
  3516.                         'tokenData' => $tokenData,
  3517.                         'obj' => $obj,
  3518.                         'id_token' => $tokenData['id_token'],
  3519.                     ];
  3520.                     return new JsonResponse($output);
  3521.                 }
  3522. //                $fields = array(
  3523. //
  3524. //                    "mode" => "0011",
  3525. //                    "payerReference" => "01723888888",
  3526. //                    "callbackURL" => $this->generateUrl(
  3527. //                        'payment_gateway_success',
  3528. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  3529. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  3530. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  3531. //                    ),
  3532. //                    "merchantAssociationInfo" => "MI05MID54RF09123456One",
  3533. //                    "amount" => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),,
  3534. //                    "currency" => "BDT",
  3535. //                    "intent" => "sale",
  3536. //                    "merchantInvoiceNumber" => 'BEI' . str_pad($gatewayInvoice->getBillerId(), 3, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4, '0', STR_PAD_LEFT)
  3537. //
  3538. //                );
  3539. //                $fields = array(
  3540. ////                    'store_id' => 'aamarpaytest', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  3541. //                    'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay,  contact integration@aamarpay.com for test/live id
  3542. //                    'amount' => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),, //transaction amount
  3543. //                    'payment_type' => 'VISA', //no need to change
  3544. //                    'currency' => strtoupper($currencyForGateway),  //currenct will be USD/BDT
  3545. //                    'tran_id' => 'BEI' . str_pad($gatewayInvoice->getBillerId(), 3, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getBillToId(), 5, '0', STR_PAD_LEFT) . str_pad($gatewayInvoice->getId(), 4, '0', STR_PAD_LEFT), //transaction id must be unique from your end
  3546. //                    'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(),  //customer name
  3547. //                    'cus_email' => $studentDetails->getEmail(), //customer email address
  3548. //                    'cus_add1' => $studentDetails->getCurrAddr(),  //customer address
  3549. //                    'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
  3550. //                    'cus_city' => $studentDetails->getCurrAddrCity(),  //customer city
  3551. //                    'cus_state' => $studentDetails->getCurrAddrState(),  //state
  3552. //                    'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
  3553. //                    'cus_country' => 'Bangladesh',  //country
  3554. //                    'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
  3555. //                    'cus_fax' => '',  //fax
  3556. //                    'ship_name' => '', //ship name
  3557. //                    'ship_add1' => '',  //ship address
  3558. //                    'ship_add2' => '',
  3559. //                    'ship_city' => '',
  3560. //                    'ship_state' => '',
  3561. //                    'ship_postcode' => '',
  3562. //                    'ship_country' => 'Bangladesh',
  3563. //                    'desc' => $productDescStr,
  3564. //                    'success_url' => $this->generateUrl(
  3565. //                        'payment_gateway_success',
  3566. //                        ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
  3567. //                            'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
  3568. //                        ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  3569. //                    ),
  3570. //                    'fail_url' => $this->generateUrl(
  3571. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  3572. //                    ),
  3573. //                    'cancel_url' => $this->generateUrl(
  3574. //                        'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
  3575. //                    ),
  3576. ////                    'opt_a' => 'Reshad',  //optional paramter
  3577. ////                    'opt_b' => 'Akil',
  3578. ////                    'opt_c' => 'Liza',
  3579. ////                    'opt_d' => 'Sohel',
  3580. ////                    'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183',  //sandbox
  3581. //                    'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524'  //live
  3582. //
  3583. //                ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
  3584. //
  3585. //                $fields_string = http_build_query($fields);
  3586. //
  3587. //                $ch = curl_init();
  3588. //                curl_setopt($ch, CURLOPT_VERBOSE, true);
  3589. //                curl_setopt($ch, CURLOPT_URL, $url);
  3590. //
  3591. //                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  3592. //                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  3593. //                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  3594. //                $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
  3595. //                curl_close($ch);
  3596. //                $this->redirect_to_merchant($url_forward);
  3597.             } else if ($paymentGatewayFromInvoice == 'onsite_pos' || $paymentGatewayFromInvoice == 'onsite_cash' || $paymentGatewayFromInvoice == 'onsite_bkash') {
  3598.                 $meetingId 0;
  3599.                 if ($gatewayInvoice->getId() != 0) {
  3600.                     if ($gatewayInvoice->getDueAmount() <= 0) {
  3601.                         $retData Buddybee::ProcessEntityInvoice($em_goc$gatewayInvoice->getId(), ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],$this->container->getParameter('kernel.root_dir'),  false,
  3602.                             $this->container->getParameter('notification_enabled'),
  3603.                             $this->container->getParameter('notification_server')
  3604.                         );
  3605.                         $meetingId $retData['meetingId'];
  3606.                     }
  3607.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  3608.                         $billerDetails = [];
  3609.                         $billToDetails = [];
  3610.                         $invoice $gatewayInvoice;
  3611.                         if ($invoice) {
  3612.                             $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3613.                                 ->findOneBy(
  3614.                                     array(
  3615.                                         'applicantId' => $invoice->getBillerId(),
  3616.                                     )
  3617.                                 );
  3618.                             $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3619.                                 ->findOneBy(
  3620.                                     array(
  3621.                                         'applicantId' => $invoice->getBillToId(),
  3622.                                     )
  3623.                                 );
  3624.                         }
  3625.                         $bodyTemplate 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
  3626.                         $bodyData = array(
  3627.                             'page_title' => 'Invoice',
  3628. //            'studentDetails' => $student,
  3629.                             'billerDetails' => $billerDetails,
  3630.                             'billToDetails' => $billToDetails,
  3631.                             'invoice' => $invoice,
  3632.                             'currencyList' => BuddybeeConstant::$currency_List,
  3633.                             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  3634.                         );
  3635.                         $attachments = [];
  3636.                         $forwardToMailAddress $billToDetails->getOAuthEmail();
  3637. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3638.                         $new_mail $this->get('mail_module');
  3639.                         $new_mail->sendMyMail(array(
  3640.                             'senderHash' => '_CUSTOM_',
  3641.                             //                        'senderHash'=>'_CUSTOM_',
  3642.                             'forwardToMailAddress' => $forwardToMailAddress,
  3643.                             'subject' => 'YourInvoice #' 'D' str_pad('BB'5'0'STR_PAD_LEFT) . str_pad('76'2'0'STR_PAD_LEFT) . str_pad($invoice->getId(), 8"0"STR_PAD_LEFT) . ' from BuddyBee ',
  3644. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  3645.                             'attachments' => $attachments,
  3646.                             'toAddress' => $forwardToMailAddress,
  3647.                             'fromAddress' => 'no-reply@buddybee.eu',
  3648.                             'userName' => 'no-reply@buddybee.eu',
  3649.                             'password' => 'Honeybee@0112',
  3650.                             'smtpServer' => 'smtp.hostinger.com',
  3651.                             'smtpPort' => 465,
  3652. //                            'emailBody' => $bodyHtml,
  3653.                             'mailTemplate' => $bodyTemplate,
  3654.                             'templateData' => $bodyData,
  3655.                             'embedCompanyImage' => 0,
  3656.                             'companyId' => 0,
  3657.                             'companyImagePath' => ''
  3658. //                        'embedCompanyImage' => 1,
  3659. //                        'companyId' => $companyId,
  3660. //                        'companyImagePath' => $company_data->getImage()
  3661.                         ));
  3662.                     }
  3663.                 }
  3664.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  3665.                 if ($meetingId != 0) {
  3666.                     $url $this->generateUrl(
  3667.                         'consultancy_session'
  3668.                     );
  3669.                     $output = [
  3670.                         'proceedToCheckout' => 0,
  3671.                         'invoiceId' => $gatewayInvoice->getId(),
  3672.                         'meetingId' => $meetingId,
  3673.                         'redirectUrl' => $url '/' $meetingId
  3674.                     ];
  3675.                 } else {
  3676.                     $url $this->generateUrl(
  3677.                         'buddybee_dashboard'
  3678.                     );
  3679.                     $output = [
  3680.                         'proceedToCheckout' => 0,
  3681.                         'invoiceId' => $gatewayInvoice->getId(),
  3682.                         'meetingId' => $meetingId,
  3683.                         'redirectUrl' => $url
  3684.                     ];
  3685.                 }
  3686.                 return new JsonResponse($output);
  3687.             }
  3688.         }
  3689.         $output = [
  3690.             'clientSecret' => 0,
  3691.             'id' => 0,
  3692.             'proceedToCheckout' => 0
  3693.         ];
  3694.         return new JsonResponse($output);
  3695. //        return $this->render('ApplicationBundle:pages/stripe:checkout.html.twig', array(
  3696. //            'page_title' => 'Checkout',
  3697. ////            'stripe' => $stripe,
  3698. //            'stripe' => null,
  3699. ////            'PaymentIntent' => $paymentIntent,
  3700. //
  3701. ////            'consultantDetail' => $consultantDetail,
  3702. ////            'consultantDetails'=> $consultantDetails,
  3703. ////
  3704. ////            'meetingSession' => $meetingSession,
  3705. ////            'packageDetails' => json_decode($meetingSession->getPcakageDetails(),true),
  3706. ////            'packageName' => json_decode($meetingSession->getPackageName(),true),
  3707. ////            'pay' => $payableAmount,
  3708. ////            'balance' => $currStudentBal
  3709. //        ));
  3710.     }
  3711.     public function BeeCodePageAction(Request $request$id)
  3712.     {
  3713.         $em_goc $this->getDoctrine()->getManager('company_group');
  3714.         $session $request->getSession();
  3715.         $invoiceId 0;
  3716.         $topic null;
  3717.         $scheduleId 0;
  3718.         $consultantDetails null;
  3719.         $consultantId 0;
  3720.         $sessionId 0;
  3721.         $topicSessionValue 0;
  3722.         $consultantSchedule null;
  3723.         $scheduleText '';
  3724.         $autoRedirected 0;
  3725.         $autoAssignMeetingSession 0;
  3726.         $topicCoinMultiplierValue $request->request->get('topicCoinMultiplierValue'$request->request->get('topicCoinMultiplierValue'1));
  3727.         $sessionConsumeCount $request->request->get('sessionConsumeCount'$topicCoinMultiplierValue $request->request->get('sessionDurationSelector'0));
  3728.         if ($request->request->has('sessionDurationSelector'))
  3729.             $sessionDuration = ($request->request->get('sessionDurationSelector'0)) * BuddybeeConstant::PER_SESSION_MINUTE / (BuddybeeConstant::COIN_GENERAL_MULT);
  3730.         else
  3731.             $sessionDuration $sessionConsumeCount BuddybeeConstant::PER_SESSION_MINUTE / (BuddybeeConstant::COIN_GENERAL_MULT);
  3732.         $meetingSessionId 0;
  3733.         $requiredPurchaseSessionCount $sessionConsumeCount;
  3734.         if ($request->isMethod('GET') && $request->query->has('autoRedirected'))
  3735.             $autoRedirected $request->query->get('autoRedirected');
  3736. //        $studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3737.         if ($request->isMethod('POST') && $request->request->has('toPackagePage')) {
  3738.             $topicId $request->request->get('consultancyTopic');
  3739.             $sessionId $request->request->get('sessionSelector');
  3740.             $topicSessionValue $request->request->get('sessionSelector');
  3741.             $consultantId $request->request->get('consultantId');
  3742.             $scheduleId $request->request->get('consultancyScheduleId'); // this is timestamp
  3743.             $scheduleTs $request->request->get('consultancyScheduleId'); // this is timestamp
  3744. //            $sessionConsumeCount = $request->request->get('sessionConsumeCount');
  3745.             $autoAssignMeetingSession 1;
  3746.             //$topic = $em->getRepository(ConsultancyTopic::class)->findAll();
  3747.             $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(array(
  3748.                 'id' => $topicId
  3749.             ));
  3750.             $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  3751.                 'applicantId' => $consultantId
  3752.             ));
  3753. //            $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findOneBy(array(
  3754. //                'consultantId' => $consultantId
  3755. //            ));
  3756. //            $schdeuledTime = [];
  3757. //            if ($consultantSchedule)
  3758. //                $schdeuledTime = json_decode($consultantSchedule->getTimeSchedule(), true);
  3759. //            if ($schdeuledTime == null)
  3760. //                $schdeuledTime = [];
  3761. //            $scheduleText = isset($schdeuledTime[$scheduleId]) ? $schdeuledTime[$scheduleId]['date'] . ' ' . $schdeuledTime[$scheduleId]['startTime'] : '';
  3762.             $scheduleTextDate = new \DateTime('@' $scheduleId);;
  3763.             $scheduleText $scheduleTextDate->format('F d, Y H:i');
  3764.             $currentUserBalance 0;
  3765.             $gatewayAmount 0;
  3766.             $redeemedAmount 0;
  3767.             $redeemedSessionCount 0;
  3768.             $payableAmount 0;
  3769.             $totalAmount 0;
  3770.             $totalSessionCount 0;
  3771.             $consumedAmount 0;
  3772.             $consumedSessionCount $request->request->get('sessionDurationSelector'0);
  3773.             $currentUserSessionBalance 0;
  3774.             $currentUserBalance 0;
  3775.             $balancedFromUserSessionCount 0;
  3776.             $balancedFromUserBalance 0;
  3777.             $studentId 0;
  3778.             if ($session->get(UserConstants::USER_ID)
  3779.                 && $session->get(UserConstants::USER_TYPE) == UserConstants::USER_TYPE_APPLICANT
  3780.             ) {
  3781.                 $studentDetails null;
  3782.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3783.                 if ($studentDetails) {
  3784.                     $currentUserBalance $studentDetails->getAccountBalance();
  3785.                     $currentUserSessionBalance $studentDetails->getSessionCountBalance();
  3786.                     $studentId $studentDetails->getApplicantId();
  3787.                 }
  3788.                 if ($consumedSessionCount <= $currentUserSessionBalance) {
  3789.                     $balancedFromUserSessionCount 1;
  3790.                 }
  3791.                 //1st do the necessary
  3792.                 $beeCode $request->request->get('beeCode''');
  3793.                 $payableAmount $request->request->get('payableAmount'0);
  3794.                 $scheduledStartTime = new \DateTime('@' $scheduleId);;
  3795.                 if ($balancedFromUserSessionCount == 1) {
  3796.                     $scheduleValidity MiscActions::CheckIfScheduleCanBeConfirmed(
  3797.                         $em_goc,
  3798.                         $request->request->get('consultantId'0),
  3799.                         $studentId,
  3800.                         $scheduledStartTime->format('U'),
  3801.                         (30 $consumedSessionCount),
  3802.                         1
  3803.                     );
  3804.                     if (!$scheduleValidity) {
  3805.                         $url $this->generateUrl(
  3806.                             'consultant_profile'
  3807.                         );
  3808.                         $output = [
  3809.                             'proceedToCheckout' => 0,
  3810.                             'message' => 'Session Booking Expired or not Found!',
  3811.                             'errorFlag' => 1,
  3812.                             'redirectUrl' => $url '/' $request->request->get('consultantId'0)
  3813.                         ];
  3814.                         if ($request->request->has('returnJson'))
  3815.                             return new JsonResponse($output);
  3816.                         else
  3817.                             return $this->redirect($url '/' $request->request->get('consultantId'0) . '?errorFlag=1&message=Session Booking Expired or not Found');
  3818.                     }
  3819.                     $new = new EntityMeetingSession();
  3820.                     $new->setTopicId($request->request->get('consultancyTopic'0));
  3821.                     $new->setConsultantId($request->request->get('consultantId'0));
  3822.                     $consultancyTopic $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic'0));
  3823.                     $new->setMeetingType($consultancyTopic $consultancyTopic->getMeetingType() : 0);
  3824.                     $new->setConsultantCanUpload($consultancyTopic $consultancyTopic->getConsultantCanUpload() : 0);
  3825.                     $new->setStudentId($studentId);
  3826.                     $scheduledEndTime = new \DateTime('@' $scheduleId);;
  3827.                     $scheduledEndTime $scheduledEndTime->modify('+' . (30 $consumedSessionCount) . ' Minute');
  3828. //                    $scheduledStartTime->setTimezone(new \DateTimeZone('UTC'));
  3829. //                    $scheduledEndTime->setTimezone(new \DateTimeZone('UTC'));
  3830.                     //$new->setScheduledTime($request->request->get('setScheduledTime'));
  3831.                     $new->setScheduledTime($scheduledStartTime);
  3832.                     $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  3833.                     $new->setDurationAllowedMin((30 $consumedSessionCount));
  3834.                     $new->setDurationLeftMin((30 $consumedSessionCount));
  3835.                     $new->setSessionExpireDate($scheduledEndTime);
  3836.                     $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  3837.                     $new->setEquivalentSessionCount($consumedSessionCount);
  3838.                     $new->setRedeemSessionCount($consumedSessionCount);
  3839.                     $new->setUsableSessionCount($consumedSessionCount);
  3840.                     $new->setMeetingActionFlag(0);// no action waiting for meeting
  3841.                     $new->setPayableAmount($payableAmount);
  3842.                     $new->setDueAmount($request->request->get('dueAmount'0));
  3843.                     //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  3844.                     //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  3845.                     $new->setPackageName(($request->request->get('packageName''')));
  3846.                     $new->setPcakageDetails(($request->request->get('packageData''')));
  3847.                     $new->setScheduleId($scheduleId);
  3848.                     $new->setSessionValue($topicSessionValue);
  3849. //                    $new->setIsPayment(0);
  3850.                     $new->setConsultantIsPaidFull(0);
  3851.                     $currentUnixTime = new \DateTime();
  3852.                     $currentUnixTimeStamp $currentUnixTime->format('U');
  3853.                     $consultantId $request->request->get('consultantId'0);
  3854.                     $new->setMeetingRoomId(str_pad($consultantId4STR_PAD_LEFT) . $currentUnixTimeStamp str_pad($studentId4STR_PAD_LEFT));
  3855.                     $currTime = new \DateTime();
  3856.                     $currTime->modify('+1 day');
  3857.                     $currTs $currTime->format('U');
  3858.                     $new->setPaidSessionCount(0);
  3859.                     $new->setDueSessionCount($consumedSessionCount);
  3860.                     $new->setExpireIfUnpaidTs($currTs);
  3861.                     $new->setBookingExpireTs($currTs);
  3862.                     $new->setConfirmationExpireTs($currTs);
  3863.                     $new->setIsPaidFull(0);
  3864.                     $new->setIsExpired(0);
  3865.                     $em_goc->persist($new);
  3866.                     $em_goc->flush();
  3867.                     $meetingSessionId $new->getSessionId();
  3868.                     $periodMarker $scheduledStartTime->format('Ym');
  3869.                     MiscActions::UpdateSchedulingRestrictions($em_goc$consultantId$periodMarker, (($request->request->get('meetingSessionScheduledDuration'30)) / 60), -(($request->request->get('meetingSessionScheduledDuration'30)) / 60));
  3870. //                            $studentDetails->setSessionCountBalance($currentUserSessionBalance-$consumedSessionCount);
  3871. //                            $studentDetails->setTotalSessionUsed($studentDetails->getTotalSessionUsed()+$consumedSessionCount);
  3872.                     $em_goc->flush();
  3873.                     $new_invoice = new EntityInvoice();
  3874.                     $invoiceDate = new \DateTime();
  3875.                     $new_invoice->setInvoiceDate($invoiceDate);
  3876.                     $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  3877.                     $new_invoice->setStudentId($studentId);
  3878.                     $new_invoice->setMeetingId($meetingSessionId);
  3879.                     $new_invoice->setAmount($totalAmount);
  3880.                     $new_invoice->setGatewayBillAmount($gatewayAmount);
  3881.                     $new_invoice->setRedeemedAmount($redeemedAmount);
  3882.                     $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  3883.                     $new_invoice->setPaidAmount(0);
  3884.                     $new_invoice->setDueAmount(0);
  3885.                     $new_invoice->setInvoiceType(1);
  3886.                     $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  3887.                     $new_invoice->setAmountType(1);
  3888.                     $new_invoice->setConsumeAmount(0);
  3889.                     $new_invoice->setSessionCount(0);
  3890.                     $new_invoice->setConsumeSessionCount($consumedSessionCount);
  3891.                     $new_invoice->setIsPaidfull(0);
  3892.                     $new_invoice->setIsProcessed(0);
  3893.                     $new_invoice->setApplicantId($studentId);
  3894.                     $new_invoice->setIsRecharge(0);
  3895.                     $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED);
  3896.                     $new_invoice->setIsPayment(0); //0 means receive
  3897.                     $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  3898.                     $new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting'1));
  3899.                     $new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting'1));
  3900.                     $new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards'1));
  3901. //            $new_invoice->setStatus($request->request->get(0));
  3902.                     $em_goc->persist($new_invoice);
  3903.                     $em_goc->flush();
  3904.                     $invoiceId $new_invoice->getId();
  3905.                     $retData =  Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],$this->container->getParameter('kernel.root_dir'),  false,
  3906.                         $this->container->getParameter('notification_enabled'),
  3907.                         $this->container->getParameter('notification_server')
  3908.                     );
  3909.                     MiscActions::RefreshBuddybeeBalanceOnSession($em_goc$request->getSession());
  3910.                     $meetingSessionId $retData['meetingId'];
  3911.                     if ($meetingSessionId != 0) {
  3912.                         $url $this->generateUrl(
  3913.                             'consultancy_session'
  3914.                         );
  3915.                         $output = [
  3916.                             'proceedToCheckout' => 0,
  3917.                             'redirectUrl' => $url '/' $meetingSessionId
  3918.                         ];
  3919.                     } else {
  3920.                         $url $this->generateUrl(
  3921.                             'buddybee_dashboard'
  3922.                         );
  3923.                         $output = [
  3924.                             'proceedToCheckout' => 0,
  3925.                             'redirectUrl' => $url
  3926.                         ];
  3927.                     }
  3928.                     if ($request->request->has('returnJson'))
  3929.                         return new JsonResponse($output);
  3930.                     else
  3931.                         return $this->redirect($url '/' $meetingSessionId);
  3932.                 }
  3933.             } else {
  3934.                 $url $this->generateUrl(
  3935.                     'buddybee_dashboard'
  3936.                 );
  3937.                 $output = [
  3938.                     'proceedToCheckout' => 0,
  3939.                     'redirectUrl' => $url
  3940.                 ];
  3941.                 if ($request->request->has('returnJson'))
  3942.                     return new JsonResponse($output);
  3943.                 else
  3944.                     return $this->redirect($url '/' $meetingSessionId);
  3945.             }
  3946. //
  3947.         }
  3948.         $packageNames BuddybeeConstant::$packageNames;
  3949.         $packageDetails BuddybeeConstant::$packageDetails;
  3950.         $userId $session->get(UserConstants::USER_ID);
  3951.         if ($userId != 0) {
  3952.             $applicantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  3953.                 'applicantId' => $userId
  3954.             ));
  3955.             if ($applicantDetails)
  3956.                 $requiredPurchaseSessionCount $sessionConsumeCount - ($applicantDetails->getSessionCountBalance());
  3957.         }
  3958.         return $this->render('@Buddybee/pages/pricing.html.twig', array(
  3959.             'page_title' => 'Package And Pricing',
  3960.             'topic' => $topic,
  3961.             'consultantDetails' => $consultantDetails,
  3962.             'packageDetails' => $packageDetails,
  3963.             'packageNames' => $packageNames,
  3964.             'scheduleId' => $scheduleId,
  3965.             'consultantId' => $consultantId,
  3966.             'topicSessionValue' => $topicSessionValue,
  3967.             'autoRedirected' => $autoRedirected,
  3968.             'meetingSessionId' => $meetingSessionId,
  3969.             'invoiceId' => $invoiceId,
  3970.             'sessionConsumeCount' => $sessionConsumeCount,
  3971.             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  3972.             'autoAssignMeetingSession' => $autoAssignMeetingSession,
  3973.             'sessionDuration' => $sessionDuration,
  3974. //            'consultantSchedule' => $consultantSchedule,
  3975.             'scheduleText' => $scheduleText,
  3976.             'userId' => $userId,
  3977. //            'timeSchedule' => $consultantSchedule
  3978.         ));
  3979. //        return $this->render('@Buddybee/pages/pricing.html.twig', array(
  3980. //            'page_title' => 'Package And Pricing',
  3981. //        ));
  3982.     }
  3983.     public function PricingPlanAction(Request $request$autoRedirected 0)
  3984.     {
  3985.         $em_goc $this->getDoctrine()->getManager('company_group');
  3986.         $session $request->getSession();
  3987.         $invoiceId 0;
  3988.         $topic null;
  3989.         $scheduleId 0;
  3990.         $consultantDetails null;
  3991.         $consultantId 0;
  3992.         $sessionId 0;
  3993.         $topicSessionValue 0;
  3994.         $consultantSchedule null;
  3995.         $scheduleText '';
  3996.         $autoRedirected 0;
  3997.         $autoAssignMeetingSession 0;
  3998.         $accountTopUpMethod '_PAYMENT_'//or _BEE_CARD_
  3999.         $packageNamesOld BuddybeeConstant::$packageNames;
  4000.         $packageDetailsOld BuddybeeConstant::$packageDetails;
  4001.         $userId $session->get(UserConstants::USER_ID);
  4002.         $packageNames = [];
  4003.         $packageDetails = [];
  4004.         foreach ($packageNamesOld as $ind => $p) {
  4005.             if ($ind == 0)
  4006.                 continue;
  4007.             $packageNames[$ind] = $p;
  4008.         }
  4009.         foreach ($packageDetailsOld as $ind => $p) {
  4010.             if ($ind == 0)
  4011.                 continue;
  4012.             $packageDetails[$ind] = $p;
  4013.         }
  4014.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  4015.         $allowedGateWays = [
  4016.             'stripe' => 1,
  4017.             'aamarpay' => 1,
  4018.             'bkash' => 1,
  4019.         ];
  4020.         if ($sandBoxMode != 1)
  4021.             $allowedGateWays BuddybeeConstant::$allowedGateWaysForLive;
  4022.         $minCoinsToPurchase $request->request->get('minCoinsToPurchase'0);
  4023.         $paymentGateway $request->request->get('paymentGateway''stripe');
  4024.         $paymentType $request->request->get('paymentType''credit');
  4025.         $retailerId $request->request->get('retailerId'0);
  4026.         if ($request->query->has('currency'))
  4027.             $currencyForGateway $request->query->get('currency');
  4028.         else
  4029.             $currencyForGateway $request->request->get('currency''usd');
  4030.         $topicCoinMultiplierValue $request->request->get('topicCoinMultiplierValue'$request->request->get('topicCoinMultiplierValue'1));
  4031.         $sessionConsumeCount $request->request->get('sessionConsumeCount'$topicCoinMultiplierValue $request->request->get('sessionDurationSelector'0));
  4032.         if ($request->request->has('sessionDurationSelector'))
  4033.             $sessionDuration = ($request->request->get('sessionDurationSelector'0)) * BuddybeeConstant::PER_SESSION_MINUTE / (BuddybeeConstant::COIN_GENERAL_MULT);
  4034.         else
  4035.             $sessionDuration $sessionConsumeCount BuddybeeConstant::PER_SESSION_MINUTE / (BuddybeeConstant::COIN_GENERAL_MULT);
  4036.         $meetingSessionId 0;
  4037.         if ($minCoinsToPurchase $sessionConsumeCount)
  4038.             $requiredPurchaseSessionCount $sessionConsumeCount;
  4039.         else
  4040.             $requiredPurchaseSessionCount $minCoinsToPurchase;
  4041.         $forRecharge 1;
  4042.         if ($request->isMethod('GET') && $request->query->has('autoRedirected'))
  4043.             $autoRedirected $request->query->get('autoRedirected');
  4044. //        $studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  4045.         if ($request->isMethod('POST') && $request->request->has('toPackagePage')) {
  4046.             $topicId $request->request->get('consultancyTopic'0);
  4047.             $sessionId $request->request->get('sessionSelector'0);
  4048.             $topicSessionValue $request->request->get('sessionSelector'0);
  4049.             $consultantId $request->request->get('consultantId'0);
  4050.             $scheduleId $request->request->get('consultancyScheduleId'0); // this is timestamp
  4051.             $scheduleTs $request->request->get('consultancyScheduleId'0); // this is timestamp
  4052. //            $sessionConsumeCount = $request->request->get('sessionConsumeCount');
  4053.             $autoAssignMeetingSession 1;
  4054.             $forRecharge 0;
  4055.             //$topic = $em->getRepository(ConsultancyTopic::class)->findAll();
  4056.             $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(array(
  4057.                 'id' => $topicId
  4058.             ));
  4059.             $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  4060.                 'applicantId' => $consultantId
  4061.             ));
  4062. //            $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findOneBy(array(
  4063. //                'consultantId' => $consultantId
  4064. //            ));
  4065. //            $schdeuledTime = [];
  4066. //            if ($consultantSchedule)
  4067. //                $schdeuledTime = json_decode($consultantSchedule->getTimeSchedule(), true);
  4068. //            if ($schdeuledTime == null)
  4069. //                $schdeuledTime = [];
  4070. //            $scheduleText = isset($schdeuledTime[$scheduleId]) ? $schdeuledTime[$scheduleId]['date'] . ' ' . $schdeuledTime[$scheduleId]['startTime'] : '';
  4071.             $scheduleTextDate = new \DateTime('@' $scheduleId);;
  4072.             $scheduleText $scheduleTextDate->format('F d, Y H:i');
  4073.             $currentUserBalance 0;
  4074.             $gatewayAmount 0;
  4075.             $redeemedAmount 0;
  4076.             $redeemedSessionCount 0;
  4077.             $payableAmount 0;
  4078.             $totalAmount 0;
  4079.             $totalSessionCount 0;
  4080.             $consumedAmount 0;
  4081.             $consumedSessionCount $sessionConsumeCount;
  4082.             $currentUserSessionBalance 0;
  4083.             $currentUserBalance 0;
  4084.             $balancedFromUserSessionCount 0;
  4085.             $balancedFromUserBalance 0;
  4086.             $studentId 0;
  4087.             if ($session->get(UserConstants::USER_ID)
  4088.                 && $session->get(UserConstants::USER_TYPE) == UserConstants::USER_TYPE_APPLICANT
  4089.             ) {
  4090.                 $studentDetails null;
  4091.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  4092.                 if ($studentDetails) {
  4093.                     $currentUserBalance $studentDetails->getAccountBalance();
  4094.                     $currentUserSessionBalance $studentDetails->getSessionCountBalance();
  4095.                     $studentId $studentDetails->getApplicantId();
  4096.                 }
  4097.                 if ($consumedSessionCount <= $currentUserSessionBalance && $minCoinsToPurchase == 0) {
  4098.                     $balancedFromUserSessionCount 1;
  4099.                 }
  4100.                 //1st do the necessary
  4101.                 $beeCode $request->request->get('beeCode''');
  4102.                 $payableAmount $request->request->get('payableAmount'0);
  4103.                 $scheduledStartTime = new \DateTime('@' $scheduleId);;
  4104.                 if ($balancedFromUserSessionCount == 1) {
  4105.                     $scheduleValidity MiscActions::CheckIfScheduleCanBeConfirmed(
  4106.                         $em_goc,
  4107.                         $request->request->get('consultantId'0),
  4108.                         $studentId,
  4109.                         $scheduledStartTime->format('U'),
  4110.                         $sessionDuration,
  4111.                         1
  4112.                     );
  4113.                     if (!$scheduleValidity) {
  4114.                         $url $this->generateUrl(
  4115.                             'consultant_profile'
  4116.                         );
  4117.                         $output = [
  4118.                             'proceedToCheckout' => 0,
  4119.                             'packageDetails' => MiscActions::toListArray($packageDetails),
  4120.                             'packageNames' => MiscActions::toListArray($packageNames),
  4121.                             'scheduleId' => $scheduleId,
  4122.                             'consultantId' => $consultantId,
  4123.                             'topicSessionValue' => $topicSessionValue,
  4124.                             'autoRedirected' => $autoRedirected,
  4125.                             'meetingSessionId' => $meetingSessionId,
  4126.                             'invoiceId' => $invoiceId,
  4127.                             'sessionConsumeCount' => $sessionConsumeCount,
  4128.                             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  4129.                             'autoAssignMeetingSession' => $autoAssignMeetingSession,
  4130.                             'sessionDuration' => $sessionDuration,
  4131. //                            'consultantSchedule' => $consultantSchedule,
  4132.                             'scheduleText' => $scheduleText,
  4133.                             'userId' => $userId,
  4134.                             'message' => 'Session Booking Expired or not Found!',
  4135.                             'errorFlag' => 1,
  4136.                             'redirectUrl' => $url '/' $request->request->get('consultantId'0)
  4137.                         ];
  4138.                         if ($request->request->has('returnJson'))
  4139.                             return new JsonResponse($output);
  4140.                         else
  4141.                             return $this->redirect($url '/' $request->request->get('consultantId'0) . '?errorFlag=1&message=Session Booking Expired or not Found');
  4142.                     }
  4143.                     $new = new EntityMeetingSession();
  4144.                     $new->setTopicId($request->request->get('consultancyTopic'0));
  4145.                     $new->setConsultantId($request->request->get('consultantId'0));
  4146.                     $consultancyTopic $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic'0));
  4147.                     $new->setMeetingType($consultancyTopic $consultancyTopic->getMeetingType() : 0);
  4148.                     $new->setConsultantCanUpload($consultancyTopic $consultancyTopic->getConsultantCanUpload() : 0);
  4149.                     $new->setStudentId($studentId);
  4150.                     $scheduledEndTime = new \DateTime('@' $scheduleId);;
  4151.                     $scheduledEndTime $scheduledEndTime->modify('+' $sessionDuration ' Minute');
  4152. //                    $scheduledStartTime->setTimezone(new \DateTimeZone('UTC'));
  4153. //                    $scheduledEndTime->setTimezone(new \DateTimeZone('UTC'));
  4154.                     //$new->setScheduledTime($request->request->get('setScheduledTime'));
  4155.                     $new->setScheduledTime($scheduledStartTime);
  4156.                     $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  4157.                     $new->setDurationAllowedMin($sessionDuration);
  4158.                     $new->setDurationLeftMin($sessionDuration);
  4159.                     $new->setSessionExpireDate($scheduledEndTime);
  4160.                     $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  4161.                     $new->setEquivalentSessionCount($consumedSessionCount);
  4162.                     $new->setRedeemSessionCount($consumedSessionCount);
  4163.                     $new->setUsableSessionCount($consumedSessionCount);
  4164.                     $new->setMeetingActionFlag(0);// no action waiting for meeting
  4165.                     $new->setPayableAmount($payableAmount);
  4166.                     $new->setDueAmount($request->request->get('dueAmount'0));
  4167.                     //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  4168.                     //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  4169.                     $new->setPackageName(($request->request->get('packageName''')));
  4170.                     $new->setPcakageDetails(($request->request->get('packageData''')));
  4171.                     $new->setScheduleId($scheduleId);
  4172.                     $new->setSessionValue($topicSessionValue);
  4173. //                    $new->setIsPayment(0);
  4174.                     $new->setConsultantIsPaidFull(0);
  4175.                     $currentUnixTime = new \DateTime();
  4176.                     $currentUnixTimeStamp $currentUnixTime->format('U');
  4177.                     $consultantId $request->request->get('consultantId'0);
  4178.                     $new->setMeetingRoomId(str_pad($consultantId4STR_PAD_LEFT) . $currentUnixTimeStamp str_pad($studentId4STR_PAD_LEFT));
  4179.                     $currTime = new \DateTime();
  4180.                     $currTime->modify('+1 day');
  4181.                     $currTs $currTime->format('U');
  4182.                     $new->setPaidSessionCount(0);
  4183.                     $new->setDueSessionCount($consumedSessionCount);
  4184.                     $new->setExpireIfUnpaidTs($currTs);
  4185.                     $new->setBookingExpireTs($currTs);
  4186.                     $new->setConfirmationExpireTs($currTs);
  4187.                     $new->setIsPaidFull(0);
  4188.                     $new->setIsExpired(0);
  4189.                     $em_goc->persist($new);
  4190.                     $em_goc->flush();
  4191.                     $meetingSessionId $new->getSessionId();
  4192.                     $periodMarker $scheduledStartTime->format('Ym');
  4193.                     MiscActions::UpdateSchedulingRestrictions($em_goc$consultantId$periodMarker, ($sessionDuration 60), -($sessionDuration 60));
  4194. //                            $studentDetails->setSessionCountBalance($currentUserSessionBalance-$consumedSessionCount);
  4195. //                            $studentDetails->setTotalSessionUsed($studentDetails->getTotalSessionUsed()+$consumedSessionCount);
  4196.                     $em_goc->flush();
  4197.                     $new_invoice = new EntityInvoice();
  4198.                     $invoiceDate = new \DateTime();
  4199.                     $new_invoice->setInvoiceDate($invoiceDate);
  4200.                     $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  4201.                     $new_invoice->setStudentId($studentId);
  4202.                     $new_invoice->setMeetingId($meetingSessionId);
  4203.                     $new_invoice->setAmount($totalAmount);
  4204.                     $new_invoice->setAmountTransferGateWayHash('internal');
  4205.                     $new_invoice->setAmountCurrency('coins');
  4206.                     $new_invoice->setGatewayBillAmount($gatewayAmount);
  4207.                     $new_invoice->setRedeemedAmount($redeemedAmount);
  4208.                     $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  4209.                     $new_invoice->setPaidAmount(0);
  4210.                     $new_invoice->setDueAmount(0);
  4211.                     $new_invoice->setInvoiceType(BuddybeeConstant::ENTITY_INVOICE_TYPE_CONSUME_COIN_FOR_MEETING_FOR_STUDENT);
  4212.                     $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  4213.                     $new_invoice->setAmountType(2);
  4214.                     $new_invoice->setConsumeAmount(0);
  4215.                     $new_invoice->setSessionCount(0);
  4216.                     $new_invoice->setConsumeSessionCount($consumedSessionCount);
  4217.                     $new_invoice->setIsPaidfull(0);
  4218.                     $new_invoice->setIsProcessed(0);
  4219.                     $new_invoice->setApplicantId($studentId);
  4220.                     $new_invoice->setIsRecharge(0);
  4221.                     $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED);
  4222.                     $new_invoice->setIsPayment(0); //0 means receive
  4223.                     $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  4224.                     $new_invoice->setAutoConfirmTaggedMeeting(1);
  4225.                     $new_invoice->setAutoConfirmOtherMeeting(0);
  4226. //            $new_invoice->setStatus($request->request->get(0));
  4227.                     $em_goc->persist($new_invoice);
  4228.                     $em_goc->flush();
  4229.                     $invoiceId $new_invoice->getId();
  4230.                     $retData =  Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],$this->container->getParameter('kernel.root_dir'),  false,
  4231.                         $this->container->getParameter('notification_enabled'),
  4232.                         $this->container->getParameter('notification_server')
  4233.                     );
  4234.                     MiscActions::RefreshBuddybeeBalanceOnSession($em_goc$request->getSession());
  4235.                     $meetingSessionId $retData['meetingId'];
  4236.                     if ($meetingSessionId != 0) {
  4237.                         $url $this->generateUrl(
  4238.                             'consultancy_session'
  4239.                         );
  4240.                         $output = [
  4241.                             'proceedToCheckout' => 0,
  4242.                             'redirectUrl' => $url '/' $meetingSessionId
  4243.                         ];
  4244.                     } else {
  4245.                         $url $this->generateUrl(
  4246.                             'buddybee_dashboard'
  4247.                         );
  4248.                         $output = [
  4249.                             'proceedToCheckout' => 0,
  4250.                             'redirectUrl' => $url
  4251.                         ];
  4252.                     }
  4253.                     if ($request->request->has('returnJson'))
  4254.                         return new JsonResponse($output);
  4255.                     else
  4256.                         return $this->redirect($url '/' $meetingSessionId);
  4257.                 } else {
  4258. //                    $session->set('hasCoin',0);
  4259.                     if ($userId != && $forRecharge == 0) {
  4260.                         $applicantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  4261.                             'applicantId' => $userId
  4262.                         ));
  4263.                         if ($applicantDetails) {
  4264.                             $requiredPurchaseSessionCountExcludingMinCond $sessionConsumeCount - ($applicantDetails->getSessionCountBalance());
  4265.                             if ($minCoinsToPurchase $requiredPurchaseSessionCountExcludingMinCond)
  4266.                                 $requiredPurchaseSessionCount $requiredPurchaseSessionCountExcludingMinCond;
  4267.                             else
  4268.                                 $requiredPurchaseSessionCount $minCoinsToPurchase;
  4269.                         }
  4270.                     }
  4271.                     $url $this->generateUrl(
  4272.                         'pricing_plan_page'
  4273.                     );
  4274.                     $filteredPackageList MiscActions::filterPackageList([
  4275.                         'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount
  4276.                     ]);
  4277.                     $convMultFromTo BuddybeeConstant::$convMultFromTo;
  4278.                     $convMultFromToModifiedArray = [];
  4279.                     $convFromEur $convMultFromTo['eur'];
  4280.                     $count 1;
  4281.                     foreach ($convFromEur as $currency => $f) {
  4282.                         $convMultFromToModifiedArray[] = array(
  4283.                             "id" => $count,
  4284.                             "currency" => $currency,
  4285.                             "value" => $f,
  4286.                         );
  4287.                         $count++;
  4288.                     }
  4289.                     $output = array(
  4290.                         'page_title' => 'Package And Pricing',
  4291. //                        'topic' => $topic,
  4292. //                        'consultantDetails' => $consultantDetails,
  4293.                         'COIN_GENERAL_MULT' => BuddybeeConstant::COIN_GENERAL_MULT,
  4294.                         'packageDetails' => $filteredPackageList['packageDetails'],
  4295.                         'packageNames' => $filteredPackageList['packageNames'],
  4296.                         'selectionValue' => $filteredPackageList['selectionValue'],
  4297.                         'selectionPackageId' => $filteredPackageList['selectionPackageId'],
  4298.                         'CONV_MULT_FROM_TO' => BuddybeeConstant::$convMultFromTo,
  4299.                         'CONV_MULT_FROM_TO_MODIFIED' => $convMultFromToModifiedArray,
  4300.                         'PER_SESSION_MINUTE' => BuddybeeConstant::PER_SESSION_MINUTE,
  4301.                         'BETWEEN_SESSION_MINUTE' => BuddybeeConstant::BETWEEN_SESSION_MINUTE,
  4302.                         'BEECOIN_VALUE_EURO' => BuddybeeConstant::BEECOIN_VALUE_EURO,
  4303.                         'scheduleId' => $scheduleId,
  4304.                         'consultantId' => $consultantId,
  4305.                         'topicSessionValue' => $topicSessionValue,
  4306.                         'autoRedirected' => $autoRedirected,
  4307.                         'meetingSessionId' => $meetingSessionId,
  4308.                         'invoiceId' => $invoiceId,
  4309.                         'sessionConsumeCount' => $sessionConsumeCount,
  4310.                         'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  4311.                         'autoAssignMeetingSession' => $autoAssignMeetingSession,
  4312.                         'sessionDuration' => $sessionDuration,
  4313. //                        'consultantSchedule' => $consultantSchedule,
  4314.                         'scheduleText' => $scheduleText,
  4315.                         'userId' => $userId,
  4316. //                        'timeSchedule' => $consultantSchedule,
  4317.                         'proceedToCheckout' => 0,
  4318.                         'message' => 'Insufficient coins!',
  4319.                         'errorFlag' => 1,
  4320.                         'redirectUrl' => $url
  4321.                     );
  4322.                     if ($request->request->has('returnJson'))
  4323.                         return new JsonResponse($output);
  4324. //                    else
  4325. //                        return $this->redirect($url . '/' . $request->request->get('consultantId', 0) . '?errorFlag=1&message=Not enough Coins');
  4326.                 }
  4327.             } else {
  4328.                 $url $this->generateUrl(
  4329.                     'buddybee_dashboard'
  4330.                 );
  4331.                 $output = [
  4332.                     'proceedToCheckout' => 0,
  4333.                     'redirectUrl' => $url
  4334.                 ];
  4335.                 if ($request->request->has('returnJson'))
  4336.                     return new JsonResponse($output);
  4337.                 else {
  4338. //                    return $this->redirect($url . '/' . $meetingSessionId);
  4339.                 }
  4340.             }
  4341. //
  4342.         } else if ($request->isMethod('POST') && $request->request->has('forRecharge')) {
  4343.             $requiredPurchaseSessionCount $request->request->get('coinCount'0);
  4344.             $forRecharge $request->request->get('forRecharge'1);
  4345.             $accountTopUpMethod $request->request->get('accountTopUpMethod''_PAYMENT_');
  4346.         }
  4347.         if ($userId != && $forRecharge == 0) {
  4348.             $applicantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  4349.                 'applicantId' => $userId
  4350.             ));
  4351.             if ($applicantDetails) {
  4352.                 $requiredPurchaseSessionCountExcludingMinCond $sessionConsumeCount - ($applicantDetails->getSessionCountBalance());
  4353.                 if ($minCoinsToPurchase $requiredPurchaseSessionCountExcludingMinCond)
  4354.                     $requiredPurchaseSessionCount $requiredPurchaseSessionCountExcludingMinCond;
  4355.                 else
  4356.                     $requiredPurchaseSessionCount $minCoinsToPurchase;
  4357.             }
  4358.         }
  4359.         $filteredPackageList MiscActions::filterPackageList([
  4360.             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount
  4361.         ]);
  4362.         return $this->render('@Buddybee/pages/pricing.html.twig', array(
  4363.             'page_title' => 'Package And Pricing',
  4364.             'topic' => $topic,
  4365.             'allowedGateWays' => $allowedGateWays,
  4366.             'consultantDetails' => $consultantDetails,
  4367.             'packageDetails' => $packageDetails,
  4368.             'packageNames' => $packageNames,
  4369.             'scheduleId' => $scheduleId,
  4370.             'paymentGateway' => $paymentGateway,
  4371.             'currencyForGateway' => $currencyForGateway,
  4372.             'convMultFromTo' => BuddybeeConstant::$convMultFromTo,
  4373.             'fontSizeByCurrency' => BuddybeeConstant::$fontSizeByCurrency,
  4374.             'beeCodePriceByCoinCountEur' => BuddybeeConstant::$beeCodePriceByCoinCountEur,
  4375.             'BEECOIN_VALUE_EURO' => BuddybeeConstant::BEECOIN_VALUE_EURO,
  4376.             'PER_SESSION_MINUTE' => BuddybeeConstant::PER_SESSION_MINUTE,
  4377.             'COIN_GENERAL_MULT' => BuddybeeConstant::COIN_GENERAL_MULT,
  4378.             'consultantId' => $consultantId,
  4379.             'topicSessionValue' => $topicSessionValue,
  4380.             'autoRedirected' => $autoRedirected,
  4381.             'meetingSessionId' => $meetingSessionId,
  4382.             'invoiceId' => $invoiceId,
  4383.             'sessionConsumeCount' => $sessionConsumeCount,
  4384.             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  4385. //            'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  4386.             'accountTopUpMethod' => $accountTopUpMethod,
  4387.             'autoAssignMeetingSession' => $autoAssignMeetingSession,
  4388.             'sessionDuration' => $sessionDuration,
  4389. //            'consultantSchedule' => $consultantSchedule,
  4390.             'scheduleText' => $scheduleText,
  4391.             'userId' => $userId,
  4392. //            'timeSchedule' => $consultantSchedule
  4393.         ));
  4394. //        return $this->render('@Buddybee/pages/pricing.html.twig', array(
  4395. //            'page_title' => 'Package And Pricing',
  4396. //        ));
  4397.     }
  4398.     public function PricingPageDataAction(Request $request)
  4399.     {
  4400.         $packageNames BuddybeeConstant::$packageNames;
  4401.         $packageDetails BuddybeeConstant::$packageDetails;
  4402.         $convMultFromTo BuddybeeConstant::$convMultFromTo;
  4403.         $convMultFromToModifiedArray = [];
  4404.         $convFromEur $convMultFromTo['eur'];
  4405.         $count 1;
  4406.         foreach ($convFromEur as $currency => $f) {
  4407.             $convMultFromToModifiedArray[] = array(
  4408.                 "id" => $count,
  4409.                 "currency" => $currency,
  4410.                 "value" => $f,
  4411.             );
  4412.             $count++;
  4413.         }
  4414.         $output = array(
  4415.             'page_title' => 'Package And Pricing',
  4416.             'CONV_MULT_FROM_TO' => BuddybeeConstant::$convMultFromTo,
  4417.             'CONV_MULT_FROM_TO_MODIFIED' => $convMultFromToModifiedArray,
  4418.             'PER_SESSION_MINUTE' => BuddybeeConstant::PER_SESSION_MINUTE,
  4419.             'BETWEEN_SESSION_MINUTE' => BuddybeeConstant::BETWEEN_SESSION_MINUTE,
  4420.             'COIN_GENERAL_MULT' => BuddybeeConstant::COIN_GENERAL_MULT,
  4421.             'BEECOIN_VALUE_EURO' => BuddybeeConstant::BEECOIN_VALUE_EURO,
  4422.             'packageDetails' => MiscActions::toListArray($packageDetails),
  4423.             'packageNames' => MiscActions::toListArray($packageNames),
  4424.         );
  4425. //        if ($request->request->has('returnJson'))
  4426.         return new JsonResponse($output);
  4427.     }
  4428.     public function BlogViewAction(Request $request$id)
  4429.     {
  4430.         $em $this->getDoctrine()->getManager('company_group');
  4431.         $topicId 0;
  4432.         if ($id != 0) {
  4433.             $blog $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateBlog')->find($id);
  4434.             $topicId $blog->getTopicId();
  4435.         } else {
  4436.             $topicId $id;
  4437.             if ($request->query->has('topicId')) {
  4438.                 $topicId $request->query->get('topicId');
  4439.                 $topic $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(
  4440.                     array(
  4441.                         'id' => $topicId,
  4442.                     )
  4443.                 );
  4444.                 $blog $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateBlog')->findOneBy(
  4445.                     array(
  4446.                         'topicId' => $topicId
  4447.                     )
  4448.                 );
  4449.                 if ($request->query->get('blog'1) == 1) {
  4450.                 } else if ($topic->getTopicMarker() == '_country_') {
  4451.                     $url $this->generateUrl(
  4452.                         'topic_list'
  4453.                     );
  4454. //                    return $this->redirect($url . "#topic" . $topicId);
  4455.                     return $this->redirect($url "/" $topicId);
  4456.                 }
  4457.             } else if ($request->query->has('countryId')) {
  4458.                 $countryId $request->query->get('countryId');
  4459.                 $topic $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(
  4460.                     array(
  4461.                         'countryId' => $countryId,
  4462.                         'topicMarker' => '_country_',
  4463.                     )
  4464.                 );
  4465.                 $topicId $topic->getId();
  4466.                 $blog $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateBlog')->findOneBy(
  4467.                     array(
  4468.                         'topicId' => $topicId
  4469.                     )
  4470.                 );
  4471.                 $url $this->generateUrl(
  4472.                     'country_view'
  4473.                 );
  4474. //                return $this->redirect($url . "#topic" . $topicId);
  4475.                 return $this->redirect($url "/" $topicId);
  4476.             } else {
  4477.                 $topic $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(
  4478.                     array(
  4479.                         'id' => $topicId,
  4480.                     )
  4481.                 );
  4482.                 $blog $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateBlog')->findOneBy(
  4483.                     array(
  4484.                         'topicId' => $topicId
  4485.                     )
  4486.                 );
  4487.                 if ($topic->getTopicMarker() == '_country_') {
  4488.                     $url $this->generateUrl(
  4489.                         'topic_list'
  4490.                     );
  4491.                     return $this->redirect($url "#topic" $topicId);
  4492.                 }
  4493.             }
  4494.         }
  4495.         $consultant $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4496.             ->createQueryBuilder('m')
  4497.             ->where("m.isConsultant = 1")
  4498.             ->andwhere("m.preferredTopicIdsAsConsultant like '%\"$topicId\"%' or  m.preferredTopicIdsAsConsultant like '%[]%' or m.preferredTopicIdsAsConsultant is null")
  4499. //            ->andwhere("m.preferredTopicIdsAsConsultant like '%\"$topicId\"%' ")
  4500.             ->orderBy('m.rating''DESC')
  4501.             ->getQuery()
  4502.             ->setMaxResults(10)
  4503.             ->getResult();
  4504.         return $this->render('@Buddybee/pages/topicSummary.html.twig', array(
  4505.             'page_title' => 'Blog',
  4506.             'blog' => $blog,
  4507.             'topicId' => $topicId,
  4508.             'consultant' => $consultant
  4509.         ));
  4510.     }
  4511.     public
  4512.     function SearchBuddyBeeAction(Request $request$queryStr '')
  4513.     {
  4514.         $em $this->getDoctrine()->getManager('company_group');
  4515.         $data = [];
  4516.         $data_by_id = [];
  4517.         $session $request->getSession();
  4518.         if ($queryStr == '_DEFAULT_')
  4519.             $queryStr '';
  4520.         if ($request->request->has('query') && $queryStr == '')
  4521.             $queryStr $request->request->get('queryStr');
  4522.         if ($queryStr == '_DEFAULT_')
  4523.             $queryStr '';
  4524.         //topic
  4525.         $filterQryForCriteria "select * from entity_create_topic where 1=1 
  4526.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  4527.         $get_kids_sql $filterQryForCriteria;
  4528.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4529.         
  4530.         $get_kids $stmt;
  4531.         $productId 0;
  4532.         if (!empty($get_kids)) {
  4533.             foreach ($get_kids as $product) {
  4534.                 if ($product['topic_marker'] == '_country_') {
  4535.                     $url $this->generateUrl(
  4536.                         'country_view'
  4537.                     );
  4538.                     $url .= ("/" $product['id']);
  4539.                 } else {
  4540.                     $url $this->generateUrl(
  4541.                         'blog_post'
  4542.                     );
  4543.                     $url .= ("?topicId=" $product['id']);
  4544.                 }
  4545.                 $pa = array();
  4546.                 $pa['id'] = $product['id'];
  4547.                 $pa['name'] = $product['topic_name'];
  4548.                 $pa['description'] = $product['topic_summary'];
  4549.                 $pa['url'] = $url;
  4550.                 $pa['type'] = 1;
  4551.                 $pa['topicMarker'] = $product['topic_marker'];
  4552.                 $pa['image'] = $product['topic_image'];
  4553.                 $data[] = $pa;
  4554.             }
  4555.         }
  4556. //blog
  4557.         $filterQryForCriteria "select * from entity_create_blog where 1=1
  4558.                                     and ( title  like '%" $queryStr "%'
  4559.                                     or subtitle  like '%" $queryStr "%'
  4560.                                     or content  like '%" $queryStr "%'
  4561.                                     )
  4562.                                     limit 10";
  4563.         $get_kids_sql $filterQryForCriteria;
  4564.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4565.         
  4566.         $get_kids $stmt;
  4567.         $productId 0;
  4568.         $url $this->generateUrl(
  4569.             'blog_post'
  4570.         );
  4571.         if (!empty($get_kids)) {
  4572.             foreach ($get_kids as $product) {
  4573.                 $pa = array();
  4574.                 $pa['id'] = $product['id'];
  4575.                 $pa['name'] = $product['title'];
  4576.                 $pa['description'] = $product['subtitle'];
  4577.                 $pa['url'] = $url "/" $product['id'];
  4578.                 $pa['type'] = 3;
  4579.                 $pa['topicMarker'] = '';
  4580.                 $pa['image'] = '';
  4581.                 $data[] = $pa;
  4582.             }
  4583.         }
  4584.         //consultant
  4585.         if ($session->get(UserConstants::USER_ID0) != 0)
  4586.             $filterQryForCriteria "select * from entity_applicant_details where is_consultant=1 and applicant_id != " $session->get(UserConstants::USER_ID0) .
  4587.                 " and ( firstname  like '%" $queryStr "%'
  4588.                                     or lastname  like '%" $queryStr "%'
  4589.                                     )
  4590.                                     limit 10";
  4591.         else
  4592.             $filterQryForCriteria "select * from entity_applicant_details where is_consultant=1
  4593.                                     and ( firstname  like '%" $queryStr "%'
  4594.                                     or lastname  like '%" $queryStr "%'
  4595.                                     )
  4596.                                     limit 10";
  4597.         $get_kids_sql $filterQryForCriteria;
  4598.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4599.         
  4600.         $get_kids $stmt;
  4601.         $productId 0;
  4602.         $url $this->generateUrl(
  4603.             'consultant_profile'
  4604.         );
  4605.         if (!empty($get_kids)) {
  4606.             foreach ($get_kids as $product) {
  4607.                 $pa = array();
  4608.                 $pa['id'] = $product['applicant_id'];
  4609.                 $pa['name'] = $product['firstname'] . ' ' $product['lastname'];
  4610.                 $pa['description'] = $product['firstname'] . ' ' $product['lastname'];
  4611.                 $pa['url'] = $url "/" $product['applicant_id'];
  4612.                 $pa['type'] = 2;
  4613.                 $pa['topicMarker'] = '';
  4614.                 $pa['image'] = $product['image'];
  4615.                 $data[] = $pa;
  4616.             }
  4617.         }
  4618.         {
  4619.             return new JsonResponse(
  4620.                 array(
  4621.                     'success' => true,
  4622. //                    'page_title' => 'Product Details',
  4623. //                    'company_data' => $company_data,
  4624.                     'data' => $data,
  4625.                 )
  4626.             );
  4627.         }
  4628.     }
  4629.     public
  4630.     function SearchCountryAction(Request $request$queryStr '')
  4631.     {
  4632.         $em $this->getDoctrine()->getManager('company_group');
  4633.         $data = [];
  4634.         $data_by_id = [];
  4635.         if ($queryStr == '_DEFAULT_')
  4636.             $queryStr '';
  4637.         if ($request->request->has('query') && $queryStr == '')
  4638.             $queryStr $request->request->get('queryStr');
  4639.         if ($queryStr == '_DEFAULT_')
  4640.             $queryStr '';
  4641.         //topic
  4642.         $filterQryForCriteria "select * from entity_create_topic where topic_marker= '_country_'
  4643.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  4644.         $get_kids_sql $filterQryForCriteria;
  4645.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4646.         
  4647.         $get_kids $stmt;
  4648.         $productId 0;
  4649.         $url $this->generateUrl(
  4650.             'blog_post'
  4651.         );
  4652.         if (!empty($get_kids)) {
  4653.             foreach ($get_kids as $product) {
  4654.                 $otherData json_decode($product['other_data'], true);
  4655.                 if ($otherData == null)
  4656.                     $otherData = [];
  4657.                 $pa = array();
  4658.                 $pa['id'] = $product['id'];
  4659.                 $pa['name'] = $product['topic_name'];
  4660.                 $pa['description'] = $product['topic_summary'];
  4661.                 $pa['specialFor'] = isset($otherData['_country__specialFor']) ? $otherData['_country__specialFor'] : '';
  4662.                 $pa['url'] = $url "?topicId=" $product['id'];
  4663.                 $pa['type'] = 1;
  4664.                 $pa['image'] = '';
  4665.                 $data[] = $pa;
  4666.             }
  4667.         }
  4668. //blog
  4669.         $filterQryForCriteria "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_country_')
  4670.                                     and ( title  like '%" $queryStr "%'  
  4671.                                     or subtitle  like '%" $queryStr "%'  
  4672.                                     or content  like '%" $queryStr "%'  
  4673.                                     )
  4674.                                     
  4675.                                     limit 10";
  4676.         $get_kids_sql $filterQryForCriteria;
  4677.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4678.         
  4679.         $get_kids $stmt;
  4680.         $productId 0;
  4681.         $url $this->generateUrl(
  4682.             'blog_post'
  4683.         );
  4684. //    $ep = $this->generateUrl(
  4685. //        'error_page'
  4686. //    );
  4687.         if (!empty($get_kids)) {
  4688.             foreach ($get_kids as $product) {
  4689.                 $pa = array();
  4690.                 $pa['id'] = $product['id'];
  4691.                 $pa['name'] = $product['title'];
  4692.                 $pa['description'] = $product['subtitle'];
  4693.                 $pa['url'] = $url "/" $product['id'];
  4694.                 $pa['type'] = 1;
  4695.                 $pa['image'] = '';
  4696.                 $data[] = $pa;
  4697.             }
  4698.         }
  4699.         return new JsonResponse(
  4700.             array(
  4701.                 'success' => true,
  4702.                 'data' => $data,
  4703.             )
  4704.         );
  4705.     }
  4706.     public
  4707.     function SearchProgramAction(Request $request$queryStr '')
  4708.     {
  4709.         $em $this->getDoctrine()->getManager('company_group');
  4710.         $data = [];
  4711.         $data_by_id = [];
  4712.         if ($queryStr == '_DEFAULT_')
  4713.             $queryStr '';
  4714.         if ($request->request->has('query') && $queryStr == '')
  4715.             $queryStr $request->request->get('queryStr');
  4716.         if ($queryStr == '_DEFAULT_')
  4717.             $queryStr '';
  4718.         //topic
  4719.         $filterQryForCriteria "select * from entity_create_topic where topic_marker= '_program_'
  4720.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  4721.         $get_kids_sql $filterQryForCriteria;
  4722.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4723.         
  4724.         $get_kids $stmt;
  4725.         $productId 0;
  4726.         $url $this->generateUrl(
  4727.             'blog_post'
  4728.         );
  4729.         if (!empty($get_kids)) {
  4730.             foreach ($get_kids as $product) {
  4731.                 $pa = array();
  4732.                 $pa['id'] = $product['id'];
  4733.                 $pa['name'] = $product['topic_name'];
  4734.                 $pa['description'] = $product['topic_summary'];
  4735.                 $pa['url'] = $url "?topicId=" $product['id'];
  4736.                 $pa['type'] = 1;
  4737.                 $pa['image'] = '';
  4738.                 $data[] = $pa;
  4739.             }
  4740.         }
  4741. //blog
  4742.         $filterQryForCriteria "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_program_')
  4743.                                     and ( title  like '%" $queryStr "%'  
  4744.                                     or subtitle  like '%" $queryStr "%'  
  4745.                                     or content  like '%" $queryStr "%'  
  4746.                                     )
  4747.                                     
  4748.                                     limit 10";
  4749.         $get_kids_sql $filterQryForCriteria;
  4750.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4751.         
  4752.         $get_kids $stmt;
  4753.         $productId 0;
  4754.         $url $this->generateUrl(
  4755.             'blog_post'
  4756.         );
  4757.         if (!empty($get_kids)) {
  4758.             foreach ($get_kids as $product) {
  4759.                 $pa = array();
  4760.                 $pa['id'] = $product['id'];
  4761.                 $pa['name'] = $product['title'];
  4762.                 $pa['description'] = $product['subtitle'];
  4763.                 $pa['url'] = $url "/" $product['id'];
  4764.                 $pa['type'] = 1;
  4765.                 $pa['image'] = '';
  4766.                 $data[] = $pa;
  4767.             }
  4768.         }
  4769.         return new JsonResponse(
  4770.             array(
  4771.                 'success' => true,
  4772.                 'data' => $data,
  4773.             )
  4774.         );
  4775.     }
  4776.     public
  4777.     function BlogSearchFromListAction(Request $request$queryStr '')
  4778.     {
  4779.         $em $this->getDoctrine()->getManager('company_group');
  4780.         $data = [];
  4781.         $data_by_id = [];
  4782.         if ($queryStr == '_DEFAULT_')
  4783.             $queryStr '';
  4784.         if ($request->request->has('query') && $queryStr == '')
  4785.             $queryStr $request->request->get('queryStr');
  4786.         if ($queryStr == '_DEFAULT_')
  4787.             $queryStr '';
  4788.         //topic
  4789.         $filterQryForCriteria "select * from entity_create_topic where 1=1 
  4790.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  4791.         $get_kids_sql $filterQryForCriteria;
  4792.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4793.         
  4794.         $get_kids $stmt;
  4795.         $productId 0;
  4796.         $url $this->generateUrl(
  4797.             'blog_post'
  4798.         );
  4799.         if (!empty($get_kids)) {
  4800.             foreach ($get_kids as $product) {
  4801.                 $pa = array();
  4802.                 $pa['id'] = $product['id'];
  4803.                 $pa['name'] = $product['topic_name'];
  4804.                 $pa['description'] = $product['topic_name'];
  4805.                 $pa['url'] = $url "?topicId=" $product['id'];
  4806.                 $pa['type'] = 1;
  4807.                 $pa['image'] = '';
  4808.                 $data[] = $pa;
  4809.             }
  4810.         }
  4811. //blog
  4812.         $filterQryForCriteria "select * from entity_create_blog where 1=1 
  4813.                                     and ( title  like '%" $queryStr "%'  
  4814.                                     or subtitle  like '%" $queryStr "%'  
  4815.                                     or content  like '%" $queryStr "%'  
  4816.                                     )
  4817.                                     
  4818.                                     limit 10";
  4819.         $get_kids_sql $filterQryForCriteria;
  4820.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4821.         
  4822.         $get_kids $stmt;
  4823.         $productId 0;
  4824.         $url $this->generateUrl(
  4825.             'blog_post'
  4826.         );
  4827.         if (!empty($get_kids)) {
  4828.             foreach ($get_kids as $product) {
  4829.                 $pa = array();
  4830.                 $pa['id'] = $product['id'];
  4831.                 $pa['name'] = $product['title'];
  4832.                 $pa['description'] = $product['subtitle'];
  4833.                 $pa['url'] = $url "/" $product['id'];
  4834.                 $pa['type'] = 1;
  4835.                 $pa['image'] = '';
  4836.                 $data[] = $pa;
  4837.             }
  4838.         }
  4839.         {
  4840.             return new JsonResponse(
  4841.                 array(
  4842.                     'success' => true,
  4843. //                    'page_title' => 'Product Details',
  4844. //                    'company_data' => $company_data,
  4845.                     'data' => $data,
  4846.                     //                    'exId'=>$id,
  4847. //                'productByCodeData' => $productByCodeData,
  4848. //                'productData' => $productData,
  4849. //                'currInvList' => $currInvList,
  4850. //                'productList' => Inventory::ProductList($em, $companyId),
  4851. //                'subCategoryList' => Inventory::ProductSubCategoryList($em, $companyId),
  4852. //                'categoryList' => Inventory::ProductCategoryList($em, $companyId),
  4853. //                'igList' => Inventory::ItemGroupList($em, $companyId),
  4854. //                'unitList' => Inventory::UnitTypeList($em),
  4855. //                'brandList' => Inventory::GetBrandList($em, $companyId),
  4856. //                'warehouse_action_list' => Inventory::warehouse_action_list($em,$this->getLoggedUserCompanyId($request),'object'),
  4857. //                'warehouseList' => Inventory::WarehouseList($em),
  4858.                 )
  4859.             );
  4860.         }
  4861.     }
  4862.     public
  4863.     function ConsultantSearchFromListAction(Request $request$queryStr '')
  4864.     {
  4865.         $em $this->getDoctrine()->getManager('company_group');
  4866.         $data = [];
  4867.         $data_by_id = [];
  4868.         if ($queryStr == '_DEFAULT_')
  4869.             $queryStr '';
  4870.         if ($request->request->has('query') && $queryStr == '')
  4871.             $queryStr $request->request->get('queryStr');
  4872.         if ($queryStr == '_DEFAULT_')
  4873.             $queryStr '';
  4874.         //consultant
  4875.         $filterQryForCriteria "select * from entity_applicant_details where is_consultant=1 
  4876.                                     and ( firstname  like '%" $queryStr "%'  
  4877.                                     or lastname  like '%" $queryStr "%'  
  4878.                                   
  4879.                                     )
  4880.                                     
  4881.                                     limit 10";
  4882.         $get_kids_sql $filterQryForCriteria;
  4883.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4884.         
  4885.         $get_kids $stmt;
  4886.         $productId 0;
  4887.         $url $this->generateUrl(
  4888.             'consultant_profile'
  4889.         );
  4890.         if (!empty($get_kids)) {
  4891.             foreach ($get_kids as $product) {
  4892.                 $pa = array();
  4893.                 $pa['id'] = $product['applicant_id'];
  4894.                 $pa['name'] = $product['firstname'] . ' ' $product['lastname'];
  4895.                 $pa['description'] = $product['firstname'] . ' ' $product['lastname'];
  4896.                 $pa['url'] = $url "/" $product['applicant_id'];
  4897.                 $pa['type'] = 2;
  4898.                 $pa['image'] = $product['image'];
  4899.                 $data[] = $pa;
  4900.             }
  4901.         }
  4902.         {
  4903.             return new JsonResponse(
  4904.                 array(
  4905.                     'success' => true,
  4906. //                    'page_title' => 'Product Details',
  4907. //                    'company_data' => $company_data,
  4908.                     'data' => $data,
  4909.                     //                    'exId'=>$id,
  4910. //                'productByCodeData' => $productByCodeData,
  4911. //                'productData' => $productData,
  4912. //                'currInvList' => $currInvList,
  4913. //                'productList' => Inventory::ProductList($em, $companyId),
  4914. //                'subCategoryList' => Inventory::ProductSubCategoryList($em, $companyId),
  4915. //                'categoryList' => Inventory::ProductCategoryList($em, $companyId),
  4916. //                'igList' => Inventory::ItemGroupList($em, $companyId),
  4917. //                'unitList' => Inventory::UnitTypeList($em),
  4918. //                'brandList' => Inventory::GetBrandList($em, $companyId),
  4919. //                'warehouse_action_list' => Inventory::warehouse_action_list($em,$this->getLoggedUserCompanyId($request),'object'),
  4920. //                'warehouseList' => Inventory::WarehouseList($em),
  4921.                 )
  4922.             );
  4923.         }
  4924.     }
  4925.     public
  4926.     function SearchUniversityAction(Request $request$queryStr '')
  4927.     {
  4928.         $em $this->getDoctrine()->getManager('company_group');
  4929.         $data = [];
  4930.         $data_by_id = [];
  4931.         if ($queryStr == '_DEFAULT_')
  4932.             $queryStr '';
  4933.         if ($request->request->has('query') && $queryStr == '')
  4934.             $queryStr $request->request->get('queryStr');
  4935.         if ($queryStr == '_DEFAULT_')
  4936.             $queryStr '';
  4937.         //topic
  4938.         $filterQryForCriteria "select * from entity_create_topic where topic_marker= '_university_'
  4939.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  4940.         $get_kids_sql $filterQryForCriteria;
  4941.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4942.         
  4943.         $get_kids $stmt;
  4944.         $productId 0;
  4945.         $url $this->generateUrl(
  4946.             'blog_post'
  4947.         );
  4948.         if (!empty($get_kids)) {
  4949.             foreach ($get_kids as $product) {
  4950.                 $pa = array();
  4951.                 $pa['id'] = $product['id'];
  4952.                 $pa['name'] = $product['topic_name'];
  4953.                 $pa['description'] = $product['topic_summary'];
  4954.                 $pa['url'] = $url "?topicId=" $product['id'];
  4955.                 $pa['type'] = 1;
  4956.                 $pa['image'] = '';
  4957.                 $data[] = $pa;
  4958.             }
  4959.         }
  4960. //blog
  4961.         $filterQryForCriteria "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_university_')
  4962.                                     and ( title  like '%" $queryStr "%'  
  4963.                                     or subtitle  like '%" $queryStr "%'  
  4964.                                     or content  like '%" $queryStr "%'  
  4965.                                     )
  4966.                                     
  4967.                                     limit 10";
  4968.         $get_kids_sql $filterQryForCriteria;
  4969.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  4970.         
  4971.         $get_kids $stmt;
  4972.         $productId 0;
  4973.         $url $this->generateUrl(
  4974.             'blog_post'
  4975.         );
  4976.         if (!empty($get_kids)) {
  4977.             foreach ($get_kids as $product) {
  4978.                 $pa = array();
  4979.                 $pa['id'] = $product['id'];
  4980.                 $pa['name'] = $product['title'];
  4981.                 $pa['description'] = $product['subtitle'];
  4982.                 $pa['url'] = $url "/" $product['id'];
  4983.                 $pa['type'] = 1;
  4984.                 $pa['image'] = '';
  4985.                 $data[] = $pa;
  4986.             }
  4987.         }
  4988.         return new JsonResponse(
  4989.             array(
  4990.                 'success' => true,
  4991.                 'data' => $data,
  4992.             )
  4993.         );
  4994.     }
  4995.     public
  4996.     function SearchSubjectAction(Request $request$queryStr '')
  4997.     {
  4998.         $em $this->getDoctrine()->getManager('company_group');
  4999.         $data = [];
  5000.         $data_by_id = [];
  5001.         if ($queryStr == '_DEFAULT_')
  5002.             $queryStr '';
  5003.         if ($request->request->has('query') && $queryStr == '')
  5004.             $queryStr $request->request->get('queryStr');
  5005.         if ($queryStr == '_DEFAULT_')
  5006.             $queryStr '';
  5007.         //topic
  5008.         $filterQryForCriteria "select * from entity_create_topic where topic_marker= '_subject_'
  5009.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  5010.         $get_kids_sql $filterQryForCriteria;
  5011.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  5012.         
  5013.         $get_kids $stmt;
  5014.         $productId 0;
  5015.         $url $this->generateUrl(
  5016.             'blog_post'
  5017.         );
  5018.         if (!empty($get_kids)) {
  5019.             foreach ($get_kids as $product) {
  5020.                 $pa = array();
  5021.                 $pa['id'] = $product['id'];
  5022.                 $pa['name'] = $product['topic_name'];
  5023.                 $pa['description'] = $product['topic_summary'];
  5024.                 $pa['url'] = $url "?topicId=" $product['id'];
  5025.                 $pa['type'] = 1;
  5026.                 $pa['image'] = '';
  5027.                 $data[] = $pa;
  5028.             }
  5029.         }
  5030. //blog
  5031.         $filterQryForCriteria "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_subject_')
  5032.                                     and ( title  like '%" $queryStr "%'  
  5033.                                     or subtitle  like '%" $queryStr "%'  
  5034.                                     or content  like '%" $queryStr "%'  
  5035.                                     )
  5036.                                     
  5037.                                     limit 10";
  5038.         $get_kids_sql $filterQryForCriteria;
  5039.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  5040.         
  5041.         $get_kids $stmt;
  5042.         $productId 0;
  5043.         $url $this->generateUrl(
  5044.             'blog_post'
  5045.         );
  5046.         if (!empty($get_kids)) {
  5047.             foreach ($get_kids as $product) {
  5048.                 $pa = array();
  5049.                 $pa['id'] = $product['id'];
  5050.                 $pa['name'] = $product['title'];
  5051.                 $pa['description'] = $product['subtitle'];
  5052.                 $pa['url'] = $url "/" $product['id'];
  5053.                 $pa['type'] = 1;
  5054.                 $pa['image'] = '';
  5055.                 $data[] = $pa;
  5056.             }
  5057.         }
  5058.         return new JsonResponse(
  5059.             array(
  5060.                 'success' => true,
  5061.                 'data' => $data,
  5062.             )
  5063.         );
  5064.     }
  5065.     public
  5066.     function TopicSearchFromTopicListAction(Request $request$queryStr '')
  5067.     {
  5068.         $em $this->getDoctrine()->getManager('company_group');
  5069.         $data = [];
  5070.         $data_by_id = [];
  5071.         if ($queryStr == '_DEFAULT_')
  5072.             $queryStr '';
  5073.         if ($request->request->has('query') && $queryStr == '')
  5074.             $queryStr $request->request->get('queryStr');
  5075.         if ($queryStr == '_DEFAULT_')
  5076.             $queryStr '';
  5077.         //topic
  5078.         $filterQryForCriteria "select * from entity_create_topic where 1=1 
  5079.                                     and topic_name  like '%" $queryStr "%'  limit 10";
  5080.         $get_kids_sql $filterQryForCriteria;
  5081.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  5082.         
  5083.         $get_kids $stmt;
  5084.         $productId 0;
  5085.         $url $this->generateUrl(
  5086.             'blog_post'
  5087.         );
  5088.         if (!empty($get_kids)) {
  5089.             foreach ($get_kids as $product) {
  5090.                 $pa = array();
  5091.                 $pa['id'] = $product['id'];
  5092.                 $pa['name'] = $product['topic_name'];
  5093.                 $pa['description'] = $product['topic_name'];
  5094.                 $pa['url'] = $url "?topicId=" $product['id'];
  5095.                 $pa['type'] = 1;
  5096.                 $pa['image'] = '';
  5097.                 $data[] = $pa;
  5098.             }
  5099.         }
  5100. //blog
  5101.         $filterQryForCriteria "select * from entity_create_blog where 1=1 
  5102.                                     and ( title  like '%" $queryStr "%'  
  5103.                                     or subtitle  like '%" $queryStr "%'  
  5104.                                     or content  like '%" $queryStr "%'  
  5105.                                     )
  5106.                                     
  5107.                                     limit 10";
  5108.         $get_kids_sql $filterQryForCriteria;
  5109.         $stmt $em->getConnection()->fetchAllAssociative($get_kids_sql);
  5110.         
  5111.         $get_kids $stmt;
  5112.         $productId 0;
  5113.         $url $this->generateUrl(
  5114.             'blog_post'
  5115.         );
  5116.         if (!empty($get_kids)) {
  5117.             foreach ($get_kids as $product) {
  5118.                 $pa = array();
  5119.                 $pa['id'] = $product['id'];
  5120.                 $pa['name'] = $product['title'];
  5121.                 $pa['description'] = $product['subtitle'];
  5122.                 $pa['url'] = $url "/" $product['id'];
  5123.                 $pa['type'] = 1;
  5124.                 $pa['image'] = '';
  5125.                 $data[] = $pa;
  5126.             }
  5127.         }
  5128.         {
  5129.             return new JsonResponse(
  5130.                 array(
  5131.                     'success' => true,
  5132. //                    'page_title' => 'Product Details',
  5133. //                    'company_data' => $company_data,
  5134.                     'data' => $data,
  5135.                     //                    'exId'=>$id,
  5136. //                'productByCodeData' => $productByCodeData,
  5137. //                'productData' => $productData,
  5138. //                'currInvList' => $currInvList,
  5139. //                'productList' => Inventory::ProductList($em, $companyId),
  5140. //                'subCategoryList' => Inventory::ProductSubCategoryList($em, $companyId),
  5141. //                'categoryList' => Inventory::ProductCategoryList($em, $companyId),
  5142. //                'igList' => Inventory::ItemGroupList($em, $companyId),
  5143. //                'unitList' => Inventory::UnitTypeList($em),
  5144. //                'brandList' => Inventory::GetBrandList($em, $companyId),
  5145. //                'warehouse_action_list' => Inventory::warehouse_action_list($em,$this->getLoggedUserCompanyId($request),'object'),
  5146. //                'warehouseList' => Inventory::WarehouseList($em),
  5147.                 )
  5148.             );
  5149.         }
  5150.     }
  5151.     public
  5152.     function topicListAction(Request $request$id 0)
  5153.     {
  5154.         $em_goc $this->getDoctrine()->getManager('company_group');
  5155.         $qryArray = array(
  5156. //            'isEvent' => [0,null]
  5157.         );
  5158.         $childQryArray = array(
  5159. //            'isEvent' => [0]
  5160.         );
  5161.         $singleDataFlag 0;
  5162.         if ($id != 0) {
  5163.             $singleDataFlag 1;
  5164.             $qryArray['id'] = $id;
  5165.             $childQryArray['parentTopicId'] = $id;
  5166.         }
  5167.         if ($request->query->get('countryId'0) != 0) {
  5168.             $singleDataFlag 1;
  5169.             $qryArray['countryId'] = $request->query->get('countryId'0);
  5170.         }
  5171.         $topics $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findBy(
  5172.             $qryArray,
  5173.             array(
  5174.                 'parentTopicId' => 'asc'
  5175.             )
  5176.         );
  5177.         $topicListByParentId = [];
  5178.         $parentTopicList = [];
  5179.         $parentList = [];
  5180.         $currentParentId 0;
  5181.         $currentTopic = [];
  5182.         foreach ($topics as $topic) {
  5183.             $currentParentId $topic->getParentTopicId();
  5184.             $childQryArray['parentTopicId'] = $topic->getId();
  5185.             $currentTopic $topic;
  5186.             if ($topic->getIsParent() == || $topic->getParentTopicId() == || $topic->getParentTopicId() == null || $topic->getParentTopicId() == '') {
  5187.                 $currentParentId $topic->getId();
  5188.                 $parentTopicList[$topic->getId()] = $topic;
  5189.                 $parentList[] = $topic->getId();
  5190.             } else if (in_array($topic->getParentTopicId(), $parentList)) {
  5191.                 if (!isset($topicListByParentId[$topic->getParentTopicId()]))
  5192.                     $topicListByParentId[$topic->getParentTopicId()] = [];
  5193.                 $topicListByParentId[$topic->getParentTopicId()][] = $topic;
  5194.             }
  5195.         }
  5196.         $topics $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findBy(
  5197.             $childQryArray,
  5198.             array(
  5199.                 'parentTopicId' => 'asc'
  5200.             )
  5201.         );
  5202.         foreach ($topics as $topic) {
  5203.             if($topic->getIsEvent() == 1)
  5204.                 continue;
  5205.             $currentParentId $topic->getParentTopicId();
  5206.             $currentTopic $topic;
  5207.             if ($topic->getIsParent() == || $topic->getParentTopicId() == || $topic->getParentTopicId() == null || $topic->getParentTopicId() == '') {
  5208.                 $currentParentId $topic->getId();
  5209.                 $parentTopicList[$topic->getId()] = $topic;
  5210.                 $parentList[] = $topic->getId();
  5211.             } else if (in_array($topic->getParentTopicId(), $parentList)) {
  5212.                 if (!isset($topicListByParentId[$topic->getParentTopicId()]))
  5213.                     $topicListByParentId[$topic->getParentTopicId()] = [];
  5214.                 $topicListByParentId[$topic->getParentTopicId()][] = $topic;
  5215.             }
  5216.         }
  5217.         if ($id != && empty($parentTopicList)) {
  5218.             $parTopic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(
  5219.                 array(
  5220.                     'parentTopicId' => $currentParentId
  5221.                 ),
  5222.                 array(
  5223.                     'parentTopicId' => 'asc'
  5224.                 )
  5225.             );
  5226.             if ($parTopic) {
  5227.                 $parentTopicList[$parTopic->getId()] = $parTopic;
  5228.                 if (!in_array($currentParentId$parentList)) {
  5229.                     if (!isset($topicListByParentId[$currentParentId]))
  5230.                         $topicListByParentId[$currentParentId] = [];
  5231.                     $topicListByParentId[$currentParentId][] = $currentTopic;
  5232.                 }
  5233.             }
  5234.         }
  5235.         return $this->render('@Buddybee/pages/topicListPage.html.twig', array(
  5236.             'page_title' => 'Topic List',
  5237.             'topicListByParentId' => $topicListByParentId,
  5238.             'currentParentId' => $currentParentId,
  5239.             'singleDataFlag' => $singleDataFlag,
  5240.             'parentTopicList' => $parentTopicList
  5241.         ));
  5242.     }
  5243.     public
  5244.     function helpAction()
  5245.     {
  5246.         return $this->render('@Buddybee/pages/helpPage.html.twig', array(
  5247.             'page_title' => 'Help',
  5248.         ));
  5249.     }
  5250.     public
  5251.     function contactPageAction()
  5252.     {
  5253.         return $this->render('@Buddybee/pages/contactPage.html.twig', array(
  5254.             'page_title' => 'Contact Us',
  5255.         ));
  5256.     }
  5257.     public
  5258.     function blogListAction($id)
  5259.     {
  5260.         $em $this->getDoctrine()->getManager('company_group');
  5261.         $blog $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateBlog')->findAll();
  5262.         return $this->render('@Buddybee/pages/blogList.html.twig', array(
  5263.             'page_title' => 'Blog List',
  5264.             'blog' => $blog,
  5265.         ));
  5266.     }
  5267.     public
  5268.     function ErrorPageAction()
  5269.     {
  5270.         return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  5271.             'page_title' => '404 Not Found',
  5272.         ));
  5273.     }
  5274.     public
  5275.     function SignupPageAction()
  5276.     {
  5277.         return $this->render('@Buddybee/pages/signupPage.html.twig', array(
  5278.             'page_title' => 'Sign Up',
  5279.         ));
  5280.     }
  5281.     public
  5282.     function UnderConstructionPageAction()
  5283.     {
  5284.         return $this->render('@Buddybee/pages/underConstructionPage.html.twig', array(
  5285.             'page_title' => 'Construction Page',
  5286.         ));
  5287.     }
  5288.     public function buddybeePromoFocusListAction()
  5289.     {
  5290.         $promoFocusList BuddybeeConstant::$promoFocusList;
  5291.         return new JsonResponse(
  5292.             array(
  5293.                 'success' => true,
  5294.                 'promoFocusList' => $promoFocusList,
  5295.             )
  5296.         );
  5297.     }
  5298. }