src/ApplicationBundle/Controller/ConsultancyPublicController.php line 2486

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