src/Controller/PincodeController.php line 466

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Pimcore\Controller\FrontendController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use symfony\Component\Routing\Annotation\Route;
  7. use Pimcore\Model\DataObject;
  8. use Pimcore\Model\Asset\Service;
  9. use Pimcore\Model\DataObject\Service as DoService;
  10. use Carbon\Carbon;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. class PincodeController extends FrontendController
  13. {
  14.     /**
  15.      * @param Request $request
  16.      * 
  17.      * @Route("/createItcPincode")
  18.      * 
  19.      * @return Response
  20.      * 
  21.      */
  22.     public function createItcPincodeAction(Request $request): Response
  23.     {
  24.         
  25.         
  26.         $pincode $request->get('pincode');
  27.         $locationcode $request->get('locationcode');
  28.         $city $request->get('city');
  29.         $state $request->get('state');
  30.         $deliveryType $request->get('deliveryType');
  31.         $is_shippingapplicable $request->get('shippingapplicable');
  32.         $merichakki_available $request->get('merichakki_available');
  33.         $nammachakki_available $request->get('nammachakki_available');
  34.         $vin_instance $request->get('vin_instance');
  35.         $createAssetFolder DoService::createFolderByPath('Pincode');
  36.         $objParentId $createAssetFolder->getId();
  37.         
  38.         if(!empty($pincode)){
  39.          
  40.             $location_code_array DataObject\Locations::getById($locationcode);
  41.             $holidayObjectName $pincode;
  42.             //Create a new object
  43.             $newObject = new DataObject\ItcAddPincode(); 
  44.             $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey($holidayObjectName'object'));
  45.             $newObject->setParentId($objParentId);
  46.             $newObject->setpincode($pincode);
  47.             $newObject->setlocation_code($location_code_array->getlocation_name());
  48.             $newObject->setcity($city);  
  49.             $newObject->setstate($state);
  50.             $newObject->setdeliverytype($deliveryType);
  51.             $newObject->setis_shipping_applicable($is_shippingapplicable);
  52.             $newObject->setmerichakki_available($merichakki_available);
  53.             $newObject->setnammachakki_available($nammachakki_available);
  54.             $newObject->setvin_instance($vin_instance);
  55.             $newObject->setPublished(true);
  56.             $newObject->save();
  57.             $locationsList DataObject\Locations::getList();
  58.             $locationsList->load();
  59.         
  60.             $entries = new DataObject\ItcAddPincode\Listing();
  61.             return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  62.     
  63.         }else{
  64.             $locationsList DataObject\Locations::getList();
  65.             $locationsList->load();
  66.             return $this->render('pincode/create-pincode.html.twig',['locationsList' => $locationsList ]);
  67.         }
  68.          
  69.     }
  70.     /**
  71.      * @param Request $request
  72.      * 
  73.      * @Route("/itcpincodeListingAction")
  74.      * 
  75.      * @return Response
  76.      * 
  77.      */
  78.     public function itcpincodeListingAction(Request $request): Response
  79.     {
  80.         
  81.         
  82.         $locationsList DataObject\Locations::getList();
  83.         $locationsList->load();
  84.         // return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  85.         // $conn = $this->container->get('doctrine')->getConnection('default');
  86.         // $sql = "select * from ...;";
  87.         // $stmt = $conn->query(sprintf($sql, $credentials['username'], sha1($credentials['password'])));
  88.         // $res = $stmt->fetch();
  89.         return $this->render('pincode/listing-pincode.html.twig'compact('locationsList'));
  90.    
  91.     }
  92.     /**
  93.      * @param Request $request
  94.      * 
  95.      * @Route("/editItcPincode/{id}")
  96.      * 
  97.      * @return Response
  98.      * 
  99.      */ 
  100.     public function editItcPincodeAction($id) { 
  101.          
  102.         $entries DataObject\ItcAddPincode::getById($id); 
  103.         $locationsLists DataObject\Locations::getList();
  104.         $locationsLists->load();
  105.         $location_codes $entries->getlocation_code();
  106.         $locationsList = new DataObject\Locations\Listing();
  107.         $locationsList->setCondition("location_name = :name", ["name" => $location_codes]);
  108.         $locationsList->load();
  109.         foreach($locationsList as $locations){
  110.             $selected '';
  111.             if(!empty($hol_locs) && $hol_locs
  112.             $selected ' selected';
  113.             $locations->selected $selected;
  114.         }
  115.         return $this->render('pincode/edit-pincode.html.twig'compact('entries','locationsList','locationsLists')); 
  116.     }
  117.     /**
  118.      * @param Request $request
  119.      * 
  120.      * @Route("/updateItcPincode")
  121.      * 
  122.      * @return Response
  123.      * 
  124.      */
  125.     public function updateItcPincodeAction(Request $request): Response
  126.     {
  127.         
  128.         
  129.         $pincode $request->get('pincode');
  130.         $locationcode $request->get('locationcode');
  131.         $state $request->get('state');
  132.         $city $request->get('city');
  133.         $deliveryType $request->get('deliveryType');
  134.         $pincodeid $request->get('pincodeid');
  135.         $is_shippingapplicable $request->get('shippingapplicable');
  136.         $merichakki_available $request->get('merichakki_available');
  137.         $nammachakki_available $request->get('nammachakki_available');
  138.         $vin_instance $request->get('vin_instance');
  139.         $locationsList DataObject\Locations::getList();
  140.         $locationsList->load();
  141.         $location_code_array DataObject\Locations::getById($locationcode);
  142.         
  143.         //Create a new object
  144.         $newObject DataObject\ItcAddPincode::getById($pincodeid); 
  145.         $newObject->setpincode($pincode);
  146.         $newObject->setlocation_code($location_code_array->getlocation_name());
  147.         $newObject->setcity($city);  
  148.         $newObject->setstate($state);
  149.         $newObject->setdeliverytype($deliveryType);
  150.         $newObject->setis_shipping_applicable($is_shippingapplicable);
  151.         $newObject->setmerichakki_available($merichakki_available);
  152.         $newObject->setnammachakki_available($nammachakki_available);
  153.         $newObject->setvin_instance($vin_instance);
  154.         $newObject->setPublished(true);
  155.         $newObject->save();
  156.         $list = new DataObject\ItcAddPincode\Listing();
  157.         return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $list ]);
  158.     
  159.     }
  160.     /**
  161.      * @param Request $request
  162.      * 
  163.      * @Route("/deleteItcPincode/{id}")
  164.      * 
  165.      * @return Response
  166.      * 
  167.      */
  168.     public function deleteItcPincodeAction($id
  169.     { 
  170.        
  171.         $entries DataObject\ItcAddPincode::getById($id); 
  172.         $delete $entries->delete();
  173.         if($delete){
  174.             $list = new DataObject\ItcAddPincode\Listing();
  175.         }else{
  176.             $list = new DataObject\ItcAddPincode\Listing();
  177.         }
  178.         $locationsList DataObject\Locations::getList();
  179.         $locationsList->load();
  180.         return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $list ]);
  181.         
  182.     }
  183.       
  184.      /**
  185.      * @param Request $request
  186.      * 
  187.      * @Route("/importPincode1")
  188.      * 
  189.      * @return Response
  190.      * 
  191.      */
  192.     public function importPincode1Action(Request $request): Response
  193.     
  194.         
  195.         $locationsList DataObject\Locations::getList();
  196.         $locationsList->load();
  197.         $entries = new DataObject\ItcAddPincode\Listing();
  198.         if(!empty(basename($_FILES["file"]["name"]))){
  199.             //get file extension
  200.             $getfile basename($_FILES["file"]["name"]);
  201.             $extention = @end(explode('.'$getfile));
  202.             $lover_extention strtolower($extention);
  203.             $filename $_FILES["file"]["tmp_name"];
  204.             // check only file accepted 
  205.             $allowTypes = array('csv'); 
  206.             if(in_array($lover_extention$allowTypes))
  207.             {
  208.                 if($_FILES["file"]["size"] > 0)
  209.                 {
  210.                     //open file and read
  211.                     $file fopen($filename"r");
  212.                     $i 0;
  213.                     while (($col fgetcsv($file10000",")) !== FALSE
  214.                     {
  215.                         $createAssetFolder DoService::createFolderByPath('Pincode');
  216.                         $objParentId $createAssetFolder->getId();
  217.                         if($i && $col[0] !='')
  218.                         {
  219.                             $holidayObjectName $col[0];
  220.                             $location $col[1];
  221.                             $location_code_array explode(',',$location);
  222.                             $location_code explode(',',$col[4]);
  223.                             //Create a new object
  224.                             $newObject = new DataObject\ItcAddPincode(); 
  225.                             $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey($holidayObjectName'object'));
  226.                             $newObject->setParentId($objParentId);
  227.                             $newObject->setpincode($col[0]);
  228.                             $newObject->setlocation_code($col[1]);
  229.                             $newObject->setcity($col[2]);  
  230.                             $newObject->setstate($col[3]);
  231.                             $newObject->setdeliverytype($location_code);
  232.                             $newObject->setis_shipping_applicable($col[5]);
  233.                             $newObject->setmerichakki_available($col[6]);
  234.                             $newObject->setnammachakki_available($col[7]);
  235.                             $newObject->setvin_instance($col[8]);
  236.                             $newObject->setPublished(true);
  237.                             $newObject->save();
  238.                         
  239.                         }
  240.                         $i++;
  241.     
  242.                     }
  243.                     return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  244.                 }
  245.             }
  246.             else{
  247.                 return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  248.             }
  249.         }
  250.         return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  251.     }
  252.     /**
  253.      * @param Request $request
  254.      * 
  255.      * @Route("/importPincode")
  256.      * 
  257.      * @return Response
  258.      * 
  259.      */
  260.      public function importPincodeAction(Request $request): Response
  261.      
  262.          
  263.          $locationsList DataObject\Locations::getList();
  264.          $locationsList->load();
  265.  
  266.          $entries = new DataObject\ItcAddPincode\Listing();
  267.  
  268.          if(!empty(basename($_FILES["file"]["name"]))){
  269.             /*------ Get ItcAddPincode Class data --------*/
  270.             $dbConnection \Pimcore\Db::get();
  271.             $pincodeClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'ItcAddPincode' ");
  272.             $pincodeObject "object_".$pincodeClassId;
  273.  
  274.              //get file extension
  275.              $getfile basename($_FILES["file"]["name"]);
  276.              $extention = @end(explode('.'$getfile));
  277.              $lover_extention strtolower($extention);
  278.              $filename $_FILES["file"]["tmp_name"];
  279.  
  280.              // check only file accepted 
  281.              $allowTypes = array('csv'); 
  282.              if(in_array($lover_extention$allowTypes))
  283.              {
  284.                  if($_FILES["file"]["size"] > 0)
  285.                  {
  286.  
  287.                      //open file and read
  288.                      $file fopen($filename"r");
  289.                      $i 0;
  290.                      while (($col fgetcsv($file10000",")) !== FALSE
  291.                      {
  292.  
  293.                          $createAssetFolder DoService::createFolderByPath('Pincode');
  294.                          $objParentId $createAssetFolder->getId();
  295.  
  296.                          if($i && $col[0] !='')
  297.                          {
  298.  
  299.                              $pincodeObjectName $col[0];
  300.                              $location $col[1];
  301.                              $location_code_array explode(',',$location);
  302.                              $location_code explode(',',$col[4]);
  303.                              /*----- Get ItcAddPincode data ---------*/
  304.                             // echo " select * from ".$pincodeObject." WHERE pincode = '".$col[0]."'"; die;
  305.                             $pincodeId $dbConnection->fetchOne(" select * from ".$pincodeObject." WHERE pincode = '".$pincodeObjectName."'");
  306.                             if(!empty($pincodeId)){
  307.                                 $newObject DataObject\ItcAddPincode::getById($pincodeId);
  308.                             } else {
  309.                                 $newObject = new DataObject\ItcAddPincode(); 
  310.                                 $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey($pincodeObjectName'object'));
  311.                                 $newObject->setParentId($objParentId);
  312.                             }
  313.                             /*----- End of Get ItcAddPincode data ---------*/
  314.  
  315.                              //Create / Update a object
  316.                              $newObject->setpincode($col[0]);
  317.                              $newObject->setlocation_code($col[1]);
  318.                              $newObject->setcity($col[2]);  
  319.                              $newObject->setstate($col[3]);
  320.                              $newObject->setdeliverytype($location_code);
  321.                              $newObject->setis_shipping_applicable($col[5]);
  322.                              $newObject->setmerichakki_available($col[6]);
  323.                              $newObject->setnammachakki_available($col[7]);
  324.                              $newObject->setvin_instance($col[8]);
  325.                              $newObject->setPublished(true);
  326.                              $newObject->save();
  327.                          
  328.                          }
  329.                          $i++;
  330.      
  331.                      }
  332.                      return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  333.  
  334.                  }
  335.              }
  336.              else{
  337.                  return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  338.              }
  339.  
  340.          }
  341.          return $this->render('pincode/listing-pincode.html.twig',['data' => $entries,'locationsList' => $entries ]);
  342.      }
  343.     public function verifyauthToken()
  344.     {
  345.         $api_key 'api-key';
  346.         $api_key_value 'cGltY29yZWFwaWtleXZhbHVl';//base64encode('pimcoreapikeyvalue);
  347.         $message "No data found"$tokenCheck 0$apikeyCheck 0;
  348.         $headers=array();
  349.         foreach (getallheaders() as $name => $value) {
  350.             $headers[$name] = $value;
  351.             if($name == 'Authtoken'$tokenCheck 1;
  352.             if($name == 'Api-Key'$apikeyCheck 1;
  353.         }
  354.         // echo 'arr:<pre>';
  355.         // print_r(apache_request_headers()); 
  356.         // die;
  357.         if($tokenCheck == && $apikeyCheck == 0){
  358.             $message "Authentication Token is missing";;
  359.         } else {
  360.             $tokenCheck_valid 0$apikeyCheck_valid 0;
  361.             /*--------------------- Validating Auth Token -----------------*/
  362.             if($tokenCheck == 1)
  363.             {
  364.                 $Authtoken $headers['Authtoken'];
  365.         
  366.                 $dbConnection \Pimcore\Db::get();
  367.                 $authTokencheck $dbConnection->fetchOne("SELECT id FROM users WHERE authToken = '".$Authtoken."' ");
  368.                 if(empty($authTokencheck)){
  369.                     $message "Authentication Token is mismatch";
  370.                 } else {
  371.                     $tokenCheck_valid 1;
  372.                 }
  373.             }
  374.             /*--------------------- Validating Api Key -----------------*/
  375.             if($apikeyCheck == 1)
  376.             {
  377.                 $AuthApikey $headers['Api-Key'];
  378.                 if(empty($AuthApikey)){
  379.                     $message "Authentication Token is mismatch";
  380.                 } else if($AuthApikey != $api_key_value){
  381.                     $message "Authentication Token is mismatch";
  382.                 } else {
  383.                     //echo $apikeyCheck_valid = 1;
  384.                 }
  385.             }
  386.             $message = ($tokenCheck_valid == || $apikeyCheck_valid == 1)?"No data found":$message;
  387.         }
  388.         return $message;
  389.     }
  390.     /**
  391.      * @param Request $request
  392.      * 
  393.      * @Route("/wearhouseDetectionApi",methods={"POST"})
  394.      * 
  395.      * @return Response
  396.      * 
  397.      */
  398.     public function wearhouseDetectionApiAction(Request $request)
  399.     { 
  400.         $message SELF::verifyauthToken();
  401.         if($message == "No data found")
  402.         {
  403.        
  404.             $createAssetFolder DoService::createFolderByPath('Location');
  405.             $objParentId $createAssetFolder->getId();
  406.             if($request->get('pincode')){
  407.                 $pincode $request->get('pincode');
  408.                 $entries = new DataObject\ItcAddPincode\Listing();
  409.                 $entries->setCondition("pincode = :name", ["name" => $pincode]);
  410.                 $entries->load();
  411.                     $data = array();
  412.                     foreach($entries as $key => $entrie){
  413.                             $location_codes $entrie->getlocation_code();
  414.                             $location = new DataObject\Locations\Listing();
  415.                             $location->setCondition("location_name = :name", ["name" => $location_codes]);
  416.                             $location->load();
  417.                             $loc_name '';
  418.                             $loc_code '';
  419.                             foreach($location as $location_code){
  420.                                 $loc_name $location_code->getlocation_name();
  421.                                 $loc_code $location_code->getlocation_code();
  422.                             
  423.                             }
  424.                             $data = array("pincode" => $entrie->getpincode(),
  425.                                             "store_code" => $loc_code,
  426.                                             "location_name" => $loc_name,
  427.                                             "city_name" => $entrie->getcity(),
  428.                                             "state" => $entrie->getstate(),
  429.                                             "delivery_type" => $entrie->getdeliverytype(),
  430.                                             "is_shipping_applicable" => $entrie->getis_shipping_applicable(),
  431.                                             "merichakki_available" => $entrie->getmerichakki_available(),
  432.                                             "nammachakki_available" => $entrie->getnammachakki_available(),
  433.                                             "vin_instance" => $entrie->getvin_instance(),
  434.                                         );
  435.                     }
  436.             }elseif($request->get('city_name')){
  437.                 $city $request->get('city_name');
  438.                 $entries = new DataObject\ItcAddPincode\Listing();
  439.                 $entries->setCondition("city = :name OR location_code = :name", ["name" => $city,"location_code" => $city]);
  440.                 $entries->setLimit(1);
  441.                 $entries->load();
  442.                 foreach($entries as $key => $entrie){
  443.                         $location_codes $entrie->getlocation_code();
  444.                         $location = new DataObject\Locations\Listing();
  445.                         $location->setCondition("location_name = :name", ["name" => $location_codes]);
  446.                         $location->load();
  447.                         $loc_name '';
  448.                         $loc_code '';
  449.                         foreach($location as $location_code){
  450.                             $loc_name $location_code->getlocation_name();
  451.                             $loc_code $location_code->getlocation_code();
  452.                         
  453.                         }
  454.                         $data = array("pincode" => $entrie->getpincode(),
  455.                                         "store_code" => $loc_code,
  456.                                         "location_name" => $loc_name,
  457.                                         "city_name" => $entrie->getcity(),
  458.                                         "state" => $entrie->getstate(),
  459.                                         "delivery_type" => $entrie->getdeliverytype(),
  460.                                         "is_shipping_applicable" => $entrie->getis_shipping_applicable(),
  461.                                         "merichakki_available" => $entrie->getmerichakki_available(),
  462.                                         "nammachakki_available" => $entrie->getnammachakki_available(),
  463.                                         "vin_instance" => $entrie->getvin_instance(),
  464.                                     );
  465.                 }
  466.             }
  467.            
  468.            
  469.         } 
  470.         else
  471.             $data[] = ['message'=>$message];
  472.             if(!empty($data)){
  473.                     return $this->json(["success" => true"data" => $data]);
  474.             }else{
  475.                  return $this->json(["success" => false"message" => "Service not available"]);
  476.             }
  477.      
  478.     }
  479.     /**
  480.      * @Route("/getPincodesData")
  481.      * This action returns a JSON response. 
  482.      */
  483.     public function getPincodesDataAction(): JsonResponse
  484.     {
  485.         /*------ Get Shipping Rate Card Class data --------*/
  486.         $dbConnection \Pimcore\Db::get();
  487.         $pincodeClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'ItcAddPincode' ");
  488.         $pincodeObject "object_".$pincodeClassId;
  489.         include "dt_scripts/pincodes_jsonp.php";
  490.         return $this->json($dt_ssp_data);
  491.     }
  492.     /**
  493.      * @param Request $request
  494.      * 
  495.      * @Route("/importPincodeByLocation")
  496.      * 
  497.      * @return Response
  498.      * 
  499.      */
  500.     public function importPincodeByLocationAction(Request $request): Response
  501.     
  502.         
  503.         $locationsList DataObject\Locations::getList();
  504.         $locationsList->load();
  505.         // $entries = new DataObject\ItcAddPincode\Listing();
  506.         if(!empty(basename($_FILES["file"]["name"]))){
  507.             $locationcode $request->get('locationcode');
  508.             $location_code_array DataObject\Locations::getById($locationcode);
  509.             $locationname $location_code_array->getlocation_name();
  510.             /*------ Get ItcAddPincode Class data --------*/
  511.             $dbConnection \Pimcore\Db::get();
  512.             $pincodeClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'ItcAddPincode' ");
  513.             $pincodeObject "object_".$pincodeClassId;
  514.             //get file extension
  515.             $getfile basename($_FILES["file"]["name"]);
  516.             $extention = @end(explode('.'$getfile));
  517.             $lover_extention strtolower($extention);
  518.             $filename $_FILES["file"]["tmp_name"];
  519.             // check only file accepted 
  520.             $allowTypes = array('csv'); 
  521.             if(in_array($lover_extention$allowTypes))
  522.             {
  523.                 if($_FILES["file"]["size"] > 0)
  524.                 {
  525.                     //open file and read
  526.                     $file fopen($filename"r");
  527.                     $i 0;
  528.                     while (($col fgetcsv($file10000",")) !== FALSE
  529.                     {
  530.                         $createAssetFolder DoService::createFolderByPath('Pincode');
  531.                         $objParentId $createAssetFolder->getId();
  532.                         if($i && $col[0] !='' && $col[1] == $locationname)
  533.                         {
  534.                             $pincodeObjectName $col[0];
  535.                             $location $col[1];
  536.                             $location_code_array explode(',',$location);
  537.                             $location_code explode(',',$col[4]);
  538.                             
  539.                             /*----- Get ItcAddPincode data ---------*/
  540.                             // echo " select * from ".$pincodeObject." WHERE pincode = '".$col[0]."'"; die;
  541.                             $pincodeId $dbConnection->fetchOne(" select * from ".$pincodeObject." WHERE pincode = '".$pincodeObjectName."'");
  542.                             if(!empty($pincodeId)){
  543.                                 $newObject DataObject\ItcAddPincode::getById($pincodeId);
  544.                             } else {
  545.                                 $newObject = new DataObject\ItcAddPincode(); 
  546.                                 $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey($pincodeObjectName'object'));
  547.                                 $newObject->setParentId($objParentId);
  548.                             }
  549.                             /*----- End of Get ItcAddPincode data ---------*/
  550.                             $newObject->setpincode($col[0]);
  551.                             $newObject->setlocation_code($col[1]);
  552.                             $newObject->setcity($col[2]);  
  553.                             $newObject->setstate($col[3]);
  554.                             $newObject->setdeliverytype($location_code);
  555.                             $newObject->setis_shipping_applicable($col[5]);
  556.                             $newObject->setmerichakki_available($col[6]);
  557.                             $newObject->setnammachakki_available($col[7]);
  558.                             $newObject->setvin_instance($col[8]);
  559.                             $newObject->setPublished(true);
  560.                             $newObject->save();
  561.                         
  562.                         }
  563.                         $i++;
  564.                     }
  565.                     return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  566.                 }
  567.             }
  568.             else{
  569.                 return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  570.             }
  571.         }
  572.         return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  573.     }
  574.     /**
  575.      * @param Request $request
  576.      * 
  577.      * @Route("/deletePincodeByLocation")
  578.      * 
  579.      * @return Response
  580.      * 
  581.      */
  582.     public function deletePincodeByLocationAction(Request $request): Response
  583.     
  584.         
  585.         $locationsList DataObject\Locations::getList();
  586.         $locationsList->load();
  587.         
  588.         $locationcode $request->get('locationcode');
  589.         if(!empty($locationcode)){
  590.         $locationcode $request->get('locationcode');
  591.         $location_code_array DataObject\Locations::getById($locationcode);
  592.         $locationname $location_code_array->getlocation_name();
  593.         // $location_code = 'Gurgaon';
  594.         $pincodesList DataObject\ItcAddPincode::getList();
  595.         $pincodesList->setCondition("location_code = '".$locationname."'");
  596.         $pincodesList->load();
  597.         if(count($pincodesList)>0)
  598.         {
  599.             foreach($pincodesList as $pincodeInfo)
  600.             {
  601.                 $pincodesdata DataObject\ItcAddPincode::getById($pincodeInfo->getId()); 
  602.                 $pincodesdatadelete $pincodesdata->delete();
  603.             }
  604.             $this->addFlash('success''Pincodes Deleted Successfully');
  605.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  606.         }
  607.         else{
  608.             $this->addFlash('failure''Pincodes Deletion failed');
  609.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  610.         }
  611.         }
  612.         $this->addFlash('failure''No Location selected');
  613.         return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  614.     }
  615.     /**
  616.      * @param Request $request
  617.      * 
  618.      * @Route("/deleteAllItcPincode/{limit}}")
  619.      * 
  620.      * @return Response
  621.      * 
  622.      */
  623.      public function deleteAllItcPincodeAction($limit=100
  624.      { 
  625.         
  626.         $locationsList DataObject\Locations::getList();
  627.         $locationsList->load();
  628.         
  629.         $pincodesList DataObject\ItcAddPincode::getList();
  630.         $slotsList->setLimit($limit);
  631.         $pincodesList->load();
  632.         if(count($pincodesList)>0)
  633.         {
  634.             foreach($pincodesList as $pincodeInfo)
  635.             {
  636.                 $pincodesdata DataObject\ItcAddPincode::getById($pincodeInfo->getId()); 
  637.                 $pincodesdatadelete $pincodesdata->delete();
  638.             }
  639.             $this->addFlash('success''Pincodes Deleted Successfully');
  640.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  641.         }
  642.         else{
  643.             $this->addFlash('failure''Pincodes Deletion failed');
  644.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  645.         }
  646.          
  647.      }
  648. }