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 verifyauthToken1()
  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.     public function verifyauthToken()
  391.     {
  392.         $api_key 'api-key';
  393.         $api_key_value 'cGltY29yZWFwaWtleXZhbHVl';//base64encode('pimcoreapikeyvalue);
  394.         $message "No data found"$apikeyCheck 0$apikeyMsg '';
  395.         $headers=array();
  396.         foreach (getallheaders() as $name => $value) {
  397.             $headers[$name] = $value;
  398.             if($name == 'Api-Key'$apikeyCheck 1;
  399.         }
  400.         
  401.         if($apikeyCheck == 0){
  402.             $message "Api-Key is mandatory!";;
  403.         } else {
  404.             $apikeyCheck_valid 0;
  405.             /*--------------------- Validating Api Key -----------------*/
  406.             if($apikeyCheck == 1)
  407.             {
  408.                 $AuthApikey $headers['Api-Key'];
  409.                 if(empty($AuthApikey)){
  410.                     $message "Key is empty, Api-Key is mandatory";
  411.                 } else if($AuthApikey != $api_key_value){
  412.                     $message "key is mismatch";
  413.                 } else {
  414.                     $apikeyCheck_valid 1;
  415.                 }
  416.             }
  417.         }
  418.         return $message;
  419.     }
  420.     /**
  421.      * @param Request $request
  422.      * 
  423.      * @Route("/wearhouseDetectionApi",methods={"POST"})
  424.      * 
  425.      * @return Response
  426.      * 
  427.      */
  428.     public function wearhouseDetectionApiAction(Request $request)
  429.     { 
  430.         $message $data SELF::verifyauthToken();
  431.         if($message == "No data found")
  432.         {
  433.        
  434.             $createAssetFolder DoService::createFolderByPath('Location');
  435.             $objParentId $createAssetFolder->getId();
  436.             if($request->get('pincode')){
  437.                 $pincode $request->get('pincode');
  438.                 $entries = new DataObject\ItcAddPincode\Listing();
  439.                 $entries->setCondition("pincode = :name", ["name" => $pincode]);
  440.                 $entries->load();
  441.                     $data = array();
  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.             }elseif($request->get('city_name')){
  467.                 $city $request->get('city_name');
  468.                 $entries = new DataObject\ItcAddPincode\Listing();
  469.                 $entries->setCondition("city = :name OR location_code = :name", ["name" => $city,"location_code" => $city]);
  470.                 $entries->setLimit(1);
  471.                 $entries->load();
  472.                 foreach($entries as $key => $entrie){
  473.                         $location_codes $entrie->getlocation_code();
  474.                         $location = new DataObject\Locations\Listing();
  475.                         $location->setCondition("location_name = :name", ["name" => $location_codes]);
  476.                         $location->load();
  477.                         $loc_name '';
  478.                         $loc_code '';
  479.                         foreach($location as $location_code){
  480.                             $loc_name $location_code->getlocation_name();
  481.                             $loc_code $location_code->getlocation_code();
  482.                         
  483.                         }
  484.                         $data = array("pincode" => $entrie->getpincode(),
  485.                                         "store_code" => $loc_code,
  486.                                         "location_name" => $loc_name,
  487.                                         "city_name" => $entrie->getcity(),
  488.                                         "state" => $entrie->getstate(),
  489.                                         "delivery_type" => $entrie->getdeliverytype(),
  490.                                         "is_shipping_applicable" => $entrie->getis_shipping_applicable(),
  491.                                         "merichakki_available" => $entrie->getmerichakki_available(),
  492.                                         "nammachakki_available" => $entrie->getnammachakki_available(),
  493.                                         "vin_instance" => $entrie->getvin_instance(),
  494.                                     );
  495.                 }
  496.             }
  497.             else
  498.             $data[] = ['message'=>$message];
  499.         } 
  500.         
  501.             if(!empty($data)){
  502.                     return $this->json(["success" => true"data" => $data]);
  503.             }else{
  504.                  return $this->json(["success" => false"message" => "Service not available"]);
  505.             }
  506.      
  507.     }
  508.     /**
  509.      * @Route("/getPincodesData")
  510.      * This action returns a JSON response. 
  511.      */
  512.     public function getPincodesDataAction(): JsonResponse
  513.     {
  514.         /*------ Get Shipping Rate Card Class data --------*/
  515.         $dbConnection \Pimcore\Db::get();
  516.         $pincodeClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'ItcAddPincode' ");
  517.         $pincodeObject "object_".$pincodeClassId;
  518.         include "dt_scripts/pincodes_jsonp.php";
  519.         return $this->json($dt_ssp_data);
  520.     }
  521.     /**
  522.      * @param Request $request
  523.      * 
  524.      * @Route("/importPincodeByLocation")
  525.      * 
  526.      * @return Response
  527.      * 
  528.      */
  529.     public function importPincodeByLocationAction(Request $request): Response
  530.     
  531.         
  532.         $locationsList DataObject\Locations::getList();
  533.         $locationsList->load();
  534.         // $entries = new DataObject\ItcAddPincode\Listing();
  535.         if(!empty(basename($_FILES["file"]["name"]))){
  536.             $locationcode $request->get('locationcode');
  537.             $location_code_array DataObject\Locations::getById($locationcode);
  538.             $locationname $location_code_array->getlocation_name();
  539.             /*------ Get ItcAddPincode Class data --------*/
  540.             $dbConnection \Pimcore\Db::get();
  541.             $pincodeClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'ItcAddPincode' ");
  542.             $pincodeObject "object_".$pincodeClassId;
  543.             //get file extension
  544.             $getfile basename($_FILES["file"]["name"]);
  545.             $extention = @end(explode('.'$getfile));
  546.             $lover_extention strtolower($extention);
  547.             $filename $_FILES["file"]["tmp_name"];
  548.             // check only file accepted 
  549.             $allowTypes = array('csv'); 
  550.             if(in_array($lover_extention$allowTypes))
  551.             {
  552.                 if($_FILES["file"]["size"] > 0)
  553.                 {
  554.                     //open file and read
  555.                     $file fopen($filename"r");
  556.                     $i 0;
  557.                     while (($col fgetcsv($file10000",")) !== FALSE
  558.                     {
  559.                         $createAssetFolder DoService::createFolderByPath('Pincode');
  560.                         $objParentId $createAssetFolder->getId();
  561.                         if($i && $col[0] !='' && $col[1] == $locationname)
  562.                         {
  563.                             $pincodeObjectName $col[0];
  564.                             $location $col[1];
  565.                             $location_code_array explode(',',$location);
  566.                             $location_code explode(',',$col[4]);
  567.                             
  568.                             /*----- Get ItcAddPincode data ---------*/
  569.                             // echo " select * from ".$pincodeObject." WHERE pincode = '".$col[0]."'"; die;
  570.                             $pincodeId $dbConnection->fetchOne(" select * from ".$pincodeObject." WHERE pincode = '".$pincodeObjectName."'");
  571.                             if(!empty($pincodeId)){
  572.                                 $newObject DataObject\ItcAddPincode::getById($pincodeId);
  573.                             } else {
  574.                                 $newObject = new DataObject\ItcAddPincode(); 
  575.                                 $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey($pincodeObjectName'object'));
  576.                                 $newObject->setParentId($objParentId);
  577.                             }
  578.                             /*----- End of Get ItcAddPincode data ---------*/
  579.                             $newObject->setpincode($col[0]);
  580.                             $newObject->setlocation_code($col[1]);
  581.                             $newObject->setcity($col[2]);  
  582.                             $newObject->setstate($col[3]);
  583.                             $newObject->setdeliverytype($location_code);
  584.                             $newObject->setis_shipping_applicable($col[5]);
  585.                             $newObject->setmerichakki_available($col[6]);
  586.                             $newObject->setnammachakki_available($col[7]);
  587.                             $newObject->setvin_instance($col[8]);
  588.                             $newObject->setPublished(true);
  589.                             $newObject->save();
  590.                         
  591.                         }
  592.                         $i++;
  593.                     }
  594.                     return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  595.                 }
  596.             }
  597.             else{
  598.                 return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  599.             }
  600.         }
  601.         return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  602.     }
  603.     /**
  604.      * @param Request $request
  605.      * 
  606.      * @Route("/deletePincodeByLocation")
  607.      * 
  608.      * @return Response
  609.      * 
  610.      */
  611.     public function deletePincodeByLocationAction(Request $request): Response
  612.     
  613.         
  614.         $locationsList DataObject\Locations::getList();
  615.         $locationsList->load();
  616.         
  617.         $locationcode $request->get('locationcode');
  618.         if(!empty($locationcode)){
  619.         $locationcode $request->get('locationcode');
  620.         $location_code_array DataObject\Locations::getById($locationcode);
  621.         $locationname $location_code_array->getlocation_name();
  622.         // $location_code = 'Gurgaon';
  623.         $pincodesList DataObject\ItcAddPincode::getList();
  624.         $pincodesList->setCondition("location_code = '".$locationname."'");
  625.         $pincodesList->load();
  626.         if(count($pincodesList)>0)
  627.         {
  628.             foreach($pincodesList as $pincodeInfo)
  629.             {
  630.                 $pincodesdata DataObject\ItcAddPincode::getById($pincodeInfo->getId()); 
  631.                 $pincodesdatadelete $pincodesdata->delete();
  632.             }
  633.             $this->addFlash('success''Pincodes Deleted Successfully');
  634.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  635.         }
  636.         else{
  637.             $this->addFlash('failure''Pincodes Deletion failed');
  638.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  639.         }
  640.         }
  641.         $this->addFlash('failure''No Location selected');
  642.         return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  643.     }
  644.     /**
  645.      * @param Request $request
  646.      * 
  647.      * @Route("/deleteAllItcPincode/{limit}}")
  648.      * 
  649.      * @return Response
  650.      * 
  651.      */
  652.      public function deleteAllItcPincodeAction($limit=100
  653.      { 
  654.         
  655.         $locationsList DataObject\Locations::getList();
  656.         $locationsList->load();
  657.         
  658.         $pincodesList DataObject\ItcAddPincode::getList();
  659.         $slotsList->setLimit($limit);
  660.         $pincodesList->load();
  661.         if(count($pincodesList)>0)
  662.         {
  663.             foreach($pincodesList as $pincodeInfo)
  664.             {
  665.                 $pincodesdata DataObject\ItcAddPincode::getById($pincodeInfo->getId()); 
  666.                 $pincodesdatadelete $pincodesdata->delete();
  667.             }
  668.             $this->addFlash('success''Pincodes Deleted Successfully');
  669.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  670.         }
  671.         else{
  672.             $this->addFlash('failure''Pincodes Deletion failed');
  673.             return $this->render('pincode/listing-pincode.html.twig',['locationsList' => $locationsList ]);
  674.         }
  675.          
  676.      }
  677. }