src/ApplicationBundle/Modules/Buddybee/Controller/BuddybeeController.php line 3495

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Modules\Buddybee\Controller;
  3. use ApplicationBundle\Constants\BuddybeeConstant;
  4. use ApplicationBundle\Constants\GeneralConstant;
  5. use ApplicationBundle\Constants\HumanResourceConstant;
  6. use ApplicationBundle\Controller\GenericController;
  7. use ApplicationBundle\Interfaces\SessionCheckInterface;
  8. use ApplicationBundle\Modules\Authentication\Constants\UserConstants; use ApplicationBundle\Modules\Api\Constants\ApiConstants;
  9. use ApplicationBundle\Modules\Buddybee\Buddybee;
  10. use ApplicationBundle\Modules\System\MiscActions;
  11. use ApplicationBundle\Modules\System\ModifyDate;
  12. use ApplicationBundle\Modules\System\System;
  13. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  14. use CompanyGroupBundle\Entity\EntityCommunicationLog;
  15. use CompanyGroupBundle\Entity\EntityConsultantSchedule;
  16. use CompanyGroupBundle\Entity\EntityCountryConsultantRequirements;
  17. use CompanyGroupBundle\Entity\EntityCreateTopic;
  18. use CompanyGroupBundle\Entity\EntityFile;
  19. use CompanyGroupBundle\Entity\EntityInvoice;
  20. use CompanyGroupBundle\Entity\EntityMeetingSession;
  21. use CompanyGroupBundle\Entity\EntityReview;
  22. use CompanyGroupBundle\Entity\EntitySkill;
  23. use CompanyGroupBundle\Entity\LiveSupportMeetingQueue;
  24. use CompanyGroupBundle\Entity\LiveSupportMeetingRoom;
  25. use Ps\PdfBundle\Annotation\Pdf;
  26. use Symfony\Component\HttpFoundation\JsonResponse;
  27. use Symfony\Component\HttpFoundation\Request;
  28. use Symfony\Component\Routing\Generator\UrlGenerator;
  29. //use Symfony\Bundle\FrameworkBundle\Console\Application;
  30. //use Symfony\Component\Console\Input\ArrayInput;
  31. //use Symfony\Component\Console\Output\NullOutput;
  32. //use Symfony\Component\Validator\Constraints\DateTime;
  33. class BuddybeeController extends GenericController implements SessionCheckInterface
  34. {
  35.     ///controllers for routes with session requirement
  36.     public function ChangePasswordAction(Request $request$startFrom 0)
  37.     {
  38.         $em $this->getDoctrine()->getManager();
  39.         $em_goc $this->getDoctrine()->getManager('company_group');
  40.         $session $request->getSession();
  41.         $message "";
  42.         $actionSuccess false;
  43.         $retData = array();
  44.         $userData = [];
  45.         $systemType $this->container->hasParameter('system_type') ? $this->container->getParameter('system_type') : '_ERP_';
  46.         $userCategory $request->request->get('userCategory'$request->query->get('userCategory''_BUDDYBEE_USER_'));
  47.         $oldPassword $request->request->get('oldPassword'$request->query->get('oldPassword'''));
  48.         $newPassword $request->request->get('newPassword'$request->query->get('newPassword'''));
  49.         $userId $request->request->get('userId'$request->query->get('userId'$session->get(UserConstants::USER_ID0)));
  50.         $userType UserConstants::USER_TYPE_APPLICANT;
  51.         if ($request->isMethod('POST')) {
  52.             //set an otp and its expire and send mail
  53.             $userObj null;
  54.             $userData = [];
  55.             if ($systemType == '_ERP_') {
  56.                 if ($userCategory == '_APPLICANT_') {
  57.                     $userType UserConstants::USER_TYPE_APPLICANT;
  58.                     $userObj $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  59.                         array(
  60.                             'applicantId' => $userId
  61.                         )
  62.                     );
  63.                     if ($userObj) {
  64.                         $oldPasswordPassed 0;
  65.                         if ($userObj->getOauthUniqueId() != && $userObj->getOauthUniqueId() != '')
  66.                             $oldPasswordPassed 1;
  67.                         else {
  68.                             if ($this->container->get('app.legacy_password_service')->verifyWithSalt($userObj->getPassword(), $oldPassword$userObj->getUserName()))
  69.                                 $oldPasswordPassed 1;
  70.                         }
  71.                         if ($oldPasswordPassed == 1) {
  72.                             $encodedPassword $this->container->get('app.legacy_password_service')->hashWithSalt($newPassword$userObj->getUserName());
  73.                             $userObj->setPassword($encodedPassword);
  74.                             $userObj->setTriggerResetPassword(0);
  75.                             $em_goc->flush();
  76.                             $actionSuccess true;
  77.                             $message "";
  78.                             $userData = array(
  79.                                 'id' => $userObj->getApplicantId(),
  80.                                 'appId' => $session->get(UserConstants::USER_APP_ID0),
  81.                                 'image' => $userObj->getImage(),
  82.                                 'firstName' => $userObj->getFirstname(),
  83.                                 'lastName' => $userObj->getLastname(),
  84. //                        'appId'=>$userObj->getUserAppId(),
  85.                             );
  86.                         } else {
  87.                             $message "Action failed!";
  88.                             $actionSuccess false;
  89.                         }
  90.                     } else {
  91.                         $message "Account not found!";
  92.                         $actionSuccess false;
  93.                     }
  94.                 } else {
  95.                     $userType UserConstants::USER_TYPE_GENERAL;
  96.                     $actionSuccess false;
  97.                 }
  98.             } else if ($systemType == '_BUDDYBEE_') {
  99.                 $userType UserConstants::USER_TYPE_APPLICANT;
  100.                 $userObj $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  101.                     array(
  102.                         'applicantId' => $userId
  103.                     )
  104.                 );
  105.                 if ($userObj) {
  106.                     $oldPasswordPassed 0;
  107.                     if ($userObj->getOauthUniqueId() != && $userObj->getOauthUniqueId() != '')
  108.                         $oldPasswordPassed 1;
  109.                     else {
  110.                         if ($this->container->get('app.legacy_password_service')->verifyWithSalt($userObj->getPassword(), $oldPassword$userObj->getUserName()))
  111.                             $oldPasswordPassed 1;
  112.                     }
  113.                     if ($oldPasswordPassed == 1) {
  114.                         $encodedPassword $this->container->get('app.legacy_password_service')->hashWithSalt($newPassword$userObj->getUserName());
  115.                         $userObj->setPassword($encodedPassword);
  116.                         $userObj->setTriggerResetPassword(0);
  117.                         $em_goc->flush();
  118.                         $actionSuccess true;
  119.                         $message "";
  120.                         $userData = array(
  121.                             'id' => $userObj->getApplicantId(),
  122.                             'appId' => $session->get(UserConstants::USER_APP_ID0),
  123.                             'image' => $userObj->getImage(),
  124.                             'firstName' => $userObj->getFirstname(),
  125.                             'lastName' => $userObj->getLastname(),
  126. //                        'appId'=>$userObj->getUserAppId(),
  127.                         );
  128.                     } else {
  129.                         $message "Action failed!";
  130.                         $actionSuccess false;
  131.                     }
  132.                 } else {
  133.                     $message "Account not found!";
  134.                     $actionSuccess false;
  135.                 }
  136.             }
  137.         }
  138.         $response = new JsonResponse(array(
  139.                 'message' => $message,
  140.                 "userType" => $userType,
  141. //                "otp"=>$otp,
  142.                 "userCategory" => $userCategory,
  143.                 "userId" => isset($userData['id']) ? $userData['id'] : 0,
  144.                 "systemType" => $systemType,
  145.                 'success' => $actionSuccess,
  146.             )
  147.         );
  148.         $response->headers->set('Access-Control-Allow-Origin''*');
  149.         return $response;
  150.     }
  151.     public function ConsultantApplyAction(Request $request$id 0)
  152.     {
  153.         $em $this->getDoctrine()->getManager('company_group');
  154.         $session $request->getSession();
  155.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  156.         $consultantRequirementsQry $em->getRepository(EntityCountryConsultantRequirements::class)->findAll();
  157.         $consultantRequirementsByCountryId = [];
  158.         foreach ($consultantRequirementsQry as $value) {
  159.             $docList json_decode($value->getDocumentList(), true);
  160.             $requiredFields json_decode($value->getRequiredFields(), true);
  161.             if ($docList == null$docList = [];
  162.             if ($requiredFields == null$requiredFields = [];
  163.             $consultantRequirementsByCountryId[$value->getCountryId()] = array(
  164.                 'documentList' => $docList,
  165.                 'requiredFields' => $requiredFields,
  166.                 'contractLetterHtml' => $value->getContractLetterHtml(),
  167.             );
  168.         }
  169.         $documentLists $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateDocument')->findAll();;
  170.         $docListArray = [];
  171.         foreach ($documentLists as $document) {
  172.             $docListArray [$document->getId()] = array(
  173.                 'id' => $document->getId(),
  174.                 'docName' => $document->getDocumentName(),
  175.                 'expiryDays' => $document->getExpiryDays(),
  176.                 'processingDays' => $document->getProcessingDays(),
  177.                 'emergencyProcessingDays' => $document->getEmergencyProcessingDays(),
  178.                 'checklist' => json_decode($document->getCheckList()),
  179.             );
  180.         }
  181.         $skillDetails $em->getRepository(EntitySkill::class)->findAll();
  182.         $companyId $this->getLoggedUserCompanyId($request);
  183.         $gender HumanResourceConstant::$sex;
  184.         $blood HumanResourceConstant::$BloodGroup;
  185.         $userId $session->get(UserConstants::USER_ID);
  186.         $education = array(
  187.             'instituteName' => $request->get('instituteName'),
  188.             'courseOfStudy' => $request->get('courseOfStudy'),
  189.             'courseStartDate' => $request->get('courseStartDate'),
  190.             'courseEndDate' => $request->get('courseEndDate'),
  191.             'result' => $request->get('result'),
  192.             'grade' => $request->get('grade'),
  193.             'degree' => $request->get('degree'),
  194.         );
  195.         $workExperience = array(
  196.             'title' => $request->get('title'),
  197.             'companyName' => $request->get('companyName'),
  198.             'jobStartDate' => $request->get('jobStartDate'),
  199.             'jobEndDate' => $request->get('jobEndDate'),
  200.             'description' => $request->get('workDescription'),
  201.         );
  202.         $certificate = array(
  203.             'certificatename' => $request->get('certificatename'),
  204.             'issuedDate' => $request->get('issuedDate'),
  205.         );
  206.         $courses = array(
  207.             'courseName' => $request->get('courseName'),
  208.             'date' => $request->get('date'),
  209.             'duration' => $request->get('duration')
  210.         );
  211.         if ($request->isMethod('POST')) {
  212.             if ($consultantDetails)
  213.                 $consultant $consultantDetails;
  214.             else
  215.                 $consultant = new EntityApplicantDetails();
  216.             $consultant->setApplicationText($request->request->get('applicationText'));
  217.             $consultant->setFirstname($request->request->get('firstname'));
  218.             $consultant->setLastname($request->request->get('lastname'));
  219.             $consultant->setIsImgLegal($request->request->get('is_img_legal'));
  220.             $consultant->setNid($request->request->get('nid'));
  221.             $consultant->setDob(new \DateTime($request->get('dob')));
  222.             $consultant->setSex($request->request->get('sex'));
  223.             $consultant->setFather($request->request->get('father'));
  224.             $consultant->setMother($request->request->get('mother'));
  225.             $consultant->setBlood($request->request->get('blood'));
  226.             $consultant->setPhone($request->request->get('phone'));
  227.             $consultant->setCountry($request->request->get('country'));
  228.             $consultant->setCurrentCountryId($request->request->get('currentCountryId'));
  229.             $consultant->setCountryId($request->request->get('currentCountryId'));
  230.             $consultant->setPostalCode($request->request->get('postalCode'));
  231.             $consultant->setDescription($request->request->get('description'));
  232.             $consultant->setCurrAddr($request->request->get('curr_addr'));
  233.             $consultant->setSkill(json_encode($request->request->get('skill')));
  234.             $consultant->setEmergencyContactNumber($request->request->get('emm_contact'));
  235.             $consultant->setEmail($request->request->get('oauth_email'));
  236.             $consultant->setCurrentEmployment($request->request->get('currentEmployment'));
  237.             $consultant->setTin($request->request->get('tin'));
  238.             $consultant->setEducationData(json_encode($education));
  239.             $consultant->setWorkExperienceData(json_encode($workExperience));
  240.             $consultant->setCertificateData(json_encode($certificate));
  241.             $consultant->setCoursesData(json_encode($courses));
  242.             $consultant->setWorkExperienceText($request->request->get('workExperience'));
  243.             $consultant->setUniversityText($request->request->get('universityText'));
  244.             $consultant->setEducationText($request->request->get('educationText'));
  245.             $consultant->setExperienceText($request->request->get('experienceText'));
  246.             $consultant->setSkillstext($request->request->get('skillText'));
  247.             $consultant->setSpeciality($request->request->get('speciality'));
  248.             $consultant->setDescription($request->request->get('aboutMe'));
  249.             $consultant->setApplyForConsultant(1);
  250.             $consultant->setApplyForConsultantDate(new \DateTime());
  251.             $em->persist($consultant);
  252.             $em->flush();
  253.             $url $this->generateUrl(
  254.                 'student_dashboard'
  255.             );
  256. //            return $this->redirect($url . "/" . $userId);
  257.             return $this->redirect($url);
  258.         }
  259.         $currDocList json_decode($consultantDetails->getDocumentList(), true);
  260.         if ($currDocList == null)
  261.             $currDocList = [];
  262.         return $this->render('@Buddybee/pages/consultantApply.html.twig', array(
  263.             'page_title' => 'Apply For Consultant ',
  264.             'gender' => $gender,
  265.             'blood' => $blood,
  266.             'consultantDetails' => $consultantDetails,
  267.             'currApplicantDocList' => $currDocList,
  268.             'consultantRequirementsByCountryId' => $consultantRequirementsByCountryId,
  269.             'docListArray' => $docListArray,
  270.             'education' => json_decode($consultantDetails->getEducationData(), true),
  271.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  272.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  273.             'courses' => json_decode($consultantDetails->getCoursesData(), true),
  274.             'languages' => json_decode($consultantDetails->getLanguagesData(), true),
  275.             'skillDetails' => $skillDetails
  276.         ));
  277.     }
  278.     public function ApplicantFileUploadAction(Request $request$id 0)
  279.     {
  280.         $em $this->getDoctrine()->getManager('company_group');
  281.         $session $request->getSession();
  282.         $EntityFileId 0;
  283.         if ($request->isMethod('POST')) {
  284.             MiscActions::RemoveExpiredFiles($em);
  285.             $storePath $request->request->get('storePath''uploads/consultantDocuments/');
  286.             if ($request->request->has('docId')) {
  287.                 $documentLists $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateDocument')->findBy(
  288.                     array(
  289.                         'Id' => $request->request->get('docId')
  290.                     )
  291.                 );;
  292.                 $docListArray = [];
  293.                 foreach ($documentLists as $document) {
  294.                     $docListArray [$document->getId()] = array(
  295.                         'id' => $document->getId(),
  296.                         'docName' => $document->getDocumentName(),
  297.                         'expiryDays' => $document->getExpiryDays(),
  298.                         'processingDays' => $document->getProcessingDays(),
  299.                         'emergencyProcessingDays' => $document->getEmergencyProcessingDays(),
  300.                         'checklist' => json_decode($document->getCheckList()),
  301.                     );
  302.                 }
  303.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/consultantDocuments/';
  304.                 $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/' $storePath;
  305.                 $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($request->request->get('applicantId'));
  306.                 $currDocList json_decode($consultantDetails->getDocumentList(), true);
  307.                 if ($currDocList == null)
  308.                     $currDocList = [];
  309.                 $doc_index_here $request->request->get('docId');
  310.                 //$checkfile = 'docFile' . $consultantDetails->getApplicantId() . '-T-' . '_' . $tid_here . '_' . $doc_index_here . '.' .pdf;
  311. //                foreach ($request->files->get('file', []) as $ind => $uploadedFile)
  312.                 $uploadedFile $request->files->get('file');
  313.                 {
  314.                     $path "";
  315.                     if ($uploadedFile != null) {
  316.                         $extension $uploadedFile->guessExtension();
  317.                         $size $uploadedFile->getSize();
  318.                         $fileName 'docFile' $consultantDetails->getApplicantId() . '-D-' '_' $doc_index_here '.' $uploadedFile->guessExtension();
  319.                         $path $fileName;
  320.                         if (!file_exists($upl_dir)) {
  321.                             mkdir($upl_dir0777true);
  322.                         }
  323.                         if (file_exists($upl_dir '' $path)) {
  324.                             chmod($upl_dir '' $path0755);
  325.                             unlink($upl_dir '' $path);
  326.                         }
  327.                         $uploadedFile->move($upl_dir$path);
  328.                         $expireTs $request->request->get('expireTs'0);
  329.                         if ($expireTs == 0) {
  330.                             if ($request->request->get('expiryDays'0) != 0) {
  331.                                 $currDate = new \DateTime();
  332.                                 $currDate->modify('+' $request->request->get('expiryDays'0) . ' day');
  333.                                 $expireTs $currDate->format('U');
  334.                             } else if ($request->request->get('expiryDate''') != '') {
  335.                                 $currDate = new \DateTime($request->request->get('expiryDate'''));
  336.                                 $currDate->modify('+14 day');
  337.                                 $expireTs $currDate->format('U');
  338.                             }
  339.                         }
  340.                         $EntityFile = new EntityFile();
  341.                         $EntityFile->setPath($this->container->getParameter('kernel.root_dir') . '/../web/' $storePath $path);
  342.                         $EntityFile->setName($path);
  343.                         $EntityFile->setRelativePath($storePath $path);
  344.                         $EntityFile->setEntityName($request->request->get('entityName''EntityApplicantDetails'));
  345.                         $EntityFile->setEntityBundle($request->request->get('entityBundle''CompanyGroupBundle'));
  346.                         $EntityFile->setEntityId($request->request->get('entityId'$session->get(UserConstants::USER_ID0)));
  347.                         $EntityFile->setEntityIdField($request->request->get('entityIdField''applicantId'));
  348.                         $EntityFile->setModifyFieldSetter($request->request->get('modifyFieldSetter'''));
  349.                         $EntityFile->setDocIdForApplicant($request->request->get('docId'0));
  350.                         $EntityFile->setMarker($request->request->get('markerHash''_ENTITY_APPLICANT_DOCUMENT_'));
  351.                         $EntityFile->setExtension($extension);
  352.                         $EntityFile->setExpireTs($expireTs);
  353.                         $EntityFile->setSize($size);
  354.                         $EntityFile->setUserId($session->get(UserConstants::USER_ID0));
  355.                         $EntityFile->setAppId($session->get(UserConstants::USER_APP_ID0));
  356.                         $EntityFile->setEmployeeId($session->get(UserConstants::USER_EMPLOYEE_ID0));
  357.                         $EntityFile->setUserType($session->get(UserConstants::USER_TYPE0));
  358.                         $em->persist($EntityFile);
  359.                         $em->flush();
  360.                         $EntityFileId $EntityFile->getId();
  361.                     }
  362.                     if (isset($currDocList[$doc_index_here])) {
  363.                         $currDocList[$doc_index_here]['docImage'] = 'uploads/consultantDocuments/' $path;
  364.                         $currDocList[$doc_index_here]['docExpiryDate'] = $request->request->get('expiryDate''');
  365. //                        else
  366. //                            $currDocListByTopicId[$tid_here][$doc_index_here]['docImage'] .= ',uploads/consultantDocuments/' . $path;
  367.                     } else {
  368.                         $docD = [
  369.                             'docId' => $doc_index_here,
  370.                             'docName' => $docListArray[$doc_index_here]['docName'],
  371.                             'docExpiryDate' => $request->request->get('expiryDate'''),
  372.                             'docImage' => '',
  373.                             'docCheckList' => [
  374.                                 'Attested' => 1,
  375.                                 'Laminated' => 1
  376.                             ]
  377.                         ];
  378.                         $currDocList[$doc_index_here] = $docD;
  379.                         $currDocList[$doc_index_here]['docImage'] = 'uploads/consultantDocuments/' $path;
  380.                     }
  381.                 }
  382.                 $consultantDetails->setDocumentList(json_encode($currDocList));
  383.                 $em->flush();
  384.                 return new JsonResponse(array(
  385.                     'success' => true,
  386.                     'path' => 'uploads/consultantDocuments/' $path,
  387.                     'docId' => $request->request->get('docId'),
  388.                     'fileId' => $EntityFileId
  389.                 ));
  390.             }
  391.         }
  392.         return new JsonResponse(array(
  393.             'success'=>false
  394.     ));
  395.     }
  396.     public function AddBalanceToApplicantAction(Request $request$id 0)
  397.     {
  398.         $em $this->getDoctrine()->getManager('company_group');
  399.         return new JsonResponse(Buddybee::AddBalanceGeneral(
  400.             $em,
  401.             $request->request->get('applicantId',$request->query->get('applicantId',0)), ///id
  402.             $request->request->get('amount',$request->query->get('amount',0)), ///id
  403.             $request->request->get('coins',$request->query->get('coins',0)) ///id
  404.         ));
  405.     }
  406.     public function consultantListAction()
  407.     {
  408.         $em $this->getDoctrine()->getManager('company_group');
  409. //        $consultantDetails = $em->getRepository(EntityApplicantDetails::class)->findAll();
  410.         $consultantDetails = [];
  411.         return $this->render('@Application/pages/human_resource/list/consultantList.html.twig', array(
  412.             'page_title' => 'Consultant List',
  413.             'consultantDetails' => $consultantDetails,
  414.         ));
  415.     }
  416.     public function jitsiApiListAction()
  417.     {
  418.         $em $this->getDoctrine()->getManager('company_group');
  419.         return $this->render('@Buddybee/pages/jitsi_api_list.html.twig', array(
  420.             'page_title' => 'Jitsi Api List',
  421.         ));
  422.     }
  423.     public function buddybeeTicketListAction()
  424.     {
  425.         $em $this->getDoctrine()->getManager('company_group');
  426. //        $consultantDetails = $em->getRepository(EntityApplicantDetails::class)->findAll();
  427.         $consultantDetails = [];
  428.         return $this->render('@Buddybee/pages/buddybee_ticket_list.html.twig', array(
  429.             'page_title' => 'Ticket List',
  430.         ));
  431.     }
  432.     public function studentListAction()
  433.     {
  434.         $em $this->getDoctrine()->getManager('company_group');
  435. //        $consultantDetails = $em->getRepository(EntityApplicantDetails::class)->findAll();
  436.         return $this->render('@Application/pages/human_resource/list/studentList.html.twig', array(
  437.             'page_title' => 'Student List',
  438.             'commPromiseTypes' => BuddybeeConstant::$commPromiseTypes,
  439.             'commPromiseDetails' => BuddybeeConstant::$commPromiseDetails,
  440.             'commTypes' => BuddybeeConstant::$commTypes,
  441.         ));
  442.     }
  443.     public function leadListAction()
  444.     {
  445.         $em $this->getDoctrine()->getManager('company_group');
  446. //        $consultantDetails = $em->getRepository(EntityApplicantDetails::class)->findAll();
  447.         return $this->render('@Application/pages/human_resource/list/leadList.html.twig', array(
  448.             'page_title' => 'Lead List',
  449.             'commPromiseTypes' => BuddybeeConstant::$commPromiseTypes,
  450.             'commPromiseDetails' => BuddybeeConstant::$commPromiseDetails,
  451.             'commTypes' => BuddybeeConstant::$commTypes,
  452.         ));
  453.     }
  454.     public function consultantApplicationListAction()
  455.     {
  456.         $em $this->getDoctrine()->getManager('company_group');
  457.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->findAll();
  458.         return $this->render('@Application/pages/human_resource/list/consultantApplicationList.html.twig', array(
  459.             'page_title' => 'Consultant Applications',
  460.             'applicationStatusObj' => array(
  461.                 => 'Applied',
  462.                 => 'Rejected',
  463.                 => 'Confirmation Pending',
  464.                 => 'Confirmed',
  465.                 => 'Declined by Applicant',
  466.             ),
  467.             'consultantDetails' => $consultantDetails,
  468.         ));
  469.     }
  470.     public function BeeCodeRechargeAction(Request $request$serial 0$pin 0)
  471.     {
  472.         $em $this->getDoctrine()->getManager('company_group');
  473.         $amount '50';
  474.         $session $request->getSession();
  475.         $userId $request->get('userId'0);
  476.         $cardId $request->get('cardId'0);
  477.         if ($userId == 0$userId $request->get('applicantId'0);
  478.         $claimFlag $request->get('claimFlag'0);
  479.         if ($userId == 0$userId $session->get(UserConstants::USER_ID);
  480.         if ($pin == 0) {
  481.             $encData $serial;
  482.             $encryptedData null;
  483.             if ($encData != "") {
  484.                 if (strlen($encData) != 10)
  485.                     $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  486.                 else
  487.                     $serial $encData;
  488.             } else if ($request->query->has('encData')) {
  489.                 $encData $request->query->get('encData');
  490.                 if (strlen($encData) != 10)
  491.                     $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  492.                 else
  493.                     $serial $encData;
  494.                 $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  495.             }
  496.             if ($encryptedData != null) {
  497.                 $serial = isset($encryptedData['serial']) ? $encryptedData['serial'] : '';
  498.                 $pin = isset($encryptedData['pin']) ? $encryptedData['pin'] : '';
  499.                 $cardId = isset($encryptedData['cardId']) ? $encryptedData['cardId'] : 0;
  500.                 if ($claimFlag == && isset($encryptedData['claimFlag']))
  501.                     $claimFlag $encryptedData['claimFlag'];
  502.             }
  503.         }
  504.         $claimData MiscActions::ClaimBeeCode($em,
  505.             [
  506.                 'claimFlag' => $claimFlag,
  507.                 'pin' => $pin,
  508.                 'cardId' => $cardId,
  509.                 'serial' => $serial,
  510.                 'userId' => $userId,
  511.             ]);
  512.         $invoiceId $request->query->get('invoiceId'0);
  513.         $meetingId 0;
  514.         $autoRedirect $request->query->get('autoRedirect'1);
  515.         $redirectUrl '';
  516.         $url $this->generateUrl(
  517.             'buddybee_dashboard', [], UrlGenerator::ABSOLUTE_URL
  518.         );
  519.         $redirectUrl $url;
  520.         $session $request->getSession();
  521.         MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  522.         if ($request->get('returnJson'0) != 0) {
  523.             $claimData['newCoinBalance'] = $session->get('BUDDYBEE_COIN_BALANCE');
  524.             $claimData['newBalance'] = $session->get('BUDDYBEE_BALANCE');
  525.             return new JsonResponse($claimData);
  526.         }
  527.         if ($claimFlag == 1) {
  528.             if ($claimData['claimSuccess'] == true)
  529.                 return $this->render('@Buddybee/pages/bee_code_recharge_success.html.twig', array(
  530.                     'page_title' => 'Success',
  531.                     'meetingId' => $meetingId,
  532.                     'amount' => $amount,
  533.                     'claimData' => $claimData,
  534. //                    'claimLink'=>$this->get('url_encryptor')->encrypt(array(
  535. //                        'cardId'=>$claimData
  536. //                    )),
  537.                     'autoRedirect' => $autoRedirect,
  538.                     'redirectUrl' => $redirectUrl,
  539.                 ));
  540.             else
  541.                 return $this->render('@Buddybee/pages/bee_code_recharge_failed.html.twig', array(
  542.                     'page_title' => 'Success',
  543.                     'meetingId' => $meetingId,
  544.                     'amount' => $amount,
  545.                     'claimData' => $claimData,
  546.                     'autoRedirect' => $autoRedirect,
  547.                     'redirectUrl' => $redirectUrl,
  548.                 ));
  549.         } else {
  550.             if ($claimData['isClaimable'] == true)
  551.                 return $this->render('@Buddybee/pages/bee_code_claimable_success.html.twig', array(
  552.                     'page_title' => 'Success',
  553.                     'meetingId' => $meetingId,
  554.                     'amount' => $amount,
  555.                     'claimData' => $claimData,
  556.                     'autoRedirect' => 0,
  557.                     'redirectUrl' => $redirectUrl,
  558.                 ));
  559.             else
  560.                 return $this->render('@Buddybee/pages/bee_code_recharge_failed.html.twig', array(
  561.                     'page_title' => 'Success',
  562.                     'meetingId' => $meetingId,
  563.                     'amount' => $amount,
  564.                     'claimData' => $claimData,
  565.                     'autoRedirect' => $autoRedirect,
  566.                     'redirectUrl' => $redirectUrl,
  567.                 ));
  568.         }
  569.     }
  570.     public function PurchaseBeeCardPageAction(Request $request$encData '')
  571.     {
  572.         $em_goc $this->getDoctrine()->getManager('company_group');
  573.         $session $request->getSession();
  574.         $retailerId 0;
  575.         $invoiceId 0;
  576.         $topic null;
  577.         $scheduleId 0;
  578.         $consultantDetails null;
  579.         $consultantId 0;
  580.         $studentId 0;
  581.         $sessionId 0;
  582.         $topicSessionValue 0;
  583.         $consultantSchedule null;
  584.         $scheduleText '';
  585.         $autoRedirected 0;
  586.         $autoAssignMeetingSession 0;
  587.         $currencyForGateway 'bdt';
  588.         $paymentGateway $request->request->get('paymentGateway''stripe');
  589.         if ($request->query->has('currency'))
  590.             $currencyForGateway $request->query->get('currency');
  591.         else
  592.             $currencyForGateway $request->request->get('currency''bdt');
  593.         $sandBoxMode $this->container->hasParameter('sand_box_mode') ? $this->container->getParameter('sand_box_mode') : 0;
  594.         $allowedGateWays = [
  595.             'stripe' => 1,
  596.             'aamarpay' => 1,
  597.             'bkash' => 1,
  598.         ];
  599.         if ($sandBoxMode != 1)
  600.             $allowedGateWays BuddybeeConstant::$allowedGateWaysForLive;
  601.         $sessionConsumeCount $request->request->get('sessionConsumeCount'$request->request->get('sessionDurationSelector'0));
  602.         $retailerId $request->request->get('retailerId'0);
  603.         $sessionDuration $sessionConsumeCount 30;
  604.         $meetingSessionId 0;
  605.         $requiredPurchaseSessionCount $sessionConsumeCount;
  606.         if ($encData != '') {
  607.             $encryptedData json_decode($this->get('url_encryptor')->decrypt($encData), true);
  608.             if (isset($encryptedData['rtlId'])) $retailerId $encryptedData['rtlId'];
  609.             if (isset($encryptedData['schTs'])) $scheduleId $encryptedData['schTs'];
  610.             if (isset($encryptedData['aams'])) $autoAssignMeetingSession $encryptedData['aams'];
  611.             if (isset($encryptedData['rpsc'])) $requiredPurchaseSessionCount $encryptedData['rpsc'];
  612.             if (isset($encryptedData['scc'])) $sessionConsumeCount $encryptedData['scc'];
  613.             if (isset($encryptedData['dur'])) $sessionDuration $encryptedData['dur'];
  614.             if (isset($encryptedData['cnsId'])) $consultantId $encryptedData['cnsId'];
  615.             if (isset($encryptedData['stdntId'])) $studentId $encryptedData['stdntId'];
  616.             if (isset($encryptedData['sem'])) $topicSessionValue $encryptedData['sem'];
  617.         } else {
  618.         }
  619.         if ($request->isMethod('GET') && $request->query->has('autoRedirected'))
  620.             $autoRedirected $request->query->get('autoRedirected');
  621. //        $studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  622.         if ($request->isMethod('POST') && $request->request->has('toPackagePage')) {
  623.             $topicId $request->request->get('consultancyTopic');
  624.             $sessionId $request->request->get('sessionSelector');
  625.             $topicSessionValue $request->request->get('sessionSelector');
  626.             $consultantId $request->request->get('consultantId');
  627.             $scheduleId $request->request->get('consultancyScheduleId'); // this is timestamp
  628.             $scheduleTs $request->request->get('consultancyScheduleId'); // this is timestamp
  629. //            $sessionConsumeCount = $request->request->get('sessionConsumeCount');
  630.             $sessionConsumeCount $request->request->get('sessionConsumeCount'$request->request->get('sessionDurationSelector'0));
  631.             $sessionDuration $sessionConsumeCount BuddybeeConstant::PER_SESSION_MINUTE;
  632.             $autoAssignMeetingSession 1;
  633.             //$topic = $em->getRepository(ConsultancyTopic::class)->findAll();
  634.             $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(array(
  635.                 'id' => $topicId
  636.             ));
  637.             $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  638.                 'applicantId' => $consultantId
  639.             ));
  640. //            $consultantSchedule = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findOneBy(array(
  641. //                'consultantId' => $consultantId
  642. //            ));
  643. //            $schdeuledTime = [];
  644. //            if ($consultantSchedule)
  645. //                $schdeuledTime = json_decode($consultantSchedule->getTimeSchedule(), true);
  646. //            if ($schdeuledTime == null)
  647. //                $schdeuledTime = [];
  648. //            $scheduleText = isset($schdeuledTime[$scheduleId]) ? $schdeuledTime[$scheduleId]['date'] . ' ' . $schdeuledTime[$scheduleId]['startTime'] : '';
  649.             $scheduleTextDate = new \DateTime('@' $scheduleId);;
  650.             $scheduleText $scheduleTextDate->format('F d, Y H:i');
  651.             $currentUserBalance 0;
  652.             $gatewayAmount 0;
  653.             $redeemedAmount 0;
  654.             $redeemedSessionCount 0;
  655.             $payableAmount 0;
  656.             $totalAmount 0;
  657.             $totalSessionCount 0;
  658.             $consumedAmount 0;
  659.             $consumedSessionCount $request->request->get('sessionDurationSelector'0);
  660.             $currentUserSessionBalance 0;
  661.             $currentUserBalance 0;
  662.             $balancedFromUserSessionCount 0;
  663.             $balancedFromUserBalance 0;
  664.             $studentId 0;
  665.             if ($session->get(UserConstants::USER_ID)
  666.                 && $session->get(UserConstants::USER_TYPE) == UserConstants::USER_TYPE_APPLICANT
  667.             ) {
  668.                 $studentDetails null;
  669.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  670.                 if ($studentDetails) {
  671.                     $currentUserBalance $studentDetails->getAccountBalance();
  672.                     $currentUserSessionBalance $studentDetails->getSessionCountBalance();
  673.                     $studentId $studentDetails->getApplicantId();
  674.                 }
  675.                 if ($consumedSessionCount <= $currentUserSessionBalance) {
  676.                     $balancedFromUserSessionCount 1;
  677.                 }
  678.                 //1st do the necessary
  679.                 $beeCode $request->request->get('beeCode''');
  680.                 $payableAmount $request->request->get('payableAmount'0);
  681.                 $scheduledStartTime = new \DateTime('@' $scheduleId);;
  682.                 if ($balancedFromUserSessionCount == 1) {
  683.                     $scheduleValidity MiscActions::CheckIfScheduleCanBeConfirmed(
  684.                         $em_goc,
  685.                         $request->request->get('consultantId'0),
  686.                         $studentId,
  687.                         $scheduledStartTime->format('U'),
  688.                         (30 $consumedSessionCount),
  689.                         1
  690.                     );
  691.                     if (!$scheduleValidity) {
  692.                         $url $this->generateUrl(
  693.                             'consultant_profile'
  694.                         );
  695.                         $output = [
  696.                             'proceedToCheckout' => 0,
  697.                             'message' => 'Session Booking Expired or not Found!',
  698.                             'errorFlag' => 1,
  699.                             'redirectUrl' => $url '/' $request->request->get('consultantId'0)
  700.                         ];
  701.                         if ($request->request->has('returnJson'))
  702.                             return new JsonResponse($output);
  703.                         else
  704.                             return $this->redirect($url '/' $request->request->get('consultantId'0) . '?errorFlag=1&message=Session Booking Expired or not Found');
  705.                     }
  706.                     $new = new EntityMeetingSession();
  707.                     $new->setTopicId($request->request->get('consultancyTopic'0));
  708.                     $new->setConsultantId($request->request->get('consultantId'0));
  709.                     $consultancyTopic $em_goc->getRepository(EntityMeetingSession::class)->find($request->request->get('consultancyTopic'0));
  710.                     $new->setMeetingType($consultancyTopic $consultancyTopic->getMeetingType() : 0);
  711.                     $new->setConsultantCanUpload($consultancyTopic $consultancyTopic->getConsultantCanUpload() : 0);
  712.                     $new->setConsultantId($request->request->get('consultantId'0));
  713.                     $new->setStudentId($studentId);
  714.                     $scheduledEndTime = new \DateTime('@' $scheduleId);;
  715.                     $scheduledEndTime $scheduledEndTime->modify('+' . (30 $consumedSessionCount) . ' Minute');
  716. //                    $scheduledStartTime->setTimezone(new \DateTimeZone('UTC'));
  717. //                    $scheduledEndTime->setTimezone(new \DateTimeZone('UTC'));
  718.                     //$new->setScheduledTime($request->request->get('setScheduledTime'));
  719.                     $new->setScheduledTime($scheduledStartTime);
  720.                     $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  721.                     $new->setDurationAllowedMin((30 $consumedSessionCount));
  722.                     $new->setDurationLeftMin((30 $consumedSessionCount));
  723.                     $new->setSessionExpireDate($scheduledEndTime);
  724.                     $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  725.                     $new->setEquivalentSessionCount($consumedSessionCount);
  726.                     $new->setRedeemSessionCount($consumedSessionCount);
  727.                     $new->setUsableSessionCount($consumedSessionCount);
  728.                     $new->setMeetingActionFlag(0);// no action waiting for meeting
  729.                     $currentUnixTime = new \DateTime();
  730.                     $currentUnixTimeStamp $currentUnixTime->format('U');
  731. //                    $studentId = $request->request->get('studentId', 0);
  732.                     $consultantId $request->request->get('consultantId'0);
  733.                     $new->setMeetingRoomId(str_pad($consultantId4STR_PAD_LEFT) . $currentUnixTimeStamp str_pad($studentId4STR_PAD_LEFT));
  734.                     $new->setPayableAmount($payableAmount);
  735.                     $new->setDueAmount($request->request->get('dueAmount'0));
  736.                     //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  737.                     //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  738.                     $new->setPackageName(($request->request->get('packageName''')));
  739.                     $new->setPcakageDetails(($request->request->get('packageData''')));
  740.                     $new->setScheduleId($scheduleId);
  741.                     $new->setSessionValue($topicSessionValue);
  742. //                    $new->setIsPayment(0);
  743.                     $new->setConsultantIsPaidFull(0);
  744.                     $em_goc->persist($new);
  745.                     $em_goc->flush();
  746.                     $meetingSessionId $new->getSessionId();
  747.                     $periodMarker $scheduledStartTime->format('Ym');
  748.                     MiscActions::UpdateSchedulingRestrictions($em_goc$consultantId$periodMarker, (($request->request->get('meetingSessionScheduledDuration'30)) / 60), -(($request->request->get('meetingSessionScheduledDuration'30)) / 60));
  749. //                            $studentDetails->setSessionCountBalance($currentUserSessionBalance-$consumedSessionCount);
  750. //                            $studentDetails->setTotalSessionUsed($studentDetails->getTotalSessionUsed()+$consumedSessionCount);
  751.                     $em_goc->flush();
  752.                     $new_invoice = new EntityInvoice();
  753.                     $new_invoice->setStudentId($studentId);
  754.                     $invoiceDate = new \DateTime();
  755.                     $new_invoice->setInvoiceDate($invoiceDate);
  756.                     $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  757.                     $new_invoice->setMeetingId($meetingSessionId);
  758.                     $new_invoice->setAmount($totalAmount);
  759.                     $new_invoice->setGatewayBillAmount($gatewayAmount);
  760.                     $new_invoice->setRedeemedAmount($redeemedAmount);
  761.                     $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  762.                     $new_invoice->setPaidAmount(0);
  763.                     $new_invoice->setDueAmount(0);
  764.                     $new_invoice->setInvoiceType(1);
  765.                     $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  766.                     $new_invoice->setAmountType(1);
  767.                     $new_invoice->setConsumeAmount(0);
  768.                     $new_invoice->setSessionCount(0);
  769.                     $new_invoice->setConsumeSessionCount($consumedSessionCount);
  770.                     $new_invoice->setIsPaidfull(0);
  771.                     $new_invoice->setIsProcessed(0);
  772.                     $new_invoice->setApplicantId($studentId);
  773.                     $new_invoice->setIsRecharge(0);
  774.                     $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED);
  775.                     $new_invoice->setIsPayment(0); //0 means receive
  776.                     $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  777. //            $new_invoice->setStatus($request->request->get(0));
  778.                     $em_goc->persist($new_invoice);
  779.                     $em_goc->flush();
  780.                     $invoiceId $new_invoice->getId();
  781.                     $retData =  Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],$this->container->getParameter('kernel.root_dir'),  false,
  782.                         $this->container->getParameter('notification_enabled'),
  783.                         $this->container->getParameter('notification_server')
  784.                     );
  785.                     MiscActions::RefreshBuddybeeBalanceOnSession($em_goc$request->getSession());
  786.                     $meetingSessionId $retData['meetingId'];
  787.                     if ($meetingSessionId != 0) {
  788.                         $url $this->generateUrl(
  789.                             'consultancy_session'
  790.                         );
  791.                         $output = [
  792.                             'proceedToCheckout' => 0,
  793.                             'redirectUrl' => $url '/' $meetingSessionId
  794.                         ];
  795.                     } else {
  796.                         $url $this->generateUrl(
  797.                             'buddybee_dashboard'
  798.                         );
  799.                         $output = [
  800.                             'proceedToCheckout' => 0,
  801.                             'redirectUrl' => $url
  802.                         ];
  803.                     }
  804.                     if ($request->request->has('returnJson'))
  805.                         return new JsonResponse($output);
  806.                     else
  807.                         return $this->redirect($url '/' $meetingSessionId);
  808.                 }
  809.             } else {
  810.                 $url $this->generateUrl(
  811.                     'buddybee_dashboard'
  812.                 );
  813.                 $output = [
  814.                     'proceedToCheckout' => 0,
  815.                     'redirectUrl' => $url
  816.                 ];
  817.                 if ($request->request->has('returnJson'))
  818.                     return new JsonResponse($output);
  819.                 else
  820.                     return $this->redirect($url '/' $meetingSessionId);
  821.             }
  822. //
  823.         }
  824.         $packageNames BuddybeeConstant::$packageNames;
  825.         $packageDetails BuddybeeConstant::$packageDetails;
  826.         $userId $studentId == $session->get(UserConstants::USER_ID) : $studentId;
  827.         if ($userId != 0) {
  828.             $applicantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  829.                 'applicantId' => $userId
  830.             ));
  831.             if ($applicantDetails)
  832.                 $requiredPurchaseSessionCount $sessionConsumeCount - ($applicantDetails->getSessionCountBalance());
  833.         }
  834.         MiscActions::RemoveExpiredTemporaryBookingsOnBeeCard($em_goc);
  835.         $cards $em_goc->getRepository("CompanyGroupBundle\\Entity\\BeeCode")->findBy(array(
  836.             'isClaimed' => 0,
  837.             'isTemporaryBooked' => [0null],
  838.             'retailerId' => $retailerId
  839.         ));
  840.         $cardsData = [];
  841.         $cardsDataByCoinValue = array(
  842.             100 => ['count' => 0],
  843.             200 => ['count' => 0],
  844.             500 => ['count' => 0],
  845.             600 => ['count' => 0],
  846.         );
  847.         foreach ($cards as $card) {
  848.             $cardsData[] = array(
  849.                 'id' => $card->getId(),
  850.                 'printed' => $card->getPrinted(),
  851.                 'amount' => $card->getAmount(),
  852.                 'coinCount' => $card->getCoinCount(),
  853.                 'pin' => $card->getPin(),
  854.                 'serial' => $card->getSerial(),
  855.             );
  856.             if ($card->getCoinCount() != null && $card->getCoinCount() != && $card->getCoinCount() != '') {
  857.                 if (!isset($cardsDataByCoinValue[$card->getCoinCount()]))
  858.                     $cardsDataByCoinValue[$card->getCoinCount()] = array(
  859.                         'count' => 0
  860.                     );
  861. //            $cardsDataByCoinValue[$card->getAmount()][] = array(
  862. //                'id' => $card->getId(),
  863. //                'printed' => $card->getPrinted(),
  864. //                'amount' => $card->getAmount(),
  865. //                'coinCount' => $card->getCoinCount(),
  866. //                'pin' => $card->getPin(),
  867. //                'serial' => $card->getSerial(),
  868. //
  869. //            );
  870.                 $cardsDataByCoinValue[$card->getCoinCount()]['count'] += 1;
  871.             }
  872.         }
  873.         return $this->render('@Buddybee/pages/purchase_bee_card.html.twig', array(
  874.             'page_title' => 'Bee Card',
  875.             'topic' => $topic,
  876.             'allowedGateWays' => $allowedGateWays,
  877.             'retailerId' => $retailerId,
  878.             'applicantId' => $userId,
  879.             'userId' => $userId,
  880.             'convMultFromTo' => BuddybeeConstant::$convMultFromTo,
  881.             'beeCodePriceByCoinCountEur' => BuddybeeConstant::$beeCodePriceByCoinCountEur,
  882.             'BEECOIN_VALUE_EURO' => BuddybeeConstant::BEECOIN_VALUE_EURO,
  883.             'paymentGateway' => $paymentGateway,
  884.             'currencyForGateway' => $currencyForGateway,
  885.             'consultantDetails' => $consultantDetails,
  886.             'packageDetails' => $packageDetails,
  887.             'packageNames' => $packageNames,
  888.             'scheduleId' => $scheduleId,
  889.             'consultantId' => $consultantId,
  890.             'topicSessionValue' => $topicSessionValue,
  891.             'autoRedirected' => $autoRedirected,
  892.             'meetingSessionId' => $meetingSessionId,
  893.             'invoiceId' => $invoiceId,
  894.             'cardsData' => $cardsData,
  895.             'cardsDataByCoinValue' => $cardsDataByCoinValue,
  896.             'CoinValueSegregation' => array(
  897.                 100200500
  898.             ),
  899.             'sessionConsumeCount' => $sessionConsumeCount,
  900.             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  901.             'autoAssignMeetingSession' => $autoAssignMeetingSession,
  902.             'sessionDuration' => $sessionDuration,
  903. //            'consultantSchedule' => $consultantSchedule,
  904.             'scheduleText' => $scheduleText,
  905. //            'timeSchedule' => $consultantSchedule
  906.         ));
  907. //        return $this->render('@Buddybee/pages/pricing.html.twig', array(
  908. //            'page_title' => 'Package And Pricing',
  909. //        ));
  910.     }
  911.     public function BuddyBeeNotificationListAction(Request $request$id 0)
  912.     {
  913. //        return $this->render('@Buddybee/pages/consultancyHomePage.html.twig', array(
  914. //            'page_title' => 'BuddyBee Home',
  915. //        ));
  916.         $em $this->getDoctrine()->getManager('company_group');
  917. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  918.         $recNotifications $em->getRepository('CompanyGroupBundle\\Entity\\EntityNotification')
  919.             ->findBy(
  920.                 array(//                    'targetId'=>$request->request->get('targetId',0)
  921.                 )
  922.             );
  923.         return $this->render('@Buddybee/pages/notification_list.html.twig', array(
  924.             'page_title' => 'Notifications',
  925.             'recNotifications' => $recNotifications,
  926.         ));
  927.     }
  928.     public function BuddyBeeNotificationViewAction(Request $request$id 0)
  929.     {
  930.         $em $this->getDoctrine()->getManager('company_group');
  931.         $notification $em->getRepository('CompanyGroupBundle\\Entity\\EntityNotification')->find($id);
  932.         if (!$notification) {
  933.             return $this->render('@Buddybee/pages/notification_detail.html.twig', array(
  934.                 'page_title' => 'Notification Detail',
  935.                 'notification' => null,
  936.                 'detailError' => 'Notification not found.',
  937.             ));
  938.         }
  939.         if ((int) $notification->getSeenFlag() !== 1) {
  940.             $notification->setSeenFlag(1);
  941.         }
  942.         if ((int) $notification->getReadFlag() !== 1) {
  943.             $notification->setReadFlag(1);
  944.         }
  945.         $em->flush();
  946.         return $this->render('@Buddybee/pages/notification_detail.html.twig', array(
  947.             'page_title' => 'Notification Detail',
  948.             'notification' => $notification,
  949.             'detailError' => '',
  950.         ));
  951.     }
  952.     public function TakeApplicantAction(Request $request$id 0)
  953.     {
  954.         $applicantId $request->request->get('applicantId'$request->query->get('applicantId'0));
  955.         $action $request->request->get('action'$request->query->get('action''_NONE_'));
  956.         $forceAction $request->request->get('forceAction'$request->query->get('forceAction'0));
  957.         $actionValue $request->request->get('actionValue'$request->query->get('actionValue'0));
  958.         $em $this->getDoctrine()->getManager('company_group');
  959. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  960.         $applicant $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  961.             ->findOneBy(
  962.                 array(//                    'targetId'=>$request->request->get('targetId',0)
  963.                     'applicantId' => explode(',',$applicantId)
  964.                 )
  965.             );
  966.         if ($applicant) {
  967.             if ($action == '_REMOVE_') {
  968.                 $get_kids_sql "
  969.                                     DELETE FROM `consultancy_availability` WHERE consultant_id in ($applicantId);
  970.                                     DELETE FROM `entity_meeting_session` WHERE student_id in ($applicantId) or consultant_id in ($applicantId); 
  971.                                     DELETE FROM `entity_invoice` WHERE biller_id in ($applicantId)  or bill_to_id in ($applicantId);
  972.                                     DELETE FROM `entity_applicant_details` WHERE applicant_id in ($applicantId) ; 
  973.                                 ";
  974.                 $stmt $em->getConnection()->executeStatement($get_kids_sql);
  975.                 
  976.                 
  977.                 return new JsonResponse(array(
  978.                     'success' => true,
  979.                     'applicantId' => $applicantId,
  980.                 ));
  981.             }
  982.             if ($action == '_INITIATE_CALL_') {
  983.                 $session $request->getSession();
  984.                 $thisUserId $session->get(UserConstants::USER_ID);
  985.                 $thisUser $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  986.                     ->findOneBy(
  987.                         array(//                    'targetId'=>$request->request->get('targetId',0)
  988.                             'applicantId' => $thisUserId
  989.                         )
  990.                     );
  991.                 $thisUserFireBaseTokens = [];
  992.                 $adminTokenList $em->getRepository('CompanyGroupBundle\\Entity\\EntityTokenStorage')
  993.                     ->createQueryBuilder('m')
  994.                     ->where("m.userId = $thisUserId")
  995.                     ->getQuery()
  996.                     ->getResult();
  997.                 foreach ($adminTokenList as $a) {
  998.                     if ($a->getFireBaseToken() != '' && $a->getFireBaseToken() != null) {
  999.                         $thisUserFireBaseTokens[] = $a->getFireBaseToken();
  1000.                     }
  1001.                 }
  1002.                 System::AddNewNotificationUpdated(
  1003.                     $this->container->getParameter('notification_enabled'),
  1004.                     $this->container->getParameter('notification_server'),
  1005.                     0//appId
  1006.                     0,//company Id
  1007.                     "Call initiation with " $applicant->getFirstname() . " " $applicant->getLastname() . " on  " $applicant->getPhone() . " ",
  1008.                     GeneralConstant::NOTIFICATION_TYPE_ALERT,//type
  1009.                     "",
  1010.                     "Call Initiation",
  1011.                     'emit',
  1012.                     1,
  1013.                     1,
  1014.                     [
  1015.                         'em' => $em,
  1016.                         'isBuddybee' => 1,
  1017.                         'targetRoute' => '_INITIATE_CALL_',
  1018.                         'targetUrl' => '_INITIATE_CALL_',
  1019.                         'targetPath' => '_INITIATE_CALL_',
  1020.                         'targetId' => $applicantId,
  1021.                         'meetingId' => 0,
  1022.                         'userId' => $applicantId,
  1023.                         'applicantId' => $applicantId,
  1024.                         'taggedUserIds' => ['BBEE_' $thisUserId],
  1025.                         'type' => 0,
  1026.                         'expireTs' => 0,
  1027.                         'userIdPrefixForSocket' => 'BBEE_',
  1028.                         'emitMarker' => '_INITIATE_CALL_',
  1029.                         'dataObj' => array(
  1030.                             'isBuddybee' => 1,
  1031.                             'targetRoute' => '_INITIATE_CALL_',
  1032.                             'targetUrl' => '_INITIATE_CALL_',
  1033.                             'targetPath' => '_INITIATE_CALL_',
  1034.                             'targetMobileAppPath' => '_INITIATE_CALL_',
  1035.                             'targetId' => $applicantId,
  1036.                             'meetingId' => 0,
  1037.                             'userId' => $applicantId,
  1038.                             'applicantId' => $applicantId,
  1039.                             'taggedUserIds' => ['BBEE_' $thisUserId],
  1040.                             'route' => '_INITIATE_CALL_',
  1041.                             'phoneNo' => $applicant->getPhone()
  1042.                         ),
  1043.                         'firebasePushData' => array(
  1044.                             'notification' => array(
  1045.                                 'title' => 'Call Initiate',
  1046.                                 'body' => "Call initiation with " $applicant->getFirstname() . " " $applicant->getLastname() . " on  " $applicant->getPhone() . " "
  1047.                             ),
  1048.                             'data' => [
  1049. //                                'score' => '850',
  1050. //                                'time' => '2:45',
  1051.                                 'route' => '_INITIATE_CALL_',
  1052.                                 'phoneNo' => $applicant->getPhone()
  1053.                             ],
  1054.                             'android' => [
  1055.                                 'notification' => [
  1056.                                     // icon: 'stock_ticker_update',
  1057.                                     // color: '#7e55c3',
  1058.                                     'imageUrl' => '_INITIATE_CALL_'
  1059.                                 ]
  1060.                             ],
  1061.                             'topic' => 'SESSION BOOKED',
  1062.                             'tokens' => $adminTokenList,
  1063.                         )
  1064.                     ]);
  1065.                 return new JsonResponse(array(
  1066.                     'success' => true,
  1067.                     'applicantId' => $applicantId,
  1068.                 ));
  1069.             }
  1070.             if ($action == '_SEND_WELCOME_MESSAGE_') {
  1071.                 $applicantWasTemporary $applicant->getIstemporaryEntry();
  1072.                 $applicant->setIstemporaryEntry(0);
  1073.                 if ($applicant->getTempPassword() != '')
  1074.                     $applicant->setTriggerResetPassword(1);
  1075.                 //salt will be username
  1076. //                $this->container->get('sha256salted_encoder')->isPasswordValid($user->getPassword(), $request->request->get('password'), $user->getSalt())
  1077.                 $em->flush();
  1078.                 if ($applicantWasTemporary == || ($applicantWasTemporary != && $forceAction == 1)) {
  1079.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  1080.                         $bodyHtml '';
  1081.                         $bodyTemplate '@Application/email/templates/buddybeeRegistrationComplete.html.twig';
  1082.                         $bodyData = array(
  1083.                             'name' => $applicant->getFirstname() . ' ' $applicant->getLastname(),
  1084.                             'email' => $applicant->getOAuthEmail(),
  1085.                             'showPassword' => $applicant->getTempPassword() != '' 0,
  1086.                             'password' => $applicant->getTempPassword(),
  1087.                         );
  1088.                         $attachments = [];
  1089.                         $forwardToMailAddress $applicant->getOAuthEmail();
  1090. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  1091.                         $new_mail $this->get('mail_module');
  1092.                         $new_mail->sendMyMail(array(
  1093.                             'senderHash' => '_CUSTOM_',
  1094.                             //                        'senderHash'=>'_CUSTOM_',
  1095.                             'forwardToMailAddress' => $forwardToMailAddress,
  1096.                             'subject' => 'Welcome to BuddyBee ',
  1097. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  1098.                             'attachments' => $attachments,
  1099.                             'encryptionMethod' => 'ssl',
  1100.                             'fromAddress' => 'no-reply@buddybee.eu',
  1101.                             'userName' => 'no-reply@buddybee.eu',
  1102.                             'password' => 'Honeybee@0112',
  1103.                             'smtpServer' => 'smtp.hostinger.com',
  1104.                             'smtpPort' => 465,
  1105. //                            'emailBody' => $bodyHtml,
  1106.                             'mailTemplate' => $bodyTemplate,
  1107.                             'templateData' => $bodyData,
  1108. //                        'embedCompanyImage' => 1,
  1109. //                        'companyId' => $companyId,
  1110. //                        'companyImagePath' => $company_data->getImage()
  1111.                         ));
  1112.                     }
  1113.                 }
  1114.                 return new JsonResponse(array(
  1115.                     'success' => true,
  1116.                     'applicantId' => $applicantId,
  1117.                 ));
  1118.             }
  1119.         }
  1120.         return new JsonResponse(array(
  1121.             'success' => false,
  1122.             'applicantId' => $applicantId,
  1123.         ));
  1124.     }
  1125.     public function AddBeeCardAction(Request $request$id 0)
  1126.     {
  1127.         $em $this->getDoctrine()->getManager('company_group');
  1128. //        $dt = Inventory::GetDrDetails($em, $id, $item_id);
  1129.         $repeatCount 1;
  1130.         $assignProductId '';
  1131.         $queryCondition = [];
  1132.         $cardList = [];
  1133.         $cardCount $request->get('cardCount'1);
  1134.         $cardAmount $request->get('cardAmount'0);
  1135.         $coinCount $request->get('coinCount'100);
  1136.         $rePrintFlag $request->request->has('rePrintFlag') ? $request->request->get('rePrintFlag') : 0;
  1137.         $cardIds json_decode($request->get('cardIds'''), true);
  1138.         $printFlag $request->request->has('printFlag') ? $request->request->get('printFlag') : 1;
  1139.         $returnJson $request->request->has('returnJson') ? $request->request->get('returnJson') : 0;
  1140.         $physicalOnly $request->get('physicalOnly'1);
  1141.         $retailerId $request->get('retailerId'0);
  1142.         $useCount $request->get('useCount'1);
  1143. //        if(!empty($cardIds))
  1144. //            $queryCondition['id']=$cardIds;
  1145. //        if($physicalOnly==1)
  1146. //            $queryCondition['isForHardCopy']=1;
  1147. //        if($rePrintFlag==0)
  1148. //            $queryCondition['printed']=[0,null];
  1149.         if ($cardAmount != 0$queryCondition['amount'] = $cardAmount;
  1150.         if ($coinCount != 0$queryCondition['coinCount'] = $coinCount;
  1151.         if ($returnJson == 1)
  1152.             $printFlag 0;
  1153.         $cards $em->getRepository('CompanyGroupBundle\\Entity\\BeeCode')
  1154.             ->findBy(
  1155.                 $queryCondition, [], $cardCount
  1156.             );
  1157.         $generateOptions = [
  1158.             'amount' => $cardAmount,
  1159.             'coinCount' => $coinCount,
  1160.             'cardCount' => $cardCount,
  1161.             'serial' => '_AUTO_',
  1162.             'pin' => '_AUTO_',
  1163.             'useCount' => $useCount,
  1164.             'retailerId' => $retailerId,
  1165.         ];
  1166.         $generatedData MiscActions::GenerateBeeCode($em$generateOptions);
  1167.         $cardList $generatedData['data'];
  1168.         return new JsonResponse($generatedData);
  1169.     }
  1170.     public function communicationLogUpdateAction(Request $request$id 0)
  1171.     {
  1172.         $em $this->getDoctrine()->getManager('company_group');
  1173.         $session $request->getSession();
  1174.         $thisUserId $session->get(UserConstants::USER_ID);
  1175.         $allTargetIds = [];
  1176. //        $targets = $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1177. //            ->findBy(
  1178. //                array(
  1179. //
  1180. //                )
  1181. //            );
  1182. //        foreach ($targets as $target)
  1183. //        {
  1184. //            if($target->getIsAdmin()==null || $target->getIsAdmin()<=0)
  1185. //            if($target->getIsConsultant()==null || $target->getIsConsultant()<=0)
  1186. //                $allTargetIds[]=$target->getApplicantId();
  1187. //
  1188. //        }
  1189.         $allTargetIds = [$request->request->get('targetId'0)];
  1190. //
  1191. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  1192.         foreach ($allTargetIds as $tid) {
  1193.             $comm $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  1194.                 ->findOneBy(
  1195.                     array(
  1196.                         'targetId' => $tid
  1197.                     )
  1198.                 );
  1199.             if (!$comm)
  1200.                 $comm = new EntityCommunicationLog();
  1201.             $target $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  1202.                 ->findOneBy(
  1203.                     array(
  1204.                         'applicantId' => $request->request->get('targetId'0)
  1205.                     )
  1206.                 );
  1207.             $commData = [];
  1208.             $commPromiseTypes BuddybeeConstant::$commPromiseTypes;
  1209.             $commTypes BuddybeeConstant::$commTypes;
  1210.             $commPromiseDetails BuddybeeConstant::$commPromiseDetails;
  1211.             $currDate = new \DateTime();
  1212.             $currDateTs $currDate->format('U');
  1213.             $dt = [];
  1214.             if ($request->request->has('tblCurRow')) {
  1215.                 foreach ($request->request->get('tblCurRow', []) as $ind => $rowId) {
  1216.                     $remdate = new \DateTime($request->request->get('reminderDate', [])[$ind]);
  1217.                     $actionTaken $request->request->get('actionTaken', [])[$ind];
  1218.                     $remEnabled $request->request->has('reminderEnabled_' $rowId0);
  1219.                     $remdateTs $remdate->format('U');
  1220.                     if ($actionTaken == && $remEnabled == 1) {
  1221.                         MiscActions::addEntityScheduledNotification($em, [
  1222.                             'senderHash' => '_CUSTOM_',
  1223.                             'bodyTemplate' => '@Application/email/templates/consultancyCommunicationReminder.html.twig',
  1224.                             'bodyData' => [
  1225.                                 'headline_1' => 'Reminder for ' $commPromiseTypes[$request->request->get('promiseType', [])[$ind]] . ' on BuddyBee',
  1226.                                 'text_1' => 'You are receiving this email to remind you of following-' $commPromiseDetails[$request->request->get('promiseType', [])[$ind]]['title'],
  1227.                                 'headline_1' => $request->request->get('reminderSubject', [])[$ind],
  1228.                                 'text_1' => $request->request->get('reminderText', [])[$ind],
  1229.                             ],
  1230.                             'subject' => 'Reminder for scheduled action on Buddybee ',
  1231.                             'emailIds' => [$target->getOAuthEmail()],
  1232.                             'companyImagePath' => '',
  1233.                             'forwardToMailAddress' => $target->getOAuthEmail(),
  1234.                             'encryptionMethod' => 'ssl',
  1235.                             'fromAddress' => 'no-reply@buddybee.eu',
  1236.                             'userName' => 'no-reply@buddybee.eu',
  1237.                             'password' => 'Honeybee@0112',
  1238.                             'smtpServer' => 'smtp.hostinger.com',
  1239.                             'startTimeTs' => $remdateTs,
  1240.                             'nextTimeTs' => $remdateTs,
  1241.                             'lastTimeTs' => $remdateTs,
  1242.                             'recurringMin' => 0,
  1243.                             'smtpPort' => 465,
  1244.                         ]);
  1245.                     }
  1246.                     $actionTaken 1;
  1247.                     $dt = array(
  1248.                         'commId' => '',
  1249.                         'promiseType' => $request->request->get('promiseType', [])[$ind],
  1250.                         'commDateTs' => $request->request->get('commDateTs', [])[$ind] != $request->request->get('commDateTs', [])[$ind] : $currDateTs,
  1251.                         'followUpDateTs' => $request->request->get('followUpDateTs', [])[$ind] != $request->request->get('followUpDateTs', [])[$ind] : 0,
  1252.                         'commEndDateTs' => $request->request->get('commDateTs', [])[$ind] != $request->request->get('commEndDateTs', [])[$ind] : $currDateTs,
  1253.                         'communicationFeedback' => $request->request->get('communicationFeedback', [])[$ind],
  1254.                         'actionTaken' => $actionTaken,
  1255.                         'reminderDateTs' => $remdateTs,
  1256.                         'reminderEnabled' => $remEnabled,
  1257.                         'reminderSubject' => $request->request->get('reminderSubject', [])[$ind],
  1258.                         'reminderText' => $request->request->get('reminderText', [])[$ind],
  1259.                     );
  1260.                     $commData[] = $dt;
  1261.                 }
  1262.             } else {
  1263.                 $commData json_decode($comm->getCommunicationHistory(), true);
  1264.                 if ($commData == null$commData = [];
  1265.                 $remdate = new \DateTime($request->request->get('reminderDateSingle'''));
  1266.                 $comDate = new \DateTime($request->request->get('commDateSingle'''));
  1267.                 $comEndDate = new \DateTime($request->request->get('commEndDateSingle'''));
  1268.                 $followUpDate $request->request->get('followUpDateSingle''') == '' '' : (new \DateTime($request->request->get('followUpDateSingle''')));
  1269.                 $followUpDateTs $request->request->get('followUpDateSingle''') == '' $followUpDate->format('U');
  1270.                 $actionTaken $request->request->get('actionTakenSingle'0);
  1271.                 $remEnabled $request->request->has('reminderEnabledSingle'0);
  1272.                 $remdateTs $remdate->format('U');
  1273.                 if ($request->request->get('refFollowUpId'0) != 0) {
  1274.                     $refFollowUp $em->getRepository('CompanyGroupBundle\\Entity\\EntityScheduledNotification')
  1275.                         ->findOneBy(
  1276.                             array(
  1277.                                 'id' => $request->request->get('refFollowUpId'0),
  1278.                                 'notificationType' => GeneralConstant::NOTIFICATION_TYPE_FOLLOW_UP,
  1279.                             )
  1280.                         );
  1281.                     if ($refFollowUp) {
  1282.                         $refFollowUp->SetActionTaken(1);
  1283.                         $em->flush();
  1284.                     }
  1285.                 }
  1286.                 if ($actionTaken == && $remEnabled == 1) {
  1287.                     MiscActions::addEntityScheduledNotification($em, [
  1288.                         'senderHash' => '_CUSTOM_',
  1289.                         'bodyTemplate' => '@Application/email/templates/consultancyCommunicationReminder.html.twig',
  1290.                         'bodyData' => [
  1291.                             'headline_1' => $request->request->get('reminderSubjectSingle'''),
  1292.                             'text_1' => $request->request->get('reminderTextSingle'''),
  1293.                         ],
  1294.                         'subject' => 'Reminder for scheduled action on Buddybee ',
  1295.                         'emailIds' => [$target->getOAuthEmail()],
  1296.                         'companyImagePath' => '',
  1297.                         'forwardToMailAddress' => $target->getOAuthEmail(),
  1298.                         'encryptionMethod' => 'ssl',
  1299.                         'fromAddress' => 'no-reply@buddybee.eu',
  1300.                         'userName' => 'no-reply@buddybee.eu',
  1301.                         'password' => 'Honeybee@0112',
  1302.                         'smtpServer' => 'smtp.hostinger.com',
  1303.                         'startTimeTs' => $remdateTs,
  1304.                         'nextTimeTs' => $remdateTs,
  1305.                         'lastTimeTs' => $remdateTs,
  1306.                         'recurringMin' => 0,
  1307.                         'smtpPort' => 465,
  1308.                     ]);
  1309.                 }
  1310.                 $followUpScheduleId 0;
  1311.                 $followUpEnabled $request->request->get('followUpEnabledSingle'0);
  1312.                 $followUpDone 0;
  1313.                 if ($actionTaken == && $request->request->get('followUpEnabledSingle'0) != 0) {
  1314.                     $followUpSchedule MiscActions::addEntityScheduledNotification($em, [
  1315.                         'senderHash' => '_CUSTOM_',
  1316.                         'bodyTemplate' => '@Application/email/templates/consultancyCommunicationReminder.html.twig',
  1317.                         'bodyData' => [
  1318.                             'headline_1' => $request->request->get('reminderSubjectSingle'''),
  1319.                             'text_1' => $request->request->get('reminderTextSingle'''),
  1320.                         ],
  1321.                         'subject' => 'Reminder for scheduled action on Buddybee ',
  1322.                         'emailIds' => [$target->getOAuthEmail()],
  1323.                         'companyImagePath' => '',
  1324.                         'forwardToMailAddress' => $target->getOAuthEmail(),
  1325.                         'encryptionMethod' => 'ssl',
  1326.                         'fromAddress' => 'no-reply@buddybee.eu',
  1327.                         'userName' => 'no-reply@buddybee.eu',
  1328.                         'password' => 'Honeybee@0112',
  1329.                         'smtpServer' => 'smtp.hostinger.com',
  1330.                         'startTimeTs' => $followUpDateTs,
  1331.                         'nextTimeTs' => $followUpDateTs,
  1332.                         'lastTimeTs' => 30 3600 24 $followUpDateTs,
  1333.                         'expiresTs' => 30 3600 24 $followUpDateTs,
  1334.                         'actionTaken' => 0,
  1335.                         'recurringMin' => 0,
  1336.                         'smtpPort' => 465,
  1337.                         'notificationType' => GeneralConstant::NOTIFICATION_TYPE_FOLLOW_UP,
  1338.                         'showAsNotification' => 1,
  1339.                         'title' => $commTypes[$request->request->get('commTypeSingle'0)]['title'] . ' follow up',
  1340.                         'body' => $request->request->get('followUpTextSingle''General communication follow up'),
  1341.                         'targetType' => 3,
  1342.                         'targetId' => $tid,
  1343.                         'userIds' => ['BBEE_' $thisUserId],
  1344.                     ]);
  1345.                     $followUpDone 0;
  1346.                     $followUpEnabled $request->request->get('followUpEnabledSingle'0);
  1347.                     if ($followUpSchedule)
  1348.                         $followUpScheduleId $followUpSchedule->getId();
  1349.                 }
  1350.                 $actionTaken 1;
  1351.                 $dt = array(
  1352.                     'commId' => '',
  1353.                     'commUserId' => 'BBEE_' $thisUserId,
  1354.                     'followUpScheduleId' => $followUpScheduleId,
  1355.                     'followUpEnabled' => $followUpEnabled,
  1356.                     'followUpDone' => $followUpDone,
  1357. //                    'commUserId' => $thisUserId,
  1358.                     'promiseType' => $request->request->get('promiseTypeSingle'0),
  1359.                     'commType' => $request->request->get('commTypeSingle'0),
  1360.                     'commDateTs' => $comDate->format('U'),
  1361.                     'commEndDateTs' => $comEndDate->format('U'),
  1362.                     'followUpDateTs' => $followUpDateTs,
  1363.                     'communicationFeedback' => $request->request->get('communicationFeedbackSingle'),
  1364.                     'reminderSubject' => $request->request->get('reminderSubjectSingle'''),
  1365.                     'reminderText' => $request->request->get('reminderTextSingle'''),
  1366.                     'followUpText' => $request->request->get('followUpTextSingle'''),
  1367.                     'refFollowUpId' => $request->request->get('refFollowUpId'0),
  1368.                     'actionTaken' => $actionTaken,
  1369.                     'reminderDateTs' => $remdateTs,
  1370.                     'reminderEnabled' => $remEnabled,
  1371.                 );
  1372.                 $commData[] = $dt;
  1373.             }
  1374.             $comm->setTargetId($tid);
  1375.             $comm->setTargetType(3); //bbee applicant /admin
  1376.             $comm->setCommunicatorId($thisUserId);
  1377.             $comm->setCommunicationHistory(json_encode($commData));
  1378.             $target->setImmediateFollowUpFlag(0);
  1379.             $target->setPendingInitialCommunication(0);
  1380.             MiscActions::updateEntityPerformanceIndex($em, [
  1381.                 'targetId' => $thisUserId,
  1382.                 'communicationData' => [
  1383.                     'count' => 1,
  1384.                     'score' => 10,
  1385.                 ],
  1386.                 'followupData' => [
  1387.                     'count' => $request->request->has('refFollowUpId') ? 0,
  1388.                     'score' => $request->request->has('refFollowUpId') ? 20 0,
  1389.                 ]
  1390.             ]);
  1391.             $em->persist($comm);
  1392.             $em->flush();
  1393.         }
  1394.         return new JsonResponse(array(
  1395.             'success' => true,
  1396.             'dt' => $dt
  1397.         ));
  1398.     }
  1399.     public function liveSupportPageSupportPersonAction(Request $request$id 0)
  1400.     {
  1401.         $em $this->getDoctrine()->getManager('company_group');
  1402.         $session $request->getSession();
  1403. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  1404. //        $comm = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  1405. //            ->findOneBy(
  1406. //                array(
  1407. //                    'targetId'=>$request->request->get('targetId',0)
  1408. //                )
  1409. //            );
  1410.         $userId $session->get(UserConstants::USER_ID);
  1411.         return $this->render('@Buddybee/pages/live_support_page_applicant.html.twig', array(
  1412. //        return $this->render('@Buddybee/pages/live_support_page_support_person.html.twig', array(
  1413.             'page_title' => 'Live Support',
  1414.             'hostId' => $userId,
  1415.             'userId' => $userId,
  1416.             'relevance' => '_SUPPORT_PERSON_'
  1417. //            'recNotifications' => $recNotifications,
  1418.         ));
  1419.     }
  1420.     public function liveSupportPageApplicantAction(Request $request$id 0)
  1421.     {
  1422.         $em $this->getDoctrine()->getManager('company_group');
  1423.         $session $request->getSession();
  1424. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  1425. //        $comm = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  1426. //            ->findOneBy(
  1427. //                array(
  1428. //                    'targetId'=>$request->request->get('targetId',0)
  1429. //                )
  1430. //            );
  1431.         $userId $session->get(UserConstants::USER_ID);
  1432.         return $this->render('@Buddybee/pages/live_support_page_applicant.html.twig', array(
  1433.             'page_title' => 'Live Support',
  1434.             'hostId' => 0,
  1435.             'userId' => $userId,
  1436.             'relevance' => '_USER_SUPPORT_'
  1437. //            'recNotifications' => $recNotifications,
  1438.         ));
  1439.     }
  1440.     public function refreshLiveSupportMeetingRoomAction(Request $request$id 0)
  1441.     {
  1442.         $em $this->getDoctrine()->getManager('company_group');
  1443.         $session $request->getSession();
  1444.         $currDate = new \DateTime();
  1445.         $currDateTs $currDate->format('U');
  1446.         $userId $session->get(UserConstants::USER_ID);
  1447.         $action $request->request->get('action''_JOIN_');  //or _LEAVE_ or _BAN_ or _CHECK_ or _CANCEL_ or _CONFIRMATION_FAILED_
  1448.         $silent $request->request->get('silent'0);  //or _LEAVE_ or _BAN_ or _CHECK_ or _CANCEL_ or _CONFIRMATION_FAILED_
  1449.         $retData = array(
  1450.             'success' => false,
  1451.             'action' => $action,
  1452.             'silent' => $silent
  1453.         );
  1454.         $hostId $request->request->get('hostId'$session->get(UserConstants::USER_ID0));
  1455.         $applicantId $request->request->get('applicantId'$hostId);
  1456.         $liveSessionId $request->request->get('liveSessionId'0);
  1457.         $liveSessionRoomCode $request->request->get('liveSessionRoomCode'0);
  1458. //        $availableOrAllowed=$request->request->get('ifAvailable',1);
  1459.         $authorizationType $request->request->get('authorizationType''_APPLICANT_');  //or _HOST_
  1460.         $joinIfAllowedIdsEmpty $request->request->get('joinIfAllowedIdsEmpty'0);  //or _HOST_
  1461.         $queueDataFlag $request->request->get('queueDataFlag'0);
  1462.         $queueJoinFlag $request->request->get('queueJoinFlag'0);
  1463.         $queJoinPassed false;
  1464.         $hasActiveLiveRoomsFlag $request->request->get('hasActiveLiveRoomsFlag'0);
  1465. //        $hasActiveLiveRoomsFlag=$request->request->get('hasActiveLiveRoomsFlag',0);
  1466.         // 1st expire aany expired meeting Room
  1467.         $expiredLiveSupportMeetingRoom $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1468.             ->createQueryBuilder('m')
  1469. //            ->where("m.hostId = :hostId")
  1470.             ->where("m.expireTs <= :expireTs")
  1471.             ->andWhere("m.expired != 0 ")
  1472. //            ->setParameter('hostId', $hostId)
  1473.             ->setParameter('expireTs'$currDateTs)
  1474. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1475. //            ->setParameter('endAt', $endDate->format('U '))
  1476. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1477.             ->getQuery()
  1478.             ->setMaxResults(100)
  1479.             ->getResult();
  1480.         foreach ($expiredLiveSupportMeetingRoom as $expRoom) {
  1481.             $expRoom->setExpired(1);
  1482.             $em->flush();
  1483.         }
  1484.         $expiredLiveSupportMeetingQueue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1485.             ->createQueryBuilder('m')
  1486. //            ->where("m.hostId = :hostId")
  1487.             ->where("(m.expireTs <= :expireTs or m.expired = 1 or (m.autoExpireTsWhenAtFront !=0 and m.autoExpireTsWhenAtFront<=:expireTs))")
  1488. //            ->andWhere(" ")
  1489. //            ->setParameter('hostId', $hostId)
  1490.             ->setParameter('expireTs'$currDateTs)
  1491. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1492. //            ->setParameter('endAt', $endDate->format('U '))
  1493. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1494.             ->getQuery()
  1495.             ->setMaxResults(100)
  1496.             ->getResult();
  1497.         foreach ($expiredLiveSupportMeetingQueue as $expQue) {
  1498.             $em->remove($expQue);
  1499.             $em->flush();
  1500.         }
  1501.         $LiveSupportMeetingRoom null;
  1502.         //now if join, find the meetinf room which is available and if not create new
  1503.         if (!$LiveSupportMeetingRoom && $liveSessionId != 0) {
  1504.             $LiveSupportMeetingRoom $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1505.                 ->findOneBy(
  1506.                     array(
  1507.                         'id' => $liveSessionId,
  1508.                         'expired' => 0,
  1509.                     )
  1510.                 );
  1511.         }
  1512.         if (!$LiveSupportMeetingRoom && $liveSessionRoomCode != 0) {
  1513.             $LiveSupportMeetingRoom $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1514.                 ->findOneBy(
  1515.                     array(
  1516.                         'meetingRoomCode' => $liveSessionRoomCode,
  1517.                         'expired' => 0,
  1518.                     )
  1519.                 );
  1520.         }
  1521. //        if(!$LiveSupportMeetingRoom && $liveSessionRoomCode!=0)
  1522. //        {
  1523. //            $LiveSupportMeetingRoom = $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1524. //                ->findOneBy(
  1525. //                    array(
  1526. //                        'meetingRoomCode'=>$liveSessionRoomCode
  1527. //                    )
  1528. //                );
  1529. //        }
  1530.         if ($action == '_JOIN_') {
  1531.             $isAllowed false;
  1532.             if ($authorizationType == '_HOST_') {
  1533.                 if (!$LiveSupportMeetingRoom && $hostId != 0) {
  1534.                     $LiveSupportMeetingRoom $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1535.                         ->findOneBy(
  1536.                             array(
  1537.                                 'hostId' => $hostId,
  1538.                                 'expired' => 0,
  1539.                             )
  1540.                         );
  1541.                 }
  1542.                 if (!$LiveSupportMeetingRoom) {
  1543.                     $LiveSupportMeetingRoom = new LiveSupportMeetingRoom();
  1544.                     $LiveSupportMeetingRoom->setHostId($hostId);
  1545.                     $LiveSupportMeetingRoom->setOccupiedByApplicant(0);
  1546.                     $LiveSupportMeetingRoom->setMeetingRoomCode(MiscActions::GenerateRandomCrypto('LVS' microtime(true)));
  1547.                 }
  1548.                 $LiveSupportMeetingRoom->setLiveFlag(1);
  1549.                 $LiveSupportMeetingRoom->setExpireTs(($currDateTs) + (3600 24));
  1550.                 $LiveSupportMeetingRoom->setExpired(0);
  1551.                 $LiveSupportMeetingRoom->setStatus(GeneralConstant::ACTIVE);
  1552.                 $em->persist($LiveSupportMeetingRoom);
  1553.                 $em->flush();
  1554.                 $isAllowed true;
  1555.                 $retData = array(
  1556.                     'success' => true,
  1557.                     'action' => $action,
  1558.                     'liveSessionId' => $LiveSupportMeetingRoom->getId(),
  1559.                     'liveSessionHostId' => $LiveSupportMeetingRoom->getHostId(),
  1560.                     'liveSessionCurrentAllowedId' => $LiveSupportMeetingRoom->getCurrentAllowedId(),
  1561.                     'isAllowed' => $isAllowed,
  1562.                     'liveSessionRoomCode' => $LiveSupportMeetingRoom->getMeetingRoomCode(),
  1563.                 );
  1564.             } else if ($authorizationType == '_APPLICANT_') {
  1565.                 $retData = array(
  1566.                     'success' => false,
  1567.                     'action' => $action,
  1568.                     'liveSessionId' => 0,
  1569.                     'liveSessionHostId' => 0,
  1570.                     'liveSessionCurrentAllowedId' => 0,
  1571.                     'hasActiveLiveRooms' => 0,
  1572.                     'positionInQueue' => -1,
  1573.                     'isAllowed' => $isAllowed,
  1574.                     'liveSessionRoomCode' => '',
  1575.                 );
  1576.                 if (!$LiveSupportMeetingRoom) {
  1577.                     $LiveSupportMeetingRooms $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1578.                         ->createQueryBuilder('m')
  1579. //                        ->where("m.hostId = :hostId")
  1580.                         ->where("m.expireTs > :expireTs")
  1581.                         ->andWhere("m.expired != 1 ")
  1582.                         ->andWhere("m.liveFlag = 1 ")
  1583.                         ->andWhere("m.status = :status ")
  1584.                         ->andWhere("m.currentAllowedId = $applicantId  or (m.currentAllowedId is null and (
  1585.                         m.allowedIdList like '%,$applicantId]%' or
  1586.                         m.allowedIdList like '%,$applicantId,%' or
  1587.                         m.allowedIdList like '%[$applicantId,%'
  1588.                         ) )")
  1589. //                        ->setParameter('hostId', $hostId)
  1590.                         ->setParameter('expireTs'$currDateTs)
  1591.                         ->setParameter('status'GeneralConstant::ACTIVE)
  1592. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1593. //            ->setParameter('endAt', $endDate->format('U '))
  1594. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1595.                         ->getQuery()
  1596.                         ->setMaxResults(1)
  1597.                         ->getResult();
  1598.                     $LiveSupportMeetingRoom = isset($LiveSupportMeetingRooms[0]) ? $LiveSupportMeetingRooms[0] : null;
  1599.                 }
  1600.                 if ($LiveSupportMeetingRoom && $LiveSupportMeetingRoom->getLiveFlag() == 1) {
  1601.                     $currentAllowedIds json_decode($LiveSupportMeetingRoom->getAllowedIdList(), true);
  1602.                     if ($currentAllowedIds == null$currentAllowedIds = [];
  1603.                     if ($LiveSupportMeetingRoom->getCurrentAllowedId() == $applicantId || in_array($applicantId$currentAllowedIds) || (empty($currentAllowedIds) && $joinIfAllowedIdsEmpty == 1)) {
  1604.                         $LiveSupportMeetingRoom->setCurrentAllowedId($applicantId);
  1605. //                        $currentAllowedIds[] = 1 * $applicantId;
  1606.                         $currentAllowedIds array_merge($currentAllowedIdsarray_diff([$applicantId], $currentAllowedIds));
  1607.                         $LiveSupportMeetingRoom->setAllowedIdList(json_encode($currentAllowedIds));
  1608.                         $LiveSupportMeetingRoom->setExpireTs(($currDateTs) + (3600 24));
  1609.                         $LiveSupportMeetingRoom->setExpired(0);
  1610.                         $LiveSupportMeetingRoom->setOccupiedByApplicant(1);
  1611.                         $LiveSupportMeetingRoom->setStatus(GeneralConstant::ACTIVE);
  1612.                         $em->flush();
  1613.                         $isAllowed true;
  1614.                         $retData['success'] = true;
  1615.                         $retData['liveSessionId'] = $LiveSupportMeetingRoom->getId();
  1616.                         $retData['isAllowed'] = $isAllowed;
  1617.                         $retData['liveSessionRoomCode'] = $LiveSupportMeetingRoom->getMeetingRoomCode();
  1618.                         $retData['liveSessionHostId'] = $LiveSupportMeetingRoom->getHostId();
  1619.                         $retData['liveSessionCurrentAllowedId'] = $LiveSupportMeetingRoom->getCurrentAllowedId();
  1620.                         $thisApplicantQueue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1621.                             ->findOneBy(
  1622.                                 array(
  1623.                                     'applicantId' => $applicantId,
  1624.                                     'expired' => 0,
  1625.                                 )
  1626.                             );
  1627.                         $em->remove($thisApplicantQueue);
  1628.                         $em->flush();
  1629.                     } else {
  1630.                         $retData['success'] = false;
  1631.                         $retData['isAllowed'] = $isAllowed;
  1632.                     }
  1633.                 }
  1634.             }
  1635.         }
  1636.         if ($action == '_CHECK_') {
  1637.             $isAllowed false;
  1638.             $position_in_queue = -1;
  1639.             $retData = array(
  1640.                 'success' => false,
  1641.                 'checkSuccess' => false,
  1642.                 'action' => $action,
  1643.                 'liveSessionId' => 0,
  1644.                 'liveSessionHostId' => 0,
  1645.                 'hasActiveLiveRooms' => 0,
  1646.                 'positionInQueue' => $position_in_queue,
  1647.                 'isAllowed' => $isAllowed,
  1648.                 'liveSessionRoomCode' => '',
  1649.             );
  1650.             if ($hasActiveLiveRoomsFlag == 1) {
  1651.                 $ActiveLiveSupportMeetingRooms $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1652.                     ->createQueryBuilder('m')
  1653. //                        ->where("m.hostId = :hostId")
  1654.                     ->where("m.expireTs > :expireTs")
  1655.                     ->andWhere("m.expired != 1 ")
  1656.                     ->andWhere("m.liveFlag = 1 ")
  1657.                     ->andWhere("m.status = :status ")
  1658. //                        ->setParameter('hostId', $hostId)
  1659.                     ->setParameter('expireTs'$currDateTs)
  1660.                     ->setParameter('status'GeneralConstant::ACTIVE)
  1661. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1662. //            ->setParameter('endAt', $endDate->format('U '))
  1663. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1664.                     ->getQuery()
  1665.                     ->setMaxResults(1)
  1666.                     ->getResult();
  1667.                 $retData['hasActiveLiveRooms'] = isset($ActiveLiveSupportMeetingRooms[0]) ? true false;
  1668.                 $retData['checkSuccess'] = isset($ActiveLiveSupportMeetingRooms[0]) ? true false;
  1669.             }
  1670.             $thisApplicantQueue null;
  1671.             if ($hasActiveLiveRoomsFlag == && !$retData['hasActiveLiveRooms']) {
  1672.                 $queJoinPassed false;
  1673.                 $retData['checkSuccess'] = false;
  1674.             } else if ($queueJoinFlag == 1) {
  1675.                 $thisApplicantQueue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1676.                     ->findOneBy(
  1677.                         array(
  1678.                             'applicantId' => $applicantId,
  1679.                             'expired' => 0,
  1680.                         )
  1681.                     );
  1682.                 if (!$thisApplicantQueue) {
  1683.                     $thisApplicantQueue = new LiveSupportMeetingQueue();
  1684.                     $thisApplicantQueue->setApplicantId($applicantId);
  1685.                     $thisApplicantQueue->setLiveSupportMeetingRoomCode('_UNSET_');
  1686.                     $thisApplicantQueue->setRemoveOnNextFailedConfirmation(0);
  1687.                     $thisApplicantQueue->setSecondsBeforeExpiryIfNotConfirmed(30);
  1688.                     $thisApplicantQueue->setAutoExpireTsWhenAtFront(0);
  1689.                     $thisApplicantQueue->setExpireTs(($currDateTs) + (3600 24));
  1690.                     $thisApplicantQueue->setExpired(0);
  1691.                     $thisApplicantQueue->setStatus(GeneralConstant::ACTIVE);
  1692.                     $em->persist($thisApplicantQueue);
  1693.                     $em->flush();
  1694.                 }
  1695.                 if ($thisApplicantQueue) {
  1696.                     $position_in_queue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1697.                         ->createQueryBuilder('m')
  1698.                         ->select("count(m)")
  1699.                         ->where("m.id < " $thisApplicantQueue->getId())
  1700.                         ->getQuery()
  1701.                         ->getSingleScalarResult();
  1702.                     $retData['positionInQueue'] = $position_in_queue;
  1703.                     $retData['checkSuccess'] = true;
  1704.                 }
  1705.             }
  1706.             if ($position_in_queue == 0) {
  1707.                 if (!$LiveSupportMeetingRoom) {
  1708.                     $LiveSupportMeetingRooms $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1709.                         ->createQueryBuilder('m')
  1710. //                        ->where("m.hostId = :hostId")
  1711.                         ->where("m.expireTs > :expireTs")
  1712.                         ->andWhere("m.expired != 1 ")
  1713.                         ->andWhere("m.liveFlag = 1 ")
  1714.                         ->andWhere("m.status = :status ")
  1715.                         ->andWhere("m.occupiedByApplicant = 0 ")
  1716.                         ->orWhere("m.currentAllowedId = $applicantId  or (m.currentAllowedId is null and (
  1717.                         m.allowedIdList like '%,$applicantId]%' or
  1718.                         m.allowedIdList like '%,$applicantId,%' or
  1719.                         m.allowedIdList like '%[$applicantId,%'
  1720.                         ) )")
  1721. //                        ->setParameter('hostId', $hostId)
  1722.                         ->setParameter('expireTs'$currDateTs)
  1723.                         ->setParameter('status'GeneralConstant::ACTIVE)
  1724. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1725. //            ->setParameter('endAt', $endDate->format('U '))
  1726. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1727.                         ->getQuery()
  1728.                         ->setMaxResults(1)
  1729.                         ->getResult();
  1730.                     $LiveSupportMeetingRoom = isset($LiveSupportMeetingRooms[0]) ? $LiveSupportMeetingRooms[0] : null;
  1731.                 }
  1732.                 if ($LiveSupportMeetingRoom) {
  1733.                     $currentAllowedIds json_decode($LiveSupportMeetingRoom->getAllowedIdList(), true);
  1734.                     if ($currentAllowedIds == null$currentAllowedIds = [];
  1735. //                    $currentAllowedIds[] = 1 * $applicantId;
  1736.                     $currentAllowedIds array_merge($currentAllowedIdsarray_diff([$applicantId], $currentAllowedIds));
  1737.                     $LiveSupportMeetingRoom->setAllowedIdList(json_encode($currentAllowedIds));
  1738.                     if ($thisApplicantQueue)
  1739.                         if ($thisApplicantQueue->getAutoExpireTsWhenAtFront() == 0)
  1740.                             $thisApplicantQueue->setAutoExpireTsWhenAtFront($currDateTs 60);
  1741.                     $em->flush();
  1742.                     $isAllowed true;
  1743.                     $queJoinPassed true;
  1744.                     $retData['success'] = true;
  1745.                     $retData['liveSessionId'] = $LiveSupportMeetingRoom->getId();
  1746.                     $retData['isAllowed'] = $isAllowed;
  1747.                     $retData['liveSessionRoomCode'] = $LiveSupportMeetingRoom->getMeetingRoomCode();
  1748.                     $retData['liveSessionHostId'] = $LiveSupportMeetingRoom->getHostId();
  1749.                 } else {
  1750.                     $retData['success'] = false;
  1751.                     $retData['isAllowed'] = $isAllowed;
  1752.                 }
  1753.             } else {
  1754.                 $firstOneInQueue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1755.                     ->findOneBy(
  1756.                         array(
  1757. //                            'applicantId' => $applicantId,
  1758.                             'expired' => 0,
  1759.                         ), array(
  1760.                             'id' => 'desc'
  1761.                         )
  1762.                     );
  1763.                 if ($firstOneInQueue) {
  1764.                     $firstOneInQueueApplicantId $firstOneInQueue->getApplicantId();
  1765.                     if (!$LiveSupportMeetingRoom) {
  1766.                         $LiveSupportMeetingRooms $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1767.                             ->createQueryBuilder('m')
  1768. //                        ->where("m.hostId = :hostId")
  1769.                             ->where("m.expireTs > :expireTs")
  1770.                             ->andWhere("m.expired != 1 ")
  1771.                             ->andWhere("m.liveFlag = 1 ")
  1772.                             ->andWhere("m.status = :status ")
  1773.                             ->andWhere("m.occupiedByApplicant = 0 ")
  1774.                             ->orWhere("m.currentAllowedId = $firstOneInQueueApplicantId  or (m.currentAllowedId is null and (
  1775.                         m.allowedIdList like '%,$firstOneInQueueApplicantId]%' or
  1776.                         m.allowedIdList like '%,$firstOneInQueueApplicantId,%' or
  1777.                         m.allowedIdList like '%[$firstOneInQueueApplicantId,%'
  1778.                         ) )")
  1779. //                        ->setParameter('hostId', $hostId)
  1780.                             ->setParameter('expireTs'$currDateTs)
  1781.                             ->setParameter('status'GeneralConstant::ACTIVE)
  1782. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1783. //            ->setParameter('endAt', $endDate->format('U '))
  1784. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1785.                             ->getQuery()
  1786.                             ->setMaxResults(1)
  1787.                             ->getResult();
  1788.                         $LiveSupportMeetingRoom = isset($LiveSupportMeetingRooms[0]) ? $LiveSupportMeetingRooms[0] : null;
  1789.                     }
  1790.                     if ($LiveSupportMeetingRoom) {
  1791.                         if ($firstOneInQueue->getAutoExpireTsWhenAtFront() == 0) {
  1792.                             $firstOneInQueue->getAutoExpireTsWhenAtFront($currDateTs 60);
  1793.                         } else if ($firstOneInQueue->getAutoExpireTsWhenAtFront() <= $currDateTs) {
  1794.                             $em->remove($firstOneInQueue);
  1795.                         }
  1796.                         $em->flush();
  1797.                     }
  1798.                 }
  1799.                 $em->flush();
  1800.             }
  1801.         }
  1802.         if ($action == '_CONFIRMATION_FAILED_') {
  1803.             $isAllowed false;
  1804.             $position_in_queue = -1;
  1805.             $retData = array(
  1806.                 'success' => false,
  1807.                 'action' => $action,
  1808.                 'liveSessionId' => 0,
  1809.                 'hasActiveLiveRooms' => 0,
  1810.                 'positionInQueue' => $position_in_queue,
  1811.                 'isAllowed' => $isAllowed,
  1812.                 'liveSessionRoomCode' => '',
  1813.             );
  1814.             $thisApplicantQueue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1815.                 ->findOneBy(
  1816.                     array(
  1817.                         'applicantId' => $applicantId,
  1818.                         'expired' => 0,
  1819.                     )
  1820.                 );
  1821. //                if (!$thisApplicantQueue) {
  1822. //                    $thisApplicantQueue = new LiveSupportMeetingQueue();
  1823. //
  1824. //                    $thisApplicantQueue->setApplicantId($applicantId);
  1825. //                    $thisApplicantQueue->setLiveSupportMeetingRoomCode('_UNSET_');
  1826. //                    $thisApplicantQueue->setRemoveOnNextFailedConfirmation(0);
  1827. //                    $thisApplicantQueue->setSecondsBeforeExpiryIfNotConfirmed(30);
  1828. //
  1829. //
  1830. //                    $thisApplicantQueue->setExpireTs((1 * $currDateTs) + (3600 * 24));
  1831. //                    $thisApplicantQueue->setExpired(0);
  1832. //                    $thisApplicantQueue->setStatus(GeneralConstant::ACTIVE);
  1833. //                    $em->persist($thisApplicantQueue);
  1834. //                    $em->flush();
  1835. //                }
  1836.             if ($thisApplicantQueue) {
  1837.                 $thisApplicantQueue->setAutoExpireTsWhenAtFront(0);
  1838.                 $em->flush();
  1839.                 if ($thisApplicantQueue->getRemoveOnNextFailedConfirmation() == 1) {
  1840.                     $em->remove($thisApplicantQueue);
  1841.                     $em->flush();
  1842.                     $thisApplicantQueue null;
  1843.                 }
  1844.             }
  1845.             if ($thisApplicantQueue) {
  1846.                 $nextApplicants $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1847.                     ->createQueryBuilder('m')
  1848. //                        ->where("m.hostId = :hostId")
  1849.                     ->where("m.expireTs > :expireTs")
  1850.                     ->andWhere("m.expired != 1 ")
  1851.                     ->andWhere("m.liveFlag = 1 ")
  1852.                     ->andWhere("m.status = :status ")
  1853.                     ->andWhere("m.currentAllowedId = $applicantId  or (m.currentAllowedId is null and (
  1854.                         m.allowedIdList like '%,$applicantId]%' or
  1855.                         m.allowedIdList like '%,$applicantId,%' or
  1856.                         m.allowedIdList like '%[$applicantId,%'
  1857.                         ) )")
  1858. //                        ->setParameter('hostId', $hostId)
  1859.                     ->setParameter('expireTs'$currDateTs)
  1860.                     ->setParameter('status'GeneralConstant::ACTIVE)
  1861. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  1862. //            ->setParameter('endAt', $endDate->format('U '))
  1863. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  1864.                     ->getQuery()
  1865.                     ->setMaxResults(1)
  1866.                     ->getResult();
  1867.                 $nextApplicantQue = isset($nextApplicants[0]) ? $nextApplicants[0] : null;
  1868.                 if ($nextApplicantQue) {
  1869.                     $thisApplicantQueue->setApplicantId($nextApplicantQue->getApplicantId());
  1870.                     $nextApplicantQue->setApplicantId($applicantId);
  1871.                     $nextApplicantQue->setRemoveOnNextFailedConfirmation(1);
  1872.                     $em->flush();
  1873.                     $position_in_queue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1874.                         ->createQueryBuilder('m')
  1875.                         ->select("count(m)")
  1876.                         ->where("m.id < " $nextApplicantQue->getId())
  1877.                         ->getQuery()
  1878.                         ->getSingleScalarResult();
  1879.                     $retData['positionInQueue'] = $position_in_queue;
  1880.                 } else {
  1881.                     $thisApplicantQueue->setRemoveOnNextFailedConfirmation(1);
  1882.                     $em->flush();
  1883.                     $position_in_queue $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingQueue')
  1884.                         ->createQueryBuilder('m')
  1885.                         ->select("count(m)")
  1886.                         ->where("m.id < " $thisApplicantQueue->getId())
  1887.                         ->getQuery()
  1888.                         ->getSingleScalarResult();
  1889.                     $retData['positionInQueue'] = $position_in_queue;
  1890.                 }
  1891.             }
  1892.         }
  1893.         if ($action == '_LEAVE_') {
  1894.             $isAllowed false;
  1895.             if ($authorizationType == '_HOST_') {
  1896.                 if (!$LiveSupportMeetingRoom && $hostId != 0) {
  1897.                     $LiveSupportMeetingRoom $em->getRepository('CompanyGroupBundle\\Entity\\LiveSupportMeetingRoom')
  1898.                         ->findOneBy(
  1899.                             array(
  1900.                                 'hostId' => $hostId,
  1901.                                 'expired' => 0,
  1902.                             )
  1903.                         );
  1904.                 }
  1905.                 if (!$LiveSupportMeetingRoom) {
  1906.                 } else {
  1907.                     $LiveSupportMeetingRoom->setLiveFlag(0);
  1908.                     $em->flush();
  1909.                     $isAllowed true;
  1910.                     $retData = array(
  1911.                         'success' => true,
  1912.                         'action' => $action,
  1913.                         'liveSessionId' => $LiveSupportMeetingRoom->getId(),
  1914.                         'isAllowed' => $isAllowed,
  1915.                         'liveSessionRoomCode' => $LiveSupportMeetingRoom->getMeetingRoomCode(),
  1916.                     );
  1917.                 }
  1918.             } else if ($authorizationType == '_APPLICANT_') {
  1919.                 if ($LiveSupportMeetingRoom) {
  1920.                     if ($applicantId == '_AUTO_')
  1921.                         $applicantId $LiveSupportMeetingRoom->getCurrentAllowedId();
  1922.                     $currentAllowedIds json_decode($LiveSupportMeetingRoom->getAllowedIdList(), true);
  1923.                     if ($currentAllowedIds == null$currentAllowedIds = [];
  1924.                     $LiveSupportMeetingRoom->setAllowedIdList(json_encode(array_diff([$applicantId], $currentAllowedIds)));
  1925.                     $LiveSupportMeetingRoom->setOccupiedByApplicant(0);
  1926.                     if ($LiveSupportMeetingRoom->getCurrentAllowedId() == $applicantId$LiveSupportMeetingRoom->setCurrentAllowedId(null);
  1927.                     $em->flush();
  1928.                     $isAllowed false;
  1929.                     $retData = array(
  1930.                         'success' => true,
  1931.                         'action' => $action,
  1932.                         'liveSessionId' => $LiveSupportMeetingRoom->getId(),
  1933.                         'isAllowed' => $isAllowed,
  1934.                         'liveSessionRoomCode' => $LiveSupportMeetingRoom->getMeetingRoomCode(),
  1935.                     );
  1936.                 } else {
  1937.                     $retData = array(
  1938.                         'success' => false,
  1939.                         'action' => $action,
  1940.                         'isAllowed' => $isAllowed,
  1941.                     );
  1942.                 }
  1943.             }
  1944.         }
  1945.         $retData['silent'] = $silent;
  1946.         return new JsonResponse($retData);
  1947.     }
  1948.     public function addApplicantToLiveSupportMeetingRoomAction(Request $request$id 0)
  1949.     {
  1950.         $em $this->getDoctrine()->getManager('company_group');
  1951.         $session $request->getSession();
  1952. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  1953. //        $comm = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  1954. //            ->findOneBy(
  1955. //                array(
  1956. //                    'targetId'=>$request->request->get('targetId',0)
  1957. //                )
  1958. //            );
  1959.         $userId $session->get(UserConstants::USER_ID);
  1960.         return new JsonResponse(array(
  1961.             'success' => true
  1962.         ));
  1963.     }
  1964.     public function testPushNotificationAction(Request $request$id 0)
  1965.     {
  1966.         $em $this->getDoctrine()->getManager('company_group');
  1967.         $session $request->getSession();
  1968.         System::sendPushNotification(['cnX9xvw9Ri2Fn3MUANOxqi:APA91bEMXJZpVv12JbjTgJXKXzn3300Nwtzpnq1zfcNYDtcJG2hZfpVxRtW1MHOLlA_NoPHHApK7489UPlsytL1BO4pv2bxj1QFDRx4t3QHcSsk_dzHINy68EDz171E17bs2LgQM5r0A'],
  1969.             $this->container->getParameter('kernel.root_dir')
  1970.         );
  1971. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  1972. //        $comm = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  1973. //            ->findOneBy(
  1974. //                array(
  1975. //                    'targetId'=>$request->request->get('targetId',0)
  1976. //                )
  1977. //            );
  1978.         $userId $session->get(UserConstants::USER_ID);
  1979.         return new JsonResponse(array(
  1980.             'success' => true
  1981.         ));
  1982.     }
  1983.     public function removeApplicantFromLiveSupportMeetingRoomAction(Request $request$id 0)
  1984.     {
  1985.         $em $this->getDoctrine()->getManager('company_group');
  1986.         $session $request->getSession();
  1987. //        $dt = Inventory::GetDrDetails($em, $id, $item_i
  1988. //        $comm = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  1989. //            ->findOneBy(
  1990. //                array(
  1991. //                    'targetId'=>$request->request->get('targetId',0)
  1992. //                )
  1993. //            );
  1994.         $userId $session->get(UserConstants::USER_ID);
  1995.         return new JsonResponse(array(
  1996.             'success' => true
  1997.         ));
  1998.     }
  1999.     public function PricingWithSessionAction(Request $request$id)
  2000.     {
  2001.         $em_goc $this->getDoctrine()->getManager('company_group');
  2002.         $session $request->getSession();
  2003.         $invoiceId 0;
  2004.         $topic null;
  2005.         $scheduleId 0;
  2006.         $consultantDetails null;
  2007.         $consultantId 0;
  2008.         $sessionId 0;
  2009.         $topicSessionValue 0;
  2010.         $consultantSchedule null;
  2011.         $scheduleText '';
  2012.         $autoRedirected 0;
  2013.         $autoAssignMeetingSession 0;
  2014.         $sessionConsumeCount $request->request->get('sessionConsumeCount'$request->request->get('sessionDurationSelector'1));
  2015.         $sessionDuration $sessionConsumeCount 30;
  2016.         $meetingSessionId 0;
  2017.         $requiredPurchaseSessionCount $sessionConsumeCount;
  2018.         $packageNames BuddybeeConstant::$packageNames;
  2019.         $packageDetails BuddybeeConstant::$packageDetails;
  2020.         $userId $session->get(UserConstants::USER_ID);
  2021.         if ($request->isMethod('GET') && $request->query->has('autoRedirected'))
  2022.             $autoRedirected $request->query->get('autoRedirected');
  2023. //        $studentDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2024.         if ($request->isMethod('POST') && $request->request->has('toPackagePage')) {
  2025.             $topicId $request->request->get('consultancyTopic');
  2026.             $sessionId $request->request->get('sessionSelector');
  2027.             $topicSessionValue $request->request->get('sessionSelector');
  2028.             $consultantId $request->request->get('consultantId');
  2029.             $scheduleId $request->request->get('consultancyScheduleId'); // this is timestamp
  2030.             $scheduleTs $request->request->get('consultancyScheduleId'); // this is timestamp
  2031. //            $sessionConsumeCount = $request->request->get('sessionConsumeCount');
  2032.             $sessionConsumeCount $request->request->get('sessionConsumeCount'$request->request->get('sessionDurationSelector'1));
  2033.             $sessionDuration $sessionConsumeCount 30;
  2034.             $autoAssignMeetingSession 1;
  2035.             //$topic = $em->getRepository(ConsultancyTopic::class)->findAll();
  2036. //            $scheduleText = isset($schdeuledTime[$scheduleId]) ? $schdeuledTime[$scheduleId]['date'] . ' ' . $schdeuledTime[$scheduleId]['startTime'] : '';
  2037.             $scheduleTextDate = new \DateTime('@' $scheduleId);;
  2038.             $scheduleText $scheduleTextDate->format('F d, Y H:i');
  2039.             $currentUserBalance 0;
  2040.             $gatewayAmount 0;
  2041.             $redeemedAmount 0;
  2042.             $redeemedSessionCount 0;
  2043.             $payableAmount 0;
  2044.             $totalAmount 0;
  2045.             $totalSessionCount 0;
  2046.             $consumedAmount 0;
  2047.             $consumedSessionCount $request->request->get('sessionDurationSelector'0);
  2048.             $currentUserSessionBalance 0;
  2049.             $currentUserBalance 0;
  2050.             $balancedFromUserSessionCount 0;
  2051.             $balancedFromUserBalance 0;
  2052.             $studentId 0;
  2053.             if ($session->get(UserConstants::USER_ID)
  2054.                 && $session->get(UserConstants::USER_TYPE) == UserConstants::USER_TYPE_APPLICANT
  2055.             ) {
  2056.                 $studentDetails null;
  2057.                 $studentDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2058.                 if ($studentDetails) {
  2059.                     $currentUserBalance $studentDetails->getAccountBalance();
  2060.                     $currentUserSessionBalance $studentDetails->getSessionCountBalance();
  2061.                     $studentId $studentDetails->getApplicantId();
  2062.                 }
  2063.                 if ($consumedSessionCount <= $currentUserSessionBalance) {
  2064.                     $balancedFromUserSessionCount 1;
  2065.                 }
  2066.                 //1st do the necessary
  2067.                 $beeCode $request->request->get('beeCode''');
  2068.                 $payableAmount $request->request->get('payableAmount'0);
  2069.                 $scheduledStartTime = new \DateTime('@' $scheduleId);;
  2070.                 if ($balancedFromUserSessionCount == 1) {
  2071. //                    $session->set('hasCoin',1);
  2072.                     $scheduleValidity MiscActions::CheckIfScheduleCanBeConfirmed(
  2073.                         $em_goc,
  2074.                         $request->request->get('consultantId'0),
  2075.                         $studentId,
  2076.                         $scheduledStartTime->format('U'),
  2077.                         (30 $consumedSessionCount),
  2078.                         1
  2079.                     );
  2080.                     if (!$scheduleValidity) {
  2081.                         $url $this->generateUrl(
  2082.                             'consultant_profile'
  2083.                         );
  2084.                         $output = [
  2085.                             'page_title' => 'Package And Pricing',
  2086. //                            'topic' => $topic,
  2087. //                            'consultantDetails' => $consultantDetails,
  2088.                             'packageDetails' => MiscActions::toListArray($packageDetails),
  2089.                             'packageNames' => MiscActions::toListArray($packageNames),
  2090.                             'scheduleId' => $scheduleId,
  2091.                             'consultantId' => $consultantId,
  2092.                             'topicSessionValue' => $topicSessionValue,
  2093.                             'autoRedirected' => $autoRedirected,
  2094.                             'meetingSessionId' => $meetingSessionId,
  2095.                             'invoiceId' => $invoiceId,
  2096.                             'sessionConsumeCount' => $sessionConsumeCount,
  2097.                             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  2098.                             'autoAssignMeetingSession' => $autoAssignMeetingSession,
  2099.                             'sessionDuration' => $sessionDuration,
  2100. //                            'consultantSchedule' => $consultantSchedule,
  2101.                             'scheduleText' => $scheduleText,
  2102.                             'userId' => $userId,
  2103. //                            'timeSchedule' => $consultantSchedule,
  2104.                             'proceedToCheckout' => 0,
  2105.                             'errorFlag' => 1,
  2106.                             'redirectUrl' => $url,
  2107.                             'message' => 'Session Booking Expired or not Found!',
  2108.                         ];
  2109.                         if ($request->request->has('returnJson'))
  2110.                             return new JsonResponse($output);
  2111.                         else
  2112.                             return $this->redirect($url '/' $request->request->get('consultantId'0) . '?errorFlag=1&message=Session Booking Expired or not Found');
  2113.                     }
  2114.                     $new = new EntityMeetingSession();
  2115.                     $new->setTopicId($request->request->get('consultancyTopic'0));
  2116.                     $new->setConsultantId($request->request->get('consultantId'0));
  2117.                     $new->setStudentId($studentId);
  2118.                     $consultancyTopic $em_goc->getRepository(EntityMeetingSession::class)->find($request->request->get('consultancyTopic'0));
  2119.                     $new->setMeetingType($consultancyTopic $consultancyTopic->getMeetingType() : 0);
  2120.                     $new->setConsultantCanUpload($consultancyTopic $consultancyTopic->getConsultantCanUpload() : 0);
  2121.                     $scheduledEndTime = new \DateTime('@' $scheduleId);;
  2122.                     $scheduledEndTime $scheduledEndTime->modify('+' . (30 $consumedSessionCount) . ' Minute');
  2123. //                    $scheduledStartTime->setTimezone(new \DateTimeZone('UTC'));
  2124. //                    $scheduledEndTime->setTimezone(new \DateTimeZone('UTC'));
  2125.                     //$new->setScheduledTime($request->request->get('setScheduledTime'));
  2126.                     $new->setScheduledTime($scheduledStartTime);
  2127.                     $new->setScheduledTimeTs($scheduledStartTime->format('U'));
  2128.                     $new->setDurationAllowedMin((30 $consumedSessionCount));
  2129.                     $new->setDurationLeftMin((30 $consumedSessionCount));
  2130.                     $new->setSessionExpireDate($scheduledEndTime);
  2131.                     $new->setSessionExpireDateTs($scheduledEndTime->format('U'));
  2132.                     $new->setEquivalentSessionCount($consumedSessionCount);
  2133.                     $new->setUsableSessionCount($consumedSessionCount);
  2134.                     $new->setMeetingActionFlag(0);// no action waiting for meeting
  2135.                     $new->setPayableAmount($payableAmount);
  2136.                     $new->setDueAmount($request->request->get('dueAmount'0));
  2137.                     $currentUnixTime = new \DateTime();
  2138.                     $currentUnixTimeStamp $currentUnixTime->format('U');
  2139. //                    $studentId = $request->request->get('studentId', $session->get(UserConstants::USER_ID));
  2140.                     $consultantId $request->request->get('consultantId'0);
  2141.                     $new->setMeetingRoomId(str_pad($consultantId4STR_PAD_LEFT) . $currentUnixTimeStamp str_pad($studentId4STR_PAD_LEFT));
  2142.                     //$new->setScheduledTime(new \DateTime($request->get('setScheduledTime')));
  2143.                     //$new->setPcakageDetails(json_encode(($request->request->get('packageData'))));
  2144.                     $new->setPackageName(($request->request->get('packageName''')));
  2145.                     $new->setPcakageDetails(($request->request->get('packageData''')));
  2146.                     $new->setScheduleId($scheduleId);
  2147.                     $new->setSessionValue($topicSessionValue);
  2148. //                    $new->setIsPayment(0);
  2149.                     $new->setConsultantIsPaidFull(0);
  2150.                     $em_goc->persist($new);
  2151.                     $em_goc->flush();
  2152.                     $meetingSessionId $new->getSessionId();
  2153. //                            $studentDetails->setSessionCountBalance($currentUserSessionBalance-$consumedSessionCount);
  2154. //                            $studentDetails->setTotalSessionUsed($studentDetails->getTotalSessionUsed()+$consumedSessionCount);
  2155.                     $em_goc->flush();
  2156.                     $new_invoice = new EntityInvoice();
  2157.                     $invoiceDate = new \DateTime();
  2158.                     $new_invoice->setInvoiceDate($invoiceDate);
  2159.                     $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  2160.                     $new_invoice->setStudentId($studentId);
  2161.                     $new_invoice->setMeetingId($meetingSessionId);
  2162.                     $new_invoice->setAmount($totalAmount);
  2163.                     $new_invoice->setGatewayBillAmount($gatewayAmount);
  2164.                     $new_invoice->setRedeemedAmount($redeemedAmount);
  2165.                     $new_invoice->setRedeemedSessionCount($redeemedSessionCount);
  2166.                     $new_invoice->setPaidAmount(0);
  2167.                     $new_invoice->setDueAmount(0);
  2168.                     $new_invoice->setInvoiceType(1);
  2169.                     $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  2170.                     $new_invoice->setAmountType(1);
  2171.                     $new_invoice->setConsumeAmount(0);
  2172.                     $new_invoice->setSessionCount(0);
  2173.                     $new_invoice->setConsumeSessionCount($consumedSessionCount);
  2174.                     $new_invoice->setIsPaidfull(0);
  2175.                     $new_invoice->setIsProcessed(0);
  2176.                     $new_invoice->setApplicantId($studentId);
  2177.                     $new_invoice->setIsRecharge(0);
  2178.                     $new_invoice->setStage(BuddybeeConstant::ENTITY_INVOICE_STAGE_INITIATED);
  2179.                     $new_invoice->setIsPayment(0); //0 means receive
  2180.                     $new_invoice->setStatus(GeneralConstant::ACTIVE); //0 means receive
  2181. //            $new_invoice->setStatus($request->request->get(0));
  2182.                     $em_goc->persist($new_invoice);
  2183.                     $em_goc->flush();
  2184.                     $invoiceId $new_invoice->getId();
  2185.                     $retData =  Buddybee::ProcessEntityInvoice($em_goc$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED],$this->container->getParameter('kernel.root_dir'),  false,
  2186.                         $this->container->getParameter('notification_enabled'),
  2187.                         $this->container->getParameter('notification_server')
  2188.                     );
  2189.                     MiscActions::RefreshBuddybeeBalanceOnSession($em_goc$request->getSession());
  2190.                     $meetingSessionId $retData['meetingId'];
  2191.                     if ($meetingSessionId != 0) {
  2192.                         $url $this->generateUrl(
  2193.                             'consultancy_session'
  2194.                         );
  2195.                         $output = [
  2196.                             'proceedToCheckout' => 0,
  2197.                             'redirectUrl' => $url '/' $meetingSessionId
  2198.                         ];
  2199.                     } else {
  2200.                         $url $this->generateUrl(
  2201.                             'buddybee_dashboard'
  2202.                         );
  2203.                         $output = [
  2204.                             'proceedToCheckout' => 0,
  2205.                             'redirectUrl' => $url
  2206.                         ];
  2207.                     }
  2208.                     if ($request->request->has('returnJson'))
  2209.                         return new JsonResponse($output);
  2210.                     else
  2211.                         return $this->redirect($url '/' $meetingSessionId);
  2212.                 } else {
  2213. //                    $session->set('hasCoin',0);
  2214.                     $url $this->generateUrl(
  2215.                         'pricing_plan_page_with_session'
  2216.                     );
  2217.                     $output = array(
  2218.                         'page_title' => 'Package And Pricing',
  2219. //                        'topic' => $topic,
  2220. //                        'consultantDetails' => $consultantDetails,
  2221.                         'COIN_GENERAL_MULT' => BuddybeeConstant::COIN_GENERAL_MULT,
  2222.                         'packageDetails' => MiscActions::toListArray($packageDetails),
  2223.                         'packageNames' => MiscActions::toListArray($packageNames),
  2224.                         'scheduleId' => $scheduleId,
  2225.                         'consultantId' => $consultantId,
  2226.                         'topicSessionValue' => $topicSessionValue,
  2227.                         'autoRedirected' => $autoRedirected,
  2228.                         'meetingSessionId' => $meetingSessionId,
  2229.                         'invoiceId' => $invoiceId,
  2230.                         'sessionConsumeCount' => $sessionConsumeCount,
  2231.                         'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  2232.                         'autoAssignMeetingSession' => $autoAssignMeetingSession,
  2233.                         'sessionDuration' => $sessionDuration,
  2234. //                        'consultantSchedule' => $consultantSchedule,
  2235.                         'scheduleText' => $scheduleText,
  2236.                         'userId' => $userId,
  2237. //                        'timeSchedule' => $consultantSchedule,
  2238.                         'proceedToCheckout' => 0,
  2239.                         'message' => 'Insufficient coins!',
  2240.                         'errorFlag' => 1,
  2241.                         'redirectUrl' => $url
  2242.                     );
  2243.                     if ($request->request->has('returnJson'))
  2244.                         return new JsonResponse($output);
  2245.                     else
  2246.                         return $this->redirect($url '/' $request->request->get('consultantId'0) . '?errorFlag=1&message=Not enough Coins');
  2247.                 }
  2248.             } else {
  2249.                 $url $this->generateUrl(
  2250.                     'buddybee_dashboard'
  2251.                 );
  2252.                 $output = [
  2253.                     'proceedToCheckout' => 0,
  2254.                     'redirectUrl' => $url
  2255.                 ];
  2256.                 if ($request->request->has('returnJson'))
  2257.                     return new JsonResponse($output);
  2258.                 else
  2259.                     return $this->redirect($url '/' $meetingSessionId);
  2260.             }
  2261. //
  2262.         }
  2263.         if ($userId != 0) {
  2264.             $applicantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findOneBy(array(
  2265.                 'applicantId' => $userId
  2266.             ));
  2267.             if ($applicantDetails)
  2268.                 $requiredPurchaseSessionCount $sessionConsumeCount - ($applicantDetails->getSessionCountBalance());
  2269.         }
  2270.         return $this->render('@Buddybee/pages/pricing.html.twig', array(
  2271.             'page_title' => 'Package And Pricing',
  2272. //            'topic' => $topic,
  2273.             'consultantDetails' => $consultantDetails,
  2274.             'packageDetails' => $packageDetails,
  2275.             'packageNames' => $packageNames,
  2276.             'scheduleId' => $scheduleId,
  2277.             'consultantId' => $consultantId,
  2278.             'topicSessionValue' => $topicSessionValue,
  2279.             'autoRedirected' => $autoRedirected,
  2280.             'meetingSessionId' => $meetingSessionId,
  2281.             'invoiceId' => $invoiceId,
  2282.             'sessionConsumeCount' => $sessionConsumeCount,
  2283.             'requiredPurchaseSessionCount' => $requiredPurchaseSessionCount,
  2284.             'autoAssignMeetingSession' => $autoAssignMeetingSession,
  2285.             'sessionDuration' => $sessionDuration,
  2286.             'consultantSchedule' => $consultantSchedule,
  2287.             'scheduleText' => $scheduleText,
  2288.             'userId' => $userId,
  2289.             'timeSchedule' => $consultantSchedule
  2290.         ));
  2291. //        return $this->render('@Buddybee/pages/pricing.html.twig', array(
  2292. //            'page_title' => 'Package And Pricing',
  2293. //        ));
  2294.     }
  2295.     public function Profile(Request $request$id)
  2296.     {
  2297.         $em $this->getDoctrine()->getManager('company_group');
  2298.         $session $request->getSession();
  2299.         if ($id != 0)
  2300.             $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  2301.         else
  2302.             $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2303. //        $review = $em->getRepository('CompanyGroupBundle\\Entity\\EntityReview')->findBy(
  2304. //            array(
  2305. //                'consultantId' => $consultantDetails->getApplicantId()
  2306. //            )
  2307. //        );
  2308. //        $meetingSession = $em->getRepository(EntityMeetingSession::class)->findBy(
  2309. //            array(
  2310. //                'studentId' => $consultantDetails->getApplicantId(),
  2311. //            )
  2312. //        );
  2313. //        $topic = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(
  2314. //            array(
  2315. //
  2316. //            )
  2317. //        );
  2318. //        $timeSchedule = array(
  2319. //            'date' => $request->get('date'),
  2320. //            'startTime' => $request->get('startTime'),
  2321. //            'endTIme' => $request->get('endTime'),
  2322. //        );
  2323.         if ($request->isMethod('POST')) {
  2324.             $timeSchedule = [];
  2325.             $clearOld $request->request->get('clearOld'1);
  2326.             $rowCount $request->request->get('rowCount', []);
  2327.             $scheduleData $request->request->get('scheduleData', []);
  2328.             if (is_string($scheduleData)) $scheduleData json_decode($scheduleDatatrue);
  2329.             if ($scheduleData == null$scheduleData = [];
  2330.             foreach ($rowCount as $key => $val) {
  2331.                 if ($request->get('scheduleType')[$key] == '' || ($request->get('scheduleType')[$key] == && $request->get('dow_' $val, []) == [])
  2332.                     || ($request->get('scheduleType')[$key] == && $request->get('date')[$key] == '')
  2333.                 )
  2334.                     continue;
  2335.                 $indTimeSche = array(
  2336.                     'id' => $request->request->has('id') ? $request->request->get('id')[$key] : 0,
  2337.                     'date' => $request->get('date')[$key],
  2338.                     'dateUpto' => $request->get('dateUpto')[$key],
  2339.                     'type' => $request->get('scheduleType')[$key],  // 0=specific date 1=every mentioned day of month 2=every mentioned day of week
  2340. //                    'dom' => $request->get('dom')[$key],  // based on type
  2341.                     'dow' => $request->get('dow_' $val),  // based on type
  2342.                     'startTime' => $request->get('startTime')[$key],
  2343.                     'endTime' => $request->get('endTime')[$key],
  2344.                     'timeZone' => $request->get('consultant_timezone_' $val$request->get('consultant_timezone''')),
  2345.                 );
  2346.                 $timeSchedule[] = $indTimeSche;
  2347.             }
  2348.             foreach ($scheduleData as $key => $val) {
  2349.                 if ($val['scheduleType'] == '' || ($val['scheduleType'] == && $val['dow'] == [])
  2350.                     || ($val['scheduleType'] == && $val['date'] == '')
  2351.                 )
  2352.                     continue;
  2353.                 $indTimeSche = array(
  2354.                     'id' => $val['id'],
  2355.                     'date' => $val['date'],
  2356.                     'dateUpto' => $val['dateUpto'],
  2357.                     'type' => $val['scheduleType'],  // 0=specific date 1=every mentioned day of month 2=every mentioned day of week
  2358. //                    'dom' => $request->get('dom')[$key],  // based on type
  2359.                     'dow' => $val['dow'],  // based on type
  2360.                     'startTime' => $val['startTime'],
  2361.                     'endTime' => $val['endTime'],
  2362.                     'deleteFlag' => isset($val['deleteFlag']) ? $val['deleteFlag'] : 0,
  2363.                     'timeZone' => $val['consultant_timezone'],
  2364.                 );
  2365.                 $timeSchedule[] = $indTimeSche;
  2366.             }
  2367.             $consultantSchedules $em->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findBy(
  2368.                 array(
  2369.                     'consultantId' => $request->request->get('consultantId')
  2370.                 )
  2371.             );
  2372.             if ($clearOld == 1) {
  2373.                 foreach ($consultantSchedules as $d) {
  2374.                     $em->remove($d);
  2375.                     $em->flush();
  2376.                 }
  2377.             }
  2378.             $newSchAvailableStatus 0;
  2379.             foreach ($timeSchedule as $d) {
  2380.                 $currDate = new \DateTime();
  2381.                 $startDate = new \DateTime($d['date'] . ' ' $d['startTime'] . ':00 ' $d['timeZone']);
  2382.                 $endDate = new \DateTime($d['dateUpto'] . ' ' $d['endTime'] . ':00 ' $d['timeZone']);
  2383.                 if ($endDate <= $currDate) {
  2384.                     if (isset($d['deleteFlag'])) {
  2385.                         if ($d['deleteFlag'] == 1) {
  2386.                         } else {
  2387.                             continue;
  2388.                         }
  2389.                     } else {
  2390.                         continue;
  2391.                     }
  2392.                 }
  2393.                 if ($d['id'] != 0)
  2394.                     $newSch $em->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findOneBy(
  2395.                         array(
  2396.                             'id' => $d['id']
  2397.                         )
  2398.                     );
  2399.                 else
  2400.                     $newSch = new EntityConsultantSchedule();
  2401.                 if ($d['dow'] == null$d['dow'] = [];
  2402.                 foreach ($d['dow'] as $j => $f) {
  2403.                     $d['dow'][$j] = $f;
  2404.                 }
  2405.                 $d['timeZone'] = str_pad($d['timeZone'], 5'0'STR_PAD_RIGHT);
  2406.                 $newSch->setConsultantId($request->request->get('consultantId'));
  2407.                 $newSch->setDow(json_encode($d['dow']));
  2408.                 $newSch->setTimezoneStr($d['timeZone']);
  2409.                 $newSch->setStartTime($d['startTime']);
  2410.                 $newSch->setEndTime($d['endTime']);
  2411.                 $newSch->setType($d['type']);
  2412.                 $newSch->setStartDate($startDate);
  2413.                 $newSch->setStartDateTs($startDate->format('U'));
  2414.                 $newSch->setEndDate($endDate);
  2415.                 $newSch->setEndDateTs($endDate->format('U'));
  2416.                 $newSch->setTimeSchedule(json_encode([]));
  2417. //                $newSch->setTimeSchedule(json_encode($timeSchedule));
  2418.                 if (isset($d['deleteFlag'])) {
  2419.                     if ($d['deleteFlag'] == 1)
  2420.                         $em->remove($newSch);
  2421.                     else {
  2422.                         $em->persist($newSch);
  2423.                         $newSchAvailableStatus 1;
  2424.                     }
  2425.                 } else {
  2426.                     $em->persist($newSch);
  2427.                     $newSchAvailableStatus 1;
  2428.                 }
  2429.                 $em->flush();
  2430.             }
  2431.             $consultantDetails->setScheduleAvailableFlag($newSchAvailableStatus);
  2432.             $em->flush();
  2433.             if ($request->request->has('returnJson') || $request->query->has('returnJson')) {
  2434.                 return new JsonResponse(
  2435.                     array(
  2436.                         'page_title' => '',
  2437.                         'timeSchedule' => $timeSchedule,
  2438.                         'success' => true
  2439.                     )
  2440.                 );
  2441.             }
  2442.         }
  2443.         $schedules $em->getRepository('CompanyGroupBundle\\Entity\\EntityConsultantSchedule')->findBy(array(
  2444.             'consultantId' => $consultantDetails->getApplicantId()
  2445.         ));
  2446.         $timeSchedule = [];
  2447.         foreach ($schedules as $key => $val) {
  2448.             $indTimeSche = array(
  2449.                 'date' => $val->getStartDate() ? $val->getStartDate()->format('Y-m-d') : '',
  2450.                 'dateUpto' => $val->getEndDate() ? $val->getEndDate()->format('Y-m-d') : '',
  2451.                 'type' => ($val->getType() != null && $val->getType() != '') ? $val->getType() : 2,  // 0=specific date 1=every mentioned day of month 2=every mentioned day of week
  2452. //                    'dom' => $request->get('dom')[$key],  // based on type
  2453.                 'dow' => ($val->getDow() != null && $val->getDow() != '') ? json_decode($val->getDow(), true) : [],  // based on type
  2454.                 'startTime' => $val->getStartTime(),
  2455.                 'endTime' => $val->getEndTime(),
  2456.                 'timeZone' => $val->getTimeZoneStr(),
  2457.             );
  2458.             $timeSchedule[] = $indTimeSche;
  2459.         }
  2460.         $coursePlanHistoryForThisUserAndTopic = [];
  2461.         $coursePlanHistoryForThisUserAndTopicArray = [];
  2462.         $defaultCoursePlanHistoryForThisUserAndTopic = [];
  2463.         $coursePlanForTopicArray = [];
  2464.         $coursePlanTopics = [];
  2465.         $meetingTopicIds = [];
  2466.         $meetings $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  2467.             ->findBy(
  2468.                 array(
  2469.                     'studentId' => $consultantDetails->getApplicantId()
  2470. //                    'id' => $meetingSession->getTopicId(),
  2471.                 )
  2472.             );
  2473.         foreach ($meetings as $m) {
  2474.             $meetingTopicIds[] = $m->getTopicId();
  2475.         }
  2476.         $topicsForCoursePlan $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')
  2477.             ->findBy(
  2478.                 array(
  2479.                     'id' => $meetingTopicIds,
  2480.                 )
  2481.             );
  2482.         if (!empty($topicsForCoursePlan)) {
  2483.             foreach ($topicsForCoursePlan as $topicForCoursePlan) {
  2484.                 $coursePlanForThisTopic json_decode($topicForCoursePlan->getCoursePlanData(), true);
  2485.                 if ($coursePlanForThisTopic == null$coursePlanForThisTopic BuddybeeConstant::$defaultCoursePlan;
  2486.                 $coursePlanTopics[$topicForCoursePlan->getId()] = $topicForCoursePlan;
  2487.                 $coursePlanForTopicArray[$topicForCoursePlan->getId()] = $coursePlanForThisTopic;
  2488.             }
  2489.         }
  2490.         $coursePlanHistoryForThisUserAndTopicEntryArray $em->getRepository('CompanyGroupBundle\\Entity\\EntityCoursePlanHistory')
  2491.             ->findBy(
  2492.                 array(
  2493.                     'studentId' => $consultantDetails->getApplicantId(),
  2494. //                    'topicId' => $meetingSession->getTopicId(),
  2495.                 )
  2496.             );
  2497.         $defaultCoursePlanHistoryForThisUserAndTopicEntry $em->getRepository('CompanyGroupBundle\\Entity\\EntityCoursePlanHistory')
  2498.             ->findOneBy(
  2499.                 array(
  2500.                     'studentId' => $consultantDetails->getApplicantId(),
  2501.                     'topicId' => 0//default
  2502.                 )
  2503.             );
  2504.         if ($defaultCoursePlanHistoryForThisUserAndTopicEntry) {
  2505.             $defaultCoursePlanHistoryForThisUserAndTopic json_decode($defaultCoursePlanHistoryForThisUserAndTopicEntry->getData(), true);
  2506.             if ($defaultCoursePlanHistoryForThisUserAndTopic == null$defaultCoursePlanHistoryForThisUserAndTopic = [];
  2507.         }
  2508.         if (!empty($coursePlanHistoryForThisUserAndTopicEntryArray)) {
  2509.             foreach ($coursePlanHistoryForThisUserAndTopicEntryArray as $coursePlanHistoryForThisUserAndTopicEntry) {
  2510.                 $coursePlanHistoryForThisUserAndTopic json_decode($coursePlanHistoryForThisUserAndTopicEntry->getData(), true);
  2511.                 if ($coursePlanHistoryForThisUserAndTopic == null$coursePlanHistoryForThisUserAndTopic = [];
  2512.                 $coursePlanHistoryForThisUserAndTopicArray[$coursePlanHistoryForThisUserAndTopicEntry->getTopicId()] = $coursePlanHistoryForThisUserAndTopic;
  2513.             }
  2514.         }
  2515.         return $this->render('@Buddybee/pages/profile.html.twig', array(
  2516.             'page_title' => 'Profile ',
  2517.             'consultantDetails' => $consultantDetails,
  2518.             'education' => json_decode($consultantDetails->getEducationData(), true),
  2519.             'workExperience' => json_decode($consultantDetails->getWorkExperienceData(), true),
  2520.             'certificate' => json_decode($consultantDetails->getCertificateData(), true),
  2521.             'timeSchedule' => $timeSchedule,
  2522.             'defaultCoursePlanHistoryForThisUserAndTopic' => $defaultCoursePlanHistoryForThisUserAndTopic,
  2523.             'coursePlanHistoryForThisUserAndTopicArray' => $coursePlanHistoryForThisUserAndTopicArray,
  2524.             'coursePlanForTopicArray' => $coursePlanForTopicArray,
  2525.             'coursePlanTopics' => $coursePlanTopics,
  2526.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  2527.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  2528. //            'review' => $review,
  2529. //            'meetingSession' => $meetingSession,
  2530. //            'topic'=>$topic,
  2531. //            'docData' =>  json_decode($topic->getDocumentData(),true),
  2532.         ));
  2533.     }
  2534.     public function ExtendMeetingDurationAction(Request $request$id)
  2535.     {
  2536.         $em $this->getDoctrine()->getManager('company_group');
  2537.         $session $request->getSession();
  2538.         if ($request->isMethod('POST')) {
  2539.             $meeting $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  2540.                 ->findOneBy(
  2541.                     array(
  2542.                         'sessionId' => $request->request->get('meetingId'0)
  2543. //                    'id' => $meetingSession->getTopicId(),
  2544.                     )
  2545.                 );
  2546.             if ($meeting) {
  2547.                 if (
  2548.                     $request->request->get('extendDuration'30) > &&
  2549.                     ((($meeting->getTotalExtensionMin()) + $request->request->get('extendDuration'30)) <= 10 || $request->request->get('forced'0) == 1)
  2550.                 ) {
  2551.                     $meeting->setDurationAllowedMin(($meeting->getDurationAllowedMin()) + $request->request->get('extendDuration'30));
  2552.                     $meeting->setDurationLeftMin(($meeting->getDurationLeftMin()) + $request->request->get('extendDuration'30));
  2553.                     $meeting->setTotalExtensionMin(($meeting->getTotalExtensionMin()) + $request->request->get('extendDuration'30));
  2554.                     $em->flush();
  2555.                     return new JsonResponse(
  2556.                         array(
  2557.                             'success' => true
  2558.                         )
  2559.                     );
  2560.                 } else {
  2561. //                    $meeting->setTotalExtensionMin((1*$meeting->getTotalExtensionMin())+$request->request->get('extendDuration', 30));
  2562. //                    $em->flush();
  2563.                     return new JsonResponse(
  2564.                         array(
  2565.                             'success' => false
  2566.                         )
  2567.                     );
  2568.                 }
  2569.             }
  2570.         }
  2571.         return new JsonResponse(
  2572.             array(
  2573.                 'success' => false
  2574.             )
  2575.         );
  2576.     }
  2577.     public function DocumentManagementAction(Request $request$id 0)
  2578.     {
  2579.         $em $this->getDoctrine()->getManager('company_group');
  2580.         $session $request->getSession();
  2581. //        $documentLists = $em->getRepository('CompanyGroupBundle\\Entity\\EntityCreateDocument')->findAll();;
  2582. //        $docListArray = [];
  2583. //        foreach ($documentLists as $document) {
  2584. //            $docListArray [$document->getId()] = array(
  2585. //                'id' => $document->getId(),
  2586. //                'docName' => $document->getDocumentName(),
  2587. //                'expiryDays' => $document->getExpiryDays(),
  2588. //                'processingDays' => $document->getProcessingDays(),
  2589. //                'emergencyProcessingDays' => $document->getEmergencyProcessingDays(),
  2590. //                'checklist' => json_decode($document->getCheckList()),
  2591. //
  2592. //            );
  2593. //        }
  2594.         if ($id == 0) {
  2595.             if ($request->isMethod('post'))
  2596.                 if ($request->request->has('applicantId'))
  2597.                     $id $request->request->get('applicantId');
  2598.         }
  2599.         if ($id != 0)
  2600.             $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($id);
  2601.         else {
  2602.             $id $session->get(UserConstants::USER_ID);
  2603.             $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2604.         }
  2605.         $meetingSessions $em->getRepository(EntityMeetingSession::class)->findBy(
  2606.             array(
  2607.                 'studentId' => $consultantDetails->getApplicantId(),
  2608.             )
  2609.         );
  2610.         $topicDetailsByTopicId = [];
  2611.         $topicDetailsByMeetingSessionId = [];
  2612.         $topicIds = [];
  2613.         $semesterIdsByTopicId = [];
  2614.         $topicData = [];
  2615.         $currDocIdListByTopicId=[];
  2616.         foreach ($meetingSessions as $meetingSession) {
  2617.             $topicIds[] = $meetingSession->getTopicId();
  2618.             $topic $em->getRepository(EntityCreateTopic::class)->findOneBy(
  2619.                 array(
  2620.                     'id' => $meetingSession->getTopicId(),
  2621.                 )
  2622.             );
  2623.             if ($topic) {
  2624.                 $topicData[$topic->getId()] = array(
  2625.                     'topicName' => $topic->getId(),
  2626.                     'id' => $topic->getTopicName()
  2627.                 );
  2628.                 if (!isset($semesterIdsByTopicId[$topic->getId()]))
  2629.                     $semesterIdsByTopicId[$topic->getId()] = [];
  2630.                 $semesterIdsByTopicId[$topic->getId()][] = $meetingSession->getSessionValue();
  2631.                 $docDetailsForThisTopic=json_decode($topic->getDocumentData(),true);
  2632.                 if($docDetailsForThisTopic==null)
  2633.                     $docDetailsForThisTopic=[];
  2634.                 if(!isset($currDocIdListByTopicId[$topic->getId()]))
  2635.                 {
  2636.                     $currDocIdListByTopicId[$topic->getId()]=[];
  2637.                     foreach ($docDetailsForThisTopic as $ggdt)
  2638.                     {
  2639.                         $currDocIdListByTopicId[$topic->getId()][]=$ggdt['document'];
  2640.                     }
  2641.                 }
  2642.                 $topicDetailsByTopicId [$topic->getId()] ['data'] = $topic;
  2643.                 $topicDetailsByTopicId [$topic->getId()]['sessionValue'] = $meetingSession->getSessionValue();
  2644.                 $topicDetailsByMeetingSessionId [$meetingSession->getSessionId()] ['data'] = $topic;
  2645.                 $topicDetailsByMeetingSessionId [$meetingSession->getSessionId()]['sessionValue'] = $meetingSession->getSessionValue();
  2646.             }
  2647.         }
  2648.         //file upload
  2649.         if ($consultantDetails)
  2650.             $new $consultantDetails;
  2651.         else
  2652.             $new = new EntityApplicantDetails();
  2653. //                $new->setDocumentList();
  2654. //                $new->setDocImage($request->files->get('img',[]));
  2655.         $em->persist($new);
  2656.         $em->flush();
  2657.         $defaultProductImage '';
  2658.         $image_list = [];
  2659.         $productImages = [];
  2660.         $upl_dir '';
  2661.         $documentList = array();
  2662.         $documentListByTopicId = [];
  2663.         $upl_dir $this->container->getParameter('kernel.root_dir') . '/../web/uploads/consultantDocuments/';
  2664.         $currDocList json_decode($new->getDocumentList(), true);
  2665.         if ($currDocList == null)
  2666.             $currDocList = [];
  2667.         $currDocListByTopicId json_decode($new->getDocumentListByTopicId(), true);
  2668.         if ($currDocListByTopicId == null)
  2669.             $currDocListByTopicId = [];
  2670.         $docList MiscActions::GetDocumentDataForBuddybeeApplicant($em,
  2671.             $id,
  2672. //            $topicIds,
  2673.             0,   //show all documents
  2674.             $semesterIdsByTopicId,
  2675.             '_BY_STATUS_'
  2676.         );
  2677.         return $this->render('@Buddybee/pages/consultancy_document_management.html.twig', array(
  2678.             'page_title' => 'Document Management ',
  2679.             'consultantDetails' => $consultantDetails,
  2680.             'topicDetailsByTopicId' => $topicDetailsByTopicId,
  2681.             'docListArray' => [],
  2682.             'currDocListByTopicId' => $currDocListByTopicId,
  2683.             'currDocIdListByTopicId' => $currDocIdListByTopicId,
  2684.             'currDocList' => $currDocList,
  2685.             'docList' => $docList,
  2686.             'topicData' => $topicData,
  2687.             'semesterIdsByTopicId' => $semesterIdsByTopicId,
  2688.             'thresholdAddDays' => BuddybeeConstant::$thresholdAddDays,
  2689.         ));
  2690.     }
  2691.     public function studentDashboardAction(Request $request$id 0)
  2692.     {
  2693.         $em $this->getDoctrine()->getManager('company_group');
  2694.         $session $request->getSession();
  2695.         $startDate = new \DateTime();
  2696. //        $startDate = new \DateTime();
  2697.         if ($id == 0) {
  2698.             if ($request->query->has('meetingSessionId'))
  2699.                 $id $request->query->get('meetingSessionId');
  2700.         }
  2701.         if ($request->isMethod('POST')) {
  2702.         }
  2703.         $studentDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2704.         $upcomingMeetingSessionList = [];
  2705.         $currTs $startDate->format('U');
  2706.         $currTs $currTs 1;
  2707.         $olderDateThreshold = new \DateTime();
  2708.         $olderDateThreshold->modify('-180 day');
  2709.         $topicIds = [];
  2710.         $semesterIdsByTopicId = [];
  2711.         $topicData = [];
  2712.         $meetingSession $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  2713.             ->createQueryBuilder('m')
  2714.             ->where("(m.studentId = :studentId or m.studentIds like '%".$session->get(UserConstants::USER_ID).",%' or m.studentIds like '%,".$session->get(UserConstants::USER_ID).",%' or m.studentIds like '%,".$session->get(UserConstants::USER_ID)."%')")
  2715.             ->andWhere("m.scheduledTimeTs >= :startAt ")
  2716. //            ->andWhere("m.sessionExpireDateTs <= :endAt")
  2717.             ->setParameter('studentId'$session->get(UserConstants::USER_ID))
  2718.             ->setParameter('startAt'$olderDateThreshold->format('U'))
  2719. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  2720. //            ->setParameter('endAt', $endDate->format('U '))
  2721. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  2722.             ->getQuery()
  2723.             ->setMaxResults(40)
  2724.             ->getResult();
  2725. //        $meetingSession = $em->getRepository(EntityMeetingSession::class)->findBy(
  2726. //            array(
  2727. //                'consultantId' => $session->get(UserConstants::USER_ID),
  2728. //            )
  2729. //        );
  2730.         $consultantListForMeeting = [];
  2731.         foreach ($meetingSession as $ms) {
  2732.             if ($ms->getScheduledTimeTs() >= $currTs || ($ms->getScheduledTimeTs() < $currTs && $ms->getSessionExpireDateTs() > $currTs))
  2733.                 $upcomingMeetingSessionList[] = $ms;
  2734.             $consultantListForMeeting[$ms->getConsultantId()] = $em->getRepository(EntityApplicantDetails::class)->findOneBy(
  2735.                 array(
  2736.                     'applicantId' => $ms->getConsultantId()
  2737.                 )
  2738.             );
  2739.             $topicIds[] = $ms->getTopicId();
  2740.             $topic $em->getRepository(EntityCreateTopic::class)->findOneBy(
  2741.                 array(
  2742.                     'id' => $ms->getTopicId(),
  2743.                 )
  2744.             );
  2745.             if ($topic) {
  2746.                 $topicData[$topic->getId()] = array(
  2747.                     'topicName' => $topic->getId(),
  2748.                     'id' => $topic->getTopicName()
  2749.                 );
  2750.                 if (!isset($semesterIdsByTopicId[$topic->getId()]))
  2751.                     $semesterIdsByTopicId[$topic->getId()] = [];
  2752.                 $semesterIdsByTopicId[$topic->getId()][] = $ms->getSessionValue();
  2753.                 $topicDetailsByTopicId [$topic->getId()] ['data'] = $topic;
  2754.                 $topicDetailsByTopicId [$topic->getId()]['sessionValue'] = $ms->getSessionValue();
  2755.                 $topicDetailsByMeetingSessionId [$ms->getSessionId()] ['data'] = $topic;
  2756.                 $topicDetailsByMeetingSessionId [$ms->getSessionId()]['sessionValue'] = $ms->getSessionValue();
  2757.             }
  2758.         }
  2759.         $docList MiscActions::GetDocumentDataForBuddybeeApplicant($em,
  2760.             $session->get(UserConstants::USER_ID),
  2761.             $topicIds,
  2762.             $semesterIdsByTopicId,
  2763.             '_BY_STATUS_'
  2764.         );
  2765.         $dashboardDataForApplicant MiscActions::GetDashboardDataForApplicant($em,
  2766.             $session->get(UserConstants::USER_ID),
  2767.             '_STUDENT_'
  2768.         );
  2769. //        $payableAmount = $meetingSession->getPayableAmount();
  2770. //        $consultantPaidAmount = (60/100) * $payableAmount;
  2771. //        $studentBal =  $consultantDetails->getAccountBalance();
  2772. //        $totalbalance = $consultantPaidAmount + $studentBal;
  2773.         return $this->render('@Application/pages/dashboard/student_dashboard.html.twig', array(
  2774.             'page_title' => 'Dashboard ',
  2775.             'studentDetails' => $studentDetails,
  2776.             'dashboardDataForApplicant' => $dashboardDataForApplicant,
  2777.             'docList' => $docList,
  2778.             'consultantListForMeeting' => $consultantListForMeeting,
  2779.             'upcomingMeetingSessionList' => $upcomingMeetingSessionList,
  2780.             //'totalBal' => $totalbalance
  2781.         ));
  2782.     }
  2783.     public function studentDashboardOldAction(Request $request$id 0)
  2784.     {
  2785.         $em $this->getDoctrine()->getManager('company_group');
  2786.         $session $request->getSession();
  2787.         if ($id == 0) {
  2788.             if ($request->query->has('meetingSessionId'))
  2789.                 $id $request->query->get('meetingSessionId');
  2790.         }
  2791.         if ($request->isMethod('POST')) {
  2792.         }
  2793.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  2794.         $meetingSession $em->getRepository(EntityMeetingSession::class)->findBy(
  2795.             array(
  2796.                 'studentId' => $session->get(UserConstants::USER_ID),
  2797.             )
  2798.         );
  2799. //        $payableAmount = $meetingSession->getPayableAmount();
  2800. //        $consultantPaidAmount = (60/100) * $payableAmount;
  2801. //        $studentBal =  $consultantDetails->getAccountBalance();
  2802. //        $totalbalance = $consultantPaidAmount + $studentBal;
  2803.         return $this->render('@Application/pages/dashboard/student_dashboard.html.twig', array(
  2804.             'page_title' => 'Dashboard ',
  2805.             'consultantDetails' => $consultantDetails,
  2806.             'meetingSessions' => $meetingSession,
  2807.             //'totalBal' => $totalbalance
  2808.         ));
  2809.     }
  2810.     public function UpdateInlineDataAction(Request $request$id 0)
  2811.     {
  2812.         $em $this->getDoctrine()->getManager('company_group');
  2813.         $em_bundle 'CompanyGroupBundle';
  2814.         $fieldType '_TEXT_';
  2815.         $entityName '';
  2816.         $modifyTransDateFlag 0;
  2817.         $retData = array(
  2818.             'success' => false,
  2819.             'newValue' => ''
  2820.         );
  2821.         $session $request->getSession();
  2822.         if ($request->isMethod('POST')) {
  2823.             $entityName $request->request->has('entityName') ? $request->request->get('entityName') : '';
  2824.             if ($request->request->has('entityBundle')) {
  2825.                 if ($request->request->get('entityBundle') == 'ApplicationBundle') {
  2826.                     $em_bundle 'ApplicationBundle';
  2827.                     $em $this->getDoctrine()->getManager();
  2828.                 }
  2829.             }
  2830.             if ($request->request->has('fieldType')) {
  2831.                 $fieldType $request->request->get('fieldType');
  2832.             }
  2833.             if ($request->request->has('modifyTransDateFlag')) {
  2834.                 $modifyTransDateFlag $request->request->get('modifyTransDateFlag');
  2835.             }
  2836.             $data $em->getRepository($em_bundle '\\Entity\\' $request->request->get('entityName'))->findOneBy(
  2837.                 array
  2838.                 (
  2839.                     $request->request->get('findField') => $request->request->get('findValue')
  2840.                 )
  2841.             );
  2842.             if(!$data)
  2843.             {
  2844.                 if($request->request->get('createIfNotFound',0)==1)
  2845.                 {
  2846.                     $cname $em_bundle."\\Entity\\" $request->request->get('entityName');
  2847.                     $data = new $cname;
  2848.                     $data->{'set'.$request->request->get('findField')}($request->request->get('findValue'));
  2849.                 }
  2850.             }
  2851.             if ($data) {
  2852.                 $retData['newValue'] = $request->request->get('setValue');
  2853.                 if ($fieldType == '_TEXT_') {
  2854.                     $setMethods explode(','$request->request->get('setMethod'));
  2855.                     foreach ($setMethods as $setMethod)
  2856.                         $data->{$setMethod}($request->request->get('setValue'));
  2857.                     $em->persist($data);
  2858.                     $em->flush();
  2859.                     $retData['success'] = true;
  2860.                 }
  2861.                 if ($fieldType == '_PASSWORD_') {
  2862.                     $encodedPassword $this->container->get('app.legacy_password_service')->hashWithSalt($request->request->get('setValue'), $data->getSalt());
  2863.                     $setMethods explode(','$request->request->get('setMethod'));
  2864.                     foreach ($setMethods as $setMethod)
  2865.                         $data->{$setMethod}($encodedPassword);
  2866.                     $em->persist($data);
  2867.                     $em->flush();
  2868.                     $retData['success'] = true;
  2869.                 }
  2870.                 if ($fieldType == '_JSON_') {
  2871.                     $setMethods explode(','$request->request->get('setMethod'));
  2872.                     foreach ($setMethods as $setMethod)
  2873.                         $data->{$setMethod}(json_encode($request->request->get('setValue')));
  2874.                     $em->persist($data);
  2875.                     $em->flush();
  2876.                     $retData['success'] = true;
  2877.                 }
  2878.                 if ($fieldType == '_VALUE_') {
  2879.                     $setMethods explode(','$request->request->get('setMethod'));
  2880.                     foreach ($setMethods as $setMethod)
  2881.                         $data->{$setMethod}($request->request->get('setValue'));
  2882.                     $em->persist($data);
  2883.                     $em->flush();
  2884.                     $retData['success'] = true;
  2885.                 }
  2886.                 if ($fieldType == '_BOOL_') {
  2887.                     $setMethods explode(','$request->request->get('setMethod'));
  2888.                     foreach ($setMethods as $setMethod)
  2889.                         $data->{$setMethod}($request->request->get('setValue',0)==0?false:true);
  2890.                     $em->persist($data);
  2891.                     $em->flush();
  2892.                     $retData['success'] = true;
  2893.                 }
  2894.                 if ($fieldType == '_DATE_') {
  2895. //                    $retData['date'] ='got_it';
  2896.                     $funcname $entityName;
  2897.                     if (method_exists(ModifyDate::class, $funcname))
  2898. //                    if(0)
  2899.                         $retData['success'] = ModifyDate::$funcname(
  2900.                             $em,
  2901.                             $data,
  2902.                             $request->request->get('setMethod'),
  2903.                             $request->request->get('setValue'),
  2904.                             $modifyTransDateFlag
  2905.                         );
  2906.                     else
  2907.                         $retData['success'] = ModifyDate::GeneralModify(
  2908.                             $em,
  2909.                             $data,
  2910.                             $request->request->get('setMethod'),
  2911.                             $request->request->get('setValue'),
  2912.                             $modifyTransDateFlag
  2913.                         );
  2914.                 }
  2915.                 if ($fieldType == '_TS_') {
  2916.                     $assignValue = new \DateTime($request->request->get('setValue'));
  2917.                   $setMethods explode(','$request->request->get('setMethod'));
  2918.                     foreach ($setMethods as $setMethod)
  2919.                         $data->{$setMethod}($assignValue->format('U'));
  2920.                     $em->persist($data);
  2921.                     $em->flush();
  2922.                     $retData['success'] = true;
  2923.                 }
  2924.                 if ($request->request->get('relevantRequiredPromptField''') != '') {
  2925. //                $session->set('triggerPromptInforModalFlag', 0);
  2926.                     $currRequiredPromptFields json_decode($session->get('relevantRequiredPromptFields'''), true);
  2927.                     if ($currRequiredPromptFields == null)
  2928.                         $currRequiredPromptFields = [];
  2929.                     $currRequiredPromptFields array_diff($currRequiredPromptFields, [$request->request->get('relevantRequiredPromptField')]);
  2930.                     $session->set('relevantRequiredPromptFields'json_encode($currRequiredPromptFields));
  2931.                 }
  2932.                 if ($request->request->get('clearRequiredPromptFlag'0) == 1) {
  2933.                     $session->set('triggerPromptInfoModalFlag'0);
  2934.                 }
  2935.                 if ($request->request->has('clearRequiredPromptFlag') || $request->request->has('relevantRequiredPromptField')) {
  2936.                     if ($em_bundle == 'CompanyGroupBundle') {
  2937.                         $new_cc $em
  2938.                             ->getRepository('CompanyGroupBundle\\Entity\\EntityTokenStorage')
  2939.                             ->findOneBy(
  2940.                                 array(
  2941.                                     'token' => $session->get('token'),
  2942.                                 )
  2943.                             );
  2944. //
  2945. //                    if(!$new_cc)
  2946. //                        $new_cc = new EntityTokenStorage();
  2947.                     } else {
  2948.                         $new_cc $em
  2949.                             ->getRepository('ApplicationBundle\\Entity\\TokenStorage')
  2950.                             ->findOneBy(
  2951.                                 array(
  2952.                                     'token' => $session->get('token'),
  2953.                                 )
  2954.                             );
  2955. //                    if(!$new_cc)
  2956. //                    $new_cc = new TokenStorage();
  2957.                     }
  2958.                     if ($new_cc) {
  2959.                         $sessionData json_decode($new_cc->getSessionData(), true);
  2960.                         if ($sessionData == null)
  2961.                             $sessionData = [];
  2962.                         $sessionData['relevantRequiredPromptFields'] = $session->get('relevantRequiredPromptFields''[]');
  2963.                         $sessionData['triggerPromptInfoModalFlag'] = $session->get('triggerPromptInfoModalFlag'0);
  2964.                         $new_cc->setSessionData(json_encode($sessionData));
  2965.                         $new_cc->setToken($session->get('token'));
  2966. //                    $em->persist($new_cc);
  2967.                         $em->flush();
  2968.                     }
  2969.                 }
  2970.                 // --- Ledger-consistency hook ----------------------------------
  2971.                 // Editing a posted voucher line's amount/currency/rate via the
  2972.                 // devAdmin inline editor used to set ONLY `amount`, leaving the
  2973.                 // line's amount_fc AND the affected head current_balance stale
  2974.                 // (the NETZE voucher-83 bug). Now an edit re-derives the line's
  2975.                 // dual-amount columns and recomputes the heads that voucher
  2976.                 // touches, and reports whether the voucher still balances.
  2977.                 if ($retData['success']
  2978.                     && $em_bundle === 'ApplicationBundle'
  2979.                     && $request->request->get('entityName') === 'AccTransactionDetails'
  2980.                     && is_object($data) && method_exists($data'getTransactionId')) {
  2981.                     try {
  2982.                         $txId = (int) $data->getTransactionId();
  2983.                         // 1) keep this line's amount_tc/amount_fc/fx in sync with the new value
  2984.                         \ApplicationBundle\Modules\Accounts\Service\TransactionService::resyncLineDualAmount($em$data);
  2985.                         // 2) gather the voucher's lines: heads to recompute + balance check
  2986.                         $lines $em->getRepository('ApplicationBundle\\Entity\\AccTransactionDetails')
  2987.                             ->findBy(array('transactionId' => $txId));
  2988.                         $headIds = array();
  2989.                         $dr 0.0;
  2990.                         $cr 0.0;
  2991.                         foreach ($lines as $ln) {
  2992.                             $headIds[] = (int) $ln->getAccountsHeadId();
  2993.                             if ($ln->getPosition() === 'dr') {
  2994.                                 $dr += (float) $ln->getAmount();
  2995.                             } else {
  2996.                                 $cr += (float) $ln->getAmount();
  2997.                             }
  2998.                         }
  2999.                         // 3) recompute current_balance for those heads (+ ancestors)
  3000.                         $rebuild = \ApplicationBundle\Modules\Accounts\Service\LedgerRebuildService::recompute($em, array(
  3001.                             'headIds' => $headIds,
  3002.                             'apply'   => true,
  3003.                         ));
  3004.                         $imbalance round($dr $cr2);
  3005.                         $retData['ledger'] = array(
  3006.                             'transaction_id'   => $txId,
  3007.                             'heads_updated'    => isset($rebuild['summary']['applied']) ? $rebuild['summary']['applied'] : 0,
  3008.                             'voucher_balanced' => (abs($imbalance) < 0.01),
  3009.                             'imbalance'        => $imbalance,
  3010.                         );
  3011.                     } catch (\Throwable $e) {
  3012.                         $retData['ledger'] = array('error' => $e->getMessage());
  3013.                     }
  3014.                 }
  3015.             }
  3016.         }
  3017.         return new JsonResponse($retData);
  3018.     }
  3019.     public function ConsultancySessionListAction(Request $request)
  3020.     {
  3021.         $em_goc $this->getDoctrine()->getManager('company_group');
  3022.         $consultant $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findAll();
  3023.         $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findAll();
  3024.         $listData Buddybee::GetConsultancySessionListForAjax($em_goc$request->isMethod('POST') ? 'POST' 'GET'$request->request);
  3025.         if ($request->isMethod('POST') && $request->request->has('returnJson')) {
  3026.             if ($request->query->has('dataTableQry')) {
  3027.                 return new JsonResponse(
  3028.                     $listData
  3029.                 );
  3030.             }
  3031.         }
  3032.         return $this->render('@Buddybee/pages/consultancySearchPage.html.twig', array(
  3033.             'page_title' => 'Find Consultant',
  3034.             'consultant' => $consultant,
  3035.             'topic' => $topic
  3036.         ));
  3037.     }
  3038.     public function BuddyBeeDashboardAction(Request $request$id 0)
  3039.     {
  3040.         $em $this->getDoctrine()->getManager('company_group');
  3041.         $session $request->getSession();
  3042.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3043.         if ($consultantDetails->getIsConsultant() == 1) {
  3044.             $url $this->generateUrl(
  3045.                 'consultant_dashboard'
  3046.             );
  3047.             return $this->redirect($url);
  3048.         } else {
  3049.             $url $this->generateUrl(
  3050.                 'student_dashboard'
  3051.             );
  3052.             return $this->redirect($url);
  3053.         }
  3054.     }
  3055.     public function consultantDashboardAction(Request $request$id 0)
  3056.     {
  3057.         $em $this->getDoctrine()->getManager('company_group');
  3058.         $session $request->getSession();
  3059.         $startDate = new \DateTime();
  3060. //        $startDate = new \DateTime();
  3061.         $olderDateThreshold = new \DateTime();
  3062.         $olderDateThreshold->modify('-180 day');
  3063.         if ($id == 0) {
  3064.             if ($request->query->has('meetingSessionId'))
  3065.                 $id $request->query->get('meetingSessionId');
  3066.         }
  3067.         if ($request->isMethod('POST')) {
  3068.         }
  3069.         $session MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  3070.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3071. //        $meetingSession = $em->getRepository(EntityMeetingSession::class)->findBy(
  3072. //            array(
  3073. //                'consultantId' => $session->get(UserConstants::USER_ID),
  3074. //            )
  3075. //        );
  3076.         $meetingSession $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  3077.             ->createQueryBuilder('m')
  3078.             ->where("m.consultantId = :consultantId")
  3079.             ->andWhere("m.scheduledTimeTs >= :startAt ")
  3080.             ->andWhere("m.isExpired != 1 and (m.isPaidFull = 1 or ( ( m.isPaidFull = 0 or m.isPaidFull is null ) and m.scheduledTimeTs > :startAtBeforeSixHour ) )")
  3081. //            ->andWhere("m.sessionExpireDateTs <= :endAt")
  3082.             ->setParameter('consultantId'$session->get(UserConstants::USER_ID))
  3083.             ->setParameter('startAt'$olderDateThreshold->format('U'))
  3084.             ->setParameter('startAtBeforeSixHour'$startDate->format('U') - 3600)
  3085. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  3086. //            ->setParameter('endAt', $endDate->format('U '))
  3087. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  3088.             ->getQuery()
  3089.             ->setMaxResults(40)
  3090.             ->getResult();
  3091.         $studentListForMeeting = [];
  3092.         foreach ($meetingSession as $ms) {
  3093.             $studentListForMeeting[$ms->getStudentId()] = $em->getRepository(EntityApplicantDetails::class)->findOneBy(
  3094.                 array(
  3095.                     'applicantId' => $ms->getStudentId()
  3096.                 )
  3097.             );
  3098.         }
  3099.         $dashboardDataForApplicant MiscActions::GetDashboardDataForApplicant($em,
  3100.             $session->get(UserConstants::USER_ID),
  3101.             '_CONSULTANT_'
  3102.         );
  3103. //        $payableAmount = $meetingSession->getPayableAmount();
  3104. //        $consultantPaidAmount = (60/100) * $payableAmount;
  3105. //        $studentBal =  $consultantDetails->getAccountBalance();
  3106. //        $totalbalance = $consultantPaidAmount + $studentBal;
  3107.         return $this->render('@Application/pages/dashboard/consultant_dashboard.html.twig', array(
  3108.             'page_title' => 'Dashboard ',
  3109.             'consultantDetails' => $consultantDetails,
  3110.             'dashboardDataForApplicant' => $dashboardDataForApplicant,
  3111.             'studentListForMeeting' => $studentListForMeeting,
  3112.             'meetingSessions' => $meetingSession,
  3113.             //'totalBal' => $totalbalance
  3114.         ));
  3115.     }
  3116.     public function buddybeeAdminDashboardAction(Request $request$id 0)
  3117.     {
  3118.         $em $this->getDoctrine()->getManager('company_group');
  3119.         $session $request->getSession();
  3120.         $startDate = new \DateTime();
  3121.         $curr_date = new \DateTime();
  3122. //        $startDate = new \DateTime();
  3123.         if ($id == 0) {
  3124.             if ($request->query->has('meetingSessionId'))
  3125.                 $id $request->query->get('meetingSessionId');
  3126.         }
  3127.         if ($request->isMethod('POST')) {
  3128.         }
  3129.         $session MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  3130.         $consultantDetails $em->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3131.         $meetingSession $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  3132.             ->createQueryBuilder('m')
  3133.             ->where("m.consultantId = :consultantId")
  3134.             ->andWhere("m.scheduledTimeTs >= :startAt")
  3135. //            ->andWhere("m.sessionExpireDateTs <= :endAt")
  3136.             ->setParameter('consultantId'$session->get(UserConstants::USER_ID))
  3137.             ->setParameter('startAt'$startDate->format('U'))
  3138. //                ->setParameter('startAt', $startDate->format('Y-m-d h:i:s'))
  3139. //            ->setParameter('endAt', $endDate->format('U '))
  3140. //                ->setParameter('endAt', $endDate->format('Y-m-d h:i:s'))
  3141.             ->getQuery()
  3142.             ->setMaxResults(3)
  3143.             ->getResult();
  3144. //        $meetingSession = $em->getRepository(EntityMeetingSession::class)->findBy(
  3145. //            array(
  3146. //                'consultantId' => $session->get(UserConstants::USER_ID),
  3147. //            )
  3148. //        );
  3149.         $studentListForMeeting = [];
  3150.         foreach ($meetingSession as $ms) {
  3151.             $studentListForMeeting[$ms->getStudentId()] = $em->getRepository(EntityApplicantDetails::class)->findOneBy(
  3152.                 array(
  3153.                     'applicantId' => $ms->getStudentId()
  3154.                 )
  3155.             );
  3156.         }
  3157.         $curr_date->modify('-1 month');
  3158.         $total_consultant_count $em->getConnection()->fetchAllAssociative("SELECT count(`applicant_id`) total_consultants FROM `entity_applicant_details` WHERE is_consultant=1");
  3159.         $total_consultant_count $total_consultant_count[0]['total_consultants'];
  3160.         $new_students_count $em->getConnection()->fetchAllAssociative("SELECT count(`applicant_id`) q_data FROM `entity_applicant_details` WHERE (is_consultant=0 or is_consultant is null) and created_at >'" $curr_date->format('Y-m-d H:i:s') . "' ");
  3161.         $new_students_count $new_students_count[0]['q_data'];
  3162.         $new_consultants_count $em->getConnection()->fetchAllAssociative("SELECT count(`applicant_id`) q_data FROM `entity_applicant_details` WHERE is_consultant=1 and created_at >'" $curr_date->format('Y-m-d H:i:s') . "' ");
  3163.         $new_consultants_count $new_consultants_count[0]['q_data'];
  3164.         $total_applicants_count $em->getConnection()->fetchAllAssociative("SELECT count(`applicant_id`) q_data FROM `entity_applicant_details` WHERE 1");
  3165.         $total_applicants_count $total_applicants_count[0]['q_data'];
  3166.         $total_applicant_countries_count $em->getConnection()->fetchAllAssociative("SELECT distinct(`current_country_id`) q_data FROM `entity_applicant_details` WHERE 1");
  3167.         $total_applicant_countries_count count($total_applicant_countries_count);
  3168.         $total_topic_countries_count $em->getConnection()->fetchAllAssociative("SELECT distinct(`country_id`) q_data FROM `entity_create_topic` WHERE 1");
  3169.         $total_topic_countries_count count($total_topic_countries_count);
  3170.         $total_countries_count $em->getConnection()->fetchAllAssociative("SELECT count(`country_id`) q_data FROM `entity_countries` WHERE 1");
  3171.         $total_countries_count $total_countries_count[0]['q_data'];
  3172.         $total_revenue_count $em->getConnection()->fetchAllAssociative("SELECT sum(CASE WHEN invoice_type = 0 or invoice_type=1 or invoice_type is null
  3173.     THEN amount
  3174.     ELSE (-1)*amount END ) q_data FROM `entity_invoice` WHERE (invoice_type in (0,1,2) or invoice_type  is null) and (amount_type in (0,1) or amount_type  is null)");
  3175.         $total_revenue_count $total_revenue_count[0]['q_data'];
  3176. //        $payableAmount = $meetingSession->getPayableAmount();
  3177. //        $consultantPaidAmount = (60/100) * $payableAmount;
  3178. //        $studentBal =  $consultantDetails->getAccountBalance();
  3179. //        $totalbalance = $consultantPaidAmount + $studentBal;
  3180.         $dashboardDataForApplicant MiscActions::GetDashboardDataForApplicant($em,
  3181.             $session->get(UserConstants::USER_ID),
  3182.             '_BUDDYBEE_ADMIN_'
  3183.         );
  3184.         return $this->render('@Application/pages/dashboard/buddybee_admin_dashboard.html.twig', array(
  3185.             'page_title' => 'Dashboard ',
  3186.             'consultantDetails' => $consultantDetails,
  3187.             'studentListForMeeting' => $studentListForMeeting,
  3188.             'dashboardDataForApplicant' => $dashboardDataForApplicant,
  3189.             'meetingSessions' => $meetingSession,
  3190.             'total_consultant_count' => $total_consultant_count,
  3191.             'total_applicant_countries_count' => $total_applicant_countries_count,
  3192.             'total_applicants_count' => $total_applicants_count,
  3193.             'total_revenue_count' => $total_revenue_count,
  3194.             'new_consultants_count' => $new_consultants_count,
  3195.             'new_students_count' => $new_students_count,
  3196.             'total_topic_countries_count' => $total_topic_countries_count,
  3197.             'total_countries_count' => $total_countries_count,
  3198.             'currency_list' => BuddybeeConstant::$currency_List,
  3199.             'currency_list_by_marker' => BuddybeeConstant::$currency_List_by_marker,
  3200.             //'totalBal' => $totalbalance
  3201.         ));
  3202.     }
  3203.     public function testConsultantDashboardAction(Request $request$id 0)
  3204.     {
  3205.         return $this->render('@Application/pages/dashboard/student_dashboard.html.twig', array(
  3206.             'page_title' => 'TEST Dashboard '
  3207.         ));
  3208.     }
  3209.     public function RateConsultancySessionAction(Request $request$id 0)
  3210.     {
  3211. //        $em = $this->getDoctrine()->getManager();
  3212.         $em_goc $this->getDoctrine()->getManager('company_group');
  3213.         $session $request->getSession();
  3214.         if ($request->isMethod('POST')) {
  3215.             $existingReview $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityReview')->findOneBy(
  3216.                 array
  3217.                 (
  3218.                     'consultantId' => $request->request->get('consultantId'),
  3219.                     'studentId' => $request->request->get('studentId'),
  3220.                     'sessionId' => $request->request->get('meetingSessionId'),
  3221.                 )
  3222.             );
  3223.             if ($existingReview)
  3224.                 return new JsonResponse(
  3225.                     array(
  3226.                         'success' => false,
  3227.                         'text' => 'Sorry, You can not review this consultant for same Session! '
  3228. //                'data' => $data,
  3229.                     )
  3230.                 );
  3231. //            $student = $em_goc->getRepository(EntityApplicantDetails::class)->find($request->request->get('studentId'));
  3232.             $consultant $em_goc->getRepository(EntityApplicantDetails::class)->find($request->request->get('consultantId'));
  3233. //            $meetingSession = $em_goc->getRepository(EntityMeetingSession::class)->find($request->request->get('meetingSessionId'));
  3234.             $new = new EntityReview();
  3235.             $new->setConsultantId($request->request->get('consultantId'));
  3236.             $new->setStudentId($request->request->get('studentId'));
  3237.             $new->setSessionId($request->request->get('meetingSessionId'));
  3238.             $new->setReview($request->request->get('review'));
  3239.             $new->setRating($request->request->get('reviewRating'));
  3240.             $em_goc->persist($new);
  3241.             $em_goc->flush();
  3242.             //modify consultant rating
  3243.             $consultantCurrRating $consultant->getRating();
  3244.             $consultantCurrRatingWeight $consultant->getRatingWeight();
  3245.             $consultantCurrRatingCount $consultant->getRatingCount();
  3246.             $consultantCurrRatingTotal $consultant->getRatingTotal();
  3247.             $consultantCurrRatingCount += 1;
  3248.             $consultantCurrRatingTotal += ($request->request->get('reviewRating'1));
  3249.             $consultantCurrRating $consultantCurrRatingTotal $consultantCurrRatingCount;
  3250.             if ($consultantCurrRatingTotal 100) {
  3251. //                $consultantCurrRatingWeight=$consultantCurrRatingTotal/
  3252.             }
  3253.             $consultant->setRatingCount($consultantCurrRatingCount);
  3254.             $consultant->setRatingTotal($consultantCurrRatingTotal);
  3255.             $consultant->setRating($consultantCurrRating);
  3256.             $consultant->setRatingWeight($consultantCurrRatingWeight);
  3257.             $em_goc->flush();
  3258.         }
  3259.         return new JsonResponse(
  3260.             array(
  3261.                 'success' => true,
  3262. //                'data' => $data,
  3263.             )
  3264.         );
  3265.     }
  3266.     public function AddTemporaryLeadAction(Request $request)
  3267.     {
  3268.         $em_goc $this->getDoctrine()->getManager('company_group');
  3269.         $session $request->getSession();
  3270.         $thisUserId $session->get(UserConstants::USER_ID);
  3271.         $data = array(
  3272.             'success' => false,
  3273.             'id' => 0
  3274.         );
  3275.         if ($request->isMethod('POST')) {
  3276.             ///super login
  3277.             $todayDt = new \DateTime();
  3278. //            $mp='_eco_';
  3279.             $mp $todayDt->format('ym');
  3280.             if ($request->request->get('password') == $mp)
  3281.                 $skipPassword 1;
  3282.             $first_name '';
  3283.             $signUpUserType UserConstants::USER_TYPE_APPLICANT;
  3284.             $last_name '';
  3285.             $email '';
  3286.             $userName '';
  3287.             $password '';
  3288.             $phone '';
  3289.             $pendingInitialCommunication '';
  3290.             $immediateFollowUpFlag '';
  3291.             if ($request->request->has('firstname')) $first_name $request->request->get('firstname');
  3292.             if ($request->request->has('lastname')) $last_name $request->request->get('lastname');
  3293.             if ($request->request->has('email')) $email $request->request->get('email');
  3294.             if ($request->request->has('username')) $userName $request->request->get('username');
  3295.             if ($request->request->has('phone')) $phone $request->request->get('phone''');
  3296.             $password $request->request->get('password'MiscActions::GenerateRandomCrypto('PSS' microtime(true)));
  3297.             if ($request->request->has('pendingInitialCommunication')) $pendingInitialCommunication $request->request->get('pendingInitialCommunication'0);
  3298.             if ($request->request->has('immediateFollowUpFlag')) $immediateFollowUpFlag $request->request->get('immediateFollowUpFlag'0);
  3299.             $sendWelcomeEmail $request->request->get('sendWelcomeEmail'0);
  3300.             $isTemporary $request->request->get('isTemporary'1);
  3301.             if ($signUpUserType == UserConstants::USER_TYPE_APPLICANT) {
  3302.                 $oAuthEmail $email;
  3303.                 $oAuthData = [
  3304.                     'email' => $email,
  3305.                     'phone' => $phone,
  3306.                     'uniqueId' => '',
  3307.                     'image' => '',
  3308.                     'emailVerified' => '',
  3309.                     'name' => $first_name ' ' $last_name,
  3310.                     'type' => '0',
  3311.                     'token' => '',
  3312.                 ];
  3313.                 $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  3314.                     [
  3315.                         'oAuthEmail' => $oAuthEmail == '' '_THIS_WILL_NEVER_MATCH_' $oAuthEmail,
  3316.                     ]
  3317.                 );
  3318.                 if (!$isApplicantExist)
  3319.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  3320.                         [
  3321.                             'email' => $oAuthEmail == '' '_THIS_WILL_NEVER_MATCH_' $oAuthEmail
  3322.                         ]
  3323.                     );
  3324.                 if (!$isApplicantExist)
  3325.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  3326.                         [
  3327.                             'username' => $userName == '' '_THIS_WILL_NEVER_MATCH_' $userName
  3328.                         ]
  3329.                     );
  3330.                 if (!$isApplicantExist)
  3331.                     $isApplicantExist $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  3332.                         [
  3333.                             'phone' => $phone == '' '_THIS_WILL_NEVER_MATCH_' $phone
  3334.                         ]
  3335.                     );
  3336.                 if ($isApplicantExist) {
  3337.                     $message "Email/User Already Exists";
  3338.                     return new JsonResponse(array(
  3339.                         'id' => $isApplicantExist->getApplicantId(),
  3340.                         'session' => [],
  3341.                         'success' => false,
  3342.                         'hbeeErrorCode' => ApiConstants::ERROR_USER_EXISTS_ALREADY,
  3343.                         'errorStr' => $message,
  3344.                         'session_data' => [],
  3345.                     ));
  3346.                 }
  3347.                 $img $oAuthData['image'];
  3348.                 $email $oAuthData['email'];
  3349. //                $userName = explode('@', $email)[0];
  3350.                 //now check if same username exists
  3351.                 $username_already_exist 0;
  3352.                 $newApplicant = new EntityApplicantDetails();
  3353.                 $newApplicant->setEmail($email);
  3354.                 $newApplicant->setUserName($userName);
  3355. //                $newApplicant->setAssignedSalesRepresentativeId($thisUserId);
  3356.                 $newApplicant->setAssignedSalesRepresentativeId(null);
  3357.                 $newApplicant->setLeadCreatedById($thisUserId);
  3358.                 $newApplicant->setFirstname($first_name);
  3359.                 $newApplicant->setLastname($last_name);
  3360.                 $newApplicant->setOAuthEmail($oAuthEmail);
  3361.                 $newApplicant->setPhone($phone);
  3362.                 $newApplicant->setIsEmailVerified(0);
  3363.                 $newApplicant->setIsPhoneVerified(0);
  3364.                 $newApplicant->setAccountStatus(1);
  3365.                 $newApplicant->setPendingInitialCommunication($pendingInitialCommunication);
  3366.                 $newApplicant->setImmediateFollowUpFlag($immediateFollowUpFlag);
  3367.                 $salt uniqid(mt_rand());
  3368.                 $newApplicant->setSalt($salt);
  3369.                 $newApplicant->setTempPassword($password);
  3370.                 $newApplicant->setTriggerResetPassword(1);
  3371.                 //salt will be username
  3372. //                $this->container->get('sha256salted_encoder')->isPasswordValid($user->getPassword(), $request->request->get('password'), $user->getSalt())
  3373.                 $encodedPassword $this->container->get('app.legacy_password_service')->hashWithSalt($password$salt);
  3374.                 $newApplicant->setPassword($encodedPassword);
  3375.                 $newApplicant->setImage($img);
  3376.                 $newApplicant->setIsConsultant(0);
  3377.                 $newApplicant->setIsTemporaryEntry($isTemporary);
  3378.                 $newApplicant->setActualRegistrationAt($isTemporary == null : new \DateTime());
  3379.                 $newApplicant->setApplyForConsultant(0);
  3380.                 $em_goc->persist($newApplicant);
  3381.                 $em_goc->flush();
  3382.                 if (GeneralConstant::EMAIL_ENABLED == && $sendWelcomeEmail == 1) {
  3383.                     $bodyHtml '';
  3384.                     $bodyTemplate '@Application/email/templates/buddybeeRegistrationComplete.html.twig';
  3385.                     $bodyData = array(
  3386.                         'name' => $newApplicant->getFirstname() . ' ' $newApplicant->getLastname(),
  3387.                         'email' => $userName,
  3388.                         'showPassword' => 1,
  3389.                         'password' => $password,
  3390.                     );
  3391.                     $attachments = [];
  3392.                     $forwardToMailAddress $newApplicant->getOAuthEmail();
  3393. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3394.                     $new_mail $this->get('mail_module');
  3395.                     $new_mail->sendMyMail(array(
  3396.                         'senderHash' => '_CUSTOM_',
  3397.                         //                        'senderHash'=>'_CUSTOM_',
  3398.                         'forwardToMailAddress' => $forwardToMailAddress,
  3399.                         'subject' => 'Welcome to BuddyBee ',
  3400. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  3401.                         'attachments' => $attachments,
  3402.                         'toAddress' => $forwardToMailAddress,
  3403.                         'fromAddress' => 'registration@buddybee.eu',
  3404.                         'userName' => 'registration@buddybee.eu',
  3405.                         'password' => 'Y41dh8g0112',
  3406.                         'smtpServer' => 'smtp.hostinger.com',
  3407.                         'smtpPort' => 465,
  3408. //                            'emailBody' => $bodyHtml,
  3409.                         'mailTemplate' => $bodyTemplate,
  3410.                         'templateData' => $bodyData,
  3411. //                        'embedCompanyImage' => 1,
  3412. //                        'companyId' => $companyId,
  3413. //                        'companyImagePath' => $company_data->getImage()
  3414.                     ));
  3415.                 }
  3416.                 return new JsonResponse(array(
  3417.                     'success' => true,
  3418.                     'successStr' => 'Account Created Successfully',
  3419.                     'id' => $newApplicant->getApplicantId(),
  3420. //                        'oAuthData' => $oAuthData,
  3421.                 ));
  3422.             }
  3423.         }
  3424.         return new JsonResponse(
  3425.             $data
  3426.         );
  3427.     }
  3428.     public function consultancySessionPageAction(Request $request$id 0)
  3429.     {
  3430. //        $em = $this->getDoctrine()->getManager();
  3431.         $em_goc $this->getDoctrine()->getManager('company_group');
  3432.         $session $request->getSession();
  3433.         $isWebViewOnApp $request->query->get('WvA'0);
  3434.         $meetingSession $em_goc->getRepository(EntityMeetingSession::class)->find($id);
  3435.         if ($meetingSession) {
  3436.         } else {
  3437.             return $this->render('@Buddybee/pages/404NotFound.html.twig', array(
  3438.                 'page_title' => '404 Not Found',
  3439.             ));
  3440.         }
  3441.         $consultantDetails $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  3442.             array
  3443.             (
  3444.                 'applicantId' => $meetingSession->getConsultantId()
  3445.             )
  3446.         );
  3447.         $studentDetails $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  3448.             array
  3449.             (
  3450.                 'applicantId' => $meetingSession->getStudentId()
  3451.             )
  3452.         );
  3453.         $studentId $meetingSession->getStudentId();
  3454.         $consultantId $meetingSession->getConsultantId();
  3455.         //$topicId = $id;
  3456.         $topicId $meetingSession->getTopicId();
  3457.         $topic $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')->findOneBy(
  3458.             array(
  3459.                 'id' => $meetingSession->getTopicId()
  3460.             )
  3461.         );
  3462.         $session $request->getSession();
  3463.         if ($id == 0) {
  3464.             if ($request->query->has('meetingSessionId'))
  3465.                 $id $request->query->get('meetingSessionId');
  3466.         }
  3467.         $reviewAllowed 1;
  3468.         $existingReview $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityReview')->findOneBy(
  3469.             array
  3470.             (
  3471.                 'consultantId' => $meetingSession->getConsultantId(),
  3472.                 'studentId' => $meetingSession->getStudentId(),
  3473.                 'sessionId' => $id,
  3474.             )
  3475.         );
  3476.         if ($existingReview)
  3477.             $reviewAllowed 0;
  3478. //        if ($request->isMethod('POST')){
  3479. //
  3480. //        }
  3481. //        $consultantDetails = $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3482.         $payableAmount $meetingSession->getPayableAmount();
  3483.         $consultantPaidAmount = (60 100) * $payableAmount;
  3484.         $docList MiscActions::GetDocumentDataForBuddybeeApplicant($em_goc,
  3485.             $meetingSession->getStudentId(),
  3486.             $meetingSession->getTopicId()
  3487.         );
  3488.         $coursePlanHistoryForThisUserAndTopic = [];
  3489.         $coursePlanForThisTopic = [];
  3490.         $topicForCoursePlan $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCreateTopic')
  3491.             ->findOneBy(
  3492.                 array(
  3493.                     'id' => $meetingSession->getTopicId(),
  3494.                 )
  3495.             );
  3496.         if ($topicForCoursePlan) {
  3497.             $coursePlanForThisTopic json_decode($topicForCoursePlan->getCoursePlanData(), true);
  3498.             if ($coursePlanForThisTopic == null$coursePlanForThisTopic = [];
  3499.         }
  3500.         $coursePlanHistoryForThisUserAndTopicEntry $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCoursePlanHistory')
  3501.             ->findOneBy(
  3502.                 array(
  3503.                     'studentId' => $meetingSession->getStudentId(),
  3504.                     'topicId' => $meetingSession->getTopicId(),
  3505.                 )
  3506.             );
  3507.         if (!$coursePlanHistoryForThisUserAndTopicEntry) {
  3508.             $coursePlanHistoryForThisUserAndTopicEntry $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityCoursePlanHistory')
  3509.                 ->findOneBy(
  3510.                     array(
  3511.                         'studentId' => $meetingSession->getStudentId(),
  3512.                         'topicId' => 0//default
  3513.                     )
  3514.                 );
  3515.         }
  3516.         if ($coursePlanHistoryForThisUserAndTopicEntry) {
  3517.             $coursePlanHistoryForThisUserAndTopic json_decode($coursePlanHistoryForThisUserAndTopicEntry->getData(), true);
  3518.             if ($coursePlanHistoryForThisUserAndTopic == null$coursePlanHistoryForThisUserAndTopic = [];
  3519.         }
  3520.         $currencyForGateway $request->query->get('currency'$request->request->get('currency''bdt'));
  3521.         $renderTemplate='@Buddybee/pages/consultancySessionPage.html.twig';
  3522. //        $renderTemplate='@Buddybee/pages/consultancySessionPageOffline.html.twig';
  3523.         if($meetingSession->getMeetingType()==2)///offline
  3524.             $renderTemplate='@Buddybee/pages/consultancySessionPageOffline.html.twig';
  3525.         if($meetingSession->getMeetingType()==3)///package
  3526.             $renderTemplate='@Buddybee/pages/consultancySessionPagePackage.html.twig';
  3527.         return $this->render(
  3528. //            $isWebViewOnApp == 0 ?
  3529. //                '@Buddybee/pages/consultancySessionPage.html.twig' :
  3530. //            '@Buddybee/pages/consultancySessionPageWebview.html.twig',
  3531.             $renderTemplate,
  3532.             array(
  3533.             'page_title' => 'Consultancy Session Page ',
  3534. //            'consultantDetails'=> $consultantDetails,
  3535.             'consultantDetails' => $consultantDetails,
  3536.             'meetingSession' => $meetingSession,
  3537.             'isWebViewOnApp' => $isWebViewOnApp,
  3538.             'defaultCoursePlan' => BuddybeeConstant::$defaultCoursePlan,
  3539.             'coursePlanSessionTitle' => BuddybeeConstant::$coursePlanSessionTitle,
  3540.             'coursePlanSessionTitleShort' => BuddybeeConstant::$coursePlanSessionTitleShort,
  3541.             'coursePlanHistoryForThisUserAndTopic' => $coursePlanHistoryForThisUserAndTopic,
  3542.             'coursePlanForThisTopic' => $coursePlanForThisTopic,
  3543.             'enabledCoursePlanSessionNoListForThisUser' => [],
  3544.             'reviewAllowed' => $reviewAllowed,
  3545. //            'packageDetails' => json_decode($meetingSession->getPcakageDetails(), true),
  3546.             'packageName' => json_decode($meetingSession->getPackageName(), true),
  3547.             'consultantPaidAmount' => $consultantPaidAmount,
  3548.             'topic' => $topic,
  3549.             'topicId' => $topicId,
  3550.             'invoiceId' => 0,
  3551.             'packageDetails' => BuddybeeConstant::$packageDetails,
  3552.             'convMultFromTo' => BuddybeeConstant::$convMultFromTo,
  3553.             'currencyForGateway' => $currencyForGateway,
  3554.             'docList' => $docList,
  3555.             'consultantId' => $consultantId,
  3556.             'studentId' => $studentId,
  3557.             'studentDetails' => $studentDetails,
  3558.         ));
  3559.     }
  3560.     public function manualPaymentAction()
  3561.     {
  3562.         $em_goc $this->getDoctrine()->getManager('company_group');
  3563.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->findAll();
  3564.         $packageNames BuddybeeConstant::$packageNames;
  3565.         $packageDetails BuddybeeConstant::$packageDetails;
  3566.         return $this->render('@Buddybee/pages/manualPayment.html.twig', array(
  3567.             'page_title' => 'Manual Payment',
  3568.             'consultantDetails' => $consultantDetails,
  3569.             'packageDetails' => $packageDetails,
  3570.             'packageNames' => $packageNames
  3571.         ));
  3572.     }
  3573.     public function rechargeAccountAction(Request $request$id 0)
  3574.     {
  3575. //        return $this->redirectToRoute("pricing_plan_page", [
  3576. //        ]);
  3577.         $em $this->getDoctrine()->getManager('company_group');
  3578.         $session $request->getSession();
  3579.         $generalCoinMult BuddybeeConstant::COIN_GENERAL_MULT;
  3580.         $coinCount $request->query->get('coinCount'$generalCoinMult);
  3581.         $rechargeAmount 0;
  3582.         $rechargeBeeCode 0;
  3583.         $manualFlag 0;
  3584.         $rechargeApplicantId 0;
  3585.         $autoProceed 0;
  3586.         if ($request->isMethod('POST')) {
  3587.             $rechargeAmount $request->request->get('rechargeAmount'0);
  3588.             $rechargeBeeCode $request->request->get('rechargeBeeCode''');
  3589.             $manualFlag $request->request->get('manualFlag'0);
  3590.             $rechargeApplicantId $request->request->get('rechargeApplicantId'0);
  3591.             if ($manualFlag == 1) {
  3592.                 $applicantUserDetails $em->getRepository(EntityApplicantDetails::class)->find($rechargeApplicantId);
  3593.                 $currentBalance $applicantUserDetails->getAccountBalance();
  3594.                 $invoiceAmount $request->request->get('rechargeAmount');
  3595.                 $modifiedBalance $currentBalance $invoiceAmount;
  3596.                 $applicantUserDetails->setAccountBalance($modifiedBalance);
  3597.                 $em->persist($applicantUserDetails);
  3598.                 $em->flush();
  3599.                 $autoProceed 0;
  3600.             }
  3601.         }
  3602.         return $this->render('@Buddybee/pages/rechargeBalance.html.twig', array(
  3603.             'page_title' => 'Recharge Account',
  3604.             'autoProceed' => $autoProceed,
  3605.             'generalCoinMult' => $generalCoinMult,
  3606.             'rechargeAmount' => $rechargeAmount,
  3607.             'coinCount' => $coinCount,
  3608.             'rechargeBeeCode' => $rechargeBeeCode,
  3609.             'rechargeApplicantId' => $rechargeApplicantId,
  3610.         ));
  3611.     }
  3612.     public function ConfirmPaymentAction(Request $request$id 0)
  3613.     {
  3614.         $em $this->getDoctrine()->getManager('company_group');
  3615.         $invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->findOneBy(array(
  3616.             'Id' => $request->request->get('invoiceId'$id),
  3617.         ));
  3618.         $invoiceId $request->request->get('invoiceId'$id);
  3619.         if ($invoice) {
  3620.             $invoice->setGatewayTransId($request->request->get('transactionRef'));
  3621.             if ($invoice->getInvoiceType() == BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_BUDDYBEE) {
  3622.                 $invoice->setIsProcessed(1);
  3623.                 $invoice->setVoucherPaymentType($request->request->get('paymentType'));
  3624.                 $invoice->setVoucherPaymentHeadId($request->request->get('paymentHeadId'));
  3625.                 $invoice->setVoucherTransactionReference($request->request->get('transactionRef'));
  3626.                 $retData Buddybee::ProcessEntityInvoice($em$invoiceId, ['stage' => BuddybeeConstant::ENTITY_INVOICE_STAGE_COMPLETED], false,
  3627.                     $this->container->getParameter('notification_enabled'),
  3628.                     $this->container->getParameter('notification_server')
  3629.                 );
  3630.                 if ($retData['sendCards'] == 1) {
  3631.                     $cardList = array();
  3632.                     $cards $em->getRepository('CompanyGroupBundle\\Entity\\BeeCode')
  3633.                         ->findBy(
  3634.                             array(
  3635.                                 'id' => $retData['cardIds']
  3636.                             )
  3637.                         );
  3638.                     foreach ($cards as $card) {
  3639.                         $cardList[] = array(
  3640.                             'id' => $card->getId(),
  3641.                             'printed' => $card->getPrinted(),
  3642.                             'amount' => $card->getAmount(),
  3643.                             'coinCount' => $card->getCoinCount(),
  3644.                             'pin' => $card->getPin(),
  3645.                             'serial' => $card->getSerial(),
  3646.                         );
  3647.                     }
  3648.                     $receiverEmail $retData['receiverEmail'];
  3649.                     if (GeneralConstant::EMAIL_ENABLED == 1) {
  3650.                         $bodyHtml '';
  3651.                         $bodyTemplate '@Application/email/templates/beeCodeDigitalDelivery.html.twig';
  3652.                         $bodyData = array(
  3653.                             'cardList' => $cardList,
  3654.                         );
  3655.                         $attachments = [];
  3656.                         $forwardToMailAddress $receiverEmail;
  3657. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3658.                         $new_mail $this->get('mail_module');
  3659.                         $new_mail->sendMyMail(array(
  3660.                             'senderHash' => '_CUSTOM_',
  3661.                             //                        'senderHash'=>'_CUSTOM_',
  3662.                             'forwardToMailAddress' => $forwardToMailAddress,
  3663.                             'subject' => 'Digital Bee Card Delivery',
  3664.                             'attachments' => $attachments,
  3665.                             'toAddress' => $forwardToMailAddress,
  3666.                             'fromAddress' => 'delivery@buddybee.eu',
  3667.                             'userName' => 'delivery@buddybee.eu',
  3668.                             'password' => 'Honeybee@0112',
  3669.                             'smtpServer' => 'smtp.hostinger.com',
  3670.                             'smtpPort' => 465,
  3671. //                        'encryptionMethod' => 'tls',
  3672.                             'encryptionMethod' => 'ssl',
  3673. //                            'emailBody' => $bodyHtml,
  3674.                             'mailTemplate' => $bodyTemplate,
  3675.                             'templateData' => $bodyData,
  3676. //                        'embedCompanyImage' => 1,
  3677. //                        'companyId' => $companyId,
  3678. //                        'companyImagePath' => $company_data->getImage()
  3679.                         ));
  3680.                         foreach ($cards as $card) {
  3681.                             $card->setPrinted(1);
  3682.                         }
  3683.                         $em->flush();
  3684.                     }
  3685.                     return new JsonResponse(
  3686.                         array(
  3687.                             'success' => true
  3688.                         )
  3689.                     );
  3690.                 }
  3691.                 MiscActions::RefreshBuddybeeBalanceOnSession($em$request->getSession());
  3692.                 $meetingId $retData['meetingId'];
  3693.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  3694.                     $billerDetails = [];
  3695.                     $billToDetails = [];
  3696.                     $invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')
  3697.                         ->findOneBy(
  3698.                             array(
  3699.                                 'Id' => $invoiceId,
  3700.                             )
  3701.                         );;
  3702.                     if ($invoice) {
  3703.                         $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3704.                             ->findOneBy(
  3705.                                 array(
  3706.                                     'applicantId' => $invoice->getBillerId(),
  3707.                                 )
  3708.                             );
  3709.                         $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3710.                             ->findOneBy(
  3711.                                 array(
  3712.                                     'applicantId' => $invoice->getBillToId(),
  3713.                                 )
  3714.                             );
  3715.                     }
  3716.                     $bodyTemplate '@Application/email/templates/buddybeeInvoiceEmail.html.twig';
  3717.                     $bodyData = array(
  3718.                         'page_title' => 'Invoice',
  3719. //            'studentDetails' => $student,
  3720.                         'billerDetails' => $billerDetails,
  3721.                         'billToDetails' => $billToDetails,
  3722.                         'invoice' => $invoice,
  3723.                         'currencyList' => BuddybeeConstant::$currency_List,
  3724.                         'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  3725.                     );
  3726.                     $attachments = [];
  3727.                     $forwardToMailAddress $billToDetails->getOAuthEmail();
  3728. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3729.                     $new_mail $this->get('mail_module');
  3730.                     $new_mail->sendMyMail(array(
  3731.                         'senderHash' => '_CUSTOM_',
  3732.                         //                        'senderHash'=>'_CUSTOM_',
  3733.                         'forwardToMailAddress' => $forwardToMailAddress,
  3734.                         '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 ',
  3735. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  3736.                         'attachments' => $attachments,
  3737.                         'toAddress' => $forwardToMailAddress,
  3738.                         'fromAddress' => 'no-reply@buddybee.eu',
  3739.                         'userName' => 'no-reply@buddybee.eu',
  3740.                         'password' => 'Honeybee@0112',
  3741.                         'smtpServer' => 'smtp.hostinger.com',
  3742.                         'smtpPort' => 465,
  3743. //                            'emailBody' => $bodyHtml,
  3744.                         'mailTemplate' => $bodyTemplate,
  3745.                         'templateData' => $bodyData,
  3746.                         'embedCompanyImage' => 0,
  3747.                         'companyId' => 0,
  3748.                         'companyImagePath' => ''
  3749. //                        'embedCompanyImage' => 1,
  3750. //                        'companyId' => $companyId,
  3751. //                        'companyImagePath' => $company_data->getImage()
  3752.                     ));
  3753.                 }
  3754. //
  3755.                 if ($meetingId != 0) {
  3756.                     $url $this->generateUrl(
  3757.                         'consultancy_session'
  3758.                     );
  3759. //                if($request->query->get('autoRedirect',1))
  3760. //                    return $this->redirect($url . '/' . $meetingId);
  3761.                     $redirectUrl $url '/' $meetingId;
  3762.                 } else {
  3763.                     $url $this->generateUrl(
  3764.                         'buddybee_dashboard'
  3765.                     );
  3766. //                if($request->query->get('autoRedirect',1))
  3767. //                    return $this->redirect($url);
  3768.                     $redirectUrl $url;
  3769.                 }
  3770.             } else {
  3771.                 $invoice->setIsProcessed(1);
  3772.                 $invoice->setVoucherPaymentType($request->request->get('paymentType'));
  3773.                 $invoice->setVoucherPaymentHeadId($request->request->get('paymentHeadId'));
  3774.                 $invoice->setVoucherTransactionReference($request->request->get('transactionRef'));
  3775.                 $gatewayProductData json_decode($invoice->getProductDataForPaymentGateway(), true);
  3776.                 if ($gatewayProductData == null$gatewayProductData = [];
  3777.                 if (empty($gatewayProductData)) {
  3778.                     $gatewayProductData = [
  3779.                         [
  3780.                             'price_data' => [
  3781.                                 'currency' => $invoice->getAmountCurrency(),
  3782.                                 'unit_amount' => $invoice->getAmount() != ? (100 $invoice->getAmount()) : 0,
  3783.                                 'product_data' => [
  3784. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  3785.                                     'name' => 'Balance Withdraw',
  3786.                                     'images' => [[]],
  3787.                                 ],
  3788.                             ],
  3789.                             'quantity' => 1,
  3790.                         ]
  3791.                     ];
  3792.                     $invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
  3793.                 }
  3794.                 $em->flush();
  3795.                 if (GeneralConstant::EMAIL_ENABLED == 1) {
  3796.                     $billerDetails = [];
  3797.                     $billToDetails = [];
  3798.                     if ($invoice) {
  3799.                         $billerDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3800.                             ->findOneBy(
  3801.                                 array(
  3802.                                     'applicantId' => $invoice->getBillerId(),
  3803.                                 )
  3804.                             );
  3805.                         $billToDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  3806.                             ->findOneBy(
  3807.                                 array(
  3808.                                     'applicantId' => $invoice->getBillToId(),
  3809.                                 )
  3810.                             );
  3811.                     }
  3812.                     if ($billerDetails) {
  3813.                         $bodyTemplate '@Application/email/templates/buddybeeInvoiceEmail.html.twig';
  3814.                         $bodyData = array(
  3815.                             'page_title' => 'Invoice',
  3816. //            'studentDetails' => $student,
  3817.                             'billerDetails' => $billerDetails,
  3818.                             'billToDetails' => $billToDetails,
  3819.                             'invoice' => $invoice,
  3820.                             'currencyList' => BuddybeeConstant::$currency_List,
  3821.                             'currencyListByMarker' => BuddybeeConstant::$currency_List_by_marker,
  3822.                         );
  3823.                         $attachments = [];
  3824.                         $forwardToMailAddress $billerDetails->getOAuthEmail();
  3825. //                    $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/temp/' . 'ledger' . '.pdf'
  3826.                         $new_mail $this->get('mail_module');
  3827.                         $new_mail->sendMyMail(array(
  3828.                             'senderHash' => '_CUSTOM_',
  3829.                             //                        'senderHash'=>'_CUSTOM_',
  3830.                             'forwardToMailAddress' => $forwardToMailAddress,
  3831.                             '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 ',
  3832. //                        'fileName' => 'Order#' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.pdf',
  3833.                             'attachments' => $attachments,
  3834.                             'toAddress' => $forwardToMailAddress,
  3835.                             'fromAddress' => 'no-reply@buddybee.eu',
  3836.                             'userName' => 'no-reply@buddybee.eu',
  3837.                             'password' => 'Honeybee@0112',
  3838.                             'smtpServer' => 'smtp.hostinger.com',
  3839.                             'smtpPort' => 465,
  3840. //                            'emailBody' => $bodyHtml,
  3841.                             'mailTemplate' => $bodyTemplate,
  3842.                             'templateData' => $bodyData,
  3843.                             'embedCompanyImage' => 0,
  3844.                             'companyId' => 0,
  3845.                             'companyImagePath' => ''
  3846. //                        'embedCompanyImage' => 1,
  3847. //                        'companyId' => $companyId,
  3848. //                        'companyImagePath' => $company_data->getImage()
  3849.                         ));
  3850.                     }
  3851.                 }
  3852.             }
  3853.         }
  3854.         return new JsonResponse(
  3855.             array(
  3856.                 'success' => true,
  3857.                 'invoiceId' => $request->request->get('invoiceId'0),
  3858.             )
  3859.         );
  3860.     }
  3861.     public function GetBuddybeeDocumentListAction(Request $request$id 0)
  3862.     {
  3863.         $em $this->getDoctrine()->getManager('company_group');
  3864.         $applicantId $request->request->get('applicantId'0);
  3865.         $topicId $request->request->get('topicId'0);
  3866.         $semesterId $request->request->get('semesterId'0);
  3867.         $meetingId $request->request->get('meetingId'0);
  3868.         if ($meetingId != 0) {
  3869.             $meeting $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')->findOneBy(array(
  3870.                 'sessionId' => $meetingId,
  3871.             ));
  3872.             if ($meeting) {
  3873.                 $applicantId $meeting->getStudentId();
  3874.                 $topicId $meeting->getTopicId();
  3875.                 $semesterId $meeting->getSessionValue();
  3876.             }
  3877.         }
  3878.         return new JsonResponse(
  3879.             MiscActions::GetDocumentDataForBuddybeeApplicant($em,
  3880.                 $applicantId,
  3881.                 $topicId,
  3882.                 [$semesterId]
  3883.             )
  3884.         );
  3885.     }
  3886.     public function CancelPaymentAction(Request $request$id 0)
  3887.     {
  3888.         $em $this->getDoctrine()->getManager('company_group');
  3889.         $invoice $em->getRepository('CompanyGroupBundle\\Entity\\EntityInvoice')->findOneBy(array(
  3890.             'Id' => $request->request->get('invoiceId'0),
  3891.         ));
  3892.         $invoice->setIsProcessed(2);
  3893.         if ($invoice->getInvoiceType() == BuddybeeConstant::ENTITY_INVOICE_TYPE_PAYMENT_TO_BUDDYBEE) {
  3894.             $invoice->setIsProcessed(2);
  3895.             $invoice->setIsExpired(1);
  3896.             $meetings $em->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')
  3897.                 ->createQueryBuilder('m')
  3898.                 ->where("(m.sessionId= :session_id  and m.sessionId is NOT NULL )")
  3899.                 ->andWhere("(m.isPaidFull=0 or m.isPaidFull is NULL )")
  3900.                 ->setParameter('session_id'$invoice->getMeetingId())
  3901.                 ->getQuery()
  3902.                 ->getResult();
  3903.             foreach ($meetings as $meeting) {
  3904. //                $meeting->setIsExpired(1);
  3905.                 $em->remove($meeting);
  3906.                 $em->flush();
  3907.             }
  3908.             $em->flush();
  3909.         } //        else if ($invoice->getInvoiceType() == BuddybeeConstant::ENTITY_INVOICE_TYPE_RECEIVE_FROM_BUDDYBEE) {
  3910.         else {
  3911.             $consultant $em->getRepository(EntityApplicantDetails::class)->find($invoice->getApplicantId());
  3912.             $consultant->setAccountBalance($consultant->getAccountBalance() + $invoice->getAmount() * BuddybeeConstant::$convMultFromToWithdrawable[$invoice->getAmountCurrency()]['eur']);
  3913.             $em->flush();
  3914.         }
  3915. //        if(consultant withdraw)
  3916.         {
  3917.         }
  3918.         $em->flush();
  3919.         return new JsonResponse(
  3920.             array(
  3921.                 'success' => true,
  3922.                 'invoiceId' => $request->request->get('invoiceId'0),
  3923.             )
  3924.         );
  3925.     }
  3926.     public function consultantPaymentAction(Request $request$id)
  3927.     {
  3928.         $em_goc $this->getDoctrine()->getManager('company_group');
  3929.         $session $request->getSession();
  3930.         $msg '';
  3931.         $singleConsultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  3932.         if ($request->isMethod('POST')) {
  3933.             if ($singleConsultantDetails)
  3934.                 $consultant $singleConsultantDetails;
  3935.             else
  3936.                 $consultant = new EntityApplicantDetails();
  3937.             $currBalance $consultant->getAccountBalance($request->request->get('currAmount') * BuddybeeConstant::$convMultFromToWithdrawable[$request->request->get('withdrawCurrency''eur')]['eur']);
  3938.             if (($request->request->get('payAmount'0) * BuddybeeConstant::$convMultFromToWithdrawable[$request->request->get('withdrawCurrency''eur')]['eur']) <= $currBalance) {
  3939.                 $new_invoice = new EntityInvoice();
  3940.                 $invoiceDate = new \DateTime();
  3941.                 $new_invoice->setInvoiceDate($invoiceDate);
  3942.                 $new_invoice->setInvoiceDateTs($invoiceDate->format('U'));
  3943.                 $new_invoice->setStudentId($request->request->get('applicantId'0));
  3944. //            $gatewayProductData = json_decode($gatewayInvoice->getProductDataForPaymentGateway(), true);
  3945.                 $gatewayProductData = [];
  3946.                 if ($gatewayProductData == null$gatewayProductData = [];
  3947.                 if (empty($gatewayProductData))
  3948.                     $gatewayProductData = [
  3949.                         [
  3950.                             'price_data' => [
  3951.                                 'currency' => $request->request->get('withdrawCurrency''eur'),
  3952.                                 'unit_amount' => $request->request->get('payAmount'0) != ? (100 $request->request->get('payAmount'0)) : 0,
  3953.                                 'product_data' => [
  3954. //                            'name' => $request->request->has('packageName') ? $request->request->get('packageName') : 'Advanced Consultancy Package',
  3955.                                     'name' => 'Balance Withdraw',
  3956.                                     'images' => [[]],
  3957.                                 ],
  3958.                             ],
  3959.                             'quantity' => 1,
  3960.                         ]
  3961.                     ];
  3962.                 $new_invoice->setProductDataForPaymentGateway(json_encode($gatewayProductData));
  3963.                 $new_invoice->setBillerId($request->request->get('applicantId'0));
  3964.                 $new_invoice->setBillToId(0);//buddybee
  3965.                 $new_invoice->setMeetingId(0);
  3966.                 $new_invoice->setAmount($request->request->get('payAmount'));
  3967.                 $new_invoice->setGateWayBillamount($request->request->get('payAmount'));
  3968.                 $new_invoice->setRedeemedAmount(0);
  3969.                 $new_invoice->setRedeemedSessionCount(0);
  3970.                 $new_invoice->setPaidAmount(0);
  3971.                 $new_invoice->setDueAmount($request->request->get('payAmount'));
  3972.                 $new_invoice->setInvoiceType(BuddybeeConstant::ENTITY_INVOICE_TYPE_RECEIVE_FROM_BUDDYBEE);//receive from buddybee
  3973.                 $new_invoice->setDocumentHash(MiscActions::GenerateRandomCrypto('BEI' microtime(true)));
  3974.                 $new_invoice->setAmountType(1);
  3975.                 $new_invoice->setAmountCurrency($request->request->get('withdrawCurrency''eur'));
  3976.                 $new_invoice->setConsumeAmount(0);
  3977.                 $new_invoice->setSessionCount(0);
  3978.                 $new_invoice->setConsumeSessionCount(0);
  3979.                 $new_invoice->setIsPaidfull(0);
  3980.                 $new_invoice->setIsProcessed(0); //pending for process
  3981.                 $new_invoice->setApplicantId($request->request->get('applicantId'0));
  3982.                 $new_invoice->setIsRecharge(0);
  3983.                 $new_invoice->setIsPayment(1); //0 means receive
  3984.                 $new_invoice->setStatus(GeneralConstant::ACTIVE);
  3985. //            $new_invoice->setStatus($request->request->get(0));
  3986.                 $em_goc->persist($new_invoice);
  3987.                 $em_goc->flush();
  3988.                 $invoiceId $new_invoice->getId();
  3989.                 $consultant->setAccountBalance($currBalance $request->request->get('payAmount') * BuddybeeConstant::$convMultFromToWithdrawable[$request->request->get('withdrawCurrency''eur')]['eur']);
  3990.                 $em_goc->flush();
  3991.                 $singleConsultantDetails $consultant;
  3992.                 $msg "Action Successful!";
  3993.             } else {
  3994.                 $msg "Action Failed!";
  3995.             }
  3996.         }
  3997.         return $this->render('@Buddybee/pages/consultantPayment.html.twig', array(
  3998.             'page_title' => 'Consultant Payment',
  3999.             'consultant' => $singleConsultantDetails,
  4000.             'msg' => $msg,
  4001.         ));
  4002.     }
  4003.     public function checkSingleConsultantBalanceAction(Request $request$id)
  4004.     {
  4005.         $em_goc $this->getDoctrine()->getManager('company_group');
  4006.         $singleConsultantDetails $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  4007.             array(
  4008.                 'applicantId' => $id
  4009.             )
  4010.         );
  4011.         return new JsonResponse(
  4012.             array(
  4013.                 'success' => true,
  4014.                 'accountBalance' => $singleConsultantDetails->getAccountBalance(),
  4015.             )
  4016.         );
  4017.     }
  4018.     public function consultantContractLetterAction(Request $request$id 0)
  4019.     {
  4020.         $gocEnabled 1;
  4021.         $currAppId 1;
  4022.         $session $request->getSession();
  4023.         $em $this->getDoctrine()->getManager();
  4024.         $companyId $this->getLoggedUserCompanyId($request);
  4025.         $designation $em->getRepository("ApplicationBundle\\Entity\\SysDepartmentPosition")->findAll();
  4026.         $departments $em->getRepository("ApplicationBundle\\Entity\\SysDepartment")->findAll();
  4027.         $em_goc $this->getDoctrine()->getManager('company_group');
  4028.         $consultantDetails $em_goc->getRepository(EntityApplicantDetails::class)->find($session->get(UserConstants::USER_ID));
  4029.         $contractLetterHtml '';
  4030.         $requirementsData $em_goc->getRepository("CompanyGroupBundle\\Entity\\EntityCountryConsultantRequirements")->findOneBy(array(
  4031.             'countryId' => $consultantDetails->getCountryId(),
  4032.         ));
  4033.         $currDate = new \DateTime();
  4034.         if ($requirementsData)
  4035.             $contractLetterHtml $requirementsData->getContractLetterHtml();
  4036.         $replaceData = array(
  4037.             "_contract_user_country_name_" => $consultantDetails->getCountry(),
  4038.             "_contract_user_passport_no_" => $consultantDetails->getNid(),
  4039.             "_contract_user_full_name_" => $consultantDetails->getFirstname() . ' ' $consultantDetails->getLastname(),
  4040.             "_contract_user_contract_date_" => $currDate->format('F d, Y'),
  4041.             "_contract_user_father_name_" => $consultantDetails->getFather(),
  4042.             "_contract_user_mother_name_" => $consultantDetails->getMother(),
  4043.             "_contract_user_email_" => $consultantDetails->getOAuthEmail(),
  4044.             "_contract_user_address_" => $consultantDetails->getCurrAddr(),
  4045.             "_contract_dob_" => $consultantDetails->getDob()->format('F d, Y'),
  4046.         );
  4047.         $contractLetterHtml str_ireplace(array_keys($replaceData), $replaceData$contractLetterHtml);
  4048.         if ($request->isMethod('POST')) {
  4049.             if ($consultantDetails)
  4050.                 $consultant $consultantDetails;
  4051.             else
  4052.                 $consultant = new EntityApplicantDetails();
  4053.             if ($request->request->get('confirmStatus'0) == 1) {
  4054.                 $consultant->setIsConsultant(1);
  4055.                 $consultant->setApplyForConsultant(4);
  4056.             } else {
  4057.                 $consultant->setIsConsultant(0);
  4058.                 $consultant->setApplyForConsultant(5);
  4059.             }
  4060.             $em_goc->persist($consultant);
  4061.             $em_goc->flush();
  4062.         }
  4063.         return $this->render('@Buddybee/pages/consultantContractLetter.html.twig', array(
  4064.             'page_title' => 'Consultant Contract',
  4065.             'designation' => $designation,
  4066.             'contractLetterHtml' => $contractLetterHtml,
  4067.             'department' => $departments
  4068.         ));
  4069.     }
  4070.     public function viewAsUserAction(Request $request$id)
  4071.     {
  4072.         $session $request->getSession();
  4073.         $em_goc $this->getDoctrine()->getManager('company_group');
  4074.         $userType $session->get(UserConstants::USER_TYPE);
  4075.         $actualUserId $session->get('actualUserId'$session->get(UserConstants::USER_ID));
  4076.         $actualUserName $session->get('actualUserName'$session->get(UserConstants::USER_NAME));
  4077.         $actualUserType $session->get('actualUserType'$session->get(UserConstants::USER_TYPE));
  4078.         $actualUserAdminLevel $session->get('actualUserAdminLevel'$session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL));
  4079.         $actualUserIsAdmin $session->get('actualUserIsAdmin'$session->get(UserConstants::IS_BUDDYBEE_ADMIN));
  4080.         $actualUserIsModerator $session->get('actualUserIsModerator'$session->get(UserConstants::IS_BUDDYBEE_MODERATOR));
  4081.         $switchToUserId $request->query->get('id'$request->request->get('id'$id));
  4082.         if ($userType == UserConstants::USER_TYPE_APPLICANT) {
  4083.             $user $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(
  4084.                 array(
  4085.                     'applicantId' => $switchToUserId
  4086.                 )
  4087.             );
  4088.             $session->set(UserConstants::USER_ID$user->getApplicantId());
  4089.             $session->set(UserConstants::IS_CONSULTANT$user->getIsConsultant() == 0);
  4090.             $session->set('BUDDYBEE_BALANCE'$user->getAccountBalance());
  4091.             $session->set('BUDDYBEE_COIN_BALANCE'$user->getSessionCountBalance());
  4092.             $session->set(UserConstants::IS_BUDDYBEE_RETAILER$user->getIsRetailer() == 0);
  4093.             $session->set(UserConstants::BUDDYBEE_RETAILER_LEVEL$user->getRetailerLevel() == 0);
  4094.             $session->set(UserConstants::BUDDYBEE_ADMIN_LEVEL$user->getIsAdmin() == ? (($user->getAdminLevel() != null && $user->getAdminLevel() !=)?$user->getAdminLevel():1) : ($user->getIsModerator() == 0));
  4095.             $session->set(UserConstants::IS_BUDDYBEE_MODERATOR$user->getIsModerator() == 0);
  4096.             $session->set(UserConstants::IS_BUDDYBEE_ADMIN$user->getIsAdmin() == 0);
  4097.             // $session->set(UserConstants::SUPPLIER_ID, $user->getSupplierId());
  4098.             $session->set(UserConstants::USER_TYPEUserConstants::USER_TYPE_APPLICANT);
  4099.             $session->set(UserConstants::USER_EMAIL$user->getOauthEmail());
  4100.             $session->set(UserConstants::USER_IMAGE$user->getImage());
  4101.             $session->set(UserConstants::USER_NAME$user->getFirstName() . ' ' $user->getLastName());
  4102.             $session->set(UserConstants::USER_DEFAULT_ROUTE'');
  4103.             $session->set(UserConstants::USER_COMPANY_ID1);
  4104.             $session->set(UserConstants::USER_COMPANY_ID_LISTjson_encode([]));
  4105.             $session->set(UserConstants::USER_COMPANY_NAME_LISTjson_encode([]));
  4106.             $session->set(UserConstants::USER_COMPANY_IMAGE_LISTjson_encode([]));
  4107.             $session->set('userCompanyDarkVibrantList'json_encode([]));
  4108.             $session->set('userCompanyVibrantList'json_encode([]));
  4109.             $session->set('userCompanyLightVibrantList'json_encode([]));
  4110.             $session->set(UserConstants::USER_COMPANY_IMAGE_LISTjson_encode([]));
  4111.             $session->set(UserConstants::USER_APP_ID0);
  4112.             $session->set(UserConstants::USER_POSITION_LIST'[]');
  4113.             $session->set(UserConstants::ALL_MODULE_ACCESS_FLAG0);
  4114.             $session->set(UserConstants::SESSION_SALTuniqid(mt_rand()));
  4115.             $session->set(UserConstants::APPLICATION_SECRET$this->container->getParameter('secret'));
  4116.             $session->set(UserConstants::USER_NOTIFICATION_ENABLEDGeneralConstant::NOTIFICATION_ENABLED == ? ($this->getParameter('notification_enabled') == 0) : 0);
  4117.             $session->set(UserConstants::USER_NOTIFICATION_SERVER$this->getParameter('notification_server'));
  4118.             $session->set('oAuthToken'$request->request->get('oAuthToken'''));
  4119.             $session->set('locale'$request->request->get('locale'''));
  4120.             $session->set('firebaseToken'$request->request->get('firebaseToken'''));
  4121.             $session->set('actualUserId'$actualUserId);
  4122.             $session->set('actualUserName'$actualUserName);
  4123.             $session->set('actualUserType'$actualUserType);
  4124.             $session->set('actualUserAdminLevel'$actualUserAdminLevel);
  4125.             $session->set('actualUserIsAdmin'$actualUserIsAdmin);
  4126.             $session->set('actualUserIsModerator'$actualUserIsModerator);
  4127.             $route_list_array = [];
  4128.             $session->set(UserConstants::USER_CURRENT_POSITION0);
  4129.             $loginID 0;
  4130. //            $loginID = MiscActions::addEntityUserLoginLog(
  4131. //                $em_goc,
  4132. //                $session->get(UserConstants::USER_ID),
  4133. //                $session->get(UserConstants::USER_ID),
  4134. //                1,
  4135. //                $request->server->get("REMOTE_ADDR"),
  4136. //                0,
  4137. //                $request->request->get('deviceId', ''),
  4138. //                $request->request->get('oAuthToken', ''),
  4139. //                $request->request->get('oAuthType', ''),
  4140. //                $request->request->get('locale', ''),
  4141. //                $request->request->get('firebaseToken', '')
  4142. //
  4143. //            );
  4144. //            $session->set(UserConstants::USER_LOGIN_ID, $loginID);
  4145.             if ($request->request->has('referer_path')) {
  4146.                 if ($request->request->get('referer_path') != '/' && $request->request->get('referer_path') != '') {
  4147.                     return $this->redirect($request->request->get('referer_path'));
  4148.                 }
  4149.             }
  4150.             $redirectRoute 'applicant_dashboard';
  4151.             if ($request->query->has('refRoute')) {
  4152.                 if ($request->query->get('refRoute') == '8917922')
  4153.                     $redirectRoute 'apply_for_consultant';
  4154.             }
  4155.             return $this->redirectToRoute($redirectRoute);
  4156.         }
  4157.     }
  4158.     public function UpdateConsultancySessionStatusAction(Request $request$id)
  4159.     {
  4160.         $em_goc $this->getDoctrine()->getManager('company_group');
  4161.         $case $request->request->get('action''_NOTHING_');
  4162.         $options $request->request->get('options', []);
  4163.         switch ($case) {
  4164.             case "_MEETING_COMPLETED_SUCCESSFULLY_":
  4165.                 $func $case '_ACTION';
  4166.                 $returnData Buddybee::$func($em_goc$options);
  4167.                 break;
  4168.             default:
  4169.                 $returnData = array(
  4170.                     'success' => false
  4171.                 );
  4172.         }
  4173.         return new JsonResponse(
  4174.             $returnData
  4175.         );
  4176.     }
  4177.     public function meetingSessionListAction(Request $request)
  4178.     {
  4179.         $em_goc $this->getDoctrine()->getManager('company_group');
  4180.         $session $request->getSession();
  4181. //        $consultantDetails = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findAll();
  4182. //        $meetingSession = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')->findAll();
  4183.         $twigFile '@Buddybee/pages/meetingSessionList.html.twig';
  4184.         if ($session->get(UserConstants::BUDDYBEE_ADMIN_LEVEL) >= 1)
  4185.             $twigFile '@Buddybee/pages/meetingSessionList.html.twig';
  4186.         else if ($session->get('isConsultant') == 1)
  4187.             $twigFile '@Buddybee/pages/meetingSessionListAsConsultant.html.twig';
  4188.         else
  4189.             $twigFile '@Buddybee/pages/meetingSessionListAsStudent.html.twig';
  4190.         return $this->render($twigFile, array(
  4191.             'page_title' => 'Consultancy Session List',
  4192. //            'consultantDetail' => $consultantDetails,
  4193. //            'meetingSession' => $meetingSession,
  4194.         ));
  4195.     }
  4196.     public function ConsultancyTransactionListAction()
  4197.     {
  4198.         $em_goc $this->getDoctrine()->getManager('company_group');
  4199. //        $consultantDetails = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findAll();
  4200. //        $meetingSession = $em_goc->getRepository('CompanyGroupBundle\\Entity\\EntityMeetingSession')->findAll();
  4201.         return $this->render('@Buddybee/pages/consultancy_transaction_list.html.twig', array(
  4202.             'page_title' => 'Transaction List',
  4203. //            'consultantDetail' => $consultantDetails,
  4204. //            'meetingSession' => $meetingSession,
  4205.         ));
  4206.     }
  4207.     public function sendBuddybeeEmailAction(Request $request)
  4208.     {
  4209.         $em $this->getDoctrine()->getManager('company_group');
  4210.         $consultantDetails $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findAll();
  4211.         $allTargetIds = [];
  4212.         $emailAddressList = [];
  4213.         $targets = [];
  4214.         if ($request->isMethod('POST')) {
  4215.             //addding log
  4216.             if ($request->request->get('userSelectionType''NONE') == 1) {
  4217.                 $emailAddressList explode(','$request->request->get('email''NONE'));
  4218.             } elseif ($request->request->get('userSelectionType''NONE') == 2) {
  4219.                 $preferredCountryIds $request->request->get('preferredCountryIdsAsStudent', []);
  4220.                 $queryStr '';
  4221.                 foreach ($preferredCountryIds as $p) {
  4222.                     if ($queryStr != '')
  4223.                         $queryStr .= " or ";
  4224.                     $queryStr .= " m.preferredCountryIdsAsStudent like '%\"$p\"%'";
  4225.                 }
  4226.                 if ($queryStr == '')
  4227.                     $targets $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4228.                         ->createQueryBuilder('m')
  4229.                         ->where("m.isConsultant = 0 or m.isConsultant is NULL ")
  4230.                         ->getQuery()
  4231. //                            ->setMaxResults(1)
  4232.                         ->getResult();
  4233.                 else
  4234.                     $targets $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4235.                         ->createQueryBuilder('m')
  4236.                         ->where("m.isConsultant = 0 or m.isConsultant is NULL ")
  4237.                         ->andwhere(' ( ' $queryStr ' ) ')
  4238.                         ->getQuery()
  4239. //                            ->setMaxResults(10)
  4240.                         ->getResult();
  4241.                 foreach ($targets as $target) {
  4242.                     $emailAddressList[] = $target->getoAuthEmail(); //remove this and fill u[p
  4243.                 }
  4244.             } elseif ($request->request->get('userSelectionType''NONE') == 3) {
  4245.                 $targets $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4246.                     ->findBy(
  4247.                         array(//                            'isConsultant' => [0,null]
  4248.                         )
  4249.                     );
  4250.                 foreach ($targets as $target) {
  4251.                     $emailAddressList[] = $target->getoAuthEmail(); //remove this and fill u[p
  4252.                 }
  4253.             } elseif ($request->request->get('userSelectionType''NONE') == 4) {
  4254.                 $targets $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4255.                     ->findBy(
  4256.                         array(
  4257.                             'isConsultant' => [0null],
  4258. //                            'isAdmin' => [0,null]
  4259.                         )
  4260.                     );
  4261.                 foreach ($targets as $target) {
  4262.                     $emailAddressList[] = $target->getoAuthEmail(); //remove this and fill u[p
  4263.                 }
  4264.             } elseif ($request->request->get('userSelectionType''NONE') == 5) {
  4265.                 $targets $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4266.                     ->findBy(
  4267.                         array(
  4268.                             'isConsultant' => 1,
  4269. //                            'isAdmin' => [0,null]
  4270.                         )
  4271.                     );
  4272.                 foreach ($targets as $target) {
  4273.                     $emailAddressList[] = $target->getoAuthEmail(); //remove this and fill u[p
  4274.                 }
  4275.             }
  4276.             if (empty($targets))
  4277.                 $targets $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')
  4278.                     ->findBy(
  4279.                         array(
  4280.                             'oAuthEmail' => $emailAddressList
  4281.                         )
  4282.                     );
  4283.             foreach ($targets as $target) {
  4284. //                if($target->getIsAdmin()==null || $target->getIsAdmin()<=0)
  4285. //                if($target->getIsConsultant()==null || $target->getIsConsultant()<=0)
  4286.                 $allTargetIds[] = $target->getApplicantId();
  4287.             }
  4288.             foreach ($allTargetIds as $tid) {
  4289.                 $comm $em->getRepository('CompanyGroupBundle\\Entity\\EntityCommunicationLog')
  4290.                     ->findOneBy(
  4291.                         array(
  4292.                             'targetId' => $tid
  4293.                         )
  4294.                     );
  4295.                 if (!$comm)
  4296.                     $comm = new EntityCommunicationLog();
  4297.                 $commData json_decode($comm->getCommunicationHistory(), true);
  4298.                 if ($commData == null)
  4299.                     $commData = [];;
  4300.                 $currDate = new \DateTime();
  4301.                 $currDateTs $currDate->format('U');
  4302.                 $actionTaken 1;
  4303.                 $dt = array(
  4304.                     'commId' => '',
  4305.                     'promiseType' => 0,
  4306.                     'commType' => 3,
  4307.                     'refFollowUpId' => 0,
  4308.                     'commDateTs' => $currDateTs,
  4309.                     'commEndDateTs' => $currDateTs,
  4310.                     'followUpDateTs' => $currDateTs,
  4311.                     'communicationFeedback' => 'Mail Sent With Subject : ' $request->request->get('subject'),
  4312.                     'actionTaken' => $actionTaken,
  4313.                     'reminderDateTs' => $currDateTs,
  4314.                     'reminderEnabled' => 0,
  4315.                 );
  4316.                 $commData[] = $dt;
  4317.                 $comm->setTargetId($tid);
  4318.                 $comm->setCommunicationHistory(json_encode($commData));
  4319.                 $em->persist($comm);
  4320.                 $em->flush();
  4321.             }
  4322.             //log ended
  4323.             $bodyTemplate '@Application/email/templates/systemEmailTemplate.html.twig';
  4324.             $bodyHtml $request->request->get('emailBody');
  4325.             $bodyData = array(
  4326.                 'bodyHtml' => $bodyHtml,
  4327.             );
  4328.             $new_mail $this->get('mail_module');
  4329. //                return new JsonResponse(
  4330. //                    $emailAddressList
  4331. //                );
  4332.             for ($p 0$p count($emailAddressList); $p $p 15) {
  4333.                 $chunkEmailAddress array_slice($emailAddressList$p15);
  4334.                 $new_mail->sendMyMail(array(
  4335.                     'senderHash' => '_CUSTOM_',
  4336.                     'encryptionMethod' => 'ssl',
  4337.                     'fromAddress' => 'no-reply@buddybee.eu',
  4338.                     'userName' => 'no-reply@buddybee.eu',
  4339.                     'password' => 'Honeybee@0112',
  4340.                     'smtpServer' => 'smtp.hostinger.com',
  4341.                     'smtpPort' => 465,
  4342.                     'forwardToMailAddress' => implode(','$chunkEmailAddress),
  4343.                     'subject' => $request->request->get('subject'),
  4344.                     'fileName' => '',
  4345.                     //'attachments' => $attachments,
  4346.                     'toAddress' => implode(','$chunkEmailAddress),
  4347.                     'mailTemplate' => $bodyTemplate,
  4348.                     'templateData' => $bodyData,
  4349. //                'embedCompanyImage' => 0,
  4350.                 ));
  4351.             }
  4352.         }
  4353.         return $this->render('@Buddybee/pages/email.html.twig', array(
  4354.             'page_title' => 'Send Email',
  4355.             'consultantDetails' => $consultantDetails
  4356.         ));
  4357.     }
  4358.     public function MakeAdminAction(Request $request$id 0)
  4359.     {
  4360.         $em $this->getDoctrine()->getManager('company_group');
  4361.         $consultant $em->getRepository('CompanyGroupBundle\\Entity\\EntityApplicantDetails')->findOneBy(array(
  4362.             'Id' => ""
  4363.         ));
  4364. //        $consultant = $em->getRepository(EntityApplicantDetails::class)->find($invoice->getApplicantId());
  4365. //        $consultant->setAccountBalance($consultant->getAccountBalance() + $invoice->getAmount());
  4366.         $em->flush();
  4367.         return new JsonResponse(
  4368.             array(
  4369.                 'success' => true,
  4370.             )
  4371.         );
  4372.     }
  4373.     public function viewBuddybeeTicketAction($id 0)
  4374.     {
  4375.         $em_goc $this->getDoctrine()->getManager('company_group');
  4376.         $ticket $em_goc->getRepository("CompanyGroupBundle\\Entity\\EntityTicket")->find($id);
  4377.         return $this->render('@Buddybee/pages/view_buddybee_ticket.html.twig', array(
  4378.             'page_title' => 'View Ticket',
  4379.             'ticket' => $ticket
  4380.         ));
  4381.     }
  4382.     public function countryListAction()
  4383.     {
  4384.         return $this->render('@Buddybee/pages/country_list.html.twig', array(
  4385.             'page_title' => 'Country List',
  4386.         ));
  4387.     }
  4388.     public function LeadManagementPanelAction(Request $request$id 0)
  4389.     {
  4390.         $currencyForGateway $request->query->get('currency'$request->request->get('currency''bdt'));
  4391.         $invoiceId 0;
  4392.         return $this->render('@Buddybee/pages/buddybee_lead_managing_panel.html.twig', array(
  4393.             'page_title' => 'Lead Management',
  4394.             'commPromiseTypes' => BuddybeeConstant::$commPromiseTypes,
  4395.             'currencyForGateway' => $currencyForGateway,
  4396.             'invoiceId' => $invoiceId,
  4397.             'packageDetails' => BuddybeeConstant::$packageDetails,
  4398.             'convMultFromTo' => BuddybeeConstant::$convMultFromTo,
  4399.             'commPromiseDetails' => BuddybeeConstant::$commPromiseDetails,
  4400.             'commTypes' => BuddybeeConstant::$commTypes,
  4401.             'commImportantTagsByHash' => BuddybeeConstant::$commImportantTagsByHash,
  4402.             'id' => $id,
  4403.         ));
  4404.     }
  4405. }