<?php
namespace ApplicationBundle\Controller;
use ApplicationBundle\ApplicationBundle;
use ApplicationBundle\Constants\AccountsConstant;
use ApplicationBundle\Constants\ConsultancyConstant;
use ApplicationBundle\Constants\HumanResourceConstant;
use ApplicationBundle\Constants\GeneralConstant;
use ApplicationBundle\Constants\MeetingSchedulingConstant;
use ApplicationBundle\Constants\InventoryConstant;
use ApplicationBundle\Constants\UserConstants;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Shipu\Bkash\Managers\Checkout;
use Shipu\Bkash\Enums\BkashKey;
use ApplicationBundle\Entity\AccCheck;
use ApplicationBundle\Entity\AccCostCentre;
use ApplicationBundle\Entity\AccSettings;
use ApplicationBundle\Entity\CheckFormat;
use ApplicationBundle\Entity\FiscalClosing;
use ApplicationBundle\Entity\HolidayCalendar;
use ApplicationBundle\Entity\HolidayCalendarDates;
use ApplicationBundle\Entity\Questionnaire;
use ApplicationBundle\Entity\Skill;
use ApplicationBundle\Entity\ConsultancyTopic;
use ApplicationBundle\Entity\EvaluationCategory;
use ApplicationBundle\Entity\BonusPolicy;
use ApplicationBundle\Entity\IncrementPolicy;
use ApplicationBundle\Entity\JobRecruitment;
use ApplicationBundle\Entity\EducationQualification;
use ApplicationBundle\Entity\TrainingCourse;
use ApplicationBundle\Entity\EmployeePerformanceEvolution;
use ApplicationBundle\Helper\Generic;
use ApplicationBundle\Modules\Consultancy\Consultancy;
use ApplicationBundle\Modules\User\Users;
use ApplicationBundle\Entity\Brs;
//use Symfony\Bundle\FrameworkBundle\Console\Application;
//use Symfony\Component\Console\Input\ArrayInput;
//use Symfony\Component\Console\Output\NullOutput;
use ApplicationBundle\Interfaces\SessionCheckInterface;
use ApplicationBundle\Modules\Accounts\Accounts;
use ApplicationBundle\Modules\FixedAsset\FixedAsset;
use ApplicationBundle\Modules\Inventory\Inventory;
use ApplicationBundle\Modules\Purchase\Purchase;
use ApplicationBundle\Modules\Sales\Client;
use ApplicationBundle\Modules\Sales\SalesOrderM;
use ApplicationBundle\Modules\System\DeleteDocument;
use ApplicationBundle\Modules\System\DocValidation;
use ApplicationBundle\Modules\System\Email;
use ApplicationBundle\Modules\System\MiscActions;
use ApplicationBundle\Modules\User\Company;
use ApplicationBundle\Modules\System\System;
use ApplicationBundle\TimeService\EntityManagerFactory;
use ApplicationBundle\Modules\System\ApprovalFunction;
use CompanyGroupBundle\CompanyGroupBundle;
use CompanyGroupBundle\Entity\EntityApplicantDetails;
use CompanyGroupBundle\Entity\EntityCoursePlanHistory;
use CompanyGroupBundle\Entity\EntityConsultantSchedule;
use CompanyGroupBundle\Entity\EntityCreateTopic;
use CompanyGroupBundle\Entity\EntityInvoice;
use CompanyGroupBundle\Entity\EntityReview;
use CompanyGroupBundle\Entity\EntityMeetingSession;
use CompanyGroupBundle\Entity\EntitySkill;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
use ApplicationBundle\Entity\AccTransactions;
use ApplicationBundle\Entity\ApplicantDetails;
use ApplicationBundle\Entity\Approval;
use ApplicationBundle\Entity\Branch;
use ApplicationBundle\Entity\Employee;
use ApplicationBundle\Entity\EmployeeAttendance;
use ApplicationBundle\Entity\EmployeeAttendanceLog;
use ApplicationBundle\Entity\EmployeeDetails;
use ApplicationBundle\Entity\EmployeeLeaveApplication;
use ApplicationBundle\Entity\EmployeeLeaveDetails;
use ApplicationBundle\Entity\EmployeeWorkplace;
use ApplicationBundle\Entity\FixedAssetProduct;
use ApplicationBundle\Entity\PayrollPolicy;
use ApplicationBundle\Entity\Payslip;
use ApplicationBundle\Entity\PurchaseOrder;
use ApplicationBundle\Entity\Region;
use ApplicationBundle\Entity\ResignApplication;
use ApplicationBundle\Entity\SalarySegregationPolicy;
use ApplicationBundle\Entity\SalesOrder;
use ApplicationBundle\Entity\ScheduledMeeting;
use ApplicationBundle\Entity\SysDepartment;
use ApplicationBundle\Entity\SysDepartmentPosition;
use ApplicationBundle\Entity\SysUser;
use ApplicationBundle\Entity\WorkHourPolicy;
use CompanyGroupBundle\Entity\EntityApplicantApplicationList;
use CompanyGroupBundle\Entity\PromoCode;
use ApplicationBundle\Modules\HumanResource\HumanResource;
use CompanyGroupBundle\Modules\ApplicantM;
use DateInterval;
use DatePeriod;
//use DateTime;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Validator\Constraints\DateTime;
use Ps\PdfBundle\Annotation\Pdf;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Serializer\Encoder\JsonDecode;
use Symfony\Component\Validator\Constraints\Json;
use Google_Client;
use Google_Service_Oauth2;
use Spatie\CalendarLinks\Link;
class ConsultancyPublicController extends GenericController
{
public function CheckBeeCodeAction(Request $request, $beeCode = '')
{
$em = $this->getDoctrine()->getManager('company_group');
if ($beeCode == '')
$beeCode = $request->query->get('beeCode', '');
if ($beeCode == '')
$beeCode = $request->request->get('beeCode', '');
return new JsonResponse(Consultancy::ProcessBeeCard($em, $beeCode));
}
public function RefreshEntityMeetingSessionScheduledNotificationAction(Request $request, $beeCode = '')
{
$em = $this->getDoctrine()->getManager('company_group');
Consultancy::refreshEntityMeetingSessionScheduledNotification($em, $request->query->get('meetingId', 0),
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server'));
return new JsonResponse(array(
'success' => true
));
}
public function CheckPromoCodeAction(Request $request, $code = '')
{
$em = $this->getDoctrine()->getManager('company_group');
if ($code == '')
$code = $request->request->get('code', $request->query->get('code', ''));
$silent = $request->request->get('silent', $request->query->get('silent', 1));
$promoCode = $em->getRepository('CompanyGroupBundle:PromoCode')
->findOneBy(
array(
'code' => $code
)
);
$data = array(
'success' => false,
'message' => 'Invalid Code'
);
$session = $request->getSession();
$claimData = MiscActions::ClaimPromoCode($em,
[
'claimFlag' => $request->query->get('claimFlag', $request->request->get('claimFlag', 0)),
'promoCode' => $code,
'orderValue' => $request->query->get('orderValue', $request->request->get('orderValue', 0)),
'orderCoin' => $request->query->get('orderCoin', $request->request->get('orderCoin', 0)),
'currency' => $request->query->get('currency', $request->request->get('currency', 'eur')),
'userId' => $request->query->get('userId', $request->request->get('userId', 0)),
]);
if ($claimData['data']['success'] == false) {
if ($session->get('codeHash', '') == $code)
$session->set('codeHash', '');
}
$claimData['data']['silent'] = $silent;
// if ($promoCode) {
//
// $data = array(
// 'success' => true,
// 'message' => '',
// 'id' => $promoCode->getId(),
// 'code' => $promoCode->getCode(),
// 'promoType' => $promoCode->getPromoType(),
// 'promoValue' => $promoCode->getPromoValue(),
// 'maxDiscountAmount' => $promoCode->getMaxDiscountAmount(),
// 'maxCoinAddition' => $promoCode->getMaxCoinAddition(),
// 'minAmountForApplication' => $promoCode->getMinAmountForApplication(),
// 'minCoinForApplication' => $promoCode->getMinCoinForApplication(),
// 'nextApplicationEachCoinCount' => $promoCode->getNextApplicationEachCoinCount(),
// 'maxUseCount' => $promoCode->getMaxUseCount(),
// 'maxUseCountPerUser' => $promoCode->getMaxUseCountPerUser(),
// 'useCountBalance' => $promoCode->getUseCountBalance(),
// 'useCountBalanceUser' => 0,
//
// 'startsAtTs' => $promoCode->getStartsAtTs(),
// 'expiresAtTs' => $promoCode->getExpiresAtTs(),
// 'perpetual' => $promoCode->getPerpetual(),
//
//
// );
//
// }
// return new JsonResponse($data);
return new JsonResponse($claimData['data']);
}
public function ReturnJsonForListenerAction(Request $request, $dataStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$amount = '50';
// if($dataStr)
$session = $request->getSession();
$dataStrFromSess = $session->get('jsonStrForListenerData');
$dataJson = json_decode($dataStrFromSess, true);
$session->set('jsonStrForListenerData', null);
if ($dataJson == null) $dataJson = [];
// if ($request->has('returnJson')) {
return new JsonResponse($dataJson);
// }
}
public function PrintBeeCardAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager('company_group');
// $dt = Inventory::GetDrDetails($em, $id, $item_id);
$repeatCount = 1;
$assignProductId = '';
$queryCondition = [];
$cardList = [];
$printFlag = $request->request->get('printFlag', $request->query->get('printFlag', 0));
$sendViaMailFlag = $request->get('sendViaMailFlag', 1);;
$receiverEmail = $request->get('receiverEmail', 'mozibul.yasser@ourhoneybee.eu');
$cardCount = $request->get('cardCount', 1);
$cardAmount = $request->get('cardAmount', 0);
$coinCount = $request->get('coinCount', 100);
$currency = $request->get('currency', 'eur');
$customQrOnly = $request->get('customQr', 0);
$customQrUrl = $request->get('customQrUrl', '');
$customQrPath = $request->get('customQrPath', '');
$customQrDataIndex = $request->get('customQrDataIndex', 'data');
$customQrDataJson = $request->get('customQrDataJson', '');
if ($customQrOnly == 1) {
return $this->render('ApplicationBundle:pages/consultancy:print_bee_card.html.twig',
// else return $this->render('ApplicationBundle:email/user:buddybee_registration.html.twig',
// else return $this->render('ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig',
array(
'page_title' => 'Bee Codes',
// 'export'=>'pdf,print',
'data' => [],
'customQrUrl' => $customQrUrl,
'customQrPath' => $customQrPath,
'customQrOnly' => $customQrOnly,
'customQrDataJson' => $customQrDataJson,
'customQrDataIndex' => $customQrDataIndex,
'productList' => [],
'repeatCount' => [],
// 'item_id' => $item_id,
'labelData' => [],
'cardList' => [],
'approval_data' => [],
'document_log' => [],
'document_mark_image' => [],
'red' => 0
)
);
}
$createIfNeeded = $request->get('createIfNeeded', 0);
$rePrintFlag = $request->request->has('rePrintFlag') ? $request->request->get('rePrintFlag') : 0;
$cardIds = json_decode($request->get('cardIds', ''), true);
$markAsPrinted = $request->request->get('markAsPrinted', $request->query->get('markAsPrinted', 0));
$returnJson = $request->request->has('returnJson') ? $request->request->get('returnJson') : 0;
$physicalOnly = $request->get('physicalOnly', 0);
$retailerId = $request->get('retailerId', 0);
if (!empty($cardIds))
$queryCondition['id'] = $cardIds;
if ($physicalOnly == 1)
$queryCondition['isForHardCopy'] = 1;
if ($rePrintFlag == 0)
$queryCondition['printed'] = [0, null];
$queryCondition['retailerId'] = $retailerId;
if ($cardAmount != 0) $queryCondition['amount'] = $cardAmount;
if ($coinCount != 0) $queryCondition['coinCount'] = $coinCount;
if ($returnJson == 1)
$printFlag = 0;
$cards = $em->getRepository('CompanyGroupBundle:BeeCode')
->findBy(
$queryCondition, [], $cardCount
);
foreach ($cards as $card) {
$cardList[] = array(
'id' => $card->getId(),
'printed' => $card->getPrinted(),
'amount' => $card->getAmount(),
'coinCount' => $card->getCoinCount(),
'pin' => $card->getPin(),
'serial' => $card->getSerial(),
);
}
if ((1 * $cardCount) > count($cards)) {
if ($createIfNeeded == 1) {
$generateOptions = [
'amount' => isset($cpd['amount']) ? $cpd['amount'] : 0,
'coinCount' => $coinCount,
'cardCount' => ((1 * $cardCount) - count($cards)),
'serial' => '_AUTO_',
'pin' => '_AUTO_',
'useCount' => 1,
'isForHardCopy' => $physicalOnly == 1 ? 1 : 0,
'retailerId' => $retailerId,
];
$generatedData = MiscActions::GenerateBeeCode($em, $generateOptions);
foreach ($generatedData['data'] as $cardDt) {
$card = $cardDt['cardEntityObj'];
$cardList[] = array(
'id' => $card->getId(),
'printed' => $card->getPrinted(),
'amount' => $card->getAmount(),
'coinCount' => $card->getCoinCount(),
'pin' => $card->getPin(),
'serial' => $card->getSerial(),
);
}
}
}
$companyId = $this->getLoggedUserCompanyId($request);
if ($request->query->has('repeatCount'))
$repeatCount = $request->query->get('repeatCount');
if ($request->request->has('print_selection_type'))
$print_selection_type = $request->request->get('print_selection_type');
if ($request->request->has('print_selection_string'))
$print_selection_string = $request->request->get('print_selection_string');
if ($request->request->has('productByCodeIds'))
$productByCodeIds = json_decode($request->request->get('productByCodeIds'), true);
if ($request->request->has('formatId'))
$assignLabelFormatId = $request->request->get('formatId');
if ($printFlag == 0) {
}
if ($sendViaMailFlag == 1) {
if (GeneralConstant::EMAIL_ENABLED == 1) {
$bodyHtml = '';
$bodyTemplate = 'ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig';
$bodyData = array(
'cardList' => $cardList,
// 'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
// 'email' => $userName,
// 'password' => $newApplicant->getPassword(),
);
$attachments = [];
$forwardToMailAddress = $receiverEmail;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'subject' => 'Digital Bee Card Delivery',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'delivery@buddybee.eu',
'userName' => 'delivery@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'encryptionMethod' => 'tls',
'encryptionMethod' => 'ssl',
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
foreach ($cards as $card) {
$card->setPrinted(1);
}
$em->flush();
}
return new JsonResponse(
array(
'success' => true
)
);
}
$productByCodeData = [];
$productList = [];
$productIds = [];
$labelData = [
'formatId' => 0
];
$formatId = 0;
// $company_data = Company::getCompanyData($em, 1);
$document_mark = array(
'original' => '/images/Original-Stamp-PNG-Picture.png',
'copy' => ''
);
$dt = $productByCodeData;
if ($request->query->has('pdf') && $this->get('knp_snappy.pdf')) {
$html = $this->renderView('ApplicationBundle:pages/inventory/print:print_label.html.twig',
array(
//full array here
'pdf' => true,
'page_title' => 'Device Labels',
'export' => 'print',
'repeatCount' => $repeatCount,
'labelData' => $labelData,
// 'brandList' => Inventory::GetBrandList($em, $companyId),
// 'item_id' => $item_id,
'data' => $dt,
'productList' => $productList,
'approval_data' => [],
'document_log' => [],
'document_mark_image' => $document_mark['original'],
'red' => 0
)
);
$pdf_response = $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
// 'orientation' => 'landscape',
'enable-javascript' => true,
// 'javascript-delay' => 1000,
'no-stop-slow-scripts' => false,
'no-background' => false,
'lowquality' => false,
'encoding' => 'utf-8',
// 'images' => true,
// 'cookie' => array(),
'dpi' => 300,
'image-dpi' => 300,
// 'enable-external-links' => true,
// 'enable-internal-links' => true
));
return new Response(
$pdf_response,
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="device_labels.pdf"'
)
);
}
$url = $this->generateUrl(
'print_label'
);
if ($markAsPrinted == 1) {
foreach ($cards as $card) {
$card->setPrinted(1);
}
$em->flush();
}
if ($returnJson == 1 && $printFlag == 0) {
// $dr = $em->getRepository('ApplicationBundle:DeliveryReceipt')->findBy(
// array(
// 'salesOrderId' => $orderId, ///material
//
// )
// );
return new JsonResponse(array(
'success' => true,
'cardList' => $cardList
// 'documentHash' => $order->getDocumentHash(),
// 'documentId' => $receiptId,
// 'documentIdPadded' => str_pad($receiptId, 8, '0', STR_PAD_LEFT),
//
// 'viewUrl' => $url . "/" . $receiptId,
));
} else return $this->render('ApplicationBundle:pages/consultancy:print_bee_card.html.twig',
// else return $this->render('ApplicationBundle:email/user:buddybee_registration.html.twig',
// else return $this->render('ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig',
array(
'page_title' => 'Bee Codes',
// 'export'=>'pdf,print',
'data' => $dt,
'customQrOnly' => $customQrOnly,
'productList' => $productList,
'repeatCount' => $repeatCount,
// 'item_id' => $item_id,
'labelData' => $labelData,
'cardList' => $cardList,
'approval_data' => [],
'document_log' => [],
'document_mark_image' => $document_mark['original'],
'red' => 0
)
);
}
public function MakePaymentOfEntityInvoiceAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$em_goc = $em;
$invoiceId = 0;
$autoRedirect = 1;
$redirectUrl = '';
$meetingId = 0;
$triggerMiddlePage = 0;
$session = $request->getSession();
$sandBoxMode = $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
$refundSuccess = 0;
$errorMsg = '';
$errorCode = '';
if ($encData != '') {
$invoiceId = $encData;
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
if (isset($encryptedData['invoiceId']))
$invoiceId = $encryptedData['invoiceId'];
if (isset($encryptedData['triggerMiddlePage']))
$triggerMiddlePage = $encryptedData['triggerMiddlePage'];
if (isset($encryptedData['autoRedirect']))
$autoRedirect = $encryptedData['autoRedirect'];
} else {
$invoiceId = $request->request->get('invoiceId', $request->query->get('invoiceId', 0));
$triggerMiddlePage = $request->request->get('triggerMiddlePage', $request->query->get('triggerMiddlePage', 0));
$meetingId = 0;
$autoRedirect = $request->query->get('autoRedirect', 1);
$redirectUrl = '';
}
$meetingId = $request->request->get('meetingId', $request->query->get('meetingId', 0));
$actionDone = 0;
if ($meetingId != 0) {
$dt = Consultancy::ConfirmAnyMeetingSessionIfPossible($em, 0, $meetingId, false,
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server'));
if ($invoiceId == 0 && $dt['success'] == true) {
$actionDone = 1;
return new JsonResponse(array(
'clientSecret' => 0,
'actionDone' => $actionDone,
'id' => 0,
'proceedToCheckout' => 0
));
}
}
// $invoiceId = $request->request->get('meetingId', $request->query->get('meetingId', 0));
$output = [
'clientSecret' => 0,
'id' => 0,
'proceedToCheckout' => 0
];
if ($invoiceId != 0) {
$gatewayInvoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')->findOneBy(
array(
'Id' => $invoiceId,
'isProcessed' => [0]
));
} else {
$gatewayInvoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')->findOneBy(
array(
'meetingId' => $meetingId,
'isProcessed' => [0]
));
}
if ($gatewayInvoice)
$invoiceId = $gatewayInvoice->getId();
$invoiceSessionCount = 0;
$payableAmount = 0;
$imageBySessionCount = [
0 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
];
if ($gatewayInvoice) {
$gatewayProductData = json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
if ($gatewayProductData == null) $gatewayProductData = [];
$gatewayAmount = 1 * number_format($gatewayInvoice->getGateWayBillamount(), 2, '.', '');
$invoiceSessionCount = $gatewayInvoice->getSessionCount();
$currencyForGateway = $gatewayInvoice->getAmountCurrency();
$gatewayAmount = round($gatewayAmount, 2);
if (empty($gatewayProductData))
$gatewayProductData = [
[
'price_data' => [
'currency' => 'eur',
'unit_amount' => $gatewayAmount != 0 ? (100 * $gatewayAmount) : 200000,
'product_data' => [
// 'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
'name' => 'Bee Coins',
'images' => [$imageBySessionCount[$invoiceSessionCount]],
],
],
'quantity' => 1,
]
];
$productDescStr = '';
$productDescArr = [];
foreach ($gatewayProductData as $gpd) {
$productDescArr[] = $gpd['price_data']['product_data']['name'];
}
$productDescStr = implode(',', $productDescArr);
$paymentGatewayFromInvoice = $gatewayInvoice->getAmountTransferGateWayHash();
if ($paymentGatewayFromInvoice == 'stripe') {
$stripe = new \Stripe\Stripe();
\Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
$stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
{
if ($request->query->has('meetingSessionId'))
$id = $request->query->get('meetingSessionId');
}
$paymentIntent = [
"id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
"object" => "payment_intent",
"amount" => 3000,
"amount_capturable" => 0,
"amount_received" => 0,
"application" => null,
"application_fee_amount" => null,
"canceled_at" => null,
"cancellation_reason" => null,
"capture_method" => "automatic",
"charges" => [
"object" => "list",
"data" => [],
"has_more" => false,
"url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
],
"client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
"confirmation_method" => "automatic",
"created" => 1546523966,
"currency" => $currencyForGateway,
"customer" => null,
"description" => null,
"invoice" => null,
"last_payment_error" => null,
"livemode" => false,
"metadata" => [],
"next_action" => null,
"on_behalf_of" => null,
"payment_method" => null,
"payment_method_options" => [],
"payment_method_types" => [
"card"
],
"receipt_email" => null,
"review" => null,
"setup_future_usage" => null,
"shipping" => null,
"statement_descriptor" => null,
"statement_descriptor_suffix" => null,
"status" => "requires_payment_method",
"transfer_data" => null,
"transfer_group" => null
];
$checkout_session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => $gatewayProductData,
'mode' => 'payment',
'success_url' => $this->generateUrl(
'payment_gateway_success',
['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
'cancel_url' => $this->generateUrl(
'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
]);
$output = [
'clientSecret' => $paymentIntent['client_secret'],
'id' => $checkout_session->id,
'paymentGateway' => $paymentGatewayFromInvoice,
'proceedToCheckout' => 1
];
// return new JsonResponse($output);
}
if ($paymentGatewayFromInvoice == 'aamarpay') {
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
$url = $sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/request.php' : 'https://secure.aamarpay.com/request.php';
$fields = array(
// 'store_id' => 'aamarpaytest', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
'amount' => 1 * number_format($gatewayInvoice->getGateWayBillamount(), 2, '.', ''), //transaction amount
'payment_type' => 'VISA', //no need to change
'currency' => strtoupper($currencyForGateway), //currenct will be USD/BDT
'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
'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(), //customer name
'cus_email' => $studentDetails->getEmail(), //customer email address
'cus_add1' => $studentDetails->getCurrAddr(), //customer address
'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
'cus_city' => $studentDetails->getCurrAddrCity(), //customer city
'cus_state' => $studentDetails->getCurrAddrState(), //state
'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
'cus_country' => 'Bangladesh', //country
'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' : $studentDetails->getPhone(), //customer phone number
'cus_fax' => '', //fax
'ship_name' => '', //ship name
'ship_add1' => '', //ship address
'ship_add2' => '',
'ship_city' => '',
'ship_state' => '',
'ship_postcode' => '',
'ship_country' => 'Bangladesh',
'desc' => $productDescStr,
'success_url' => $this->generateUrl(
'payment_gateway_success',
['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
'fail_url' => $this->generateUrl(
'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
'cancel_url' => $this->generateUrl(
'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
// 'opt_a' => 'Reshad', //optional paramter
// 'opt_b' => 'Akil',
// 'opt_c' => 'Liza',
// 'opt_d' => 'Sohel',
// 'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183', //sandbox
'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524' //live
); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
curl_close($ch);
// $this->redirect_to_merchant($url_forward);
$output = [
// 'redirectUrl' => 'https://sandbox.aamarpay.com/'.$url_forward, //keeping it off temporarily
'redirectUrl' => ($sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/' : 'https://secure.aamarpay.com/') . $url_forward, //keeping it off temporarily
// 'fields'=>$fields,
// 'fields_string'=>$fields_string,
// 'redirectUrl' => $this->generateUrl(
// 'payment_gateway_success',
// ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
// 'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
// ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
'paymentGateway' => $paymentGatewayFromInvoice,
'proceedToCheckout' => 1
];
// return new JsonResponse($output);
} else if ($paymentGatewayFromInvoice == 'bkash') {
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
$baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' : 'https://tokenized.pay.bka.sh/v1.2.0-beta';
$username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' : '01891962953';
$password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' : ',a&kPV4deq&';
$app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' : '2ueVHdwz5gH3nxx7xn8wotlztc';
$app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' : '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
$request_data = array(
'app_key' => $app_key_value,
'app_secret' => $app_secret_value
);
$url = curl_init($baseUrl . '/tokenized/checkout/token/grant');
$request_data_json = json_encode($request_data);
$header = array(
'Content-Type:application/json',
'username:' . $username_value,
'password:' . $password_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $request_data_json);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$tokenData = json_decode(curl_exec($url), true);
curl_close($url);
$id_token = $tokenData['id_token'];
$goToBkashPage = 0;
if ($tokenData['statusCode'] == '0000') {
$auth = $id_token;
$requestbody = array(
"mode" => "0011",
// "payerReference" => "",
"payerReference" => $gatewayInvoice->getInvoiceDateTs(),
"callbackURL" => $this->generateUrl(
'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
),
// "merchantAssociationInfo" => "MI05MID54RF09123456One",
"amount" => number_format($gatewayInvoice->getGateWayBillamount(), 2, '.', ''),
"currency" => "BDT",
"intent" => "sale",
"merchantInvoiceNumber" => $invoiceId
);
$url = curl_init($baseUrl . '/tokenized/checkout/create');
$requestbodyJson = json_encode($requestbody);
$header = array(
'Content-Type:application/json',
'Authorization:' . $auth,
'X-APP-Key:' . $app_key_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $requestbodyJson);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$resultdata = curl_exec($url);
curl_close($url);
// return new JsonResponse($resultdata);
$obj = json_decode($resultdata, true);
$goToBkashPage = 1;
$justNow = new \DateTime();
$justNow->modify('+' . $tokenData['expires_in'] . ' second');
$gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
$gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
$gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
$gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
$em->flush();
$output = [
'redirectUrl' => $obj['bkashURL'],
'paymentGateway' => $paymentGatewayFromInvoice,
'proceedToCheckout' => $goToBkashPage,
'tokenData' => $tokenData,
'obj' => $obj,
'id_token' => $tokenData['id_token'],
];
}
// $fields = array(
//
// "mode" => "0011",
// "payerReference" => "01723888888",
// "callbackURL" => $this->generateUrl(
// 'payment_gateway_success',
// ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
// 'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
// ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
// "merchantAssociationInfo" => "MI05MID54RF09123456One",
// "amount" => $gatewayInvoice->getGateWayBillamount(),
// "currency" => "BDT",
// "intent" => "sale",
// "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)
//
// );
// $fields = array(
//// 'store_id' => 'aamarpaytest', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
// 'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
// 'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
// 'payment_type' => 'VISA', //no need to change
// 'currency' => strtoupper($currencyForGateway), //currenct will be USD/BDT
// '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
// 'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(), //customer name
// 'cus_email' => $studentDetails->getEmail(), //customer email address
// 'cus_add1' => $studentDetails->getCurrAddr(), //customer address
// 'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
// 'cus_city' => $studentDetails->getCurrAddrCity(), //customer city
// 'cus_state' => $studentDetails->getCurrAddrState(), //state
// 'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
// 'cus_country' => 'Bangladesh', //country
// 'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
// 'cus_fax' => '', //fax
// 'ship_name' => '', //ship name
// 'ship_add1' => '', //ship address
// 'ship_add2' => '',
// 'ship_city' => '',
// 'ship_state' => '',
// 'ship_postcode' => '',
// 'ship_country' => 'Bangladesh',
// 'desc' => $productDescStr,
// 'success_url' => $this->generateUrl(
// 'payment_gateway_success',
// ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
// 'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
// ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
// 'fail_url' => $this->generateUrl(
// 'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
// 'cancel_url' => $this->generateUrl(
// 'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
//// 'opt_a' => 'Reshad', //optional paramter
//// 'opt_b' => 'Akil',
//// 'opt_c' => 'Liza',
//// 'opt_d' => 'Sohel',
//// 'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183', //sandbox
// 'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524' //live
//
// ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
//
// $fields_string = http_build_query($fields);
//
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_VERBOSE, true);
// curl_setopt($ch, CURLOPT_URL, $url);
//
// curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
// curl_close($ch);
// $this->redirect_to_merchant($url_forward);
}
}
if ($triggerMiddlePage == 1) return $this->render('ApplicationBundle:pages/consultancy:makePaymentOfEntityInvoiceLandingPage.html.twig', array(
'page_title' => 'Invoice Payment',
'data' => $output,
));
else
return new JsonResponse($output);
}
public function TriggerLoginForBookMeetingAction(Request $request, $encData = '')
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$session = $request->getSession();
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
$token = $request->request->get('token', $session->get('token', ''));
if ($token != '')
MiscActions::DeleteToken($em_goc, $token);
$session->clear();
$session->set('CLEARLOGIN', 1);
if (isset($encryptedData['LAST_REQUEST_URI_BEFORE_LOGIN']))
$session->set('LAST_REQUEST_URI_BEFORE_LOGIN', $encryptedData['LAST_REQUEST_URI_BEFORE_LOGIN']);
// $request->headers->setCookie(Cookie::create('CLEARLOGINCOOKIE', 1
// )
//
// );
return $this->redirectToRoute('user_login');
}
public function RefundEntityInvoiceAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$invoiceId = 0;
$currIsProcessedFlagValue = '_UNSET_';
$session = $request->getSession();
$sandBoxMode = $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
$paymentId = $request->query->get('paymentID', 0);
$status = $request->query->get('status', 0);
$refundSuccess = 0;
$errorMsg = '';
$errorCode = '';
if ($encData != '') {
$invoiceId = $encData;
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
if (isset($encryptedData['invoiceId']))
$invoiceId = $encryptedData['invoiceId'];
if (isset($encryptedData['autoRedirect']))
$autoRedirect = $encryptedData['autoRedirect'];
} else {
$invoiceId = $request->request->get('invoiceId', $request->query->get('invoiceId', 0));
$meetingId = 0;
$autoRedirect = $request->query->get('autoRedirect', 1);
$redirectUrl = '';
}
$gatewayInvoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')->findOneBy(
array(
'Id' => $invoiceId,
'isProcessed' => [1]
));
if ($gatewayInvoice) {
$gatewayInvoice->setIsProcessed(3); //pending settlement
$currIsProcessedFlagValue = $gatewayInvoice->getIsProcessed();
$em->flush();
if ($gatewayInvoice->getAmountTransferGateWayHash() == 'bkash') {
$invoiceId = $gatewayInvoice->getId();
$paymentID = $gatewayInvoice->getGatewayPaymentId();
$trxID = $gatewayInvoice->getGatewayTransId();
$justNow = new \DateTime();
$baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' : 'https://tokenized.pay.bka.sh/v1.2.0-beta';
$username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' : '01891962953';
$password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' : ',a&kPV4deq&';
$app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' : '2ueVHdwz5gH3nxx7xn8wotlztc';
$app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' : '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
$justNowTs = $justNow->format('U');
if ($gatewayInvoice->getGatewayIdTokenExpireTs() <= $justNowTs) {
$refresh_token = $gatewayInvoice->getGatewayIdRefreshToken();
$request_data = array(
'app_key' => $app_key_value,
'app_secret' => $app_secret_value,
'refresh_token' => $refresh_token
);
$url = curl_init($baseUrl . '/tokenized/checkout/token/refresh');
$request_data_json = json_encode($request_data);
$header = array(
'Content-Type:application/json',
'username:' . $username_value,
'password:' . $password_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $request_data_json);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$tokenData = json_decode(curl_exec($url), true);
curl_close($url);
$justNow = new \DateTime();
$justNow->modify('+' . $tokenData['expires_in'] . ' second');
$gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
$gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
$gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
$em->flush();
}
$auth = $gatewayInvoice->getGatewayIdToken();;
$post_token = array(
'paymentID' => $paymentID,
'trxID' => $trxID,
'reason' => 'Full Refund Policy',
'sku' => 'RSTR',
'amount' => 1 * number_format($gatewayInvoice->getGateWayBillamount(), 2, '.', ''),
);
$url = curl_init($baseUrl . '/tokenized/checkout/payment/refund');
$posttoken = json_encode($post_token);
$header = array(
'Content-Type:application/json',
'Authorization:' . $auth,
'X-APP-Key:' . $app_key_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $posttoken);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$resultdata = curl_exec($url);
curl_close($url);
$obj = json_decode($resultdata, true);
// return new JsonResponse($obj);
if (isset($obj['completedTime']))
$refundSuccess = 1;
else if (isset($obj['errorCode'])) {
$refundSuccess = 0;
$errorCode = $obj['errorCode'];
$errorMsg = $obj['errorMessage'];
}
// $gatewayInvoice->setGatewayTransId($obj['trxID']);
$em->flush();
}
if ($refundSuccess == 1) {
Consultancy::RefundEntityInvoice($em, $invoiceId);
$currIsProcessedFlagValue = 4;
}
} else {
}
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
return new JsonResponse(
array(
'success' => $refundSuccess,
'errorCode' => $errorCode,
'isProcessed' => $currIsProcessedFlagValue,
'errorMsg' => $errorMsg,
)
);
}
public function ViewEntityInvoiceAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$invoiceId = 0;
$autoRedirect = 1;
$redirectUrl = '';
$meetingId = 0;
$invoice = null;
if ($encData != '') {
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
$invoiceId = $encData;
if (isset($encryptedData['invoiceId']))
$invoiceId = $encryptedData['invoiceId'];
if (isset($encryptedData['autoRedirect']))
$autoRedirect = $encryptedData['autoRedirect'];
} else {
$invoiceId = $request->query->get('invoiceId', 0);
$meetingId = 0;
$autoRedirect = $request->query->get('autoRedirect', 1);
$redirectUrl = '';
}
// $invoiceList = [];
$billerDetails = [];
$billToDetails = [];
if ($invoiceId != 0) {
$invoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')
->findOneBy(
array(
'Id' => $invoiceId,
)
);
if ($invoice) {
$billerDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillerId(),
)
);
$billToDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillToId(),
)
);
}
// foreach ($invoice as data) {
// $invoiceData = array(
// 'id' => data->getStudentId(),
//
// );
// $invoiceList = $invoiceData;
// }
}
// $student= [];
// $studentDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
// ->findBy(
// array(
// 'applicantId' => $invoiceId->getStudentId(),
//
// )
// );
//
//
//
// foreach ($studentDetails as $studentDetail) {
// $studentData = array(
// 'firstName' => $studentDetail->getFirstName(),
// 'lasttName' => $studentDetail->getLastName(),
//
// );
// $student = $studentData;
// }
if ($request->query->get('sendMail', 0) == 1 && GeneralConstant::EMAIL_ENABLED == 1) {
$billerDetails = [];
$billToDetails = [];
if ($invoice) {
$billerDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillerId(),
)
);
$billToDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillToId(),
)
);
$bodyTemplate = 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
$bodyData = array(
'page_title' => 'Invoice',
// 'studentDetails' => $student,
'billerDetails' => $billerDetails,
'billToDetails' => $billToDetails,
'invoice' => $invoice,
'currencyList' => ConsultancyConstant::$currency_List,
'currencyListByMarker' => ConsultancyConstant::$currency_List_by_marker,
);
$attachments = [];
$forwardToMailAddress = $billToDetails->getOAuthEmail();
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'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 ',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'no-reply@buddybee.eu',
'userName' => 'no-reply@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 0,
'companyId' => 0,
'companyImagePath' => ''
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
}
}
if ($invoice) {
} else {
return $this->render('ApplicationBundle:pages/consultancy:404NotFound.html.twig', array(
'page_title' => '404 Not Found',
));
}
return $this->render('ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig', array(
'page_title' => 'Invoice',
// 'studentDetails' => $student,
'billerDetails' => $billerDetails,
'billToDetails' => $billToDetails,
'invoice' => $invoice,
'currencyList' => ConsultancyConstant::$currency_List,
'currencyListByMarker' => ConsultancyConstant::$currency_List_by_marker,
));
}
public function ConfirmBuddybeeMeetingAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$invoiceId = 0;
$autoRedirect = 1;
$redirectUrl = '';
$meetingId = 0;
$studentId = 0;
$consultantId = 0;
$confirmBookingPaymentWise = '_UNCHANGED_';
$confirmedByStudent = '_UNCHANGED_';
$confirmedByConsultant = '_UNCHANGED_';
if ($encData != '') {
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
if (isset($encryptedData['meetingId'])) $meetingId = $encryptedData['meetingId'];
if (isset($encryptedData['studentId'])) $studentId = $encryptedData['studentId'];
if (isset($encryptedData['consultantId'])) $consultantId = $encryptedData['consultantId'];
if (isset($encryptedData['confirmBookingPaymentWise'])) $confirmBookingPaymentWise = $encryptedData['confirmBookingPaymentWise'];
if (isset($encryptedData['confirmedByConsultant'])) $confirmedByConsultant = $encryptedData['confirmedByConsultant'];
if (isset($encryptedData['confirmedByStudent'])) $confirmedByStudent = $encryptedData['confirmedByStudent'];
} else {
$meetingId = $request->request->get('meetingId', $request->query->get('meetingId', 0));
$consultantId = $request->request->get('consultantId', $request->query->get('consultantId', 0));
$studentId = $request->request->get('studentId', $request->query->get('studentId', 0));
$confirmBookingPaymentWise = $request->request->get('confirmBookingPaymentWise', $request->query->get('confirmBookingPaymentWise', '_UNCHANGED_'));
$confirmedByStudent = $request->request->get('confirmedByStudent', $request->query->get('confirmedByStudent', '_UNCHANGED_'));
$confirmedByConsultant = $request->request->get('confirmedByConsultant', $request->query->get('confirmedByConsultant', '_UNCHANGED_'));
}
if ($meetingId != 0) {
if ($confirmBookingPaymentWise == 1) {
Consultancy::ConfirmAnyMeetingSessionIfPossible($em, $studentId, $meetingId);
}
Consultancy::ModifyConfirmationInfo($em, $meetingId, $confirmedByStudent, $confirmedByConsultant);
} else {
if ($confirmBookingPaymentWise == 1) {
Consultancy::ConfirmAnyMeetingSessionIfPossible($em, $studentId, $meetingId);
}
}
return new JsonResponse(
array(
'success' => true
)
);
}
public function BuddyBeeAdminReportTestAction(Request $request, $encData = '')
{
$toPrint = "";
$gocList = [];
$now = new \DateTime();
$now->setTimezone(new \DateTimeZone('+0000'));
$yday = new \DateTime();
$yday->modify('-1 day');
$yday->setTimezone(new \DateTimeZone('+0000'));
$currDate_YMD = $now->format('Y-m-d H:i:s');
$yday_start_YMD = $yday->format('Y-m-d 00:00:00');
$yday_YMD = $yday->format('Y-m-d 23:59:59');
$currDateTs = $now->format('U');
$gocList = [];
$dayOfMonth = new \DateTime();
$dayOfMonth->modify('-30 day');
$firstDayOfMonth_YMD = $dayOfMonth->format('Y-m-d 00:00:00');
$lastWeek = new \DateTime();
$lastWeek->modify('-6 day');
$lasstWeek_YMD = $lastWeek->format('Y-m-d 00:00:00');
$cgem = $this->getDoctrine()->getManager('company_group');
$currDate = new \DateTime();
$currDateTs = 1 * $currDate->format('U');
$toDeleteIdList = [];
// $toPrint.="\nSearching $gocDbName Now..";
//check if there are flags the flags and set them in enti
$reportData = array(
'newUser' => 0,
'totalUser' => 0,
'newInvoicePurchasePaid' => 0,
'totalInvoicePurchasePaid' => 0,
'newCoinPurchased' => 0,
'totalCoinPurchased' => 0,
'newPaidBookings' => 0,
'totalPaidBookings' => 0,
'dateStr' => $currDate->format('F d, Y'),
'monthWiseUser' => 0,
'lastWeek' => 0,
'monthlyInvoicePurchasePaid' => 0,
'weeklyInvoicePurchasePaid' => 0,
'monthlyPaidBookings' => 0,
'weeklyPaidBookings' => 0,
'monthlyCoinPurchased' => 0,
'weeklyCoinPurchased' => 0,
'newLead' => 0,
'weeklyLead' => 0,
'monthlyLead' => 0,
'totalLead' => 0
);
//get
$reportData['newUser'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
->andWhere("m.actualRegistrationAt <= :yday_YMD ")
->setParameter('yday_start_YMD', $yday_start_YMD)
->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['monthWiseUser'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
// ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
// ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
->andWhere('m.actualRegistrationAt BETWEEN :firstDayOfThisMonth AND :currentDate')
->setParameter('firstDayOfThisMonth', $firstDayOfMonth_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['lastWeek'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
// ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
// ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
->andWhere('m.actualRegistrationAt BETWEEN :lastWeek AND :currentDate')
->setParameter('lastWeek', $lasstWeek_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['totalUser'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 0 or m.isTemporaryEntry is null)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
// ->andWhere("m.createdAt >= :yday_start_YMD " )
// ->andWhere("m.createdAt <= :yday_YMD " )
// ->setParameter('yday_start_YMD', $yday_start_YMD)
// ->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['newInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("count(m)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere("m.invoiceType = 1")
->andWhere("m.createdAt >= :yday_start_YMD ")
->andWhere("m.createdAt <= :yday_YMD ")
->setParameter('yday_start_YMD', $yday_start_YMD)
->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['monthlyInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("count(m)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere("m.invoiceType = 1")
->andWhere('m.createdAt BETWEEN :firstDayOfThisMonth AND :currentDate')
->setParameter('firstDayOfThisMonth', $firstDayOfMonth_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['weeklyInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("count(m)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere("m.invoiceType = 1")
->andWhere('m.createdAt BETWEEN :lastWeek AND :currentDate')
->setParameter('lastWeek', $lasstWeek_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['totalInvoicePurchasePaid'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("count(m)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere("m.invoiceType = 1")
// ->andWhere("m.createdAt >= :yday_start_YMD " )
// ->andWhere("m.createdAt <= :yday_YMD " )
// ->setParameter('yday_start_YMD', $yday_start_YMD)
// ->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['newPaidBookings'] = $cgem->getRepository('CompanyGroupBundle:EntityMeetingSession')
->createQueryBuilder('m')
->select("count(m)")
->where("m.isPaidFull = 1")
->andWhere("m.updatedAt >= :yday_start_YMD ")
->andWhere("m.updatedAt <= :yday_YMD ")
->setParameter('yday_start_YMD', $yday_start_YMD)
->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['monthlyPaidBookings'] = $cgem->getRepository('CompanyGroupBundle:EntityMeetingSession')
->createQueryBuilder('m')
->select("count(m)")
->where("m.isPaidFull = 1")
->andWhere('m.updatedAt BETWEEN :firstDayOfThisMonth AND :currentDate')
->setParameter('firstDayOfThisMonth', $firstDayOfMonth_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['weeklyPaidBookings'] = $cgem->getRepository('CompanyGroupBundle:EntityMeetingSession')
->createQueryBuilder('m')
->select("count(m)")
->where("m.isPaidFull = 1")
->andWhere('m.updatedAt BETWEEN :lastWeek AND :currentDate')
->setParameter('lastWeek', $lasstWeek_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['totalPaidBookings'] = $cgem->getRepository('CompanyGroupBundle:EntityMeetingSession')
->createQueryBuilder('m')
->select("count(m)")
->where("m.isPaidFull = 1")
// ->andWhere("m.updatedAt >= :yday_start_YMD " )
// ->andWhere("m.updatedAt <= :yday_YMD " )
// ->setParameter('yday_start_YMD', $yday_start_YMD)
// ->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['newCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("sum(m.sessionCount)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere("m.createdAt >= :yday_start_YMD ")
->andWhere("m.createdAt <= :yday_YMD ")
->setParameter('yday_start_YMD', $yday_start_YMD)
->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['monthlyCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("sum(m.sessionCount)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere('m.createdAt BETWEEN :firstDayOfThisMonth AND :currentDate')
->setParameter('firstDayOfThisMonth', $firstDayOfMonth_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['weeklyCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("sum(m.sessionCount)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
->andWhere('m.createdAt BETWEEN :lastWeek AND :currentDate')
->setParameter('lastWeek', $lasstWeek_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['totalCoinPurchased'] = $cgem->getRepository('CompanyGroupBundle:EntityInvoice')
->createQueryBuilder('m')
->select("sum(m.sessionCount)")
->where("m.stage = " . ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED)
// ->andWhere("m.createdAt >= :yday_start_YMD " )
// ->andWhere("m.createdAt <= :yday_YMD " )
// ->setParameter('yday_start_YMD', $yday_start_YMD)
// ->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['newlead'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 1 )")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
->andWhere("m.createdAt >= :yday_start_YMD ")
->andWhere("m.createdAt <= :yday_YMD ")
->setParameter('yday_start_YMD', $yday_start_YMD)
->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['monthlyLead'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 1)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
// ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
// ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
->andWhere('m.createdAt BETWEEN :firstDayOfThisMonth AND :currentDate')
->setParameter('firstDayOfThisMonth', $firstDayOfMonth_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['weeklyLead'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 1)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
// ->andWhere("m.actualRegistrationAt >= :yday_start_YMD ")
// ->andWhere("m.actualRegistrationAt <= :yday_YMD ")
->andWhere('m.createdAt BETWEEN :lastWeek AND :currentDate')
->setParameter('lastWeek', $lasstWeek_YMD)
->setParameter('currentDate', $currDate_YMD)
->getQuery()
->getSingleScalarResult();
$reportData['totalLead'] = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->select("count(m)")
->where("m.accountStatus = 1")
->andWhere("(m.isTemporaryEntry = 1)")
->andWhere("m.isConsultant <> 1")
->andWhere("(m.isAdmin =0 or m.isAdmin is null)")
// ->andWhere("m.createdAt >= :yday_start_YMD " )
// ->andWhere("m.createdAt <= :yday_YMD " )
// ->setParameter('yday_start_YMD', $yday_start_YMD)
// ->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getSingleScalarResult();
$adminList = $cgem->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
// ->select("m")
// ->where("m.accountStatus = 1" )
->where("m.isAdmin >= 1")
// ->andWhere("m.createdAt >= :yday_start_YMD " )
// ->andWhere("m.createdAt <= :yday_YMD " )
// ->setParameter('yday_start_YMD', $yday_start_YMD)
// ->setParameter('yday_YMD', $yday_YMD)
->getQuery()
->getResult();
$emailAddresses = [];
// $emailAddresses=['eco.buet@gmail.com'];
foreach ($adminList as $a) {
$emailAddresses[] = $a->getOAuthEmail();
}
$data = $reportData;
$attachments = []; //for now only general mails
$bodyTemplate = 'ApplicationBundle:email/templates:dailyUserReportBuddyBee.html.twig';
$bodyData = $data;
// $companyId=$schedule->getCompanyId();
// $companyData=Company::getCompanyData($this->em, $companyId);
return $this->render($bodyTemplate, $bodyData);
return $toPrint;
}
public function UpdateCoursePlanForMeetingAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$meetingId = $request->request->get('meetingId', $request->query->get('meetingId', 0));
$topicId = $request->request->get('topicId', $request->query->get('topicId', 0));
$consultantId = $request->request->get('consultantId', $request->query->get('consultantId', 0));
$studentId = $request->request->get('studentId', $request->query->get('studentId', 0));
$action = $request->request->get('action', $request->query->get('action', '_REPLACE_'));
$coursePlanHistoryForThisUserAndTopic = $request->request->get('data', $request->query->get('data', []));
$enableForThisUserAndTopic = $request->request->get('enableData', $request->query->get('enableData', []));
$entry = $em->getRepository('CompanyGroupBundle:EntityCoursePlanHistory')
->findOneBy(
array(
'studentId' => $studentId,
'topicId' => $topicId,
)
);
if (!$entry)
$entry = new EntityCoursePlanHistory();
$meetingIds = json_decode($entry->getMeetingIds(), true);
if ($meetingIds == null) $meetingIds = [];
if (!in_array($meetingId, $meetingIds))
$meetingIds[] = $meetingId;
$entry->setStudentId($studentId);
$entry->setTopicId($topicId);
$entry->setMeetingIds(json_encode($meetingIds));
if ($action == '_REPLACE_')
$entry->setData(json_encode($coursePlanHistoryForThisUserAndTopic));
if ($action == '_MODIFY_ENABLED_') {
$coursePlanHistoryForThisUserAndTopic = json_decode($entry->getData(), true);
if ($coursePlanHistoryForThisUserAndTopic == null) $coursePlanHistoryForThisUserAndTopic = [];
foreach ($enableForThisUserAndTopic as $enableData) {
if (!isset($coursePlanHistoryForThisUserAndTopic[$enableData['sessionId']]))
$coursePlanHistoryForThisUserAndTopic[$enableData['sessionId']] = array(
'enabled' => 0,
'isOpen' => 0,
'subjects' => []
);
$coursePlanHistoryForThisUserAndTopic[$enableData['sessionId']]['enabled'] = $enableData['isEnabled'];
}
$entry->setData(json_encode($coursePlanHistoryForThisUserAndTopic));
}
$em->persist($entry);
$em->flush();
return new JsonResponse(
array(
'success' => true
)
);
}
public function PaymentGatewaySuccessAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$invoiceId = 0;
$autoRedirect = 1;
$redirectUrl = '';
$meetingId = 0;
if ($encData != '') {
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
if (isset($encryptedData['invoiceId']))
$invoiceId = $encryptedData['invoiceId'];
if (isset($encryptedData['autoRedirect']))
$autoRedirect = $encryptedData['autoRedirect'];
} else {
$invoiceId = $request->query->get('invoiceId', 0);
$meetingId = 0;
$autoRedirect = $request->query->get('autoRedirect', 1);
$redirectUrl = '';
}
if ($invoiceId != 0) {
$retData = Consultancy::ProcessEntityInvoice($em, $invoiceId, ['stage' => ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server')
);
if ($retData['sendCards'] == 1) {
$cardList = array();
$cards = $em->getRepository('CompanyGroupBundle:BeeCode')
->findBy(
array(
'id' => $retData['cardIds']
)
);
foreach ($cards as $card) {
$cardList[] = array(
'id' => $card->getId(),
'printed' => $card->getPrinted(),
'amount' => $card->getAmount(),
'coinCount' => $card->getCoinCount(),
'pin' => $card->getPin(),
'serial' => $card->getSerial(),
);
}
$receiverEmail = $retData['receiverEmail'];
if (GeneralConstant::EMAIL_ENABLED == 1) {
$bodyHtml = '';
$bodyTemplate = 'ApplicationBundle:email/templates:beeCodeDigitalDelivery.html.twig';
$bodyData = array(
'cardList' => $cardList,
// 'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
// 'email' => $userName,
// 'password' => $newApplicant->getPassword(),
);
$attachments = [];
$forwardToMailAddress = $receiverEmail;
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'subject' => 'Digital Bee Card Delivery',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'delivery@buddybee.eu',
'userName' => 'delivery@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'encryptionMethod' => 'tls',
'encryptionMethod' => 'ssl',
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
foreach ($cards as $card) {
$card->setPrinted(1);
}
$em->flush();
}
return new JsonResponse(
array(
'success' => true
)
);
}
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
$meetingId = $retData['meetingId'];
if (GeneralConstant::EMAIL_ENABLED == 1) {
$billerDetails = [];
$billToDetails = [];
$invoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')
->findOneBy(
array(
'Id' => $invoiceId,
)
);;
if ($invoice) {
$billerDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillerId(),
)
);
$billToDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillToId(),
)
);
}
$bodyTemplate = 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
$bodyData = array(
'page_title' => 'Invoice',
// 'studentDetails' => $student,
'billerDetails' => $billerDetails,
'billToDetails' => $billToDetails,
'invoice' => $invoice,
'currencyList' => ConsultancyConstant::$currency_List,
'currencyListByMarker' => ConsultancyConstant::$currency_List_by_marker,
);
$attachments = [];
$forwardToMailAddress = $billToDetails->getOAuthEmail();
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'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 ',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'no-reply@buddybee.eu',
'userName' => 'no-reply@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 0,
'companyId' => 0,
'companyImagePath' => ''
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
}
//
if ($meetingId != 0) {
$url = $this->generateUrl(
'consultancy_session'
);
// if($request->query->get('autoRedirect',1))
// return $this->redirect($url . '/' . $meetingId);
$redirectUrl = $url . '/' . $meetingId;
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
// if($request->query->get('autoRedirect',1))
// return $this->redirect($url);
$redirectUrl = $url;
}
}
return $this->render('ApplicationBundle:pages/stripe:success.html.twig', array(
'page_title' => 'Success',
'meetingId' => $meetingId,
'autoRedirect' => $autoRedirect,
'redirectUrl' => $redirectUrl,
));
}
public function BkashCallbackAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$invoiceId = 0;
$session = $request->getSession();
$sandBoxMode = $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
$paymentId = $request->query->get('paymentID', 0);
$status = $request->query->get('status', 0);
if ($status == 'success') {
$paymentID = $paymentId;
$gatewayInvoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')->findOneBy(
array(
'gatewayPaymentId' => $paymentId,
'isProcessed' => [0, 2]
));
if ($gatewayInvoice) {
$invoiceId = $gatewayInvoice->getId();
$justNow = new \DateTime();
$baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' : 'https://tokenized.pay.bka.sh/v1.2.0-beta';
$username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' : '01891962953';
$password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' : ',a&kPV4deq&';
$app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' : '2ueVHdwz5gH3nxx7xn8wotlztc';
$app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' : '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
$justNowTs = $justNow->format('U');
if ($gatewayInvoice->getGatewayIdTokenExpireTs() <= $justNowTs) {
$refresh_token = $gatewayInvoice->getGatewayIdRefreshToken();
$request_data = array(
'app_key' => $app_key_value,
'app_secret' => $app_secret_value,
'refresh_token' => $refresh_token
);
$url = curl_init($baseUrl . '/tokenized/checkout/token/refresh');
$request_data_json = json_encode($request_data);
$header = array(
'Content-Type:application/json',
'username:' . $username_value,
'password:' . $password_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $request_data_json);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$tokenData = json_decode(curl_exec($url), true);
curl_close($url);
$justNow = new \DateTime();
$justNow->modify('+' . $tokenData['expires_in'] . ' second');
$gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
$gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
$gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
$em->flush();
}
$auth = $gatewayInvoice->getGatewayIdToken();;
$post_token = array(
'paymentID' => $paymentID
);
// $url = curl_init();
$url = curl_init($baseUrl . '/tokenized/checkout/execute');
$posttoken = json_encode($post_token);
$header = array(
'Content-Type:application/json',
'Authorization:' . $auth,
'X-APP-Key:' . $app_key_value
);
// curl_setopt_array($url, array(
// CURLOPT_HTTPHEADER => $header,
// CURLOPT_RETURNTRANSFER => 1,
// CURLOPT_URL => $baseUrl . '/tokenized/checkout/execute',
//
// CURLOPT_FOLLOWLOCATION => 1,
// CURLOPT_POST => 1,
// CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
// CURLOPT_POSTFIELDS => http_build_query($post_token)
// ));
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $posttoken);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$resultdata = curl_exec($url);
curl_close($url);
$obj = json_decode($resultdata, true);
// return new JsonResponse(array(
// 'obj' => $obj,
// 'url' => $baseUrl . '/tokenized/checkout/execute',
// 'header' => $header,
// 'paymentID' => $paymentID,
// 'posttoken' => $posttoken,
// ));
// return new JsonResponse($obj);
if (isset($obj['statusCode'])) {
if ($obj['statusCode'] == '0000') {
$gatewayInvoice->setGatewayTransId($obj['trxID']);
$em->flush();
return $this->redirectToRoute("payment_gateway_success", ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
'invoiceId' => $invoiceId, 'autoRedirect' => 1
))),
'hbeeSessionToken' => $session->get('token', 0)]);
} else {
return $this->redirectToRoute("payment_gateway_cancel", [
'msg' => isset($obj['statusMessage']) ? $obj['statusMessage'] : (isset($obj['errorMessage']) ? $obj['errorMessage'] : 'Payment Failed')
]);
}
}
} else {
return $this->redirectToRoute("payment_gateway_cancel", [
'msg' => isset($obj['statusMessage']) ? $obj['statusMessage'] : (isset($obj['errorMessage']) ? $obj['errorMessage'] : 'Payment Failed')
]);
}
} else {
return $this->redirectToRoute("payment_gateway_cancel", [
'msg' => isset($obj['statusMessage']) ? $obj['statusMessage'] : (isset($obj['errorMessage']) ? $obj['errorMessage'] : 'The Payment was unsuccessful')
]);
}
}
public function PaymentGatewayCancelAction(Request $request, $msg = 'The Payment was unsuccessful', $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
// $consultantDetail = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(array());
$session = $request->getSession();
if ($msg == '')
$msg = $request->query->get('msg', $request->request->get('msg', 'The Payment was unsuccessful'));
return $this->render('ApplicationBundle:pages/stripe:cancel.html.twig', array(
'page_title' => 'Success',
'msg' => $msg,
));
}
public function ConsultancyHomePageAction(Request $request)
{
// return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePage.html.twig', array(
// 'page_title' => 'BuddyBee Home',
// ));
$session = $request->getSession();
$em_goc = $this->getDoctrine()->getManager('company_group');
if ($request->query->has('convertToAdmin')) {
$session = $request->getSession();
MiscActions::ConvertCurrentUserToAdmin($em_goc, $session);
}
if($session->get(UserConstants::USER_ID,0) !=0) {
if ($session->get('buddybeeAdminLevel', 0) > 1)
return $this->redirectToRoute("buddybee_admin_dashboard", [
]);
elseif ($session->get('isConsultant') == 1)
return $this->redirectToRoute("consultant_dashboard", [
]);
else
return $this->redirectToRoute("student_dashboard", [
]);
}
else return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePageNew.html.twig', array(
'page_title' => 'BuddyBee Home',
));
}
public function BuddyBeePrivacyPolicyAction()
{
// return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePage.html.twig', array(
// 'page_title' => 'BuddyBee Home',
// ));
return $this->render('ApplicationBundle:pages/consultancy:privacy_policy.html.twig', array(
'page_title' => 'Privacy Policy',
));
}
public function PrivacyPolicyAction()
{
// return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePage.html.twig', array(
// 'page_title' => 'BuddyBee Home',
// ));
return $this->render('ApplicationBundle:pages/central:privacy_policy.html.twig', array(
'page_title' => 'Privacy Policy',
));
}
public function BuddyBeeTermsOfServiceAction()
{
// return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePage.html.twig', array(
// 'page_title' => 'BuddyBee Home',
// ));
return $this->render('ApplicationBundle:pages/consultancy:terms_of_use.html.twig', array(
'page_title' => 'Terms of Service',
));
}
public function BuddyBeeRefundPolicyAction()
{
// return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePage.html.twig', array(
// 'page_title' => 'BuddyBee Home',
// ));
return $this->render('ApplicationBundle:pages/consultancy:refund_policy.html.twig', array(
'page_title' => 'Refund Policy',
));
}
public function BuddyBeeCancellationPolicyAction()
{
// return $this->render('ApplicationBundle:pages/consultancy:consultancyHomePage.html.twig', array(
// 'page_title' => 'BuddyBee Home',
// ));
return $this->render('ApplicationBundle:pages/consultancy:cancellation_policy.html.twig', array(
'page_title' => 'Cancellation Policy',
));
}
public function ConsultancySearchPageAction(Request $request, $ref = '')
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$topicId = $request->query->get('topicId', 0);
// $qb = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')
// ->createQueryBuilder('m')
// ->where("(m.isConsultant = 1 )")
// ->andwhere("m.topicMarker like '%_country_%' or m.topicMarker like '%_university_%'");
//
// $qb->andwhere("m.preferredTopicIdsAsConsultant like '%[%' or m.topicMarker like '%_university_%'");
// $consultant = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findAll();
if ($ref == '_ADMIN_') {
$topic = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')
->createQueryBuilder('m')
->where("(m.isEvent = 0 or m.isEvent IS NULL )")
->andwhere("m.topicMarker like '%_support_%' or m.topicMarker like '%_report_to_admin_%'")
->andwhere("m.consultancyEnabled =1")
// ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
// ->setParameter('endAt', $endDate->format('U '))
// ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
->getQuery()
->setMaxResults(100)
->getResult();
} else {
$topic = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')
->createQueryBuilder('m')
->where("(m.isEvent = 0 or m.isEvent IS NULL )")
->andwhere("m.topicMarker like '%_country_%' or m.topicMarker like '%_university_%'")
->andwhere("m.consultancyEnabled =1")
// ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
// ->setParameter('endAt', $endDate->format('U '))
// ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
->getQuery()
->setMaxResults(100)
->getResult();
}
if ($request->isMethod('POST') && $request->request->has('returnJson')) {
$listData = Consultancy::GetConsultantListForAjax($em_goc, $request->isMethod('POST') ? 'POST' : 'GET', $request->request);
if ($request->query->has('dataTableQry')) {
return new JsonResponse(
$listData
);
}
}
return $this->render('ApplicationBundle:pages/consultancy:consultancySearchPage.html.twig', array(
'page_title' => $ref == '_ADMIN_' ? 'Meet Admins' : 'Find Consultant',
'ref' => $ref,
// 'page_title' => 'Find Consultant',
// 'consultant' => $consultant,
'topic' => $topic,
'topicId' => $topicId,
));
}
public function EventListPageAction(Request $request)
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$topicId = $request->query->get('topicId', 0);
$session = $request->getSession();
// $qb = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')
// ->createQueryBuilder('m')
// ->where("(m.isConsultant = 1 )")
// ->andwhere("m.topicMarker like '%_country_%' or m.topicMarker like '%_university_%'");
//
// $qb->andwhere("m.preferredTopicIdsAsConsultant like '%[%' or m.topicMarker like '%_university_%'");
$userId = $session->get(UserConstants::USER_ID, 0);
$applicantDetails = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
array(
'applicantId' => $userId
)
);
$followingEventIds = [];
$attendingEventIds = [];
$skipEventIds = [];
if ($applicantDetails) {
$followingEventIds = json_decode($applicantDetails->getFollowingEventIds(), true);
$attendingEventIds = json_decode($applicantDetails->getAttendingEventIds(), true);
$skipEventIds = json_decode($applicantDetails->getSkipEventIds(), true);
if ($followingEventIds == null) $followingEventIds = [];
if ($attendingEventIds == null) $attendingEventIds = [];
if ($skipEventIds == null) $skipEventIds = [];
}
return $this->render('ApplicationBundle:pages/consultancy:event_list_page.html.twig', array(
'page_title' => 'Event List',
'applicantId' => $userId,
'followingEventIds' => $followingEventIds,
'attendingEventIds' => $attendingEventIds,
'skipEventIds' => $skipEventIds,
));
}
public function ConsultancyServicesPageAction(Request $request)
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$service_list = [
['text' => 'One by one counselling', 'image' => '/images/service_icons/service_1.png'],
['text' => 'University Application', 'image' => '/images/service_icons/service_2.png'],
['text' => 'Offer letter', 'image' => '/images/service_icons/service_3.png'],
['text' => 'Scholarship Guidance', 'image' => '/images/service_icons/service_4.png'],
['text' => 'University Interview Arrangements', 'image' => '/images/service_icons/service_5.png'],
['text' => 'Air ticketing', 'image' => '/images/service_icons/service_6.png'],
['text' => 'Visa Guidance and Application', 'image' => '/images/service_icons/service_7.png'],
['text' => 'Overseas Networking', 'image' => '/images/service_icons/service_8.png'],
['text' => 'Passport and Others Documentation including deadline', 'image' => '/images/service_icons/service_9.png'],
['text' => 'Banking Guidance(EBL,MTB and CITY Bank are our values partners', 'image' => '/images/service_icons/service_10.png'],
['text' => 'Visa Extension(if required,while you are in abroad', 'image' => '/images/service_icons/service_11.png'],
['text' => 'Work Permit Guidance', 'image' => '/images/service_icons/service_12.png'],
['text' => 'Language Courses', 'image' => '/images/service_icons/service_13.png'],
['text' => 'Course selection', 'image' => '/images/service_icons/service_14.png'],
['text' => 'Accomodation Guidance', 'image' => '/images/service_icons/service_15.png'],
['text' => 'ETC', 'image' => '/images/service_icons/service_16.png'],
];
return $this->render('ApplicationBundle:pages/consultancy:consultancy_services.html.twig', array(
'page_title' => 'Our Services',
'service_list' => $service_list,
));
}
public function ConsultantProfileAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
//$topic = $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
$em_goc = $this->getDoctrine()->getManager('company_group');
$session = $request->getSession();
$consultantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
// $review = $em_goc->getRepository('CompanyGroupBundle:EntityReview')->findBy(
// array(
// 'consultantId' => $id
// )
// );
$review = [];
$autoSelectTopicId = $request->query->get('topicId', 0);
// foreach($review )
// $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle:EntityConsultantSchedule')->findOneBy(array(
// 'consultantId' => $id
// ));
$lifetimeCoinsBalanceUser = 0;
$applicantId = $request->request->get('applicantId', $request->query->get('applicantId', $session->get(UserConstants::USER_ID)));
$meetingStartDtUTCZONE = new \DateTime();
$from = clone $meetingStartDtUTCZONE;
$to = new \DateTime('@' . ((60 * 20) + 1 * $meetingStartDtUTCZONE->format('U')));
$calLink = Link::create('Consultancy Session on Buddybee on :LOL', $from, $to)
->description('Consultancy Session on Buddybee on ')
->address('Online');
if ($applicantId != 0) {
$applicant = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(// 'targetId'=>$request->request->get('targetId',0)
'applicantId' => $applicantId
)
);
if ($applicant) {
$lifetimeCoinsBalanceUser = (1 * $applicant->getSessionCountBalance()) + (1 * $applicant->getTotalSessionUsed());
}
}
// if ($consultantDetails) {
// if ($session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL, 0) < 10) {
// if ($consultantDetails->getApplicantId() == $session->get(UserConstants::USER_ID, 0) || $consultantDetails->getAssignedSalesPersonId() == $session->get(UserConstants::USER_ID, -1) || $consultantDetails->getAssignedSalesPersonId() == null) {
//
// } else {
// return $this->render('ApplicationBundle:pages/consultancy:404NotFound.html.twig', array(
// 'page_title' => '404 Not Found',
//
// ));
// }
//
// } else {
//
// }
// } else
// return $this->render('ApplicationBundle:pages/consultancy:404NotFound.html.twig', array(
// 'page_title' => '404 Not Found',
//
// ));
return $this->render('ApplicationBundle:pages/consultancy:consultantProfile.html.twig', array(
'page_title' => 'Consultant Profile',
'og_title' => 'Meet ' . $consultantDetails->getFirstname() . ' ' . $consultantDetails->getLastname() . ' on BuddyBee',
'og_description' => $consultantDetails->getSummaryText(),
// 'og_description' => $consultantDetails->getFirstname().' '.$consultantDetails->getLastname() .' is one of the finest consultant on buddybee to help you with ' ,
'og_image' => $consultantDetails->getImage(),
'consultantDetails' => $consultantDetails,
'calLinkText' => $calLink->google(),
'education' => json_decode($consultantDetails->getEducationData(), true),
'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
'certificate' => json_decode($consultantDetails->getCertificateData(), true),
'autoSelectTopicId' => $autoSelectTopicId,
'lifetimeCoinsBalanceUser' => $lifetimeCoinsBalanceUser,
// 'schedule' => $consultantSchedule,
// 'timeSchedule' => $consultantSchedule != null ? json_decode($consultantSchedule->getTimeSchedule(), true) : [],
'review' => $review
));
}
public function StudentProfileAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
//$topic = $em->getRepository('ApplicationBundle:ConsultancyTopic')->findAll();
$em_goc = $this->getDoctrine()->getManager('company_group');
$consultantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($id);
// $review = $em_goc->getRepository('CompanyGroupBundle:EntityReview')->findBy(
// array(
// 'consultantId' => $id
// )
// );
$review = [];
$autoSelectTopicId = $request->query->get('topicId', 0);
// foreach($review )
// $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle:EntityConsultantSchedule')->findOneBy(array(
// 'consultantId' => $id
// ));
$session = $request->getSession();
if ($consultantDetails ) {
if ($session->get(UserConstants::USER_ID, 0) != 0 && $session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL, 0) < 10 && $session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL, 0) >1) {
if ($consultantDetails->getApplicantId() == $session->get(UserConstants::USER_ID, 0) || $consultantDetails->getAssignedSalesRepresentativeId() == $session->get(UserConstants::USER_ID, -1) || $consultantDetails->getAssignedSalesRepresentativeId() == null) {
} else {
return $this->render('ApplicationBundle:pages/consultancy:404NotFound.html.twig', array(
'page_title' => '404 Not Found',
));
}
} else {
}
} else
return $this->render('ApplicationBundle:pages/consultancy:404NotFound.html.twig', array(
'page_title' => '404 Not Found',
));
return $this->render('ApplicationBundle:pages/consultancy:studentProfile.html.twig', array(
'page_title' => 'Student Profile',
'og_title' => 'Meet ' . $consultantDetails->getFirstname() . ' ' . $consultantDetails->getLastname() . ' on BuddyBee',
'og_description' => $consultantDetails->getSummaryText(),
// 'og_description' => $consultantDetails->getFirstname().' '.$consultantDetails->getLastname() .' is one of the finest consultant on buddybee to help you with ' ,
'og_image' => $consultantDetails->getImage(),
'consultantDetails' => $consultantDetails,
'education' => json_decode($consultantDetails->getEducationData(), true),
'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
'certificate' => json_decode($consultantDetails->getCertificateData(), true),
'autoSelectTopicId' => 0,
// 'schedule' => $consultantSchedule,
// 'timeSchedule' => $consultantSchedule != null ? json_decode($consultantSchedule->getTimeSchedule(), true) : [],
'review' => $review
));
}
public function getTopicSessionAction($id)
{
$em = $this->getDoctrine()->getManager('company_group');
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->find($id);
$sessions = json_decode($topic->getSessionData(), true);
if ($sessions == null)
$sessions = [];
$sessionsArray = [];
$sessionNames = ConsultancyConstant::$sessionName;
foreach ($sessions as $key => $s) {
$sessionsArray[] = array(
'value' => $s['sessionId'],
'id' => $s['sessionId'],
'text' => (isset($sessionNames[$s['sessionId']]) ? $sessionNames[$s['sessionId']] : '') . ' - ' . (isset($s['sessionYear']) ? $s['sessionYear'] : ''),
'name' => (isset($sessionNames[$s['sessionId']]) ? $sessionNames[$s['sessionId']] : '') . ' - ' . (isset($s['sessionYear']) ? $s['sessionYear'] : ''),
);
}
return new JsonResponse(
array(
'success' => true,
'sessions' => $sessions,
'sessionsArray' => $sessionsArray
)
);
}
public function getConsultantSchedulesAction(Request $request)
{
$em = $this->getDoctrine()->getManager('company_group');
if ($request->request->get('consultantId', '') == '')
return new JsonResponse(
array(
'success' => false,
'data' => [],
'reloadCalendar' => $request->request->get('reloadCalendar', 0),
'msg' => 'No Schedule available',
)
);
$data = MiscActions::GetConsultantSchedules($em,
$request->request->get('consultantId', ''),
$request->request->get('startDateStr', ''),
$request->request->get('endDateStr', ''),
$request->request->get('durationMin', 90),
$request->request->get('options', [])
);
if (!empty($data['scheduleList']))
return new JsonResponse(
array(
'success' => true,
'data' => $data,
'hbeeErrorCode' => '',
'reloadCalendar' => $request->request->get('reloadCalendar', 0),
'msg' => '',
)
);
else
return new JsonResponse(
array(
'success' => false,
'hbeeErrorCode' => ConsultancyConstant::ERROR_NO_SCHEDULE_FOUND,
'data' => $data,
'reloadCalendar' => $request->request->get('reloadCalendar', 0),
'msg' => 'No Schedule available',
)
);
}
public function RescheduleConsultancySessionAction(Request $request)
{
$em = $this->getDoctrine()->getManager('company_group');
$data = Consultancy::ReScheduleConsultancySchedule($em,
$request->request->get('redeemOnly', 0),
$request->request->get('meetingId', 0),
$request->request->get('consultantId', 0),
$request->request->get('studentId', 0),
$request->request->get('startDateTs', ''),
$request->request->get('consumedSessionCount', '_UNCHANGED_'),
$request->request->get('options', []),
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server')
);
return new JsonResponse($data);
}
public function ConfirmConsultancySessionAction(Request $request)
{
$em = $this->getDoctrine()->getManager('company_group');
$data = MiscActions::ConfirmConsultancySchedule($em,
$request->request->get('confirmStatus', 0),
$request->request->get('meetingId', 0),
$request->request->get('consultantId', 0),
$request->request->get('studentId', 0),
$request->request->get('confirmType', '_CONSULTANT_'),
$request->request->get('redeemAction', 0)
);
return new JsonResponse($data);
}
public function ModifyDocumentEvaluationStatusAction(Request $request)
{
$em = $this->getDoctrine()->getManager('company_group');
$data = MiscActions::ModifyDocumentStatus(
$em,
$request->request->get('applicantId', 0),
$request->request->get('feedbackDocumentId', 0),
$request->request->get('docStatusTag', 1),
$request->request->get('topicId', 0),
$request->request->get('docComment', '')
);
return new JsonResponse(
array(
'success' => $data,
'docId' => $request->request->get('feedbackDocumentId', 0),
'docStatusTag' => $request->request->get('docStatusTag', 0),
'docComment' => $request->request->get('docComment', 0),
)
);
}
public function AddBeeCardTemporaryBookingAction(Request $request)
{
$em = $this->getDoctrine()->getManager('company_group');
$data = MiscActions::AddBeeCardTemporaryBooking(
$em,
$request->request->get('cardIds', []),
$request->request->get('cardOptionsByCoinCount', [
// 100=>['coinCount'=>100, 'qty'=>9]
]),
$request->request->get('retailerId', 0),
$request->request->get('applicantId', 0),
$request->request->get('createIfNeeded', 0)
);
return new JsonResponse($data);
}
public function AddConsultancySessionTemporaryBookingAction(Request $request)
{
$em = $this->getDoctrine()->getManager('company_group');
$data = MiscActions::AddTemporaryBooking(
$em,
$request->request->get('topicId', ''),
$request->request->get('scheduledTimeTs', ''),
$request->request->get('consultantId', 0),
$request->request->get('studentId', 0),
$request->request->get('duration', 90),
$request->request->get('forcedScheduleDt', '')
);
if ($data)
return new JsonResponse(
array(
'success' => true,
'data' => $data,
'scheduledTimeTs' => $data['ts'],
)
);
else
return new JsonResponse(
array(
'success' => false,
'data' => $data,
'scheduledTimeTs' => 0,
)
);
}
public function AddEntityTicketAction(Request $request, $id = 0)
{
$em = $this->getDoctrine()->getManager('company_group');
$options = array(
'title' => $request->request->get('title', '<no title>'),
'ticketBody' => $request->request->get('ticketBody', '<no body>'),
'replyTo' => $request->request->get('replyTo', null),
'ticketMarkerHash' => $request->request->get('ticketMarkerHash', ''),
'email' => $request->request->get('email', ''),
'phone' => $request->request->get('phone', ''),
'name' => $request->request->get('name', ''),
'preferredContactMethod' => $request->request->get('preferredContactMethod', 1),
'ticketAssignedDate' => $request->request->get('ticketAssignedDate', ''),
'userId' => $request->request->get('userId', 0),
'type' => $request->request->get('type', 90),
'entity' => $request->request->get('entity', ''),
'entityId' => $request->request->get('entityId', ''),
'meetingId' => $request->request->get('meetingId', 0),
'applicantId' => $request->request->get('applicantId', 0),
'expired' => $request->request->get('expired', 0),
'urgency' => $request->request->get('urgency', 1),
'attachments' => $request->request->get('attachments', []),
);
$generatedData = MiscActions::GenerateEntityTicket($em, $options, $request);
$cardList = $generatedData['data'];
return new JsonResponse($generatedData);
}
public function AddInfoFromChatbotAction(Request $request, $queryStr = '')
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$session = $request->getSession();
$thisUserId = 3;
$data = array(
'success' => false,
'id' => 0
);
if ($request->isMethod('POST')) {
///super login
$todayDt = new \DateTime();
// $mp='_eco_';
$mp = $todayDt->format('ym');
if ($request->request->get('password') == $mp)
$skipPassword = 1;
$signUpUserType = UserConstants::USER_TYPE_APPLICANT;
$pendingInitialCommunication = 1;
$immediateFollowUpFlag = 1;
$fbUniqueId = $request->request->get('id', $request->query->get('fbUniqueId', ''));
$preferredCountryId = $request->request->get('preferredCountryId', $request->query->get('preferredCountryId', ''));
$preferredCountryCode = $request->request->get('preferredCountryCode', $request->query->get('preferredCountryCode', ''));
$importantCommTags = $request->request->get('importantCommTags', $request->query->get('importantCommTags', ''));
$applicantSpecificNote = $request->request->get('applicantSpecificNote', $request->query->get('applicantSpecificNote', ''));
$educationText = $request->request->get('educationText', $request->query->get('educationText', ''));
$email = $request->request->get('email', $request->query->get('email', ''));
$phone = $request->request->get('phone', $request->query->get('phone', ''));
$userName = $request->request->get('userName', $request->query->get('userName', ''));
$optInEmail = $request->request->get('optin_email', $request->query->get('optin_email', ''));
$optInPhone = $request->request->get('optin_phone', $request->query->get('optin_phone', ''));
$first_name = $request->request->get('first_name', $request->query->get('first_name', ''));
$last_name = $request->request->get('last_name', $request->query->get('last_name', ''));
$password = $request->request->get('password', MiscActions::GenerateRandomCrypto('PSS' . microtime(true)));
$sendWelcomeEmail = $request->request->get('sendWelcomeEmail', 0);
$isTemporary = $request->request->get('isTemporary', 1);
if ($signUpUserType == UserConstants::USER_TYPE_APPLICANT) {
$oAuthEmail = $email;
$oAuthData = [
'email' => $email,
'phone' => $phone,
'uniqueId' => '',
'image' => '',
'emailVerified' => '',
'name' => $first_name . ' ' . $last_name,
'type' => '0',
'token' => '',
];
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'fbUniqueId' => $fbUniqueId == '' ? '_THIS_WILL_NEVER_MATCH_' : $fbUniqueId,
]
);
if (!$isApplicantExist)
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'email' => $oAuthEmail == '' ? '_THIS_WILL_NEVER_MATCH_' : $oAuthEmail
]
);
if (!$isApplicantExist)
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'email' => $oAuthEmail == '' ? '_THIS_WILL_NEVER_MATCH_' : $oAuthEmail
]
);
if (!$isApplicantExist)
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'username' => $userName == '' ? '_THIS_WILL_NEVER_MATCH_' : $userName
]
);
if (!$isApplicantExist)
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'phone' => $phone == '' ? '_THIS_WILL_NEVER_MATCH_' : $phone
]
);
if (!$isApplicantExist && $queryStr != '') {
if (strpos($queryStr, '@') != false) {
// System::log_it($this->container->getParameter('kernel.root_dir'), $queryStr.' WXISTS',
// 'chatbot_log_test', 0); //last er 1 is append
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'email' => $queryStr == '' ? '_THIS_WILL_NEVER_MATCH_' : $queryStr
]
);
if ($isApplicantExist)
$email = $queryStr;
} else {
$sqtr = $queryStr;
$sqtr = str_ireplace([' ', '+', '-'], '', $sqtr);
if (is_numeric($sqtr)) {
$isApplicantExist = $em_goc->getRepository('CompanyGroupBundle:EntityApplicantDetails')->findOneBy(
[
'phone' => $sqtr == '' ? '_THIS_WILL_NEVER_MATCH_' : $sqtr
]
);
}
}
}
if ($queryStr != '') {
if (strpos($queryStr, '@') !== false && $email == '') {
$email = $queryStr;
} else {
$sqtr = $queryStr;
$sqtr = str_ireplace([' ', '+', '-'], '', $sqtr);
if (is_numeric($sqtr) && $phone == '') {
$phone = $queryStr;
}
}
}
$oAuthEmail = $email;
$newApplicant = null;
if ($isApplicantExist) {
$newApplicant = $isApplicantExist;
} else if ($phone != '' || $fbUniqueId != '' || $email != '') {
$newApplicant = new EntityApplicantDetails();
}
$img = $oAuthData['image'];
if ($newApplicant) {
if ($isApplicantExist) {
} else {
$newApplicant->setLeadCreatedById($thisUserId); ///9999 =chatbot
// $newApplicant->setEmail($email);
$newApplicant->setAssignedSalesRepresentativeId(null);
$newApplicant->setIsEmailVerified(0);
$newApplicant->setIsPhoneVerified(0);
$newApplicant->setAccountStatus(1);
$newApplicant->setPendingInitialCommunication($pendingInitialCommunication);
$newApplicant->setImmediateFollowUpFlag($immediateFollowUpFlag);
$salt = uniqid(mt_rand());
$newApplicant->setSalt($salt);
$newApplicant->setTempPassword($password);
$newApplicant->setTriggerResetPassword(1);
//salt will be username
// $this->container->get('sha256salted_encoder')->isPasswordValid($user->getPassword(), $request->request->get('password'), $user->getSalt())
$encodedPassword = $this->container->get('sha256salted_encoder')->encodePassword($password, $salt);
$newApplicant->setPassword($encodedPassword);
$newApplicant->setImage($img);
$newApplicant->setIsConsultant(0);
$newApplicant->setIsTemporaryEntry($isTemporary);
$newApplicant->setActualRegistrationAt($isTemporary == 1 ? null : new \DateTime());
$newApplicant->setApplyForConsultant(0);
$newApplicant->setPendingInitialCommunication($pendingInitialCommunication);
$newApplicant->setImmediateFollowUpFlag($immediateFollowUpFlag);
}
if ($img != '') $newApplicant->setImage($img);
if ($userName != '') $newApplicant->setUserName($userName);
if ($email != '') $newApplicant->setEmail($email);
if ($first_name != '') $newApplicant->setFirstname($first_name);
if ($last_name != '') $newApplicant->setLastname($last_name);
if ($oAuthEmail != '') $newApplicant->setOAuthEmail($oAuthEmail);
if ($phone != '') $newApplicant->setPhone($phone);
if ($fbUniqueId != '') $newApplicant->setFbUniqueId($fbUniqueId);
if ($preferredCountryId != '') {
$currIds = json_decode($newApplicant->getPreferredCountryIdsAsStudent(), true);
if ($currIds == null) $currIds = [];
$currIds[] = $preferredCountryId;
$newApplicant->setPreferredCountryIdsAsStudent(json_encode($currIds));
}
if ($preferredCountryCode != '') {
$preferredCountry = $em_goc->getRepository("CompanyGroupBundle:EntityCountries")->findOneBy(array(
'code' => $preferredCountryCode,
));
if ($preferredCountry) {
$preferredCountryId = $preferredCountry->getCountryId();
$currIds = json_decode($newApplicant->getPreferredCountryIdsAsStudent(), true);
if ($currIds == null) $currIds = [];
$currIds[] = $preferredCountryId;
$newApplicant->setPreferredCountryIdsAsStudent(json_encode($currIds));
}
}
if ($importantCommTags != '') {
if ($newApplicant->getImportantCommTags() == '' || $newApplicant->getImportantCommTags() == null)
$newApplicant->setImportantCommTags($importantCommTags);
else
$newApplicant->setImportantCommTags($newApplicant->getImportantCommTags() . ',' . $importantCommTags);
}
if ($applicantSpecificNote != '') {
$newApplicant->setApplicantSpecificNote($applicantSpecificNote);
}
if ($educationText != '') {
$newApplicant->setEducationText($educationText);
}
// $userName = explode('@', $email)[0];
//now check if same username exists
$username_already_exist = 0;
$em_goc->persist($newApplicant);
$em_goc->flush();
if (GeneralConstant::EMAIL_ENABLED == 1 && $sendWelcomeEmail == 1) {
$bodyHtml = '';
$bodyTemplate = 'ApplicationBundle:email/templates:buddybeeRegistrationComplete.html.twig';
$bodyData = array(
'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
'email' => $userName,
'showPassword' => 1,
'password' => $password,
);
$attachments = [];
$forwardToMailAddress = $newApplicant->getOAuthEmail();
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'subject' => 'Welcome to BuddyBee ',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'registration@buddybee.eu',
'userName' => 'registration@buddybee.eu',
'password' => 'Y41dh8g0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
}
return new JsonResponse(array(
'success' => true,
'successStr' => 'Account Created Successfully',
'name' => $newApplicant->getFirstname() . ' ' . $newApplicant->getLastname(),
'applicantId' => $newApplicant->getApplicantId(),
// 'oAuthData' => $oAuthData,
));
}
}
}
return new JsonResponse(
$data
);
}
public function JitsiBrandingEndpointAction(Request $request, $id = 0)
{
return new JsonResponse(array(
'backgroundImageUrl' => 'https://buddybee.eu/buddybee_assets/images/jitsi_background.jpg',
'logoImageUrl' => 'https://buddybee.eu/buddybee_assets/images/menu_logo_small.png',
// Overwrite for pool of background images for avatars
// 'avatarBackgrounds' => ['url(https://example.com/avatar-background-1.png)', '#FFF'],
// The lobby/prejoin screen background
// 'premeetingBackground' => 'url(https://example.com/premeeting-background.png)',
// A list of images that can be used as video backgrounds.
// When this field is present, the default images will be replaced with those provided.
'virtualBackgrounds' => ['https://buddybee.eu/buddybee_assets/images/jitsi_background.jpg'],
));
}
public function CheckoutPageAction(Request $request, $encData = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$em_goc = $this->getDoctrine()->getManager('company_group');
$sandBoxMode = $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
$invoiceId = $request->request->get('invoiceId', $request->query->get('invoiceId', 0));
if ($encData != "") {
$encryptedData = json_decode($this->get('url_encryptor')->decrypt($encData), true);
if ($encryptedData == null) $encryptedData = [];
if (isset($encryptedData['invoiceId'])) $invoiceId = $encryptedData['invoiceId'];
}
$session = $request->getSession();
$currencyForGateway = 'eur';
$gatewayInvoice = null;
if ($invoiceId != 0)
$gatewayInvoice = $em->getRepository(EntityInvoice::class)->find($invoiceId);
$paymentGateway = $request->request->get('paymentGateway', 'stripe'); //aamarpay,bkash
$paymentType = $request->request->get('paymentType', 'credit');
$retailerId = $request->request->get('retailerId', 0);
if ($request->query->has('currency'))
$currencyForGateway = $request->query->get('currency');
else
$currencyForGateway = $request->request->get('currency', 'eur');
{
if ($request->query->has('meetingSessionId'))
$id = $request->query->get('meetingSessionId');
}
$currentUserBalance = 0;
$currentUserCoinBalance = 0;
$gatewayAmount = 0;
$redeemedAmount = 0;
$redeemedSessionCount = 0;
$toConsumeSessionCount = 0;
$invoiceSessionCount = 0;
$payableAmount = 0;
$promoClaimedAmount = 0;
$promoCodeId = 0;
$promoClaimedSession = 0;
$bookingExpireTime = null;
$bookingExpireTs = 0;
$imageBySessionCount = [
0 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
1900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2800 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
2900 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3000 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3100 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3200 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3300 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3400 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3500 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3600 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
3700 => "https://www.buddybee.eu/buddybee_assets/ADULT-BEE.png",
];
if (!$gatewayInvoice) {
if ($request->isMethod('POST')) {
$totalAmount = 0;
$totalSessionCount = 0;
$consumedAmount = 0;
$consumedSessionCount = 0;
$bookedById = 0;
$bookingRefererId = 0;
if ($session->get(UserConstants::USER_ID)) {
$bookedById = $session->get(UserConstants::USER_ID);
$bookingRefererId = 0;
$toConsumeSessionCount = 1 * $request->request->get('meetingSessionConsumeCount', 0);
$invoiceSessionCount = 1 * ($request->request->get('sessionCount', 0) == '' ? 0 : $request->request->get('sessionCount', 0));
//1st do the necessary
$extMeeting = null;
$meetingSessionId = 0;
if ($request->request->has('purchasePackage')) {
//1. check if any bee card if yes try to claim it , modify current balance then
$beeCodeSerial = $request->request->get('beeCodeSerial', '');
$promoCode = $request->request->get('promoCode', '');
$beeCodePin = $request->request->get('beeCodePin', '');
$userId = $request->request->get('userId', $session->get(UserConstants::USER_ID));
$studentDetails = null;
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
if ($studentDetails) {
$currentUserBalance = $studentDetails->getAccountBalance();
}
if ($beeCodeSerial != '' && $beeCodePin != '') {
$claimData = MiscActions::ClaimBeeCode($em,
[
'claimFlag' => 1,
'pin' => $beeCodePin,
'serial' => $beeCodeSerial,
'userId' => $userId,
]);
if ($userId == $session->get(UserConstants::USER_ID)) {
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
$claimData['newCoinBalance'] = $session->get('BUDDYBEE_COIN_BALANCE');
$claimData['newBalance'] = $session->get('BUDDYBEE_BALANCE');
}
$redeemedAmount = $claimData['data']['claimedAmount'];
$redeemedSessionCount = $claimData['data']['claimedCoin'];
} else
if ($userId == $session->get(UserConstants::USER_ID)) {
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
}
$payableAmount = round($request->request->get('payableAmount', 0), 0);
$totalAmountWoDiscount = round($request->request->get('totalAmountWoDiscount', 0), 0);
//now claim and process promocode
if ($promoCode != '') {
$claimData = MiscActions::ClaimPromoCode($em,
[
'claimFlag' => 1,
'promoCode' => $promoCode,
'decryptedPromoCodeData' => json_decode($this->get('url_encryptor')->decrypt($promoCode), true),
'orderValue' => $totalAmountWoDiscount,
'currency' => $currencyForGateway,
'orderCoin' => $invoiceSessionCount,
'userId' => $userId,
]);
$promoClaimedAmount = 0;
// $promoClaimedAmount = $claimData['data']['claimedAmount']*(ConsultancyConstant::$convMultFromTo['eur'][$currencyForGateway]);
$promoCodeId = $claimData['promoCodeId'];
$promoClaimedSession = $claimData['data']['claimedCoin'];
}
if ($userId == $session->get(UserConstants::USER_ID)) {
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
$currentUserBalance = $session->get('BUDDYBEE_BALANCE');
$currentUserCoinBalance = $session->get('BUDDYBEE_COIN_BALANCE');
} else {
if ($bookingRefererId == 0)
$bookingRefererId = $session->get(UserConstants::USER_ID);
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($userId);
if ($studentDetails) {
$currentUserBalance = $studentDetails->getAccountBalance();
$currentUserCoinBalance = $studentDetails->getSessionCountBalance();
if ($bookingRefererId != $userId && $bookingRefererId != 0) {
$bookingReferer = $em_goc->getRepository(EntityApplicantDetails::class)->find($bookingRefererId);
if ($bookingReferer)
if ($bookingReferer->getIsAdmin()) {
$studentDetails->setAssignedSalesRepresentativeId($bookingRefererId);
$em_goc->flush();
}
}
}
}
//2. check if any promo code if yes add it to promo discount
//3. check if scheule is still temporarily booked if not return that you cannot book it
Consultancy::ExpireAnyMeetingSessionIfNeeded($em);
Consultancy::ExpireAnyEntityInvoiceIfNeeded($em);
if ($request->request->get('autoAssignMeetingSession', 0) == 1
&& $request->request->get('consultancyScheduleId', 0) != 0
&& $request->request->get('consultancyScheduleId', 0) != ''
) {
//1st check if a meeting session exxists with same TS, student id , consultant id
$scheduledStartTime = new \DateTime('@' . $request->request->get('consultancyScheduleId', ''));
$extMeeting = $em->getRepository('CompanyGroupBundle:EntityMeetingSession')
->findOneBy(
array(
'scheduledTimeTs' => $scheduledStartTime->format('U'),
'consultantId' => $request->request->get('consultantId', 0),
'studentId' => $request->request->get('studentId', 0),
'durationAllowedMin' => $request->request->get('meetingSessionScheduledDuration', ConsultancyConstant::PER_SESSION_MINUTE),
)
);
if ($extMeeting) {
$new = $extMeeting;
$meetingSessionId = $new->getSessionId();
$periodMarker = $scheduledStartTime->format('Ym');
} else {
$scheduleValidity = MiscActions::CheckIfScheduleCanBeConfirmed(
$em,
$request->request->get('consultantId', 0),
$request->request->get('studentId', 0),
$scheduledStartTime->format('U'),
$request->request->get('meetingSessionScheduledDuration', ConsultancyConstant::PER_SESSION_MINUTE),
1
);
if (!$scheduleValidity) {
$url = $this->generateUrl(
'consultant_profile'
);
$output = [
'proceedToCheckout' => 0,
'message' => 'Session Booking Expired or not Found!',
'errorFlag' => 1,
'redirectUrl' => $url . '/' . $request->request->get('consultantId', 0)
];
return new JsonResponse($output);
}
$new = new EntityMeetingSession();
$new->setTopicId($request->request->get('consultancyTopic', 0));
$new->setConsultantId($request->request->get('consultantId', 0));
$new->setStudentId($request->request->get('studentId', 0));
$consultancyTopic = $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic', 0));
$new->setMeetingType($consultancyTopic ? $consultancyTopic->getMeetingType() : 0);
$new->setConsultantCanUpload($consultancyTopic ? $consultancyTopic->getConsultantCanUpload() : 0);
$scheduledEndTime = new \DateTime($request->request->get('scheduledTime', ''));
$scheduledEndTime = $scheduledEndTime->modify('+' . $request->request->get('meetingSessionScheduledDuration', 30) . ' minute');
//$new->setScheduledTime($request->request->get('setScheduledTime'));
$new->setScheduledTime($scheduledStartTime);
$new->setDurationAllowedMin($request->request->get('meetingSessionScheduledDuration', 30));
$new->setDurationLeftMin($request->request->get('meetingSessionScheduledDuration', 30));
$new->setSessionExpireDate($scheduledEndTime);
$new->setSessionExpireDateTs($scheduledEndTime->format('U'));
$new->setEquivalentSessionCount($request->request->get('meetingSessionConsumeCount', 0));
$new->setMeetingSpecificNote($request->request->get('meetingSpecificNote', ''));
$new->setUsableSessionCount($request->request->get('meetingSessionConsumeCount', 0));
$new->setRedeemSessionCount($request->request->get('meetingSessionConsumeCount', 0));
$new->setMeetingActionFlag(0);// no action waiting for meeting
$new->setScheduledTime($scheduledStartTime);
$new->setScheduledTimeTs($scheduledStartTime->format('U'));
$new->setPayableAmount($request->request->get('payableAmount', 0));
$new->setDueAmount($request->request->get('dueAmount', 0));
//$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
//$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
$new->setPackageName(($request->request->get('packageName', '')));
$new->setPcakageDetails(($request->request->get('packageData', '')));
$new->setScheduleId(($request->request->get('consultancyScheduleId', 0)));
$currentUnixTime = new \DateTime();
$currentUnixTimeStamp = $currentUnixTime->format('U');
$studentId = $request->request->get('studentId', 0);
$consultantId = $request->request->get('consultantId', 0);
$new->setMeetingRoomId(str_pad($consultantId, 4, STR_PAD_LEFT) . $currentUnixTimeStamp . str_pad($studentId, 4, STR_PAD_LEFT));
$new->setSessionValue(($request->request->get('sessionValue', 0)));
// $new->setIsPayment(0);
$new->setConsultantIsPaidFull(0);
if ($bookingExpireTs == 0) {
$bookingExpireTime = new \DateTime();
$currTime = new \DateTime();
$currTimeTs = $currTime->format('U');
$bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (24 * 3600);
if ($bookingExpireTs < $currTimeTs) {
if ((1 * $scheduledStartTime->format('U')) - $currTimeTs > (12 * 3600))
$bookingExpireTs = (1 * $scheduledStartTime->format('U')) - (2 * 3600);
else
$bookingExpireTs = (1 * $scheduledStartTime->format('U'));
}
// $bookingExpireTs = $bookingExpireTime->format('U');
}
$new->setPaidSessionCount(0);
$new->setBookedById($bookedById);
$new->setBookingRefererId($bookingRefererId);
$new->setDueSessionCount($request->request->get('meetingSessionConsumeCount', 0));
$new->setExpireIfUnpaidTs($bookingExpireTs);
$new->setBookingExpireTs($bookingExpireTs);
$new->setConfirmationExpireTs($bookingExpireTs);
$new->setIsPaidFull(0);
$new->setIsExpired(0);
$em_goc->persist($new);
$em_goc->flush();
$meetingSessionId = $new->getSessionId();
$periodMarker = $scheduledStartTime->format('Ym');
MiscActions::UpdateSchedulingRestrictions($em_goc, $consultantId, $periodMarker, (($request->request->get('meetingSessionScheduledDuration', 30)) / 60), -(($request->request->get('meetingSessionScheduledDuration', 30)) / 60));
}
}
//4. if after all this stages passed then calcualte gateway payable
if ($request->request->get('isRecharge', 0) == 1) {
if (($redeemedAmount + $promoClaimedAmount) >= $payableAmount) {
$payableAmount = ($redeemedAmount + $promoClaimedAmount);
$gatewayAmount = 0;
} else
$gatewayAmount = $payableAmount - ($redeemedAmount + $promoClaimedAmount);
} else {
if ($toConsumeSessionCount <= $currentUserCoinBalance && $invoiceSessionCount <= $toConsumeSessionCount) {
$payableAmount = 0;
$gatewayAmount = 0;
} else if (($redeemedAmount + $promoClaimedAmount) >= $payableAmount) {
$payableAmount = ($redeemedAmount + $promoClaimedAmount);
$gatewayAmount = 0;
} else
$gatewayAmount = $payableAmount <= ($currentUserBalance + ($redeemedAmount + $promoClaimedAmount)) ? 0 : ($payableAmount - $currentUserBalance - ($redeemedAmount + $promoClaimedAmount));
}
$gatewayAmount = round($gatewayAmount, 2);
$dueAmount = round($request->request->get('dueAmount', $payableAmount), 0);
if ($request->request->has('gatewayProductData'))
$gatewayProductData = $request->request->get('gatewayProductData');
$gatewayProductData = [[
'price_data' => [
'currency' => $currencyForGateway,
'unit_amount' => $gatewayAmount != 0 ? ((100 * $gatewayAmount) / ($invoiceSessionCount != 0 ? $invoiceSessionCount : 1)) : 200000,
'product_data' => [
// 'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
'name' => 'Bee Coins',
'images' => [$imageBySessionCount[$invoiceSessionCount]],
],
],
'quantity' => $invoiceSessionCount != 0 ? $invoiceSessionCount : 1,
]];
$new_invoice = null;
if ($extMeeting) {
$new_invoice = $em->getRepository('CompanyGroupBundle:EntityInvoice')
->findOneBy(
array(
'invoiceType' => $request->request->get('invoiceType', ConsultancyConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_BUDDYBEE),
'meetingId' => $extMeeting->getSessionId(),
)
);
}
if ($new_invoice) {
} else {
$new_invoice = new EntityInvoice();
$invoiceDate = new \DateTime();
$new_invoice->setInvoiceDate($invoiceDate);
$new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
$new_invoice->setStudentId($userId);
$new_invoice->setBillerId($retailerId == 0 ? 0 : $retailerId);
$new_invoice->setRetailerId($retailerId);
$new_invoice->setBillToId($userId);
$new_invoice->setAmountTransferGateWayHash($paymentGateway);
$new_invoice->setAmountCurrency($currencyForGateway);
$cardIds = $request->request->get('cardIds', []);
$new_invoice->setMeetingId($meetingSessionId);
$new_invoice->setGatewayBillAmount($gatewayAmount);
$new_invoice->setRedeemedAmount($redeemedAmount);
$new_invoice->setPromoDiscountAmount($promoClaimedAmount);
$new_invoice->setPromoCodeId($promoCodeId);
$new_invoice->setRedeemedSessionCount($redeemedSessionCount);
$new_invoice->setPaidAmount($payableAmount - $dueAmount);
$new_invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
$new_invoice->setDueAmount($dueAmount);
$new_invoice->setInvoiceType($request->request->get('invoiceType', ConsultancyConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_BUDDYBEE));
$new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' . microtime(true)));
$new_invoice->setCardIds(json_encode($cardIds));
$new_invoice->setAmountType($request->request->get('amountType', 1));
$new_invoice->setAmount($payableAmount);
$new_invoice->setConsumeAmount($payableAmount);
$new_invoice->setSessionCount($invoiceSessionCount);
$new_invoice->setConsumeSessionCount($toConsumeSessionCount);
$new_invoice->setIsPaidfull(0);
$new_invoice->setIsProcessed(0);
$new_invoice->setApplicantId($userId);
$new_invoice->setBookedById($bookedById);
$new_invoice->setBookingRefererId($bookingRefererId);
$new_invoice->setIsRecharge($request->request->get('isRecharge', 0));
$new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting', 0));
$new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting', 0));
$new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards', 0));
$new_invoice->setIsPayment(0); //0 means receive
$new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
$new_invoice->setStage(ConsultancyConstant::ENTITY_INVOICE_STAGE_INITIATED); //0 means receive
if ($bookingExpireTs == 0) {
$bookingExpireTime = new \DateTime();
$bookingExpireTime->modify('+30 day');
$bookingExpireTs = $bookingExpireTime->format('U');
}
$new_invoice->setExpireIfUnpaidTs($bookingExpireTs);
$new_invoice->setBookingExpireTs($bookingExpireTs);
$new_invoice->setConfirmationExpireTs($bookingExpireTs);
// $new_invoice->setStatus($request->request->get(0));
$em_goc->persist($new_invoice);
$em_goc->flush();
}
$invoiceId = $new_invoice->getId();
$gatewayInvoice = $new_invoice;
if ($request->request->get('isRecharge', 0) == 1) {
} else {
if ($gatewayAmount <= 0) {
$meetingId = 0;
if ($invoiceId != 0) {
$retData = Consultancy::ProcessEntityInvoice($em_goc, $invoiceId, ['stage' => ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server')
);
$meetingId = $retData['meetingId'];
}
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
if (GeneralConstant::EMAIL_ENABLED == 1) {
$billerDetails = [];
$billToDetails = [];
$invoice = $gatewayInvoice;
if ($invoice) {
$billerDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillerId(),
)
);
$billToDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillToId(),
)
);
}
$bodyTemplate = 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
$bodyData = array(
'page_title' => 'Invoice',
// 'studentDetails' => $student,
'billerDetails' => $billerDetails,
'billToDetails' => $billToDetails,
'invoice' => $invoice,
'currencyList' => ConsultancyConstant::$currency_List,
'currencyListByMarker' => ConsultancyConstant::$currency_List_by_marker,
);
$attachments = [];
$forwardToMailAddress = $billToDetails->getOAuthEmail();
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'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 ',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'no-reply@buddybee.eu',
'userName' => 'no-reply@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 0,
'companyId' => 0,
'companyImagePath' => ''
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
}
if ($meetingId != 0) {
$url = $this->generateUrl(
'consultancy_session'
);
$output = [
'invoiceId' => $gatewayInvoice->getId(),
'meetingId' => $meetingId,
'proceedToCheckout' => 0,
'redirectUrl' => $url . '/' . $meetingId
];
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
$output = [
'invoiceId' => $gatewayInvoice->getId(),
'meetingId' => 0,
'proceedToCheckout' => 0,
'redirectUrl' => $url
];
}
return new JsonResponse($output);
// return $this->redirect($url);
} else {
}
// $url = $this->generateUrl(
// 'checkout_page'
// );
//
// return $this->redirect($url."?meetingSessionId=".$new->getSessionId().'&invoiceId='.$invoiceId);
}
}
} else {
$url = $this->generateUrl(
'applicant_login'
);
$session->set('LAST_REQUEST_URI_BEFORE_LOGIN', $this->generateUrl(
'pricing_plan_page', [
'autoRedirected' => 1
],
UrlGenerator::ABSOLUTE_URL
));
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url,
'clearLs' => 0
];
return new JsonResponse($output);
}
//now proceed to checkout page if the user has lower balance or recharging
//$invoiceDetails = $em->getRepository('CompanyGroupBundle:EntityInvoice')->
}
}
if ($gatewayInvoice) {
$gatewayProductData = json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
if ($gatewayProductData == null) $gatewayProductData = [];
if (empty($gatewayProductData))
$gatewayProductData = [
[
'price_data' => [
'currency' => 'eur',
'unit_amount' => $gatewayAmount != 0 ? (100 * $gatewayAmount) : 200000,
'product_data' => [
// 'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
'name' => 'Bee Coins',
'images' => [$imageBySessionCount[$invoiceSessionCount]],
],
],
'quantity' => 1,
]
];
$productDescStr = '';
$productDescArr = [];
foreach ($gatewayProductData as $gpd) {
$productDescArr[] = $gpd['price_data']['product_data']['name'];
}
$productDescStr = implode(',', $productDescArr);
$paymentGatewayFromInvoice = $gatewayInvoice->getAmountTransferGateWayHash();
if ($paymentGateway == null) $paymentGatewayFromInvoice = 'stripe';
if ($paymentGatewayFromInvoice == 'stripe' || $paymentGatewayFromInvoice == 'aamarpay' || $paymentGatewayFromInvoice == 'bkash') {
if (GeneralConstant::EMAIL_ENABLED == 1) {
$billerDetails = [];
$billToDetails = [];
$invoice = $gatewayInvoice;
if ($invoice) {
$billerDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillerId(),
)
);
$billToDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillToId(),
)
);
}
$bodyTemplate = 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
$bodyData = array(
'page_title' => 'Invoice',
// 'studentDetails' => $student,
'billerDetails' => $billerDetails,
'billToDetails' => $billToDetails,
'invoice' => $invoice,
'currencyList' => ConsultancyConstant::$currency_List,
'currencyListByMarker' => ConsultancyConstant::$currency_List_by_marker,
);
$attachments = [];
$forwardToMailAddress = $billToDetails->getOAuthEmail();
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'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 ',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'no-reply@buddybee.eu',
'userName' => 'no-reply@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 0,
'companyId' => 0,
'companyImagePath' => ''
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
}
}
if ($paymentGatewayFromInvoice == 'stripe') {
$stripe = new \Stripe\Stripe();
\Stripe\Stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
$stripe::setApiKey('sk_test_51IxYTAJXs21fVb0QMop2Nb0E7u9Da4LwGrym1nGHUHqaSNtT3p9HBgHd7YyDsTKHscgPPECPQniTy79Ab8Sgxfbm00JF2AndUz');
{
if ($request->query->has('meetingSessionId'))
$id = $request->query->get('meetingSessionId');
}
$paymentIntent = [
"id" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs",
"object" => "payment_intent",
"amount" => 3000,
"amount_capturable" => 0,
"amount_received" => 0,
"application" => null,
"application_fee_amount" => null,
"canceled_at" => null,
"cancellation_reason" => null,
"capture_method" => "automatic",
"charges" => [
"object" => "list",
"data" => [],
"has_more" => false,
"url" => "/v1/charges?payment_intent=pi_1DoWjK2eZvKYlo2Csy9J3BHs"
],
"client_secret" => "pi_1DoWjK2eZvKYlo2Csy9J3BHs_secret_vmxAcWZxo2kt1XhpWtZtnjDtd",
"confirmation_method" => "automatic",
"created" => 1546523966,
"currency" => $currencyForGateway,
"customer" => null,
"description" => null,
"invoice" => null,
"last_payment_error" => null,
"livemode" => false,
"metadata" => [],
"next_action" => null,
"on_behalf_of" => null,
"payment_method" => null,
"payment_method_options" => [],
"payment_method_types" => [
"card"
],
"receipt_email" => null,
"review" => null,
"setup_future_usage" => null,
"shipping" => null,
"statement_descriptor" => null,
"statement_descriptor_suffix" => null,
"status" => "requires_payment_method",
"transfer_data" => null,
"transfer_group" => null
];
$checkout_session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => $gatewayProductData,
'mode' => 'payment',
'success_url' => $this->generateUrl(
'payment_gateway_success',
['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
'cancel_url' => $this->generateUrl(
'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
]);
$output = [
'clientSecret' => $paymentIntent['client_secret'],
'id' => $checkout_session->id,
'paymentGateway' => $paymentGatewayFromInvoice,
'proceedToCheckout' => 1
];
return new JsonResponse($output);
}
if ($paymentGatewayFromInvoice == 'aamarpay') {
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
$url = $sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/request.php' : 'https://secure.aamarpay.com/request.php';
$fields = array(
// 'store_id' => 'aamarpaytest', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
'amount' => $gatewayInvoice->getGateWayBillamount(), //transaction amount
'payment_type' => 'VISA', //no need to change
'currency' => strtoupper($currencyForGateway), //currenct will be USD/BDT
'tran_id' => $gatewayInvoice->getDocumentHash(), //transaction id must be unique from your end
'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(), //customer name
'cus_email' => $studentDetails->getEmail(), //customer email address
'cus_add1' => $studentDetails->getCurrAddr(), //customer address
'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
'cus_city' => $studentDetails->getCurrAddrCity(), //customer city
'cus_state' => $studentDetails->getCurrAddrState(), //state
'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
'cus_country' => 'Bangladesh', //country
'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? '+8801911706483' : $studentDetails->getPhone(), //customer phone number
'cus_fax' => '', //fax
'ship_name' => '', //ship name
'ship_add1' => '', //ship address
'ship_add2' => '',
'ship_city' => '',
'ship_state' => '',
'ship_postcode' => '',
'ship_country' => 'Bangladesh',
'desc' => $productDescStr,
'success_url' => $this->generateUrl(
'payment_gateway_success',
['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
'fail_url' => $this->generateUrl(
'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
'cancel_url' => $this->generateUrl(
'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
),
// 'opt_a' => 'Reshad', //optional paramter
// 'opt_b' => 'Akil',
// 'opt_c' => 'Liza',
// 'opt_d' => 'Sohel',
// 'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183', //sandbox
'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524' //live
); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
curl_close($ch);
// $this->redirect_to_merchant($url_forward);
$output = [
// 'redirectUrl' => 'https://sandbox.aamarpay.com/'.$url_forward, //keeping it off temporarily
'redirectUrl' => ($sandBoxMode == 1 ? 'https://sandbox.aamarpay.com/' : 'https://secure.aamarpay.com/') . $url_forward, //keeping it off temporarily
// 'fields'=>$fields,
// 'fields_string'=>$fields_string,
// 'redirectUrl' => $this->generateUrl(
// 'payment_gateway_success',
// ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
// 'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
// ))), 'hbeeSessionToken' => $request->request->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
'paymentGateway' => $paymentGatewayFromInvoice,
'proceedToCheckout' => 1
];
return new JsonResponse($output);
} else if ($paymentGatewayFromInvoice == 'bkash') {
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($gatewayInvoice->getBillToId());
$baseUrl = ($sandBoxMode == 1) ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta' : 'https://tokenized.pay.bka.sh/v1.2.0-beta';
$username_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02' : '01891962953';
$password_value = ($sandBoxMode == 1) ? 'sandboxTokenizedUser02@12345' : ',a&kPV4deq&';
$app_key_value = ($sandBoxMode == 1) ? '4f6o0cjiki2rfm34kfdadl1eqq' : '2ueVHdwz5gH3nxx7xn8wotlztc';
$app_secret_value = ($sandBoxMode == 1) ? '2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b' : '49Ay3h3wWJMBFD7WF5CassyLrtA1jt6ONhspqjqFx5hTjhqh5dHU';
$request_data = array(
'app_key' => $app_key_value,
'app_secret' => $app_secret_value
);
$url = curl_init($baseUrl . '/tokenized/checkout/token/grant');
$request_data_json = json_encode($request_data);
$header = array(
'Content-Type:application/json',
'username:' . $username_value,
'password:' . $password_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $request_data_json);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$tokenData = json_decode(curl_exec($url), true);
curl_close($url);
$id_token = $tokenData['id_token'];
$goToBkashPage = 0;
if ($tokenData['statusCode'] == '0000') {
$auth = $id_token;
$requestbody = array(
"mode" => "0011",
// "payerReference" => "01723888888",
"payerReference" => $invoiceDate->format('U'),
"callbackURL" => $this->generateUrl(
'bkash_callback', [], UrlGenerator::ABSOLUTE_URL
),
// "merchantAssociationInfo" => "MI05MID54RF09123456One",
"amount" => 1 * number_format($gatewayInvoice->getGateWayBillamount(), 2, '.', ''),
"currency" => "BDT",
"intent" => "sale",
"merchantInvoiceNumber" => $invoiceId
);
$url = curl_init($baseUrl . '/tokenized/checkout/create');
$requestbodyJson = json_encode($requestbody);
$header = array(
'Content-Type:application/json',
'Authorization:' . $auth,
'X-APP-Key:' . $app_key_value
);
curl_setopt($url, CURLOPT_HTTPHEADER, $header);
curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url, CURLOPT_POSTFIELDS, $requestbodyJson);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$resultdata = curl_exec($url);
curl_close($url);
// echo $resultdata;
$obj = json_decode($resultdata, true);
$goToBkashPage = 1;
$justNow = new \DateTime();
$justNow->modify('+' . $tokenData['expires_in'] . ' second');
$gatewayInvoice->setGatewayIdTokenExpireTs($justNow->format('U'));
$gatewayInvoice->setGatewayIdToken($tokenData['id_token']);
$gatewayInvoice->setGatewayPaymentId($obj['paymentID']);
$gatewayInvoice->setGatewayIdRefreshToken($tokenData['refresh_token']);
$em->flush();
$output = [
'redirectUrl' => $obj['bkashURL'],
'paymentGateway' => $paymentGatewayFromInvoice,
'proceedToCheckout' => $goToBkashPage,
'tokenData' => $tokenData,
'obj' => $obj,
'id_token' => $tokenData['id_token'],
];
return new JsonResponse($output);
}
// $fields = array(
//
// "mode" => "0011",
// "payerReference" => "01723888888",
// "callbackURL" => $this->generateUrl(
// 'payment_gateway_success',
// ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
// 'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
// ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
// "merchantAssociationInfo" => "MI05MID54RF09123456One",
// "amount" => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),,
// "currency" => "BDT",
// "intent" => "sale",
// "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)
//
// );
// $fields = array(
//// 'store_id' => 'aamarpaytest', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
// 'store_id' => $sandBoxMode == 1 ? 'aamarpaytest' : 'buddybee', //store id will be aamarpay, contact integration@aamarpay.com for test/live id
// 'amount' => 1*number_format($gatewayInvoice->getGateWayBillamount(),2,'.',''),, //transaction amount
// 'payment_type' => 'VISA', //no need to change
// 'currency' => strtoupper($currencyForGateway), //currenct will be USD/BDT
// '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
// 'cus_name' => $studentDetails->getFirstname() . ' ' . $studentDetails->getLastName(), //customer name
// 'cus_email' => $studentDetails->getEmail(), //customer email address
// 'cus_add1' => $studentDetails->getCurrAddr(), //customer address
// 'cus_add2' => $studentDetails->getCurrAddrCity(), //customer address
// 'cus_city' => $studentDetails->getCurrAddrCity(), //customer city
// 'cus_state' => $studentDetails->getCurrAddrState(), //state
// 'cus_postcode' => $studentDetails->getCurrAddrZip(), //postcode or zipcode
// 'cus_country' => 'Bangladesh', //country
// 'cus_phone' => ($studentDetails->getPhone() == null || $studentDetails->getPhone() == '') ? ' + 8801911706483' : $studentDetails->getPhone(), //customer phone number
// 'cus_fax' => '', //fax
// 'ship_name' => '', //ship name
// 'ship_add1' => '', //ship address
// 'ship_add2' => '',
// 'ship_city' => '',
// 'ship_state' => '',
// 'ship_postcode' => '',
// 'ship_country' => 'Bangladesh',
// 'desc' => $productDescStr,
// 'success_url' => $this->generateUrl(
// 'payment_gateway_success',
// ['encData' => $this->get('url_encryptor')->encrypt(json_encode(array(
// 'invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1)
// ))), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
// 'fail_url' => $this->generateUrl(
// 'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
// 'cancel_url' => $this->generateUrl(
// 'payment_gateway_cancel', ['invoiceId' => $invoiceId, 'autoRedirect' => $request->request->get('autoRedirect', 1), 'hbeeSessionToken' => $session->get('token', 0)], UrlGenerator::ABSOLUTE_URL
// ),
//// 'opt_a' => 'Reshad', //optional paramter
//// 'opt_b' => 'Akil',
//// 'opt_c' => 'Liza',
//// 'opt_d' => 'Sohel',
//// 'signature_key' => 'dbb74894e82415a2f7ff0ec3a97e4183', //sandbox
// 'signature_key' => $sandBoxMode == 1 ? 'dbb74894e82415a2f7ff0ec3a97e4183' : 'b7304a40e21fe15af3be9a948307f524' //live
//
// ); //signature key will provided aamarpay, contact integration@aamarpay.com for test/live signature key
//
// $fields_string = http_build_query($fields);
//
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_VERBOSE, true);
// curl_setopt($ch, CURLOPT_URL, $url);
//
// curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// $url_forward = str_replace('"', '', stripslashes(curl_exec($ch)));
// curl_close($ch);
// $this->redirect_to_merchant($url_forward);
} else if ($paymentGatewayFromInvoice == 'onsite_pos' || $paymentGatewayFromInvoice == 'onsite_cash' || $paymentGatewayFromInvoice == 'onsite_bkash') {
$meetingId = 0;
if ($gatewayInvoice->getId() != 0) {
if ($gatewayInvoice->getDueAmount() <= 0) {
$retData = Consultancy::ProcessEntityInvoice($em_goc, $gatewayInvoice->getId(), ['stage' => ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server')
);
$meetingId = $retData['meetingId'];
}
if (GeneralConstant::EMAIL_ENABLED == 1) {
$billerDetails = [];
$billToDetails = [];
$invoice = $gatewayInvoice;
if ($invoice) {
$billerDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillerId(),
)
);
$billToDetails = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->findOneBy(
array(
'applicantId' => $invoice->getBillToId(),
)
);
}
$bodyTemplate = 'ApplicationBundle:email/templates:buddybeeInvoiceEmail.html.twig';
$bodyData = array(
'page_title' => 'Invoice',
// 'studentDetails' => $student,
'billerDetails' => $billerDetails,
'billToDetails' => $billToDetails,
'invoice' => $invoice,
'currencyList' => ConsultancyConstant::$currency_List,
'currencyListByMarker' => ConsultancyConstant::$currency_List_by_marker,
);
$attachments = [];
$forwardToMailAddress = $billToDetails->getOAuthEmail();
// $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
$new_mail = $this->get('mail_module');
$new_mail->sendMyMail(array(
'senderHash' => '_CUSTOM_',
// 'senderHash'=>'_CUSTOM_',
'forwardToMailAddress' => $forwardToMailAddress,
'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 ',
// 'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
'attachments' => $attachments,
'toAddress' => $forwardToMailAddress,
'fromAddress' => 'no-reply@buddybee.eu',
'userName' => 'no-reply@buddybee.eu',
'password' => 'Honeybee@0112',
'smtpServer' => 'smtp.hostinger.com',
'smtpPort' => 465,
// 'emailBody' => $bodyHtml,
'mailTemplate' => $bodyTemplate,
'templateData' => $bodyData,
'embedCompanyImage' => 0,
'companyId' => 0,
'companyImagePath' => ''
// 'embedCompanyImage' => 1,
// 'companyId' => $companyId,
// 'companyImagePath' => $company_data->getImage()
));
}
}
MiscActions::RefreshBuddybeeBalanceOnSession($em, $request->getSession());
if ($meetingId != 0) {
$url = $this->generateUrl(
'consultancy_session'
);
$output = [
'proceedToCheckout' => 0,
'invoiceId' => $gatewayInvoice->getId(),
'meetingId' => $meetingId,
'redirectUrl' => $url . '/' . $meetingId
];
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
$output = [
'proceedToCheckout' => 0,
'invoiceId' => $gatewayInvoice->getId(),
'meetingId' => $meetingId,
'redirectUrl' => $url
];
}
return new JsonResponse($output);
}
}
$output = [
'clientSecret' => 0,
'id' => 0,
'proceedToCheckout' => 0
];
return new JsonResponse($output);
// return $this->render('ApplicationBundle:pages/stripe:checkout.html.twig', array(
// 'page_title' => 'Checkout',
//// 'stripe' => $stripe,
// 'stripe' => null,
//// 'PaymentIntent' => $paymentIntent,
//
//// 'consultantDetail' => $consultantDetail,
//// 'consultantDetails'=> $consultantDetails,
////
//// 'meetingSession' => $meetingSession,
//// 'packageDetails' => json_decode($meetingSession->getPcakageDetails(),true),
//// 'packageName' => json_decode($meetingSession->getPackageName(),true),
//// 'pay' => $payableAmount,
//// 'balance' => $currStudentBal
// ));
}
public function BeeCodePageAction(Request $request, $id)
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$session = $request->getSession();
$invoiceId = 0;
$topic = null;
$scheduleId = 0;
$consultantDetails = null;
$consultantId = 0;
$sessionId = 0;
$topicSessionValue = 0;
$consultantSchedule = null;
$scheduleText = '';
$autoRedirected = 0;
$autoAssignMeetingSession = 0;
$topicCoinMultiplierValue = $request->request->get('topicCoinMultiplierValue', $request->request->get('topicCoinMultiplierValue', 1));
$sessionConsumeCount = $request->request->get('sessionConsumeCount', $topicCoinMultiplierValue * $request->request->get('sessionDurationSelector', 0));
if ($request->request->has('sessionDurationSelector'))
$sessionDuration = ($request->request->get('sessionDurationSelector', 0)) * ConsultancyConstant::PER_SESSION_MINUTE / (ConsultancyConstant::COIN_GENERAL_MULT);
else
$sessionDuration = $sessionConsumeCount * ConsultancyConstant::PER_SESSION_MINUTE / (ConsultancyConstant::COIN_GENERAL_MULT);
$meetingSessionId = 0;
$requiredPurchaseSessionCount = $sessionConsumeCount;
if ($request->isMethod('GET') && $request->query->has('autoRedirected'))
$autoRedirected = $request->query->get('autoRedirected');
// $studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
if ($request->isMethod('POST') && $request->request->has('toPackagePage')) {
$topicId = $request->request->get('consultancyTopic');
$sessionId = $request->request->get('sessionSelector');
$topicSessionValue = $request->request->get('sessionSelector');
$consultantId = $request->request->get('consultantId');
$scheduleId = $request->request->get('consultancyScheduleId'); // this is timestamp
$scheduleTs = $request->request->get('consultancyScheduleId'); // this is timestamp
// $sessionConsumeCount = $request->request->get('sessionConsumeCount');
$autoAssignMeetingSession = 1;
//$topic = $em->getRepository(ConsultancyTopic::class)->findAll();
$topic = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(array(
'id' => $topicId
));
$consultantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
'applicantId' => $consultantId
));
// $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle:EntityConsultantSchedule')->findOneBy(array(
// 'consultantId' => $consultantId
// ));
// $schdeuledTime = [];
// if ($consultantSchedule)
// $schdeuledTime = json_decode($consultantSchedule->getTimeSchedule(), true);
// if ($schdeuledTime == null)
// $schdeuledTime = [];
// $scheduleText = isset($schdeuledTime[$scheduleId]) ? $schdeuledTime[$scheduleId]['date'] . ' ' . $schdeuledTime[$scheduleId]['startTime'] : '';
$scheduleTextDate = new \DateTime('@' . $scheduleId);;
$scheduleText = $scheduleTextDate->format('F d, Y H:i');
$currentUserBalance = 0;
$gatewayAmount = 0;
$redeemedAmount = 0;
$redeemedSessionCount = 0;
$payableAmount = 0;
$totalAmount = 0;
$totalSessionCount = 0;
$consumedAmount = 0;
$consumedSessionCount = $request->request->get('sessionDurationSelector', 0);
$currentUserSessionBalance = 0;
$currentUserBalance = 0;
$balancedFromUserSessionCount = 0;
$balancedFromUserBalance = 0;
$studentId = 0;
if ($session->get(UserConstants::USER_ID)
&& $session->get(UserConstants::USER_TYPE) == UserConstants::USER_TYPE_APPLICANT
) {
$studentDetails = null;
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
if ($studentDetails) {
$currentUserBalance = $studentDetails->getAccountBalance();
$currentUserSessionBalance = $studentDetails->getSessionCountBalance();
$studentId = $studentDetails->getApplicantId();
}
if ($consumedSessionCount <= $currentUserSessionBalance) {
$balancedFromUserSessionCount = 1;
}
//1st do the necessary
$beeCode = $request->request->get('beeCode', '');
$payableAmount = $request->request->get('payableAmount', 0);
$scheduledStartTime = new \DateTime('@' . $scheduleId);;
if ($balancedFromUserSessionCount == 1) {
$scheduleValidity = MiscActions::CheckIfScheduleCanBeConfirmed(
$em_goc,
$request->request->get('consultantId', 0),
$studentId,
$scheduledStartTime->format('U'),
(30 * $consumedSessionCount),
1
);
if (!$scheduleValidity) {
$url = $this->generateUrl(
'consultant_profile'
);
$output = [
'proceedToCheckout' => 0,
'message' => 'Session Booking Expired or not Found!',
'errorFlag' => 1,
'redirectUrl' => $url . '/' . $request->request->get('consultantId', 0)
];
if ($request->request->has('returnJson'))
return new JsonResponse($output);
else
return $this->redirect($url . '/' . $request->request->get('consultantId', 0) . '?errorFlag=1&message=Session Booking Expired or not Found');
}
$new = new EntityMeetingSession();
$new->setTopicId($request->request->get('consultancyTopic', 0));
$new->setConsultantId($request->request->get('consultantId', 0));
$consultancyTopic = $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic', 0));
$new->setMeetingType($consultancyTopic ? $consultancyTopic->getMeetingType() : 0);
$new->setConsultantCanUpload($consultancyTopic ? $consultancyTopic->getConsultantCanUpload() : 0);
$new->setStudentId($studentId);
$scheduledEndTime = new \DateTime('@' . $scheduleId);;
$scheduledEndTime = $scheduledEndTime->modify('+' . (30 * $consumedSessionCount) . ' Minute');
// $scheduledStartTime->setTimezone(new \DateTimeZone('UTC'));
// $scheduledEndTime->setTimezone(new \DateTimeZone('UTC'));
//$new->setScheduledTime($request->request->get('setScheduledTime'));
$new->setScheduledTime($scheduledStartTime);
$new->setScheduledTimeTs($scheduledStartTime->format('U'));
$new->setDurationAllowedMin((30 * $consumedSessionCount));
$new->setDurationLeftMin((30 * $consumedSessionCount));
$new->setSessionExpireDate($scheduledEndTime);
$new->setSessionExpireDateTs($scheduledEndTime->format('U'));
$new->setEquivalentSessionCount($consumedSessionCount);
$new->setRedeemSessionCount($consumedSessionCount);
$new->setUsableSessionCount($consumedSessionCount);
$new->setMeetingActionFlag(0);// no action waiting for meeting
$new->setPayableAmount($payableAmount);
$new->setDueAmount($request->request->get('dueAmount', 0));
//$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
//$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
$new->setPackageName(($request->request->get('packageName', '')));
$new->setPcakageDetails(($request->request->get('packageData', '')));
$new->setScheduleId($scheduleId);
$new->setSessionValue($topicSessionValue);
// $new->setIsPayment(0);
$new->setConsultantIsPaidFull(0);
$currentUnixTime = new \DateTime();
$currentUnixTimeStamp = $currentUnixTime->format('U');
$consultantId = $request->request->get('consultantId', 0);
$new->setMeetingRoomId(str_pad($consultantId, 4, STR_PAD_LEFT) . $currentUnixTimeStamp . str_pad($studentId, 4, STR_PAD_LEFT));
$currTime = new \DateTime();
$currTime->modify('+1 day');
$currTs = $currTime->format('U');
$new->setPaidSessionCount(0);
$new->setDueSessionCount($consumedSessionCount);
$new->setExpireIfUnpaidTs($currTs);
$new->setBookingExpireTs($currTs);
$new->setConfirmationExpireTs($currTs);
$new->setIsPaidFull(0);
$new->setIsExpired(0);
$em_goc->persist($new);
$em_goc->flush();
$meetingSessionId = $new->getSessionId();
$periodMarker = $scheduledStartTime->format('Ym');
MiscActions::UpdateSchedulingRestrictions($em_goc, $consultantId, $periodMarker, (($request->request->get('meetingSessionScheduledDuration', 30)) / 60), -(($request->request->get('meetingSessionScheduledDuration', 30)) / 60));
// $studentDetails->setSessionCountBalance($currentUserSessionBalance-$consumedSessionCount);
// $studentDetails->setTotalSessionUsed($studentDetails->getTotalSessionUsed()+$consumedSessionCount);
$em_goc->flush();
$new_invoice = new EntityInvoice();
$invoiceDate = new \DateTime();
$new_invoice->setInvoiceDate($invoiceDate);
$new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
$new_invoice->setStudentId($studentId);
$new_invoice->setMeetingId($meetingSessionId);
$new_invoice->setAmount($totalAmount);
$new_invoice->setGatewayBillAmount($gatewayAmount);
$new_invoice->setRedeemedAmount($redeemedAmount);
$new_invoice->setRedeemedSessionCount($redeemedSessionCount);
$new_invoice->setPaidAmount(0);
$new_invoice->setDueAmount(0);
$new_invoice->setInvoiceType(1);
$new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' . microtime(true)));
$new_invoice->setAmountType(1);
$new_invoice->setConsumeAmount(0);
$new_invoice->setSessionCount(0);
$new_invoice->setConsumeSessionCount($consumedSessionCount);
$new_invoice->setIsPaidfull(0);
$new_invoice->setIsProcessed(0);
$new_invoice->setApplicantId($studentId);
$new_invoice->setIsRecharge(0);
$new_invoice->setStage(ConsultancyConstant::ENTITY_INVOICE_STAGE_INITIATED);
$new_invoice->setIsPayment(0); //0 means receive
$new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
$new_invoice->setAutoConfirmTaggedMeeting($request->request->get('autoConfirmTaggedMeeting', 1));
$new_invoice->setAutoConfirmOtherMeeting($request->request->get('autoConfirmOtherMeeting', 1));
$new_invoice->setAutoClaimPurchasedCards($request->request->get('autoClaimPurchasedCards', 1));
// $new_invoice->setStatus($request->request->get(0));
$em_goc->persist($new_invoice);
$em_goc->flush();
$invoiceId = $new_invoice->getId();
$retData = Consultancy::ProcessEntityInvoice($em_goc, $invoiceId, ['stage' => ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server')
);
MiscActions::RefreshBuddybeeBalanceOnSession($em_goc, $request->getSession());
$meetingSessionId = $retData['meetingId'];
if ($meetingSessionId != 0) {
$url = $this->generateUrl(
'consultancy_session'
);
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url . '/' . $meetingSessionId
];
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url
];
}
if ($request->request->has('returnJson'))
return new JsonResponse($output);
else
return $this->redirect($url . '/' . $meetingSessionId);
}
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url
];
if ($request->request->has('returnJson'))
return new JsonResponse($output);
else
return $this->redirect($url . '/' . $meetingSessionId);
}
//
}
$packageNames = ConsultancyConstant::$packageNames;
$packageDetails = ConsultancyConstant::$packageDetails;
$userId = $session->get(UserConstants::USER_ID);
if ($userId != 0) {
$applicantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
'applicantId' => $userId
));
if ($applicantDetails)
$requiredPurchaseSessionCount = $sessionConsumeCount - (1 * $applicantDetails->getSessionCountBalance());
}
return $this->render('ApplicationBundle:pages/consultancy:pricing.html.twig', array(
'page_title' => 'Package And Pricing',
'topic' => $topic,
'consultantDetails' => $consultantDetails,
'packageDetails' => $packageDetails,
'packageNames' => $packageNames,
'scheduleId' => $scheduleId,
'consultantId' => $consultantId,
'topicSessionValue' => $topicSessionValue,
'autoRedirected' => $autoRedirected,
'meetingSessionId' => $meetingSessionId,
'invoiceId' => $invoiceId,
'sessionConsumeCount' => $sessionConsumeCount,
'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
'autoAssignMeetingSession' => $autoAssignMeetingSession,
'sessionDuration' => $sessionDuration,
// 'consultantSchedule' => $consultantSchedule,
'scheduleText' => $scheduleText,
'userId' => $userId,
// 'timeSchedule' => $consultantSchedule
));
// return $this->render('ApplicationBundle:pages/consultancy:pricing.html.twig', array(
// 'page_title' => 'Package And Pricing',
// ));
}
public function PricingPlanAction(Request $request, $autoRedirected = 0)
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$session = $request->getSession();
$invoiceId = 0;
$topic = null;
$scheduleId = 0;
$consultantDetails = null;
$consultantId = 0;
$sessionId = 0;
$topicSessionValue = 0;
$consultantSchedule = null;
$scheduleText = '';
$autoRedirected = 0;
$autoAssignMeetingSession = 0;
$accountTopUpMethod = '_PAYMENT_'; //or _BEE_CARD_
$packageNamesOld = ConsultancyConstant::$packageNames;
$packageDetailsOld = ConsultancyConstant::$packageDetails;
$userId = $session->get(UserConstants::USER_ID);
$packageNames = [];
$packageDetails = [];
foreach ($packageNamesOld as $ind => $p) {
if ($ind == 0)
continue;
$packageNames[$ind] = $p;
}
foreach ($packageDetailsOld as $ind => $p) {
if ($ind == 0)
continue;
$packageDetails[$ind] = $p;
}
$sandBoxMode = $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
$allowedGateWays = [
'stripe' => 1,
'aamarpay' => 1,
'bkash' => 1,
];
if ($sandBoxMode != 1)
$allowedGateWays = ConsultancyConstant::$allowedGateWaysForLive;
$minCoinsToPurchase = $request->request->get('minCoinsToPurchase', 0);
$paymentGateway = $request->request->get('paymentGateway', 'stripe');
$paymentType = $request->request->get('paymentType', 'credit');
$retailerId = $request->request->get('retailerId', 0);
if ($request->query->has('currency'))
$currencyForGateway = $request->query->get('currency');
else
$currencyForGateway = $request->request->get('currency', 'usd');
$topicCoinMultiplierValue = $request->request->get('topicCoinMultiplierValue', $request->request->get('topicCoinMultiplierValue', 1));
$sessionConsumeCount = $request->request->get('sessionConsumeCount', $topicCoinMultiplierValue * $request->request->get('sessionDurationSelector', 0));
if ($request->request->has('sessionDurationSelector'))
$sessionDuration = ($request->request->get('sessionDurationSelector', 0)) * ConsultancyConstant::PER_SESSION_MINUTE / (ConsultancyConstant::COIN_GENERAL_MULT);
else
$sessionDuration = $sessionConsumeCount * ConsultancyConstant::PER_SESSION_MINUTE / (ConsultancyConstant::COIN_GENERAL_MULT);
$meetingSessionId = 0;
if ($minCoinsToPurchase < $sessionConsumeCount)
$requiredPurchaseSessionCount = $sessionConsumeCount;
else
$requiredPurchaseSessionCount = $minCoinsToPurchase;
$forRecharge = 1;
if ($request->isMethod('GET') && $request->query->has('autoRedirected'))
$autoRedirected = $request->query->get('autoRedirected');
// $studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
if ($request->isMethod('POST') && $request->request->has('toPackagePage')) {
$topicId = $request->request->get('consultancyTopic', 0);
$sessionId = $request->request->get('sessionSelector', 0);
$topicSessionValue = $request->request->get('sessionSelector', 0);
$consultantId = $request->request->get('consultantId', 0);
$scheduleId = $request->request->get('consultancyScheduleId', 0); // this is timestamp
$scheduleTs = $request->request->get('consultancyScheduleId', 0); // this is timestamp
// $sessionConsumeCount = $request->request->get('sessionConsumeCount');
$autoAssignMeetingSession = 1;
$forRecharge = 0;
//$topic = $em->getRepository(ConsultancyTopic::class)->findAll();
$topic = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(array(
'id' => $topicId
));
$consultantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
'applicantId' => $consultantId
));
// $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle:EntityConsultantSchedule')->findOneBy(array(
// 'consultantId' => $consultantId
// ));
// $schdeuledTime = [];
// if ($consultantSchedule)
// $schdeuledTime = json_decode($consultantSchedule->getTimeSchedule(), true);
// if ($schdeuledTime == null)
// $schdeuledTime = [];
// $scheduleText = isset($schdeuledTime[$scheduleId]) ? $schdeuledTime[$scheduleId]['date'] . ' ' . $schdeuledTime[$scheduleId]['startTime'] : '';
$scheduleTextDate = new \DateTime('@' . $scheduleId);;
$scheduleText = $scheduleTextDate->format('F d, Y H:i');
$currentUserBalance = 0;
$gatewayAmount = 0;
$redeemedAmount = 0;
$redeemedSessionCount = 0;
$payableAmount = 0;
$totalAmount = 0;
$totalSessionCount = 0;
$consumedAmount = 0;
$consumedSessionCount = $sessionConsumeCount;
$currentUserSessionBalance = 0;
$currentUserBalance = 0;
$balancedFromUserSessionCount = 0;
$balancedFromUserBalance = 0;
$studentId = 0;
if ($session->get(UserConstants::USER_ID)
&& $session->get(UserConstants::USER_TYPE) == UserConstants::USER_TYPE_APPLICANT
) {
$studentDetails = null;
$studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
if ($studentDetails) {
$currentUserBalance = $studentDetails->getAccountBalance();
$currentUserSessionBalance = $studentDetails->getSessionCountBalance();
$studentId = $studentDetails->getApplicantId();
}
if ($consumedSessionCount <= $currentUserSessionBalance && $minCoinsToPurchase == 0) {
$balancedFromUserSessionCount = 1;
}
//1st do the necessary
$beeCode = $request->request->get('beeCode', '');
$payableAmount = $request->request->get('payableAmount', 0);
$scheduledStartTime = new \DateTime('@' . $scheduleId);;
if ($balancedFromUserSessionCount == 1) {
$scheduleValidity = MiscActions::CheckIfScheduleCanBeConfirmed(
$em_goc,
$request->request->get('consultantId', 0),
$studentId,
$scheduledStartTime->format('U'),
$sessionDuration,
1
);
if (!$scheduleValidity) {
$url = $this->generateUrl(
'consultant_profile'
);
$output = [
'proceedToCheckout' => 0,
'packageDetails' => MiscActions::toListArray($packageDetails),
'packageNames' => MiscActions::toListArray($packageNames),
'scheduleId' => $scheduleId,
'consultantId' => $consultantId,
'topicSessionValue' => $topicSessionValue,
'autoRedirected' => $autoRedirected,
'meetingSessionId' => $meetingSessionId,
'invoiceId' => $invoiceId,
'sessionConsumeCount' => $sessionConsumeCount,
'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
'autoAssignMeetingSession' => $autoAssignMeetingSession,
'sessionDuration' => $sessionDuration,
// 'consultantSchedule' => $consultantSchedule,
'scheduleText' => $scheduleText,
'userId' => $userId,
'message' => 'Session Booking Expired or not Found!',
'errorFlag' => 1,
'redirectUrl' => $url . '/' . $request->request->get('consultantId', 0)
];
if ($request->request->has('returnJson'))
return new JsonResponse($output);
else
return $this->redirect($url . '/' . $request->request->get('consultantId', 0) . '?errorFlag=1&message=Session Booking Expired or not Found');
}
$new = new EntityMeetingSession();
$new->setTopicId($request->request->get('consultancyTopic', 0));
$new->setConsultantId($request->request->get('consultantId', 0));
$consultancyTopic = $em_goc->getRepository(EntityCreateTopic::class)->find($request->request->get('consultancyTopic', 0));
$new->setMeetingType($consultancyTopic ? $consultancyTopic->getMeetingType() : 0);
$new->setConsultantCanUpload($consultancyTopic ? $consultancyTopic->getConsultantCanUpload() : 0);
$new->setStudentId($studentId);
$scheduledEndTime = new \DateTime('@' . $scheduleId);;
$scheduledEndTime = $scheduledEndTime->modify('+' . $sessionDuration . ' Minute');
// $scheduledStartTime->setTimezone(new \DateTimeZone('UTC'));
// $scheduledEndTime->setTimezone(new \DateTimeZone('UTC'));
//$new->setScheduledTime($request->request->get('setScheduledTime'));
$new->setScheduledTime($scheduledStartTime);
$new->setScheduledTimeTs($scheduledStartTime->format('U'));
$new->setDurationAllowedMin($sessionDuration);
$new->setDurationLeftMin($sessionDuration);
$new->setSessionExpireDate($scheduledEndTime);
$new->setSessionExpireDateTs($scheduledEndTime->format('U'));
$new->setEquivalentSessionCount($consumedSessionCount);
$new->setRedeemSessionCount($consumedSessionCount);
$new->setUsableSessionCount($consumedSessionCount);
$new->setMeetingActionFlag(0);// no action waiting for meeting
$new->setPayableAmount($payableAmount);
$new->setDueAmount($request->request->get('dueAmount', 0));
//$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
//$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
$new->setPackageName(($request->request->get('packageName', '')));
$new->setPcakageDetails(($request->request->get('packageData', '')));
$new->setScheduleId($scheduleId);
$new->setSessionValue($topicSessionValue);
// $new->setIsPayment(0);
$new->setConsultantIsPaidFull(0);
$currentUnixTime = new \DateTime();
$currentUnixTimeStamp = $currentUnixTime->format('U');
$consultantId = $request->request->get('consultantId', 0);
$new->setMeetingRoomId(str_pad($consultantId, 4, STR_PAD_LEFT) . $currentUnixTimeStamp . str_pad($studentId, 4, STR_PAD_LEFT));
$currTime = new \DateTime();
$currTime->modify('+1 day');
$currTs = $currTime->format('U');
$new->setPaidSessionCount(0);
$new->setDueSessionCount($consumedSessionCount);
$new->setExpireIfUnpaidTs($currTs);
$new->setBookingExpireTs($currTs);
$new->setConfirmationExpireTs($currTs);
$new->setIsPaidFull(0);
$new->setIsExpired(0);
$em_goc->persist($new);
$em_goc->flush();
$meetingSessionId = $new->getSessionId();
$periodMarker = $scheduledStartTime->format('Ym');
MiscActions::UpdateSchedulingRestrictions($em_goc, $consultantId, $periodMarker, ($sessionDuration / 60), -($sessionDuration / 60));
// $studentDetails->setSessionCountBalance($currentUserSessionBalance-$consumedSessionCount);
// $studentDetails->setTotalSessionUsed($studentDetails->getTotalSessionUsed()+$consumedSessionCount);
$em_goc->flush();
$new_invoice = new EntityInvoice();
$invoiceDate = new \DateTime();
$new_invoice->setInvoiceDate($invoiceDate);
$new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
$new_invoice->setStudentId($studentId);
$new_invoice->setMeetingId($meetingSessionId);
$new_invoice->setAmount($totalAmount);
$new_invoice->setAmountTransferGateWayHash('internal');
$new_invoice->setAmountCurrency('coins');
$new_invoice->setGatewayBillAmount($gatewayAmount);
$new_invoice->setRedeemedAmount($redeemedAmount);
$new_invoice->setRedeemedSessionCount($redeemedSessionCount);
$new_invoice->setPaidAmount(0);
$new_invoice->setDueAmount(0);
$new_invoice->setInvoiceType(ConsultancyConstant::ENTITY_INVOICE_TYPE_CONSUME_COIN_FOR_MEETING_FOR_STUDENT);
$new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' . microtime(true)));
$new_invoice->setAmountType(2);
$new_invoice->setConsumeAmount(0);
$new_invoice->setSessionCount(0);
$new_invoice->setConsumeSessionCount($consumedSessionCount);
$new_invoice->setIsPaidfull(0);
$new_invoice->setIsProcessed(0);
$new_invoice->setApplicantId($studentId);
$new_invoice->setIsRecharge(0);
$new_invoice->setStage(ConsultancyConstant::ENTITY_INVOICE_STAGE_INITIATED);
$new_invoice->setIsPayment(0); //0 means receive
$new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
$new_invoice->setAutoConfirmTaggedMeeting(1);
$new_invoice->setAutoConfirmOtherMeeting(0);
// $new_invoice->setStatus($request->request->get(0));
$em_goc->persist($new_invoice);
$em_goc->flush();
$invoiceId = $new_invoice->getId();
$retData = Consultancy::ProcessEntityInvoice($em_goc, $invoiceId, ['stage' => ConsultancyConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
$this->container->getParameter('notification_enabled'),
$this->container->getParameter('notification_server')
);
MiscActions::RefreshBuddybeeBalanceOnSession($em_goc, $request->getSession());
$meetingSessionId = $retData['meetingId'];
if ($meetingSessionId != 0) {
$url = $this->generateUrl(
'consultancy_session'
);
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url . '/' . $meetingSessionId
];
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url
];
}
if ($request->request->has('returnJson'))
return new JsonResponse($output);
else
return $this->redirect($url . '/' . $meetingSessionId);
} else {
// $session->set('hasCoin',0);
if ($userId != 0 && $forRecharge == 0) {
$applicantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
'applicantId' => $userId
));
if ($applicantDetails) {
$requiredPurchaseSessionCountExcludingMinCond = $sessionConsumeCount - (1 * $applicantDetails->getSessionCountBalance());
if ($minCoinsToPurchase < $requiredPurchaseSessionCountExcludingMinCond)
$requiredPurchaseSessionCount = $requiredPurchaseSessionCountExcludingMinCond;
else
$requiredPurchaseSessionCount = $minCoinsToPurchase;
}
}
$url = $this->generateUrl(
'pricing_plan_page'
);
$filteredPackageList = MiscActions::filterPackageList([
'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount
]);
$convMultFromTo = ConsultancyConstant::$convMultFromTo;
$convMultFromToModifiedArray = [];
$convFromEur = $convMultFromTo['eur'];
$count = 1;
foreach ($convFromEur as $currency => $f) {
$convMultFromToModifiedArray[] = array(
"id" => $count,
"currency" => $currency,
"value" => $f,
);
$count++;
}
$output = array(
'page_title' => 'Package And Pricing',
// 'topic' => $topic,
// 'consultantDetails' => $consultantDetails,
'COIN_GENERAL_MULT' => ConsultancyConstant::COIN_GENERAL_MULT,
'packageDetails' => $filteredPackageList['packageDetails'],
'packageNames' => $filteredPackageList['packageNames'],
'selectionValue' => $filteredPackageList['selectionValue'],
'selectionPackageId' => $filteredPackageList['selectionPackageId'],
'CONV_MULT_FROM_TO' => ConsultancyConstant::$convMultFromTo,
'CONV_MULT_FROM_TO_MODIFIED' => $convMultFromToModifiedArray,
'PER_SESSION_MINUTE' => ConsultancyConstant::PER_SESSION_MINUTE,
'BETWEEN_SESSION_MINUTE' => ConsultancyConstant::BETWEEN_SESSION_MINUTE,
'BEECOIN_VALUE_EURO' => ConsultancyConstant::BEECOIN_VALUE_EURO,
'scheduleId' => $scheduleId,
'consultantId' => $consultantId,
'topicSessionValue' => $topicSessionValue,
'autoRedirected' => $autoRedirected,
'meetingSessionId' => $meetingSessionId,
'invoiceId' => $invoiceId,
'sessionConsumeCount' => $sessionConsumeCount,
'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
'autoAssignMeetingSession' => $autoAssignMeetingSession,
'sessionDuration' => $sessionDuration,
// 'consultantSchedule' => $consultantSchedule,
'scheduleText' => $scheduleText,
'userId' => $userId,
// 'timeSchedule' => $consultantSchedule,
'proceedToCheckout' => 0,
'message' => 'Insufficient coins!',
'errorFlag' => 1,
'redirectUrl' => $url
);
if ($request->request->has('returnJson'))
return new JsonResponse($output);
// else
// return $this->redirect($url . '/' . $request->request->get('consultantId', 0) . '?errorFlag=1&message=Not enough Coins');
}
} else {
$url = $this->generateUrl(
'buddybee_dashboard'
);
$output = [
'proceedToCheckout' => 0,
'redirectUrl' => $url
];
if ($request->request->has('returnJson'))
return new JsonResponse($output);
else {
// return $this->redirect($url . '/' . $meetingSessionId);
}
}
//
} else if ($request->isMethod('POST') && $request->request->has('forRecharge')) {
$requiredPurchaseSessionCount = $request->request->get('coinCount', 0);
$forRecharge = $request->request->get('forRecharge', 1);
$accountTopUpMethod = $request->request->get('accountTopUpMethod', '_PAYMENT_');
}
if ($userId != 0 && $forRecharge == 0) {
$applicantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
'applicantId' => $userId
));
if ($applicantDetails) {
$requiredPurchaseSessionCountExcludingMinCond = $sessionConsumeCount - (1 * $applicantDetails->getSessionCountBalance());
if ($minCoinsToPurchase < $requiredPurchaseSessionCountExcludingMinCond)
$requiredPurchaseSessionCount = $requiredPurchaseSessionCountExcludingMinCond;
else
$requiredPurchaseSessionCount = $minCoinsToPurchase;
}
}
$filteredPackageList = MiscActions::filterPackageList([
'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount
]);
return $this->render('ApplicationBundle:pages/consultancy:pricing.html.twig', array(
'page_title' => 'Package And Pricing',
'topic' => $topic,
'allowedGateWays' => $allowedGateWays,
'consultantDetails' => $consultantDetails,
'packageDetails' => $packageDetails,
'packageNames' => $packageNames,
'scheduleId' => $scheduleId,
'paymentGateway' => $paymentGateway,
'currencyForGateway' => $currencyForGateway,
'convMultFromTo' => ConsultancyConstant::$convMultFromTo,
'fontSizeByCurrency' => ConsultancyConstant::$fontSizeByCurrency,
'beeCodePriceByCoinCountEur' => ConsultancyConstant::$beeCodePriceByCoinCountEur,
'BEECOIN_VALUE_EURO' => ConsultancyConstant::BEECOIN_VALUE_EURO,
'PER_SESSION_MINUTE' => ConsultancyConstant::PER_SESSION_MINUTE,
'COIN_GENERAL_MULT' => ConsultancyConstant::COIN_GENERAL_MULT,
'consultantId' => $consultantId,
'topicSessionValue' => $topicSessionValue,
'autoRedirected' => $autoRedirected,
'meetingSessionId' => $meetingSessionId,
'invoiceId' => $invoiceId,
'sessionConsumeCount' => $sessionConsumeCount,
'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
// 'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
'accountTopUpMethod' => $accountTopUpMethod,
'autoAssignMeetingSession' => $autoAssignMeetingSession,
'sessionDuration' => $sessionDuration,
// 'consultantSchedule' => $consultantSchedule,
'scheduleText' => $scheduleText,
'userId' => $userId,
// 'timeSchedule' => $consultantSchedule
));
// return $this->render('ApplicationBundle:pages/consultancy:pricing.html.twig', array(
// 'page_title' => 'Package And Pricing',
// ));
}
public function PricingPageDataAction(Request $request)
{
$packageNames = ConsultancyConstant::$packageNames;
$packageDetails = ConsultancyConstant::$packageDetails;
$convMultFromTo = ConsultancyConstant::$convMultFromTo;
$convMultFromToModifiedArray = [];
$convFromEur = $convMultFromTo['eur'];
$count = 1;
foreach ($convFromEur as $currency => $f) {
$convMultFromToModifiedArray[] = array(
"id" => $count,
"currency" => $currency,
"value" => $f,
);
$count++;
}
$output = array(
'page_title' => 'Package And Pricing',
'CONV_MULT_FROM_TO' => ConsultancyConstant::$convMultFromTo,
'CONV_MULT_FROM_TO_MODIFIED' => $convMultFromToModifiedArray,
'PER_SESSION_MINUTE' => ConsultancyConstant::PER_SESSION_MINUTE,
'BETWEEN_SESSION_MINUTE' => ConsultancyConstant::BETWEEN_SESSION_MINUTE,
'COIN_GENERAL_MULT' => ConsultancyConstant::COIN_GENERAL_MULT,
'BEECOIN_VALUE_EURO' => ConsultancyConstant::BEECOIN_VALUE_EURO,
'packageDetails' => MiscActions::toListArray($packageDetails),
'packageNames' => MiscActions::toListArray($packageNames),
);
// if ($request->request->has('returnJson'))
return new JsonResponse($output);
}
public function BlogViewAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager('company_group');
$topicId = 0;
if ($id != 0) {
$blog = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->find($id);
$topicId = $blog->getTopicId();
} else {
$topicId = $id;
if ($request->query->has('topicId')) {
$topicId = $request->query->get('topicId');
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'id' => $topicId,
)
);
$blog = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findOneBy(
array(
'topicId' => $topicId
)
);
if ($request->query->get('blog', 1) == 1) {
} else if ($topic->getTopicMarker() == '_country_') {
$url = $this->generateUrl(
'topic_list'
);
// return $this->redirect($url . "#topic" . $topicId);
return $this->redirect($url . "/" . $topicId);
}
} else if ($request->query->has('countryId')) {
$countryId = $request->query->get('countryId');
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'countryId' => $countryId,
'topicMarker' => '_country_',
)
);
$topicId = $topic->getId();
$blog = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findOneBy(
array(
'topicId' => $topicId
)
);
$url = $this->generateUrl(
'country_view'
);
// return $this->redirect($url . "#topic" . $topicId);
return $this->redirect($url . "/" . $topicId);
} else {
$topic = $em->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'id' => $topicId,
)
);
$blog = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findOneBy(
array(
'topicId' => $topicId
)
);
if ($topic->getTopicMarker() == '_country_') {
$url = $this->generateUrl(
'topic_list'
);
return $this->redirect($url . "#topic" . $topicId);
}
}
}
$consultant = $em->getRepository('CompanyGroupBundle:EntityApplicantDetails')
->createQueryBuilder('m')
->where("m.isConsultant = 1")
->andwhere("m.preferredTopicIdsAsConsultant like '%\"$topicId\"%' or m.preferredTopicIdsAsConsultant like '%[]%' or m.preferredTopicIdsAsConsultant is null")
// ->andwhere("m.preferredTopicIdsAsConsultant like '%\"$topicId\"%' ")
->orderBy('m.rating', 'DESC')
->getQuery()
->setMaxResults(10)
->getResult();
return $this->render('ApplicationBundle:pages/consultancy:topicSummary.html.twig', array(
'page_title' => 'Blog',
'blog' => $blog,
'topicId' => $topicId,
'consultant' => $consultant
));
}
public
function SearchBuddyBeeAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
$session = $request->getSession();
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where 1=1
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
if ($product['topic_marker'] == '_country_') {
$url = $this->generateUrl(
'country_view'
);
$url .= ("/" . $product['id']);
} else {
$url = $this->generateUrl(
'blog_post'
);
$url .= ("?topicId=" . $product['id']);
}
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_summary'];
$pa['url'] = $url;
$pa['type'] = 1;
$pa['topicMarker'] = $product['topic_marker'];
$pa['image'] = $product['topic_image'];
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where 1=1
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 3;
$pa['topicMarker'] = '';
$pa['image'] = '';
$data[] = $pa;
}
}
//consultant
if ($session->get(UserConstants::USER_ID, 0) != 0)
$filterQryForCriteria = "select * from entity_applicant_details where is_consultant=1 and applicant_id != " . $session->get(UserConstants::USER_ID, 0) .
" and ( firstname like '%" . $queryStr . "%'
or lastname like '%" . $queryStr . "%'
)
limit 10";
else
$filterQryForCriteria = "select * from entity_applicant_details where is_consultant=1
and ( firstname like '%" . $queryStr . "%'
or lastname like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'consultant_profile'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['applicant_id'];
$pa['name'] = $product['firstname'] . ' ' . $product['lastname'];
$pa['description'] = $product['firstname'] . ' ' . $product['lastname'];
$pa['url'] = $url . "/" . $product['applicant_id'];
$pa['type'] = 2;
$pa['topicMarker'] = '';
$pa['image'] = $product['image'];
$data[] = $pa;
}
}
{
return new JsonResponse(
array(
'success' => true,
// 'page_title' => 'Product Details',
// 'company_data' => $company_data,
'data' => $data,
)
);
}
}
public
function SearchCountryAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where topic_marker= '_country_'
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$otherData = json_decode($product['other_data'], true);
if ($otherData == null)
$otherData = [];
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_summary'];
$pa['specialFor'] = isset($otherData['_country__specialFor']) ? $otherData['_country__specialFor'] : '';
$pa['url'] = $url . "?topicId=" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_country_')
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
// $ep = $this->generateUrl(
// 'error_page'
// );
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
return new JsonResponse(
array(
'success' => true,
'data' => $data,
)
);
}
public
function SearchProgramAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where topic_marker= '_program_'
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_summary'];
$pa['url'] = $url . "?topicId=" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_program_')
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
return new JsonResponse(
array(
'success' => true,
'data' => $data,
)
);
}
public
function BlogSearchFromListAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where 1=1
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_name'];
$pa['url'] = $url . "?topicId=" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where 1=1
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
{
return new JsonResponse(
array(
'success' => true,
// 'page_title' => 'Product Details',
// 'company_data' => $company_data,
'data' => $data,
// 'exId'=>$id,
// 'productByCodeData' => $productByCodeData,
// 'productData' => $productData,
// 'currInvList' => $currInvList,
// 'productList' => Inventory::ProductList($em, $companyId),
// 'subCategoryList' => Inventory::ProductSubCategoryList($em, $companyId),
// 'categoryList' => Inventory::ProductCategoryList($em, $companyId),
// 'igList' => Inventory::ItemGroupList($em, $companyId),
// 'unitList' => Inventory::UnitTypeList($em),
// 'brandList' => Inventory::GetBrandList($em, $companyId),
// 'warehouse_action_list' => Inventory::warehouse_action_list($em,$this->getLoggedUserCompanyId($request),'object'),
// 'warehouseList' => Inventory::WarehouseList($em),
)
);
}
}
public
function ConsultantSearchFromListAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//consultant
$filterQryForCriteria = "select * from entity_applicant_details where is_consultant=1
and ( firstname like '%" . $queryStr . "%'
or lastname like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'consultant_profile'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['applicant_id'];
$pa['name'] = $product['firstname'] . ' ' . $product['lastname'];
$pa['description'] = $product['firstname'] . ' ' . $product['lastname'];
$pa['url'] = $url . "/" . $product['applicant_id'];
$pa['type'] = 2;
$pa['image'] = $product['image'];
$data[] = $pa;
}
}
{
return new JsonResponse(
array(
'success' => true,
// 'page_title' => 'Product Details',
// 'company_data' => $company_data,
'data' => $data,
// 'exId'=>$id,
// 'productByCodeData' => $productByCodeData,
// 'productData' => $productData,
// 'currInvList' => $currInvList,
// 'productList' => Inventory::ProductList($em, $companyId),
// 'subCategoryList' => Inventory::ProductSubCategoryList($em, $companyId),
// 'categoryList' => Inventory::ProductCategoryList($em, $companyId),
// 'igList' => Inventory::ItemGroupList($em, $companyId),
// 'unitList' => Inventory::UnitTypeList($em),
// 'brandList' => Inventory::GetBrandList($em, $companyId),
// 'warehouse_action_list' => Inventory::warehouse_action_list($em,$this->getLoggedUserCompanyId($request),'object'),
// 'warehouseList' => Inventory::WarehouseList($em),
)
);
}
}
public
function SearchUniversityAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where topic_marker= '_university_'
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_summary'];
$pa['url'] = $url . "?topicId=" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_university_')
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
return new JsonResponse(
array(
'success' => true,
'data' => $data,
)
);
}
public
function SearchSubjectAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where topic_marker= '_subject_'
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_summary'];
$pa['url'] = $url . "?topicId=" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where topic_id in (select DISTINCT id from entity_create_topic where topic_marker= '_subject_')
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
return new JsonResponse(
array(
'success' => true,
'data' => $data,
)
);
}
public
function TopicSearchFromTopicListAction(Request $request, $queryStr = '')
{
$em = $this->getDoctrine()->getManager('company_group');
$data = [];
$data_by_id = [];
if ($queryStr == '_DEFAULT_')
$queryStr = '';
if ($request->request->has('query') && $queryStr == '')
$queryStr = $request->request->get('queryStr');
if ($queryStr == '_DEFAULT_')
$queryStr = '';
//topic
$filterQryForCriteria = "select * from entity_create_topic where 1=1
and topic_name like '%" . $queryStr . "%' limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['topic_name'];
$pa['description'] = $product['topic_name'];
$pa['url'] = $url . "?topicId=" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
//blog
$filterQryForCriteria = "select * from entity_create_blog where 1=1
and ( title like '%" . $queryStr . "%'
or subtitle like '%" . $queryStr . "%'
or content like '%" . $queryStr . "%'
)
limit 10";
$get_kids_sql = $filterQryForCriteria;
$stmt = $em->getConnection()->prepare($get_kids_sql);
$stmt->execute();
$get_kids = $stmt->fetchAll();
$productId = 0;
$url = $this->generateUrl(
'blog_post'
);
if (!empty($get_kids)) {
foreach ($get_kids as $product) {
$pa = array();
$pa['id'] = $product['id'];
$pa['name'] = $product['title'];
$pa['description'] = $product['subtitle'];
$pa['url'] = $url . "/" . $product['id'];
$pa['type'] = 1;
$pa['image'] = '';
$data[] = $pa;
}
}
{
return new JsonResponse(
array(
'success' => true,
// 'page_title' => 'Product Details',
// 'company_data' => $company_data,
'data' => $data,
// 'exId'=>$id,
// 'productByCodeData' => $productByCodeData,
// 'productData' => $productData,
// 'currInvList' => $currInvList,
// 'productList' => Inventory::ProductList($em, $companyId),
// 'subCategoryList' => Inventory::ProductSubCategoryList($em, $companyId),
// 'categoryList' => Inventory::ProductCategoryList($em, $companyId),
// 'igList' => Inventory::ItemGroupList($em, $companyId),
// 'unitList' => Inventory::UnitTypeList($em),
// 'brandList' => Inventory::GetBrandList($em, $companyId),
// 'warehouse_action_list' => Inventory::warehouse_action_list($em,$this->getLoggedUserCompanyId($request),'object'),
// 'warehouseList' => Inventory::WarehouseList($em),
)
);
}
}
public
function topicListAction(Request $request, $id = 0)
{
$em_goc = $this->getDoctrine()->getManager('company_group');
$qryArray = array(
// 'isEvent' => [0,null]
);
$childQryArray = array(
// 'isEvent' => [0]
);
$singleDataFlag = 0;
if ($id != 0) {
$singleDataFlag = 1;
$qryArray['id'] = $id;
$childQryArray['parentTopicId'] = $id;
}
if ($request->query->get('countryId', 0) != 0) {
$singleDataFlag = 1;
$qryArray['countryId'] = $request->query->get('countryId', 0);
}
$topics = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
$qryArray,
array(
'parentTopicId' => 'asc'
)
);
$topicListByParentId = [];
$parentTopicList = [];
$parentList = [];
$currentParentId = 0;
$currentTopic = [];
foreach ($topics as $topic) {
$currentParentId = $topic->getParentTopicId();
$childQryArray['parentTopicId'] = $topic->getId();
$currentTopic = $topic;
if ($topic->getIsParent() == 1 || $topic->getParentTopicId() == 0 || $topic->getParentTopicId() == null || $topic->getParentTopicId() == '') {
$currentParentId = $topic->getId();
$parentTopicList[$topic->getId()] = $topic;
$parentList[] = $topic->getId();
} else if (in_array($topic->getParentTopicId(), $parentList)) {
if (!isset($topicListByParentId[$topic->getParentTopicId()]))
$topicListByParentId[$topic->getParentTopicId()] = [];
$topicListByParentId[$topic->getParentTopicId()][] = $topic;
}
}
$topics = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')->findBy(
$childQryArray,
array(
'parentTopicId' => 'asc'
)
);
foreach ($topics as $topic) {
if($topic->getIsEvent() == 1)
continue;
$currentParentId = $topic->getParentTopicId();
$currentTopic = $topic;
if ($topic->getIsParent() == 1 || $topic->getParentTopicId() == 0 || $topic->getParentTopicId() == null || $topic->getParentTopicId() == '') {
$currentParentId = $topic->getId();
$parentTopicList[$topic->getId()] = $topic;
$parentList[] = $topic->getId();
} else if (in_array($topic->getParentTopicId(), $parentList)) {
if (!isset($topicListByParentId[$topic->getParentTopicId()]))
$topicListByParentId[$topic->getParentTopicId()] = [];
$topicListByParentId[$topic->getParentTopicId()][] = $topic;
}
}
if ($id != 0 && empty($parentTopicList)) {
$parTopic = $em_goc->getRepository('CompanyGroupBundle:EntityCreateTopic')->findOneBy(
array(
'parentTopicId' => $currentParentId
),
array(
'parentTopicId' => 'asc'
)
);
if ($parTopic) {
$parentTopicList[$parTopic->getId()] = $parTopic;
if (!in_array($currentParentId, $parentList)) {
if (!isset($topicListByParentId[$currentParentId]))
$topicListByParentId[$currentParentId] = [];
$topicListByParentId[$currentParentId][] = $currentTopic;
}
}
}
return $this->render('ApplicationBundle:pages/consultancy:topicListPage.html.twig', array(
'page_title' => 'Topic List',
'topicListByParentId' => $topicListByParentId,
'currentParentId' => $currentParentId,
'singleDataFlag' => $singleDataFlag,
'parentTopicList' => $parentTopicList
));
}
public
function helpAction()
{
return $this->render('ApplicationBundle:pages/consultancy:helpPage.html.twig', array(
'page_title' => 'Help',
));
}
public
function contactPageAction()
{
return $this->render('ApplicationBundle:pages/consultancy:contactPage.html.twig', array(
'page_title' => 'Contact Us',
));
}
public
function blogListAction($id)
{
$em = $this->getDoctrine()->getManager('company_group');
$blog = $em->getRepository('CompanyGroupBundle:EntityCreateBlog')->findAll();
return $this->render('ApplicationBundle:pages/consultancy:blogList.html.twig', array(
'page_title' => 'Blog List',
'blog' => $blog,
));
}
public
function ErrorPageAction()
{
return $this->render('ApplicationBundle:pages/consultancy:404NotFound.html.twig', array(
'page_title' => '404 Not Found',
));
}
public
function SignupPageAction()
{
return $this->render('ApplicationBundle:pages/consultancy:signupPage.html.twig', array(
'page_title' => 'Sign Up',
));
}
public
function UnderConstructionPageAction()
{
return $this->render('ApplicationBundle:pages/consultancy:underConstructionPage.html.twig', array(
'page_title' => 'Construction Page',
));
}
public function buddybeePromoFocusListAction()
{
$promoFocusList = ConsultancyConstant::$promoFocusList;
return new JsonResponse(
array(
'success' => true,
'promoFocusList' => $promoFocusList,
)
);
}
}