src/ApplicationBundle/Modules/MarketPlace/Controller/MarketPlacePublicController.php line 378

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Modules\MarketPlace\Controller;
  3. use ApplicationBundle\Constants\EmployeeConstant;
  4. use ApplicationBundle\Constants\GeneralConstant;
  5. use ApplicationBundle\Controller\GenericController;
  6. use ApplicationBundle\Modules\Authentication\Constants\UserConstants; use ApplicationBundle\Modules\Api\Constants\ApiConstants;
  7. use ApplicationBundle\Modules\Buddybee\Buddybee;
  8. use ApplicationBundle\Modules\System\MiscActions;
  9. use ApplicationBundle\Modules\User\Company;
  10. use ApplicationBundle\Modules\Inventory\Inventory;
  11. use CompanyGroupBundle\Entity\EntityCreateTopic;
  12. use CompanyGroupBundle\Entity\EntityInvoice;
  13. use CompanyGroupBundle\Entity\EntityMeetingSession;
  14. use Endroid\QrCode\Builder\BuilderInterface;
  15. use Endroid\QrCodeBundle\Response\QrCodeResponse;
  16. use Ps\PdfBundle\Annotation\Pdf;
  17. use Symfony\Component\HttpFoundation\JsonResponse;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  20. use Symfony\Component\Routing\Generator\UrlGenerator;
  21. class MarketPlacePublicController extends GenericController
  22. {
  23.     // home
  24.     public function HomeViewAction(Request $request$id 0)
  25.     {
  26.         $em $this->getDoctrine()->getManager();
  27.         $companyId $this->getLoggedUserCompanyId($request);
  28.         $company_data Company::getCompanyData($em$companyId);
  29.         $products $em->getRepository('ApplicationBundle\\Entity\\InvProducts')->findOneBy(
  30.             array(
  31.                 'id' => $id
  32.             )
  33.         );
  34.         $dataArray = array(
  35.             'page_title' => 'Home',
  36.             'company_data' => $company_data,
  37.             'products' => $products,
  38.             'brandList' => Inventory::GetBrandList($em$companyId),
  39.             'igList' => Inventory::ItemGroupList($em$companyId)
  40.         );
  41.         return $this->render('@MarketPlace/pages/views/market_place_home_view.html.twig'$dataArray
  42.         );
  43.     }
  44.     public function CompareProductViewAction(Request $request)
  45.     {
  46.         $em $this->getDoctrine()->getManager();
  47.         if ($request->get('returnJson'0) == 1) {
  48.             $pids $request->get('pIds', []);
  49.             $tempProductData $em->getRepository('ApplicationBundle\\Entity\\InvProducts')
  50.                 ->findBy(
  51.                     array(
  52.                         'id' => $pids
  53.                     )
  54.                 );
  55.             // For FIFO structure
  56.             $productDataObjects = [];
  57.             foreach ($pids as $pid) {
  58.                 foreach ($tempProductData as $tempProduct) {
  59.                     if ($tempProduct->getId() == $pid) {
  60.                         $productDataObjects[] = $tempProduct;
  61.                         break;
  62.                     }
  63.                 }
  64.             }
  65.             $data = [];
  66.             $specIds = [];
  67.             $specListById = [];
  68.             foreach ($productDataObjects as $productDataObject) {
  69.                 $specData = [];
  70.                 $tempSpecData json_decode($productDataObject->getSpecData(), true);
  71.                 if ($tempSpecData == null$tempSpecData = [];
  72.                 foreach ($tempSpecData as $indSpecData) {
  73.                     $specData[$indSpecData['id']] = [
  74.                         'id' => $indSpecData['id'],
  75.                         'value' => $indSpecData['value']
  76.                     ];
  77.                     if (!in_array($indSpecData['id'], $specIds))
  78.                         $specIds[] = $indSpecData['id'];
  79.                 }
  80.                 $d = array(
  81.                     'id' => $productDataObject->getId(),
  82.                     'name' => $productDataObject->getName(),
  83.                     'defaultImage' => $productDataObject->getDefaultImage(),
  84.                     'specData' => $specData,
  85.                 );
  86.                 $data[] = $d;
  87.             }
  88.             $specList $em->getRepository('ApplicationBundle\\Entity\\SpecType')
  89.                 ->findBy(
  90.                     array(
  91.                         'id' => $specIds
  92.                     )
  93.                 );
  94.             $specListById = [];
  95.             foreach ($specList as $specHere) {
  96.                 $specListById[$specHere->getId()] = $specHere->getName();
  97.             }
  98.             return new JsonResponse(array('data' => $data'specListById' => $specListById'specIds' => $specIds));
  99.             //            foreach ($specData as $specDatum){
  100.             //                $finSpecData[]=[
  101.             //                    'id' => $specDatum['id'],
  102.             //                    'name' => isset($specListById[$specDatum['id']])?$specListById[$specDatum['id']]:'',
  103.             //                    'value' => $specDatum['value']
  104.             //                ];
  105.             //            }
  106.         }
  107.         return $this->render('@MarketPlace/pages/views/market_place_compare_products.html.twig',
  108.             array(
  109.                 'page_title' => 'Compare Products',
  110.             ));
  111.     }
  112.     // about us
  113.     public function AboutUsViewAction()
  114.     {
  115.         return $this->render('@MarketPlace/pages/views/market_place_about_us.html.twig',
  116.             array(
  117.                 'page_title' => 'About Us',
  118.             ));
  119.     }
  120.     // our product
  121.     public function ProductListAction(Request $request$id 0)
  122.     {
  123.         $em $this->getDoctrine()->getManager();
  124.         $companyId $this->getLoggedUserCompanyId($request);
  125.         $company_data Company::getCompanyData($em$companyId);
  126.         $products $em->getRepository('ApplicationBundle\\Entity\\InvProducts')->findOneBy(
  127.             array(
  128.                 'id' => $id
  129.             )
  130.         );
  131.         $dataArray = array(
  132.             'page_title' => 'Our Product',
  133.             'company_data' => $company_data,
  134.             'products' => $products,
  135.             'brandList' => Inventory::GetBrandList($em$companyId),
  136.             'igList' => Inventory::ItemGroupList($em$companyId)
  137.         );
  138.         return $this->render('@MarketPlace/pages/list/market_place_product_list.html.twig'$dataArray
  139.         );
  140.     }
  141.     // our prpject
  142.     public function OurProjectAction()
  143.     {
  144.         return $this->render('@MarketPlace/pages/views/market_place_our_project.html.twig',
  145.             array(
  146.                 'page_title' => 'Our Project',
  147.             )
  148.         );
  149.     }
  150.     // single project
  151.     public function SingleProjectAction()
  152.     {
  153.         return $this->render('@MarketPlace/pages/views/market_place_single_project.html.twig',
  154.             array(
  155.                 'page_title' => 'Project Details',
  156.             )
  157.         );
  158.     }
  159.     // single product
  160.     public function ProductViewAction(Request $request$id 0)
  161.     {
  162.         $em $this->getDoctrine()->getManager();
  163.         $companyId $this->getLoggedUserCompanyId($request);
  164.         $company_data Company::getCompanyData($em$companyId);
  165.         $data = [];
  166.         $ex_id $id;
  167.         $specData = [];
  168.         $specIds = [];
  169.         $productData $em->getRepository('ApplicationBundle\\Entity\\InvProducts')
  170.             ->findOneBy(
  171.                 array(
  172.                     'id' => $id,
  173.                 )
  174.             );
  175.         if ($productData) {
  176.             $tempSpecData json_decode($productData->getSpecData(), true);
  177.             if ($tempSpecData == null) {
  178.                 $tempSpecData = [];
  179.             }
  180.             foreach ($tempSpecData as $indx) {
  181.                 $specData[] = [
  182.                     'id' => $indx['id'],
  183.                     'value' => $indx['value'],
  184.                 ];
  185.                 $specIds[] = $indx['id'];
  186.             }
  187.         }
  188.         $specList $em->getRepository('ApplicationBundle\\Entity\\SpecType')->findBy(
  189.             array(
  190.                 'id' => $specIds
  191.             )
  192.         );
  193.         $specListById = [];
  194.         foreach ($specList as $specDatum) {
  195.             $specListById[$specDatum->getId()] = $specDatum->getName();
  196.         }
  197.         $finSpecData = [];
  198.         foreach ($specData as $specDatum) {
  199.             $finSpecData[] = [
  200.                 'id' => $specDatum['id'],
  201.                 'name' => isset($specListById[$specDatum['id']]) ? $specListById[$specDatum['id']] : '',
  202.                 'value' => $specDatum['value'],
  203.             ];
  204.         }
  205.         $productFdm $productData->getProductFdm();
  206.         preg_match('/SZ(\d+)/'$productFdm$szMatch);
  207.         preg_match('/SO(\d+)/'$productFdm$soMatch);
  208.         preg_match('/ST(\d+)/'$productFdm$stMatch);
  209.         preg_match('/SH(\d+)/'$productFdm$shMatch);
  210.         $subCategoryZeroId $szMatch[1] ?? null;
  211.         $subCategoryOneId $soMatch[1] ?? null;
  212.         $subCategoryTwoId $stMatch[1] ?? null;
  213.         $subCategoryThreeId $shMatch[1] ?? null;
  214.         //        dump($subCategoryOneId);
  215.         $currInvList $em->getRepository('ApplicationBundle\\Entity\\InventoryStorage')
  216.             ->findBy(
  217.                 array(
  218.                     'productId' => $id
  219.                 )
  220.             );
  221.         $trans_history $em->getRepository('ApplicationBundle\\Entity\\InvItemTransaction')
  222.             ->findBy(
  223.                 array(
  224.                     'productId' => $id
  225.                 ), array(
  226.                     'transactionDate' => 'ASC',
  227.                     'id' => 'ASC'
  228.                 )
  229.             );
  230.         $igData $em->getRepository('ApplicationBundle\\Entity\\InvItemGroup')
  231.             ->findOneBy(array(
  232.                 'id' => $productData->getIgId(),
  233.             ));
  234.         $itemGroupList = [];
  235.         $categorizationData json_decode($igData->getCategorizationData(), true) ??
  236.             [
  237.                 ["alias" => "Category""en" => 1"inc" => "1"],
  238.                 ["alias" => "Sub Category""en" => 1"inc" => "1"],
  239.             ];
  240.         $subCategoryTypes $em->getRepository('ApplicationBundle\\Entity\\InvProductSubCategories')
  241.             ->findBy(array(
  242.                 'id' => [$subCategoryZeroId$subCategoryOneId$subCategoryTwoId$subCategoryThreeId],
  243.             ));
  244.         $subCategoryTypeList = [];
  245.         foreach ($subCategoryTypes as $sc) {
  246.             $subCategoryTypeList[$sc->getId()] = $sc->getName();
  247.         }
  248.         $productDataObj = array();
  249.         if ($request->isMethod('POST') && $request->request->has('returnJson')) {
  250.             $getters array_filter(get_class_methods($productData), function ($method) {
  251.                 return 'get' === substr($method03);
  252.             });
  253.             foreach ($getters as $getter) {
  254.                 if ($getter == 'getGlobalId')
  255.                     continue;
  256.                 $Fieldname str_replace('get'''$getter);
  257.                 $productDataObj[$Fieldname] = $productData->{$getter}(); // `foo!`
  258.             }
  259.             if ($request->request->has('genInfoOnly') && $request->request->get('genInfoOnly') == 1) {
  260.                 $dataArray = array(
  261.                     'success' => true,
  262.                     'page_title' => 'Product Details',
  263.                     'company_data' => $company_data,
  264.                     'ex_id' => $ex_id,
  265.                     'productData' => $productData,
  266.                     'productDataObj' => $productDataObj,
  267.                     'defaultImageAppendUrl' => '/uploads/Products/',
  268.                 );
  269.             } else {
  270.                 $dataArray = array(
  271.                     'success' => true,
  272.                     'page_title' => 'Product Details',
  273.                     'og_title' => $productDataObj->getName(),
  274.                     'og_image' => $productDataObj->getDefaultImage(),
  275.                     'company_data' => $company_data,
  276.                     'ex_id' => $ex_id,
  277.                     'productData' => $productData,
  278.                     'productDataObj' => $productDataObj,
  279.                     'finSpecData' => $finSpecData,
  280.                     'currInvList' => $currInvList,
  281.                     'trans_history' => $trans_history,
  282.                     'entityList' => GeneralConstant::$Entity_list_details,
  283.                     'itemGroupList' => $itemGroupList,
  284.                     'categorizationData' => $categorizationData,
  285.                     'products' => Inventory::ProductList($this->getDoctrine()->getManager()),
  286.                     'subCategoryList' => $subCategoryTypeList,
  287.                     'categoryList' => Inventory::ProductCategoryList($em$companyId),
  288.                     'igList' => Inventory::ItemGroupList($em$companyId),
  289.                     'unitList' => Inventory::UnitTypeList($em),
  290.                     'brandList' => Inventory::GetBrandList($em$companyId),
  291.                     'warehouse_action_list' => Inventory::warehouse_action_list($em$this->getLoggedUserCompanyId($request), 'object'),
  292.                     'warehouseList' => Inventory::WarehouseList($em),
  293.                     'defaultImageAppendUrl' => '/uploads/Products/',
  294.                 );
  295.             }
  296.             return new JsonResponse(
  297.                 $dataArray
  298.             );
  299.         }
  300.         $dataArray = array(
  301.             'page_title' => 'Product Details',
  302.             'company_data' => $company_data,
  303.             'ex_id' => $ex_id,
  304.             'productData' => $productData,
  305.             'finSpecData' => $finSpecData,
  306.             'currInvList' => $currInvList,
  307.             'trans_history' => $trans_history,
  308.             'entityList' => GeneralConstant::$Entity_list_details,
  309.             'productList' => Inventory::ProductList($em$companyId),
  310.             'itemGroupList' => $itemGroupList,
  311.             'categorizationData' => $categorizationData,
  312.             'subCategoryZeroId' => $subCategoryZeroId,
  313.             'subCategoryOneId' => $subCategoryOneId,
  314.             'subCategoryTwoId' => $subCategoryTwoId,
  315.             'subCategoryThreeId' => $subCategoryThreeId,
  316.             //'productList' => Inventory::ProductList($em, $companyId),
  317.             'products' => Inventory::ProductList($this->getDoctrine()->getManager()),
  318.             'subCategoryList' => $subCategoryTypeList,
  319.             'categoryList' => Inventory::ProductCategoryList($em$companyId),
  320.             'igList' => Inventory::ItemGroupList($em$companyId),
  321.             'unitList' => Inventory::UnitTypeList($em),
  322.             'spec_type' => Inventory::SpecTypeList($this->getDoctrine()->getManager()),
  323.             'brandList' => Inventory::GetBrandList($em$companyId),
  324.             'warehouse_action_list' => Inventory::warehouse_action_list($em$this->getLoggedUserCompanyId($request), 'object'),
  325.             'warehouseList' => Inventory::WarehouseList($em),
  326.         );
  327.         return $this->render('@MarketPlace/pages/views/market_place_product_view.html.twig'$dataArray
  328.         );
  329.     }
  330.     // ** list related page **
  331.     // customer plant
  332.     public function CustomerPlantViewAction()
  333.     {
  334.         return $this->render('@MarketPlace/pages/list/market_place_build_customer_plant_list.html.twig',
  335.             array(
  336.                 'page_title' => 'Build Customer plant',
  337.             ));
  338.     }
  339.     // *****sofia project started*****
  340.     // sign in page
  341.     public function SofiaSignIn()
  342.     {
  343.         return $this->render('@MarketPlace/pages/views/sofia_login.html.twig',
  344.             array(
  345.                 'page_title' => 'Sofia Login',
  346.             ));
  347.     }
  348.     // sign up page
  349.     public function SofiaSignUp()
  350.     {
  351.         return $this->render('@MarketPlace/pages/views/sofia_signup.html.twig',
  352.             array(
  353.                 'page_title' => 'Sofia Signup',
  354.             ));
  355.     }
  356.     // confirmation
  357.     public function SofiaConfirmation()
  358.     {
  359.         return $this->render('@MarketPlace/pages/views/sofia_confirmation.html.twig',
  360.             array(
  361.                 'page_title' => 'Sofia Confirmation',
  362.             ));
  363.     }
  364.     // create site
  365.     public function SofiaCreatesite()
  366.     {
  367.         return $this->render('@MarketPlace/pages/views/sofia_create_site.html.twig',
  368.             array(
  369.                 'page_title' => 'Create Site',
  370.             ));
  371.     }
  372.     // dashboard details
  373.     public function SofiaDashboardDetails()
  374.     {
  375.         return $this->render('@MarketPlace/pages/views/sofia_dashboard_details.html.twig',
  376.             array(
  377.                 'page_title' => 'Create Site',
  378.             ));
  379.     }
  380.     // dashboard admin
  381.     public function SofiaDashboardCheckSiteHeartbeat(Request $request$id 0)
  382.     {
  383.         $sitesQry $this->getDoctrine()->getManager('company_group')
  384.             ->getRepository("CompanyGroupBundle\\Entity\\EmsSite")
  385.             ->findBy(array(
  386.                 'id' => $request->get('site_ids')
  387.             ));
  388.         $sites = [];
  389.         foreach ($sitesQry as $site) {
  390.             $siteDT = array(
  391.                 'siteId' => $site->getId(),
  392.                 'siteName' => $site->getSiteName(),
  393.                 'siteNote' => $site->getSiteNote(),
  394.                 'siteLocation' => $site->getSiteLocation(),
  395.                 'address' => $site->getAddress(),
  396.                 'siteActive' => 0,
  397.                 'lastDataSince' => 0,
  398.             );
  399.             $siteDataQry $this->getDoctrine()->getManager('company_group')
  400.                 ->getRepository("CompanyGroupBundle\\Entity\\DeviceSensorData")
  401.                 ->findOneBy(array(
  402.                     'siteId' => $site->getId(),
  403.                 ), array(
  404.                     'timestampTs' => 'DESC'
  405.                 ));
  406.             if ($siteDataQry) {
  407.                 $siteDT['lastDataSince'] = $siteDataQry->getTimestampTs();
  408.             }
  409.             $sites[] = $siteDT;
  410.         }
  411.         return new JsonResponse(array(
  412.             'success' => true,
  413.             'sites' => $sites,
  414.             'siteIds' =>  $request->get('site_ids'),
  415.         ));
  416.     }
  417.     public function SofiaDashboardAdmin()
  418.     {
  419.         $sitesQry $this->getDoctrine()->getManager('company_group')
  420.             ->getRepository("CompanyGroupBundle\\Entity\\EmsSite")
  421.             ->findBy(array());
  422.         $sites = [];
  423.         $siteIds = [];
  424.         foreach ($sitesQry as $site) {
  425.             $siteDT = array(
  426.                 'siteId' => $site->getId(),
  427.                 'siteName' => $site->getSiteName(),
  428.                 'siteNote' => $site->getSiteNote(),
  429.                 'siteLocation' => $site->getSiteLocation(),
  430.                 'address' => $site->getAddress(),
  431.                 'siteActive' => 0,
  432.                 'lastDataSince' => '',
  433.             );
  434.             $siteDataQry $this->getDoctrine()->getManager('company_group')
  435.                 ->getRepository("CompanyGroupBundle\\Entity\\DeviceSensorData")
  436.                 ->findOneBy(array(
  437.                     'siteId' => $site->getId(),
  438.                 ), array(
  439.                     'timestampTs' => 'DESC'
  440.                 ));
  441.             if ($siteDataQry) {
  442.                 $siteDT['lastDataSince'] = $siteDataQry->getTimestampTs();
  443.             }
  444.             $sites[$site->getId()] = $siteDT;
  445.             $siteIds[] = 1*$site->getId();
  446.         }
  447.         return $this->render('@MarketPlace/pages/views/sofia_dashboard_admin.html.twig',
  448.             array(
  449.                 'page_title' => 'Dashboard Admin',
  450.                 'sites' => $sites,
  451.                 'siteIds' => $siteIds,
  452.             ));
  453.     }
  454.     // dashboard graph
  455.     public function SofiaDashboardGraph(Request $request$id 0)
  456.     {
  457.         return $this->render('@MarketPlace/pages/views/sofia_dashboard_graph.html.twig',
  458.             array(
  459.                 'page_title' => 'Dashboard Graph',
  460.                 'siteId' => $id,
  461.             ));
  462.     }
  463.     // dashboard profile
  464.     public function SofiaDashboardUserProfile()
  465.     {
  466.         return $this->render('@MarketPlace/pages/views/sofia_user_profile.html.twig',
  467.             array(
  468.                 'page_title' => 'User Profile',
  469.             ));
  470.     }
  471. }