src/Controller/DeliveryslotapiController.php line 2482

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 Pimcore\Model\User;
  12. use Firebase\JWT\JWT;
  13. use Firebase\JWT\Key;
  14. class DeliveryslotapiController extends FrontendController
  15. {
  16.     /**
  17.      * @Route("/holidays/getlist")
  18.      */
  19.     public function getlistAction()
  20.     {
  21.         $api_log_info "API:Get All Holidays - ".date("YmdHis")." ".time();
  22.         $log_data "Started - ".$api_log_info;
  23.         SELF::createApiLog($log_data);
  24.         $holidaysList DataObject\Holidays::getList();
  25.         $holidaysList->load();
  26.         
  27.         $log_data $api_log_info." | holidaysList Count:".json_encode(count($holidaysList));
  28.         SELF::createApiLog($log_data);
  29.         if(count($holidaysList) > 0){
  30.             foreach ($holidaysList as $key => $holidayInfo) {  
  31.                 $log_data $api_log_info." | holidayInfo:".json_encode($holidayInfo);
  32.                 SELF::createApiLog($log_data);
  33.                 
  34.                 $location_codes $holidayInfo->getlocation_code();
  35.                 $loc_name '';
  36.                 $log_data $api_log_info." | location_codes:".json_encode($location_codes);
  37.                 SELF::createApiLog($log_data);
  38.                 foreach($location_codes as $location_code){
  39.                     $loc_name .= $location_code->getlocation_name().' ';
  40.                 }
  41.                 $log_data $api_log_info." | loc_name:".json_encode($loc_name);
  42.                 SELF::createApiLog($log_data);
  43.                 $data[] = array(
  44.                     "name" => $holidayInfo->getname(),
  45.                     "loc_name" => $loc_name,
  46.                     "holidaydate" => $holidayInfo->getHolidaydate());
  47.                 $log_data $api_log_info." | data:".json_encode($data);
  48.                 SELF::createApiLog($log_data);
  49.             }
  50.         } else $data[] = [];
  51.         // return $slotsList;
  52.         $returndata = ["success" => true"data" => $data];
  53.         $log_data "Ended - ".$api_log_info." | returndata:".json_encode($returndata);
  54.         SELF::createApiLog($log_data);
  55.         return $this->json(["success" => true"data" => $data]);
  56.     }
  57.     /*-------------------------------- Slots Related APIs ----------------------------*/
  58.     /**
  59.      * @Route("/deliveryslots/list")
  60.      */
  61.     public function listAction()
  62.     {
  63.         $api_log_info "API:Get Delivery Slots based on Today and Current Time - ".date("YmdHis")." ".time();
  64.         $log_data "Started - ".$api_log_info;
  65.         SELF::createApiLog($log_data);
  66.         $today_date strtotime("Y-m-d");
  67.         $cur_time date("H:i");
  68.         $log_data $api_log_info." | today_date:".json_encode($today_date)." | cur_time:".json_encode($cur_time);
  69.         SELF::createApiLog($log_data);
  70.         $slotsList DataObject\Slots::getList();
  71.         $slotsList->setCondition("slotdate >= ? AND prior_time >= ?",[$today_date$cur_time]);
  72.         // $slotsList->setOffset(0);
  73.         $slotsList->setLimit(100);
  74.         $slotsList->setOrderKey("slotdate");
  75.         $slotsList->setOrder("desc");
  76.         $slotsList->load();
  77.         // $slotsList = DataObject\Slots::getList();
  78.         // $slotsList->setOffset(0);
  79.         // $slotsList->setLimit(10);
  80.         // $slotsList->load();
  81.         $log_data $api_log_info." | slotsList count:".json_encode(count($slotsList));
  82.         SELF::createApiLog($log_data);
  83.         // if(count($slotsList) > 0){
  84.             foreach ($slotsList as $key => $slotInfo) {
  85.                 $log_data $api_log_info." | slotInfo:".json_encode($slotInfo);
  86.                 SELF::createApiLog($log_data);
  87.                 // $location_code = $blog->getlocation_code()->getlocation_code();
  88.                 // $location_code = (!empty($slotInfo->getloc_id()) && $slotInfo->getloc_id())?$slotInfo->getloc_id()->getlocation_code():'';
  89.                 // $loc_name = (!empty($slotInfo->getloc_id()) && $slotInfo->getloc_id())?$slotInfo->getloc_id()->getlocation_name():'';
  90.                 $slotLocationData DataObject\Locations::getById($slotInfo->getLoc_id());
  91.                 $loc_name = (!empty($slotLocationData) && $slotLocationData->getlocation_name())?$slotLocationData->getlocation_name():'';
  92.                 $location_code = (!empty($slotLocationData) && $slotLocationData->getlocation_code())?$slotLocationData->getlocation_code():'';
  93.                 // foreach($location_codes as $location_code){
  94.                 //     $loc_name = $location_code->getlocation_name();
  95.                 // }
  96.                 $log_data $api_log_info." | location_code:".json_encode($location_code)." | loc_name:".json_encode($loc_name);
  97.                 SELF::createApiLog($log_data);
  98.                 $data[] = array(
  99.                     "slotId" => $slotInfo->getId(),
  100.                     "prior_time" => $slotInfo->getprior_time(),
  101.                     // "picking_time" => $slotInfo->getpicking_time(),
  102.                     "location_code" => $location_code,
  103.                     "loc_name" => $loc_name,
  104.                     // "charge" => $slotInfo->getcharge(),
  105.                     "slotdate" => $slotInfo->getslotdate(),
  106.                     "fromtime" => $slotInfo->getfromtime(),
  107.                     "totime" => $slotInfo->gettotime(),
  108.                     "maxorder" => $slotInfo->getmaxorder(),
  109.                     "ordercount" => $slotInfo->getordercount(),
  110.                     "delivery_mode" => $slotInfo->getdelivery_mode());
  111.                 
  112.                 $log_data $api_log_info." | data:".json_encode($data);
  113.                 SELF::createApiLog($log_data);
  114.             }
  115.         // } else $data[] = [];
  116.         // return $slotsList;
  117.         $returnData = ["success" => true"data" => $data];
  118.         $log_data "Ended - ".$api_log_info." | returnData:".json_encode($returnData);
  119.         SELF::createApiLog($log_data);
  120.         return $this->json(["success" => true"data" => $data]);
  121.     }
  122.     /**
  123.      * @Route("/deliveryslots/saveslots")
  124.      */
  125.     public function saveslotsAction()
  126.     {
  127.         $api_log_info "API:Generating / Saving Delivery Slots - ".date("YmdHis")." ".time();
  128.         $log_data "Started - ".$api_log_info;
  129.         SELF::createApiLog($log_data);
  130.         /*--------------- Settings info ----------------*/
  131.         $settingsInfo SELF::getSettingInfo($api_log_info);
  132.         $log_data $api_log_info." | settingsInfo:".json_encode($settingsInfo);
  133.         SELF::createApiLog($log_data);
  134.         /*----------- End of Settings Info -------------*/
  135.         // echo 'settingsInfo:<pre>';
  136.         // echo $settingsInfo['stg_deliveryslot_config_is_upcountry_configuration_applicable'];
  137.         // print_r($settingsInfo); die;
  138.         $locationsList DataObject\Locations::getList();
  139.         $locationsList->load();
  140.         $log_data $api_log_info." | locationsList count:".json_encode(count($locationsList));
  141.         SELF::createApiLog($log_data);
  142.         foreach($locationsList as $location)//Start of Locations Loop
  143.         {
  144.             $log_data $api_log_info." | location:".json_encode($location);
  145.             SELF::createApiLog($log_data);
  146.             //echo "<br>Id:".$location->getId()."|Location Name:".$location->getLocation_name()."|Location Code:".$location->getLocation_code();
  147.             $location_id $location->getId();
  148.             $locationName $location->getLocation_name();
  149.             $locationCode $location->getLocation_code();
  150.             /*------ Check Location is Up Country or not --------*/
  151.             $Is_location_up_country = (strpos(strtolower($locationName),"up country") || strpos(strtoupper($locationCode),"UPCTR"))?1:0;
  152.             $log_data $api_log_info." | location_id:".json_encode($location_id)." | locationName:".json_encode($locationName)." | locationCode:".json_encode($locationCode)." | Is_location_up_country:".json_encode($Is_location_up_country);
  153.             SELF::createApiLog($log_data);
  154.             $holidaysList DataObject\Holidays::getList();
  155.             $holidaysList->setCondition("location_code like '%,".$location_id.",%'");
  156.             $holidaysList->load();
  157.             // if(count($holidaysList) > 0)
  158.             // {
  159.                 $holidayDates $rangeDates = [];
  160.                 foreach($holidaysList as $holiday)
  161.                 {
  162.                     $log_data $api_log_info." | holiday:".json_encode($holiday);
  163.                     SELF::createApiLog($log_data);
  164.                     $holiday_locations_list $holiday->getLocation_code();
  165.                     $holidaydate $holiday->getHolidaydate();
  166.                     $holidayDate date("Y-m-d"strtotime($holidaydate));
  167.                     $holidaysenddate $holiday->getHolidaysenddate();
  168.                     $log_data $api_log_info." | holiday_locations_list:".json_encode($holiday_locations_list)." | holidaydate:".json_encode($holidaydate)." | holidaysenddate:".json_encode($holidaysenddate);
  169.                     SELF::createApiLog($log_data);
  170.                     if(!empty($holidaysenddate) && $holidaysenddate){
  171.                         $holidaysenddate date("Y-m-d"strtotime($holidaysenddate));
  172.                         $rangeDates self::getDatesFromRange($holidayDate$holidaysenddate);
  173.                         $log_data $api_log_info." | rangeDates:".json_encode($rangeDates)." | holidaysenddate:".json_encode($holidaysenddate);
  174.                         SELF::createApiLog($log_data);
  175.                         foreach($rangeDates as $rangeDateInfo){
  176.                             $log_data $api_log_info." | rangeDateInfo:".json_encode($rangeDateInfo);
  177.                             SELF::createApiLog($log_data);
  178.                             array_push($holidayDates,$rangeDateInfo);
  179.                             $log_data $api_log_info." | holidayDates:".json_encode($holidayDates);
  180.                             SELF::createApiLog($log_data);
  181.                         }
  182.                     } else {
  183.                         array_push($holidayDates,$holidayDate);
  184.                         $log_data $api_log_info." | holidayDate:".json_encode($holidayDate)." | holidayDates:".json_encode($holidayDates);
  185.                         SELF::createApiLog($log_data);
  186.                     }
  187.                 }
  188.                 // if(!empty($rangeDates)){
  189.                 //     echo '<pre>'; print_r($holidayDates); die;
  190.                 // }
  191.                 /*----------- Delivery Slot Times Loop Starts --------*/
  192.                 $deliveryslottimesList DataObject\Deliveryslottimes::getList();
  193.                 $deliveryslottimesList->load();
  194.                 //echo '<br>deliveryslottimesList Count:'.count($deliveryslottimesList);
  195.                 $log_data $api_log_info." | deliveryslottimesList Count:".json_encode(count($deliveryslottimesList));
  196.                 SELF::createApiLog($log_data);
  197.                 if(count($deliveryslottimesList)>0)
  198.                 {
  199.                     foreach($deliveryslottimesList as $deliveryslottimes)
  200.                     {
  201.                         $log_data $api_log_info." | deliveryslottimes:".json_encode($deliveryslottimes);
  202.                         SELF::createApiLog($log_data);
  203.                         // echo '<pre>deliveryslottimes:'; print_r($deliveryslottimes); //die;
  204.                         $slot_prepare_days = ($deliveryslottimes->getprepare_days())?$deliveryslottimes->getprepare_days():0;
  205.                         $slot_generate_days = ($deliveryslottimes->getslot_generate_days())?$deliveryslottimes->getslot_generate_days():7;
  206.                         $saturday_slot_availability = ($deliveryslottimes->getsaturday_slot_availability())?$deliveryslottimes->getsaturday_slot_availability():'No';
  207.                         $sunday_slot_availability = ($deliveryslottimes->getsunday_slot_availability())?$deliveryslottimes->getsunday_slot_availability():'No';
  208.                         $slot_generate_days $slot_generate_days+$settingsInfo['stg_normalloc_slot_generate_days']; 
  209.                         $log_data $api_log_info." | slot_prepare_days:".json_encode($slot_prepare_days)." | slot_generate_days:".json_encode($slot_generate_days)." | saturday_slot_availability:".json_encode($saturday_slot_availability)." | sunday_slot_availability:".json_encode($sunday_slot_availability)." | setting stg_normalloc_slot_generate_days:".json_encode($settingsInfo['stg_normalloc_slot_generate_days'])." | slot_generate_days:".json_encode($slot_generate_days);
  210.                         SELF::createApiLog($log_data);
  211.                         /*--------------------- Up Country Configuration ------------------------*/
  212.                         $is_upcountry_configuration_applicable = ($deliveryslottimes->getis_upcountry_configuration_applicable())?$deliveryslottimes->getis_upcountry_configuration_applicable():'No';
  213.                         $slot_upcountry_prepare_days = ($deliveryslottimes->getupcountry_prepare_days())?$deliveryslottimes->getupcountry_prepare_days():0;
  214.                         $upcountry_slot_generate_days = ($deliveryslottimes->getupcountry_slot_generate_days())?$deliveryslottimes->getupcountry_slot_generate_days():7;
  215.                         $upcountry_saturday_slot_availability = ($deliveryslottimes->getupcountry_saturday_slot_availability())?$deliveryslottimes->getupcountry_saturday_slot_availability():'No';
  216.                         $upcountry_sunday_slot_availability = ($deliveryslottimes->getupcountry_sunday_slot_availability())?$deliveryslottimes->getupcountry_sunday_slot_availability():'No';
  217.                         $upcountry_slot_generate_days $upcountry_slot_generate_days+$settingsInfo['stg_upcountryloc_slot_generate_days']; 
  218.                         $log_data $api_log_info." | is_upcountry_configuration_applicable:".json_encode($is_upcountry_configuration_applicable)." | slot_upcountry_prepare_days:".json_encode($slot_upcountry_prepare_days)." | upcountry_slot_generate_days:".json_encode($upcountry_slot_generate_days)." | upcountry_saturday_slot_availability:".json_encode($upcountry_saturday_slot_availability)." | upcountry_sunday_slot_availability:".json_encode($upcountry_sunday_slot_availability)." | setting stg_upcountryloc_slot_generate_days:".json_encode($settingsInfo['stg_upcountryloc_slot_generate_days'])." | upcountry_slot_generate_days:".json_encode($upcountry_slot_generate_days);
  219.                         SELF::createApiLog($log_data);
  220.                         if($settingsInfo['stg_deliveryslot_config_is_upcountry_configuration_applicable'] == 'Yes' && $Is_location_up_country == 1)//if($is_upcountry_configuration_applicable == 'Yes' && $Is_location_up_country == 1)
  221.                             $delSlotTimesAvailibility = ['slot_prepare_days'=>$slot_upcountry_prepare_days,'slot_generate_days'=>$upcountry_slot_generate_days,'saturday_slot_availability'=>$upcountry_saturday_slot_availability,'sunday_slot_availability'=>$upcountry_sunday_slot_availability];
  222.                         else
  223.                             $delSlotTimesAvailibility = ['slot_prepare_days'=>$slot_prepare_days,'slot_generate_days'=>$slot_generate_days,'saturday_slot_availability'=>$saturday_slot_availability,'sunday_slot_availability'=>$sunday_slot_availability];
  224.                         $log_data $api_log_info." | delSlotTimesAvailibility:".json_encode($delSlotTimesAvailibility);
  225.                         SELF::createApiLog($log_data);
  226.                         // echo '<pre>delSlotTimesAvailibility:'; print_r($delSlotTimesAvailibility); //die;
  227.                         $weekdates self::getWeekDates($holidayDatesdate("Y-m-d"), $delSlotTimesAvailibility);
  228.                         // echo '<pre>weekdates:'; print_r($weekdates);
  229.                         $log_data $api_log_info." | weekdates:".json_encode($weekdates);
  230.                         SELF::createApiLog($log_data);
  231.                         foreach($weekdates as $weekdate)
  232.                         {
  233.                             $log_data $api_log_info." | weekdate:".json_encode($weekdate);
  234.                             SELF::createApiLog($log_data);
  235.                             $slotsList DataObject\Deliveryslotrules::getList();
  236.                             // $slotsList->setCondition("location_code like '%,".$location_id.",%'");
  237.                             $slotsList->setCondition("location_ids IS NOT NULL AND location_ids like '%,".$location_id.",%'");
  238.                             $slotsList->load();
  239.                             //echo '<br>slotsList Count:'.count($slotsList);
  240.                             $log_data $api_log_info." | slotsList count:".json_encode(count($slotsList));
  241.                             SELF::createApiLog($log_data);
  242.                             if(count($slotsList) > 0)
  243.                             {
  244.                                 foreach($slotsList as $slot)
  245.                                 {
  246.                                     $log_data $api_log_info." | slot:".json_encode($slot);
  247.                                     SELF::createApiLog($log_data);
  248.                                     $prior_time $slot->getprior_time();
  249.                                     $location_codes $slot->getlocation_ids();//$slot->getlocation_code();
  250.                                     // $picking_time = $slot->getpicking_time();
  251.                                     $delivery_mode $slot->getdelivery_mode();
  252.                                     // $charge = $slot->getcharge();
  253.                                     $fromtime $slot->getfromtime();
  254.                                     $totime $slot->gettotime();
  255.                                     $maxorder $slot->getmaxorder();
  256.                                     // $ordercount = $slot->getordercount();
  257.                                     $date $weekdate;//$slot->getslotdate();
  258.                                     $date2 date("m/d/y"strtotime($date));
  259.                                     $dates Carbon::createFromFormat('m/d/y'$date2);
  260.                                     $location_code_array = [];
  261.                                     // echo '<pre>location_codes Count:'.count($location_codes);
  262.                                     $log_data $api_log_info." | location_codes:".json_encode($location_codes);
  263.                                     SELF::createApiLog($log_data);
  264.                                     if(!empty($location_codes))
  265.                                     {
  266.                                         foreach($location_codes as $location_id_info){//foreach($location_codes as $location_code){//Location Code loop Starts
  267.                                             $log_data $api_log_info." | location_id_info:".json_encode($location_id_info);
  268.                                             SELF::createApiLog($log_data);
  269.                                             if($location_id == $location_id_info)//if($location_id == $location_code->getId())
  270.                                             {
  271.                                                 $log_data $api_log_info." | location_id:".json_encode($location_id)." | location_id_info:".json_encode($location_id_info);
  272.                                                 SELF::createApiLog($log_data);
  273.                                                 // $location_code_array[] = DataObject\Locations::getById($location_code->getId());
  274.                                                 // $location_code_id = DataObject\Locations::getById($location_code->getId());
  275.     
  276.                                                 // $loc_id = $location_code->getId();
  277.     
  278.                                                 $location_code_array[] = DataObject\Locations::getById($location_id_info);
  279.                                                 $location_code_id DataObject\Locations::getById($location_id_info);
  280.                                                 $log_data $api_log_info." | location_code_id:".json_encode($location_code_id);
  281.                                                 SELF::createApiLog($log_data);
  282.     
  283.                                                 $loc_id $location_id_info;
  284.     
  285.                                                 /*----------- Delivery Slot Times Loop Starts --------*/
  286.                                                 // $deliveryslottimesList = DataObject\Deliveryslottimes::getList();
  287.                                                 // $deliveryslottimesList->load();
  288.                                                 // //echo '<br>deliveryslottimesList Count:'.count($deliveryslottimesList);
  289.                                                 // if(count($deliveryslottimesList)>0)
  290.                                                 // {
  291.                                                 //     foreach($deliveryslottimesList as $deliveryslottimes)
  292.                                                 //     {
  293.                                                         /*------------ Checking the slot data -------------*/
  294.                                                         $slotCheck 1;
  295.                                                         $today_date date("Y-m-d"strtotime($weekdate));
  296.                                                         $cur_time $prior_time;
  297.     
  298.                                                         $checkDataList DataObject\Slots::getList();
  299.     
  300.                                                         if ($checkDataList->getClass()->getFieldDefinition('slotdate')->isFilterable()) {
  301.                                                             $checkDataList->filterBySlotdate($today_date'=');
  302.                                                         }
  303.     
  304.                                                         if ($checkDataList->getClass()->getFieldDefinition('prior_time')->isFilterable()) {
  305.                                                             $checkDataList->filterByprior_time($cur_time'=');
  306.                                                         }
  307.     
  308.                                                         if ($checkDataList->getClass()->getFieldDefinition('delivery_mode')->isFilterable()) {
  309.                                                             $checkDataList->filterBydelivery_mode($delivery_mode'=');
  310.                                                         }
  311.                                                         // $checkDataList->setCondition("loc_id__id = ".$loc_id);
  312.                                                         // $checkDataList->setCondition("delivery_mode = '".$delivery_mode."' ");
  313.     
  314.                                                         $checkDataList->setLimit(100);
  315.                                                         $checkDataList->setOrderKey("slotdate");
  316.                                                         $checkDataList->setOrder("asc");
  317.                                                         $checkDataList->load();
  318.                                                         //echo '<br>checkDataList Count:'.count($checkDataList);
  319.     
  320.                                                         $checkData_loc_valid 0$checkData_locs = [];
  321.                                                         $log_data $api_log_info." | checkDataList count:".json_encode(count($checkDataList));
  322.                                                         SELF::createApiLog($log_data);
  323.                                                         
  324.                                                         if(count($checkDataList) > 0)
  325.                                                         {
  326.                                                             foreach($checkDataList as $checkData)
  327.                                                             {
  328.                                                                 $log_data $api_log_info." | checkData:".json_encode($checkData);
  329.                                                                 SELF::createApiLog($log_data);
  330.                                                         
  331.                                                                 // $checkData_locData = $checkData->getloc_id();
  332.                                                                 // $checkData_locId = $checkData_locData->getId();
  333.                                                                 $checkData_locId $checkData->getloc_id();
  334.                                                                 array_push($checkData_locs$checkData_locId);
  335.                                                                 $log_data $api_log_info." | checkData_locId:".json_encode($checkData_locId)." | checkData_locs:".json_encode($checkData_locs);
  336.                                                                 SELF::createApiLog($log_data);
  337.                                                             }
  338.                                                         }
  339.                                                         $checkData_loc_valid = (empty($checkData_locs) || (!empty($checkData_locs) && !in_array($loc_id$checkData_locs)) || count($checkDataList) <= 0)?1:0;
  340.                                                         $log_data $api_log_info." | checkData_loc_valid:".json_encode($checkData_loc_valid);
  341.                                                         SELF::createApiLog($log_data);
  342.     
  343.                                                         // echo '<br>checkData_locId:'.$checkData_locId;
  344.                                                         // echo '<pre>checkData_locs:';
  345.                                                         // print_r($checkData_locs);
  346.                                                         // echo '<br>checkData_loc_valid:'.$checkData_loc_valid;
  347.                                                         /*------------ End of Checking the slot data -------------*/
  348.     
  349.                                                         if($checkData_loc_valid == 1){
  350.                                                             // $generateObjFolderId = self::generateSlotObjFolder('Slots',$delivery_mode,$loc_id);
  351.     
  352.                                                             $createAssetFolder DoService::createFolderByPath('Slots');
  353.                                                             $objParentId $createAssetFolder->getId();
  354.     
  355.                                                             // $holidayObjectName = $location_code.'-'.$name;
  356.                                                             $slotObjectName $weekdate.'-'.$loc_id.'-'.$slot->getId().'-'.$deliveryslottimes->getId().'-'.time();
  357.     
  358.                                                             $slotObject = new DataObject\Slots(); 
  359.                                                             $slotObject->setKey(\Pimcore\Model\Element\Service::getValidKey($slotObjectName'object'));
  360.                                                             $slotObject->setParentId($objParentId);
  361.                                                             $slotObject->setPrior_time($prior_time);
  362.                                                             // $slotObject->setPicking_time($picking_time);
  363.                                                             $slotObject->setDelivery_mode($delivery_mode);
  364.                                                             // $slotObject->setSlotdate($date2);
  365.                                                             $slotObject->setSlotdate($dates);
  366.                                                             $slotObject->setfromtime($fromtime);
  367.                                                             $slotObject->settotime($totime);
  368.                                                             $slotObject->setmaxorder($maxorder);
  369.     
  370.                                                             // $slotObject->setLocation_code($location_code_array);
  371.     
  372.                                                             // $slotObject->setCharge($charge);
  373.                                                             $slotObject->setdeliveryslottime_id(DataObject\Deliveryslottimes::getById($deliveryslottimes->getId()));
  374.                                                             // $slotObject->setloc_id(DataObject\Locations::getById($location_code->getId()));
  375.                                                             // $slotObject->setloc_id(DataObject\Locations::getById($location_id_info));
  376.                                                             $slotObject->setloc_id($location_id_info);
  377.     
  378.                                                             $slotObject->setPublished(true);
  379.                                                             $slotObject->save();
  380.                                                             $log_data $api_log_info." | objParentId :".json_encode($objParentId)." | slotObjectName :".json_encode($slotObjectName)." | save slot : success";
  381.                                                             SELF::createApiLog($log_data);
  382.                                                         }
  383.                                                 //     }
  384.                                                 // }
  385.                                             }
  386.                                             /*---------- Delivery Slot Time loop ends ------------*/
  387.                                         }//Location Code loop ends
  388.                                     }
  389.                                 }
  390.                             }
  391.                         }
  392.                     }
  393.                 }
  394.             // }
  395.         }//End of Locations Loop
  396.         
  397.         $log_data "Ended - ".$api_log_info." | data : Slot Created for one week Successfully'";
  398.         SELF::createApiLog($log_data);
  399.         return $this->json(["success" => true"data" => 'Slot Created for one week Successfully']);
  400.     }
  401.     /**
  402.      * @Route("deliveryslots/updateslotordercount", methods={"POST"})
  403.      */
  404.     public function updateslotordercountAction(Request $request)
  405.     {
  406.         $api_log_info "API:Update Delivery Slot Order Count based on slotId - ".date("YmdHis")." ".time();
  407.         $log_data "Started - ".$api_log_info;
  408.         SELF::createApiLog($log_data);
  409.         $message SELF::verifyauthToken($api_log_info);
  410.         $log_data $api_log_info." | message:".json_encode($message);
  411.         SELF::createApiLog($log_data);
  412.         $data = [];
  413.         if($message == "No data found")
  414.         {
  415.             $slotId $request->get('slotId');
  416.             $ordercount $request->get('ordercount');
  417.             $log_data $api_log_info." | slotId:".json_encode($slotId)." | ordercount:".json_encode($ordercount);
  418.             SELF::createApiLog($log_data);
  419.             if($slotId == "" || $ordercount == "")
  420.             {
  421.                 $data "slotId and ordercount are mandatory!";
  422.                 $log_data $api_log_info." | data:".json_encode($data);
  423.                 SELF::createApiLog($log_data);
  424.             } else 
  425.             {
  426.                 $slotruleObject DataObject\Slots::getById($slotId);
  427.                 $log_data $api_log_info." | slotruleObject:".json_encode($slotruleObject);
  428.                 SELF::createApiLog($log_data);
  429.                 if(!empty($slotruleObject) && $slotruleObject->getId()){
  430.                     $slotruleObject->setordercount($ordercount);
  431.                     $slotruleObject->save();
  432.                     $data "Slot Updated Successfully!";
  433.                     $log_data $api_log_info." | data:".json_encode($data);
  434.                     SELF::createApiLog($log_data);
  435.                 } else {
  436.                     $data "This Slot Id ".$slotId." is not existed, Please try with valid Slot Id";
  437.                     $log_data $api_log_info." | data:".json_encode($data);
  438.                     SELF::createApiLog($log_data);
  439.                 }
  440.             }
  441.         }else $data[] = ['message'=>$message];
  442.         $data = (empty($data))?$message:$data;
  443.         $returnData = ["success" => true"data" => $data];
  444.         $log_data "Ended - ".$api_log_info." | returnData:".json_encode($returnData);
  445.         SELF::createApiLog($log_data);
  446.         return $this->json(["success" => true"data" => $message]);
  447.     }
  448.     /**
  449.      * @Route("/deliveryslots/getSlot/{id}")
  450.      */
  451.     public function getSlot($id)
  452.     {
  453.         $api_log_info "API:Slot Info by Slot ID | ID:".$id." - ".date("YmdHis")." ".time();
  454.         $log_data "Started - ".$api_log_info;
  455.         SELF::createApiLog($log_data);
  456.         $message SELF::verifyauthToken($api_log_info);
  457.         $log_data $api_log_info." | message:".json_encode($message);
  458.         SELF::createApiLog($log_data);
  459.         $data = [];
  460.         if($message == "No data found")
  461.         {
  462.             $slot DataObject\Slots::getById($id);  
  463.         
  464.             $log_data $api_log_info." | slot:".json_encode($slot);
  465.             SELF::createApiLog($log_data);
  466.             if(isset($slot) && $slot->getId() != ''){
  467.                 
  468.                 $slotLocationData DataObject\Locations::getById($slot->getLoc_id());
  469.                 $loc_name = (!empty($slotLocationData) && $slotLocationData->getlocation_name())?$slotLocationData->getlocation_name():'';
  470.                 $loc_code = (!empty($slotLocationData) && $slotLocationData->getlocation_code())?$slotLocationData->getlocation_code():'';
  471.                 $log_data $api_log_info." | slotLocationData:".json_encode($slotLocationData)." | loc_name:".json_encode($loc_name)." | loc_code:".json_encode($loc_code);
  472.                 SELF::createApiLog($log_data);
  473.                 $data = array(
  474.                     "prior_time" => $slot->getprior_time(),
  475.                     // "picking_time" => $slot->getpicking_time(),
  476.                     // "charge" => $slot->getcharge(),
  477.                     "slotdate" => date("Y-m-d"strtotime($slot->getslotdate())),//$slot->getslotdate(),
  478.                     "loc_code" => $loc_code,
  479.                     "loc_name" => $loc_name,
  480.                     "fromtime" => $slot->getfromtime(),
  481.                     "totime" => $slot->gettotime(),
  482.                     "maxorder" => $slot->getmaxorder(),
  483.                     "ordercount" => $slot->getordercount(),
  484.                     "delivery_mode" => $slot->getdelivery_mode());
  485.                 $log_data $api_log_info." | data:".json_encode($data);
  486.                 SELF::createApiLog($log_data);
  487.             } else {
  488.                 $data "No data found";
  489.                 $log_data $api_log_info." | data:".json_encode($data);
  490.                 SELF::createApiLog($log_data);
  491.             }   
  492.         }else $data[] = ['message'=>$message];
  493.         $data = (empty($data))?$message:$data;  
  494.         
  495.         $returnData = ["success" => true"data" => $data];
  496.         $log_data "Ended - ".$api_log_info." | returnData:".json_encode($returnData);
  497.         SELF::createApiLog($log_data);
  498.         
  499.         // return $slotsList;
  500.         return $this->json(["success" => true"data" => $data]);
  501.     }
  502.     /**
  503.      * @Route("/deliveryslots/getStoreslot/{id}")
  504.      */
  505.     public function getStoreslot($id)
  506.     {
  507.         $api_log_info "API:Get Delivery Slots based on Location Code for Today and Time only | ID:".$id." - ".date("YmdHis")." ".time();
  508.         $log_data "Started - ".$api_log_info;
  509.         SELF::createApiLog($log_data);
  510.         $data ="No data found";
  511.         if($id == "")
  512.         {
  513.             $data ="Location Code is mandatory!";
  514.             $log_data $api_log_info." | data:".json_encode($data);
  515.             SELF::createApiLog($log_data);
  516.         } else 
  517.         {
  518.             /*---- Check Location by Location Code ---------*/
  519.             $locData DataObject\Locations::getBylocation_code($id1);
  520.             $log_data $api_log_info." | locData:".json_encode($locData);
  521.             SELF::createApiLog($log_data);
  522.             if(empty($locData) || empty($locData->getId()))
  523.             {
  524.                 $data "Location is not exited, please try with valid location code!";
  525.                 $log_data $api_log_info." | data:".json_encode($data);
  526.                 SELF::createApiLog($log_data);
  527.             } else {
  528.                 $loc_id $locData->getId();
  529.                 $today_date date("Y-m-d");//"2024-01-03";//
  530.                 $cur_time date("H:i");
  531.                 $log_data $api_log_info." | loc_id:".json_encode($loc_id)." | today_date:".json_encode($today_date)." | cur_time:".json_encode($cur_time);
  532.                 SELF::createApiLog($log_data);
  533.                 $slotsList DataObject\Slots::getList();
  534.                 if ($slotsList->getClass()->getFieldDefinition('slotdate')->isFilterable()) {
  535.                     $slotsList->filterBySlotdate($today_date'=');
  536.                 }
  537.                 if ($slotsList->getClass()->getFieldDefinition('prior_time')->isFilterable()) {
  538.                     $slotsList->filterByprior_time($cur_time'>=');
  539.                 }
  540.                 $slotsList->setCondition("loc_id = ".$loc_id);
  541.                 $slotsList->setLimit(100);
  542.                 $slotsList->setOrderKey("slotdate");
  543.                 $slotsList->setOrder("asc");
  544.                 $slotsList->load();
  545.                 $log_data $api_log_info." | slotsList count:".json_encode(count($slotsList));
  546.                 SELF::createApiLog($log_data);
  547.                 $data = [];
  548.                 if(count($slotsList) > 0){
  549.                     foreach ($slotsList as $key => $slotInfo) {
  550.                         $log_data $api_log_info." | slotInfo:".json_encode($slotInfo);
  551.                         SELF::createApiLog($log_data);
  552.                         $slotLocationData DataObject\Locations::getById($slotInfo->getLoc_id());
  553.                         $log_data $api_log_info." | slotLocationData:".json_encode($slotLocationData);
  554.                         SELF::createApiLog($log_data);
  555.                         $loc_name $slotLocationData->getlocation_name();
  556.                         $loc_code $slotLocationData->getlocation_code();
  557.                         $log_data $api_log_info." | loc_name:".json_encode($loc_name)." | loc_code:".json_encode($loc_code);
  558.                         SELF::createApiLog($log_data);
  559.             
  560.                         // if($loc_name != 0 && $loc_name == $id){
  561.                         // if(!empty($loc_codes) && in_array($id, $loc_codes)){//&& $id!= '' 
  562.                             // if(!empty($blog->getloc_id()) && $blog->getloc_id()->getlocation_code() == $id){//&& $id!= '' 
  563.                             $data[] = array(
  564.                                 "slotId" => $slotInfo->getId(),
  565.                                 "prior_time" => $slotInfo->getprior_time(),
  566.                                 // "picking_time" => $slotInfo->getpicking_time(),
  567.                                 "location_code" => $loc_code,
  568.                                 "loc_name" => $loc_name,
  569.                                 // "charge" => $slotInfo->getcharge(),
  570.                                 "slotdate" => $slotInfo->getslotdate(),
  571.                                 "fromtime" => $slotInfo->getfromtime(),
  572.                                 "totime" => $slotInfo->gettotime(),
  573.                                 "maxorder" => $slotInfo->getmaxorder(),
  574.                                 "ordercount" => $slotInfo->getordercount(),
  575.                                 "delivery_mode" => $slotInfo->getdelivery_mode());
  576.                             $log_data $api_log_info." | data:".json_encode($data);
  577.                             SELF::createApiLog($log_data);
  578.                         //}
  579.                     }
  580.                 } else $data "No data found";
  581.             }
  582.         }
  583.         $return_data = ["success" => true"data" => $data];
  584.         $log_data $api_log_info." | return_data:".json_encode($return_data);
  585.         SELF::createApiLog($log_data);
  586.         
  587.         return $this->json(["success" => true"data" => $data]);
  588.     }
  589.     /**
  590.      * @Route("/deliveryslottime/gelocslottimes/{locCode}")
  591.      */
  592.     public function gelocslottimesAction($locCode)
  593.     {
  594.         date_default_timezone_set('Asia/Kolkata');
  595.         $api_log_info "API:Retriving Delivery Slots by Location Code | locCode:".$locCode." - ".date("YmdHis")." ".time();
  596.         $log_data "Started - ".$api_log_info;
  597.         SELF::createApiLog($log_data);
  598.         $message SELF::verifyauthToken($api_log_info);
  599.         $log_data $api_log_info." | message:".json_encode($message);
  600.         SELF::createApiLog($log_data);
  601.         $Is_location_up_country $is_upcountry_configuration_applicable '';
  602.         if($message == "No data found")
  603.         {
  604.             $today_date date("Y-m-d");
  605.             $tomorrow_date date('Y-m-d'strtotime($today_date ' +1 day'));
  606.             $dates_list = array($today_date$tomorrow_date);
  607.             
  608.             $log_data $api_log_info." | dates_list:".json_encode($dates_list);
  609.             SELF::createApiLog($log_data);
  610.             /*---- Check Location by Location Code ---------*/
  611.             $locationData DataObject\Locations::getBylocation_code($locCode1);
  612.             
  613.             $log_data $api_log_info." | locationData:".json_encode($locationData);
  614.             SELF::createApiLog($log_data);
  615.             /*--------------- Settings info ----------------*/
  616.             $settingsInfo SELF::getSettingInfo($api_log_info);
  617.             $log_data $api_log_info." | settingsInfo:".json_encode($settingsInfo);
  618.             SELF::createApiLog($log_data);
  619.             /*----------- End of Settings Info -------------*/
  620.              /*--------- Getting Delivery Modes settings ----------*/
  621.             $setting_slot_time_flag $settingsInfo['setting_slot_time_flag'];
  622.             $setting_deliveryModes $settingsInfo['setting_deliveryModes'];
  623.             $settingDataId $settingsInfo['settingDataId'];
  624.             // echo 'settingsInfo:<pre>';
  625.             // print_r($settingsInfo); die;
  626.             
  627.             $log_data $api_log_info." | setting_slot_time_flag:".json_encode($setting_slot_time_flag)."| setting_deliveryModes:".json_encode($setting_deliveryModes)."| settingDataId:".json_encode($settingDataId);
  628.             SELF::createApiLog($log_data);
  629.             if(!empty($locationData) && !empty($locationData->getId()))
  630.             {
  631.                 $parentLoc_id $locationData->getId();
  632.                 $parentLocationName $locationData->getLocation_name();
  633.                 $parentLocationCode $locationData->getLocation_code();
  634.                 $fastDelivery $locationData->getfastDeliveryAvailable();
  635.                 $location_type $locationData->getlocation_type();
  636.                 /*------ Check Location is Up Country or not --------*/
  637.                 $Is_location_up_country = (strpos(strtolower($parentLocationName),"up country") || strpos(strtoupper($parentLocationCode),"UPCTR"))?1:0;
  638.                 $log_data $api_log_info." | parentLoc_id:".json_encode($parentLoc_id)."| parentLocationName:".json_encode($parentLocationName)."| parentLocationCode:".json_encode($parentLocationCode);
  639.                 SELF::createApiLog($log_data);
  640.                 //------ get holidays list ------------//
  641.                 $holidaysList DataObject\Holidays::getList();
  642.                 $holidaysList->setCondition("location_code like '%,".$parentLoc_id.",%'");
  643.                 $holidaysList->load();
  644.                 
  645.                 $holidayDates = [];
  646.                 foreach($holidaysList as $holiday)
  647.                 {
  648.                     $log_data $api_log_info." | holiday:".json_encode($holiday);
  649.                     SELF::createApiLog($log_data);
  650.                     $holiday_locations_list $holiday->getLocation_code();
  651.                     $holidaydate $holiday->getHolidaydate();
  652.                     $holidayDate date("Y-m-d"strtotime($holidaydate));
  653.                     $log_data $api_log_info." | holiday_locations_list:".json_encode($holiday_locations_list)."| holidaydate:".json_encode($holidaydate);
  654.                     SELF::createApiLog($log_data);
  655.                     
  656.                     $holidaysenddate $holiday->getHolidaysenddate();
  657.                     if(!empty($holidaysenddate) && $holidaysenddate){
  658.                         $holidaysenddate date("Y-m-d"strtotime($holidaysenddate));
  659.                         $rangeDates self::getDatesFromRange($holidayDate$holidaysenddate);
  660.                         $log_data $api_log_info." | holidaysenddate:".json_encode($holidaysenddate)."| rangeDates:".json_encode($rangeDates);
  661.                         SELF::createApiLog($log_data);
  662.                         
  663.                         foreach($rangeDates as $rangeDateInfo){
  664.                             array_push($holidayDates,$rangeDateInfo);
  665.                         }
  666.                     } else {
  667.                         array_push($holidayDates,$holidayDate);
  668.                     }
  669.                 }
  670.                 $delSlotTimesList DataObject\Deliveryslottimes::getList();
  671.                 $delSlotTimesList->setOrderKey("o_id");
  672.                 $delSlotTimesList->setOrder("desc");
  673.                 $delSlotTimesList->load();
  674.                 // foreach($dates_list as $cur_date){
  675.                     $log_data $api_log_info." | delSlotTimesList count:".count($delSlotTimesList);
  676.                     SELF::createApiLog($log_data);
  677.                     
  678.                     if(count($delSlotTimesList) > 0){
  679.                         $cur_time date("H:i");//"09:00";//
  680.                         $log_data $api_log_info." | cur_time:".$cur_time;
  681.                         SELF::createApiLog($log_data);
  682.                         foreach($delSlotTimesList as $delSlotTimes)
  683.                         {
  684.                             $log_data $api_log_info." | delSlotTimes:".json_encode($delSlotTimes);
  685.                             SELF::createApiLog($log_data);
  686.                             //------- Get Week Dates based on Holidays and Slot Time data ---------//
  687.                             $slot_prepare_days = ($delSlotTimes->getprepare_days())?$delSlotTimes->getprepare_days():0;
  688.                             $slot_generate_days = ($delSlotTimes->getslot_generate_days())?$delSlotTimes->getslot_generate_days():7;
  689.                             $saturday_slot_availability = ($delSlotTimes->getsaturday_slot_availability())?$delSlotTimes->getsaturday_slot_availability():'No';
  690.                             $sunday_slot_availability = ($delSlotTimes->getsunday_slot_availability())?$delSlotTimes->getsunday_slot_availability():'No';
  691.                             $log_data $api_log_info." | slot_prepare_days:".json_encode($slot_prepare_days)."| slot_generate_days:".json_encode($slot_generate_days)."| saturday_slot_availability:".json_encode($saturday_slot_availability)."| sunday_slot_availability:".json_encode($sunday_slot_availability);
  692.                             SELF::createApiLog($log_data);
  693.                             /*--------------------- Up Country Configuration ------------------------*/
  694.                             $is_upcountry_configuration_applicable = ($delSlotTimes->getis_upcountry_configuration_applicable())?$delSlotTimes->getis_upcountry_configuration_applicable():'No';
  695.                             $slot_upcountry_prepare_days = ($delSlotTimes->getupcountry_prepare_days())?$delSlotTimes->getupcountry_prepare_days():0;
  696.                             $upcountry_slot_generate_days = ($delSlotTimes->getupcountry_slot_generate_days())?$delSlotTimes->getupcountry_slot_generate_days():7;
  697.                             $upcountry_saturday_slot_availability = ($delSlotTimes->getupcountry_saturday_slot_availability())?$delSlotTimes->getupcountry_saturday_slot_availability():'No';
  698.                             $upcountry_sunday_slot_availability = ($delSlotTimes->getupcountry_sunday_slot_availability())?$delSlotTimes->getupcountry_sunday_slot_availability():'No';
  699.                             $log_data $api_log_info." | is_upcountry_configuration_applicable:".json_encode($is_upcountry_configuration_applicable)."| slot_upcountry_prepare_days:".json_encode($slot_upcountry_prepare_days)."| upcountry_slot_generate_days:".json_encode($upcountry_slot_generate_days)."| upcountry_saturday_slot_availability:".json_encode($upcountry_saturday_slot_availability)."| upcountry_sunday_slot_availability:".json_encode($upcountry_sunday_slot_availability);
  700.                             SELF::createApiLog($log_data);
  701.                             /*--------------------- Darkstore Configuration ------------------------*/
  702.                             $is_darkstore_configuration_applicable = ($delSlotTimes->getis_darkstore_configuration_applicable())?$delSlotTimes->getis_darkstore_configuration_applicable():'No';
  703.                             $slot_darkstore_prepare_days = ($delSlotTimes->getdarkstore_prepare_days())?$delSlotTimes->getdarkstore_prepare_days():0;
  704.                             $darkstore_slot_generate_days = ($delSlotTimes->getdarkstore_slot_generate_days())?$delSlotTimes->getdarkstore_slot_generate_days():7;
  705.                             $darkstore_saturday_slot_availability = ($delSlotTimes->getdarkstore_saturday_slot_availability())?$delSlotTimes->getdarkstore_saturday_slot_availability():'No';
  706.                             $darkstore_sunday_slot_availability = ($delSlotTimes->getdarkstore_sunday_slot_availability())?$delSlotTimes->getdarkstore_sunday_slot_availability():'No';
  707.                             $log_data $api_log_info." | is_darkstore_configuration_applicable:".json_encode($is_darkstore_configuration_applicable)."| slot_darkstore_prepare_days:".json_encode($slot_darkstore_prepare_days)."| darkstore_slot_generate_days:".json_encode($darkstore_slot_generate_days)."| darkstore_saturday_slot_availability:".json_encode($darkstore_saturday_slot_availability)."| darkstore_sunday_slot_availability:".json_encode($darkstore_sunday_slot_availability);
  708.                             SELF::createApiLog($log_data);
  709.                             $log_data $api_log_info." | settings stg_deliveryslot_config_is_darkstore_configuration_applicable:".json_encode($settingsInfo['stg_deliveryslot_config_is_darkstore_configuration_applicable'])."| location_type:".json_encode($location_type);
  710.                             SELF::createApiLog($log_data);
  711.                             // echo '<pre>';
  712.                             // print_r($settingsInfo);die;
  713.                             // echo $settingsInfo['stg_deliveryslot_config_is_darkstore_configuration_applicable'];
  714.                             // echo "<br>";
  715.                             // echo $location_type;
  716.                             // die;
  717.                             if($settingsInfo['stg_deliveryslot_config_is_darkstore_configuration_applicable'] == 'Yes' && $location_type == 'Darkstore')
  718.                             {                                
  719.                                 $slot_prepare_days $slot_darkstore_prepare_days;
  720.                                 $slot_generate_days $darkstore_slot_generate_days;
  721.                                 $saturday_slot_availability $darkstore_saturday_slot_availability;
  722.                                 $sunday_slot_availability $darkstore_sunday_slot_availability;
  723.                                 
  724.                                 $cur_slot_generate_days = ($delSlotTimes->getdarkstore_slot_generate_days())?$delSlotTimes->getdarkstore_slot_generate_days():0;
  725.                                 
  726.                                 $stg_normalloc_upcounry_slot_generate_days = ($cur_time $settingsInfo['stg_delslot_darkstoreloc_morethan_fromtime'] && $cur_time $settingsInfo['stg_delslot_darkstoreloc_lessthaneq_totime'])?$settingsInfo['stg_delslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays']:$settingsInfo['stg_delslot_darkstoreloc_after_totime_extra_generate_slotdays'];
  727.                                 $slot_generate_days $slot_generate_days+$stg_normalloc_upcounry_slot_generate_days;
  728.                                 $log_data $api_log_info." | slot_prepare_days:".json_encode($slot_prepare_days)."| slot_generate_days:".json_encode($slot_generate_days)."| saturday_slot_availability:".json_encode($saturday_slot_availability)."| sunday_slot_availability:".json_encode($sunday_slot_availability)."| cur_slot_generate_days:".json_encode($cur_slot_generate_days)."| stg_normalloc_upcounry_slot_generate_days:".json_encode($stg_normalloc_upcounry_slot_generate_days)."| slot_generate_days:".json_encode($slot_generate_days);
  729.                                 SELF::createApiLog($log_data);
  730.                             } else if($settingsInfo['stg_deliveryslot_config_is_upcountry_configuration_applicable'] == 'Yes' && $Is_location_up_country == 1)//if($is_upcountry_configuration_applicable == 'Yes' && $Is_location_up_country == 1)
  731.                             {                                
  732.                                 $slot_prepare_days $slot_upcountry_prepare_days;
  733.                                 $slot_generate_days $upcountry_slot_generate_days;
  734.                                 $saturday_slot_availability $upcountry_saturday_slot_availability;
  735.                                 $sunday_slot_availability $upcountry_sunday_slot_availability;
  736.                                 
  737.                                 $cur_slot_generate_days = ($delSlotTimes->getupcountry_slot_generate_days())?$delSlotTimes->getupcountry_slot_generate_days():0;
  738.                                 
  739.                                 // $slot_generate_days = ($cur_time > $settingsInfo['stg_delslot_upcountryloc_morethan_fromtime'] && $cur_time < $settingsInfo['stg_delslot_upcountryloc_lessthaneq_totime'])?$slot_generate_days+$settingsInfo['stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays']:$slot_generate_days+$settingsInfo['stg_delslot_normalloc_after_totime_extra_generate_slotdays'];
  740.                                 
  741.                                 $stg_normalloc_upcounry_slot_generate_days = ($cur_time $settingsInfo['stg_delslot_upcountryloc_morethan_fromtime'] && $cur_time $settingsInfo['stg_delslot_upcountryloc_lessthaneq_totime'])?$settingsInfo['stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays']:$settingsInfo['stg_delslot_upcountryloc_after_totime_extra_generate_slotdays'];
  742.                                 $slot_generate_days $slot_generate_days+$stg_normalloc_upcounry_slot_generate_days;
  743.                                 $log_data $api_log_info." | slot_prepare_days:".json_encode($slot_prepare_days)."| slot_generate_days:".json_encode($slot_generate_days)."| saturday_slot_availability:".json_encode($saturday_slot_availability)."| sunday_slot_availability:".json_encode($sunday_slot_availability)."| cur_slot_generate_days:".json_encode($cur_slot_generate_days)."| stg_normalloc_upcounry_slot_generate_days:".json_encode($stg_normalloc_upcounry_slot_generate_days)."| slot_generate_days:".json_encode($slot_generate_days);
  744.                                 SELF::createApiLog($log_data);
  745.                             } else {
  746.                                 $cur_slot_generate_days = ($delSlotTimes->getslot_generate_days())?$delSlotTimes->getslot_generate_days():0;
  747.                                 // $slot_generate_days = ($cur_time > $setting_slot_time_flag)?$slot_generate_days+1:$slot_generate_days;
  748.                                 $stg_normalloc_upcounry_slot_generate_days = ($cur_time $settingsInfo['stg_delslot_normalloc_morethan_fromtime'] && $cur_time $settingsInfo['stg_delslot_normalloc_lessthaneq_totime'])?$settingsInfo['stg_delslot_normalloc_bw_from_to_time_extra_generate_slotdays']:$settingsInfo['stg_delslot_normalloc_after_totime_extra_generate_slotdays'];
  749.                                 $slot_generate_days $slot_generate_days+$stg_normalloc_upcounry_slot_generate_days;
  750.                                 $log_data $api_log_info." | cur_slot_generate_days:".json_encode($cur_slot_generate_days)."| stg_normalloc_upcounry_slot_generate_days:".json_encode($stg_normalloc_upcounry_slot_generate_days);
  751.                                 SELF::createApiLog($log_data);
  752.                             }
  753.                             $cur_slot_prepare_days = ($slot_prepare_days == 0)?$slot_prepare_days+$stg_normalloc_upcounry_slot_generate_days:$slot_prepare_days+$stg_normalloc_upcounry_slot_generate_days-1;
  754.                             $cur_slot_prepare_days = (!empty($fastDelivery)) ? $cur_slot_prepare_days;
  755.                             $log_data $api_log_info." | cur_slot_prepare_days:".json_encode($cur_slot_prepare_days);
  756.                             SELF::createApiLog($log_data);
  757.                             
  758.                             $delSlotTimesAvailibility = ['slot_prepare_days'=>$cur_slot_prepare_days,'slot_generate_days'=>$slot_generate_days,'saturday_slot_availability'=>$saturday_slot_availability,'sunday_slot_availability'=>$sunday_slot_availability];
  759.                             $log_data $api_log_info." | delSlotTimesAvailibility:".json_encode($delSlotTimesAvailibility);
  760.                             SELF::createApiLog($log_data);
  761.                             
  762.                             $weekdates self::getWeekDates($holidayDatesdate("Y-m-d"), $delSlotTimesAvailibility);
  763.                             $log_data $api_log_info." | weekdates:".json_encode($weekdates);
  764.                             SELF::createApiLog($log_data);
  765.                             // echo $cur_time." | ".$setting_slot_time_flag;
  766.                             // echo 'delSlotTimesAvailibility<pre>:';
  767.                             // print_r($delSlotTimesAvailibility);
  768.                             // echo 'weekdates<pre>:';
  769.                             // print_r($weekdates);die;
  770.                             //------- Get Week Dates based on Holidays and Slot Time data ---------//
  771.                             // $prepare_days = $delSlotTimes->getprepare_days();
  772.                             // $delSlot_date = ($prepare_days == 0)?$tomorrow_date:date('Y-m-d', strtotime($today_date . ' +'.$prepare_days.' day'));
  773.                             if($settingsInfo['stg_deliveryslot_config_is_darkstore_configuration_applicable'] == 'Yes' && $location_type == 'Darkstore')
  774.                             {
  775.                                 $delSlot_date = ($slot_prepare_days == 0)?date('Y-m-d'):date('Y-m-d'strtotime($today_date ' +'.$slot_prepare_days.' day'));
  776.                             } else {
  777.                                 $delSlot_date = ($slot_prepare_days == 0)?$tomorrow_date:date('Y-m-d'strtotime($today_date ' +'.$slot_prepare_days.' day'));
  778.                             }
  779.                             if(!empty($fastDelivery)){
  780.                                 date_default_timezone_set('Asia/Kolkata');
  781.                                 $delSlot_date date('Y-m-d');
  782.                                 
  783.                                 // Get the current hour
  784.                                 $currentHour = (int)date('H');
  785.                                 // Check if the current time is greater than 6 PM
  786.                                 if ($currentHour >= 18) {
  787.                                     // Add one day to the current date
  788.                                     $delSlot_date date('Y-m-d'strtotime($delSlot_date ' +1 day'));
  789.                                 }
  790.                             }
  791.                             $delSlot_date1 date("Y-m-d"strtotime($delSlot_date));
  792.                             
  793.                             $cur_time_data explode(" ",$cur_time);
  794.                             // $slot_generate_days = ($delSlotTimes->getslot_generate_days())?$delSlotTimes->getslot_generate_days():0;
  795.                             // $slot_generate_days_limit = ($slot_generate_days > 0)?$slot_generate_days:1;
  796.                             $slot_generate_days_limit = ($cur_slot_generate_days 0)?$cur_slot_generate_days:1;
  797.                             $log_data $api_log_info." | delSlot_date:".json_encode($delSlot_date)."| delSlot_date1:".json_encode($delSlot_date1)."| cur_time_data:".json_encode($cur_time_data)."| slot_generate_days_limit:".json_encode($slot_generate_days_limit);
  798.                             SELF::createApiLog($log_data);
  799.                             // echo $tomorrow_date.":".$weekdates[0];
  800.                             /* if($cur_time > $setting_slot_time_flag)//if($cur_time > '18:00')
  801.                             {
  802.                                 // if($tomorrow_date >= $weekdates[0])
  803.                                 // {
  804.                                 //     $weekdates = ($slot_generate_days > 0)?array_values(array_diff($weekdates,[$weekdates[0]])):[$weekdates[1]];
  805.                                 // } else {
  806.                                 //     $no_of_weekdates = count($weekdates);
  807.                                 //     $weekdates = ($slot_generate_days > 0)?array_values(array_diff($weekdates,[$weekdates[$no_of_weekdates-1]])):[$weekdates[0]];
  808.                                 // }
  809.                                 
  810.                                 $no_of_weekdates = count($weekdates);
  811.                                 // $weekdates = ($slot_generate_days > 0)?array_values(array_diff($weekdates,[$weekdates[$no_of_weekdates-1]])):[$weekdates[0]];
  812.                                 $weekdates = ($slot_generate_days > 0)?array_values(array_diff($weekdates,[$weekdates[0]])):[$weekdates[1]];
  813.                             } else {
  814.                                 $weekdates = ($slot_generate_days > 0)?$weekdates:[$weekdates[0]];
  815.                             } */
  816.                             /* if($settingsInfo['stg_deliveryslot_config_is_upcountry_configuration_applicable'] == 'Yes' && $Is_location_up_country == 1)
  817.                             {
  818.                                 if($cur_time > $settingsInfo['stg_delslot_upcountryloc_morethan_fromtime'] && $cur_time < $settingsInfo['stg_delslot_upcountryloc_lessthaneq_totime'])
  819.                                 {
  820.                                     $weekdates = ($slot_generate_days > 0)?array_values(array_diff($weekdates,[$weekdates[0]])):[$weekdates[1]];
  821.                                 } else {
  822.                                     $weekdates = ($slot_generate_days > 0)?$weekdates:[$weekdates[0]];
  823.                                 }
  824.                                 if(($slot_generate_days > 0)){
  825.                                     for($ii=0; $ii<$stg_normalloc_upcounry_slot_generate_days; $ii++)
  826.                                     {
  827.                                         $weekdates = array_values(array_diff($weekdates,[$weekdates[0]]));
  828.                                     }
  829.                                 } else 
  830.                                 $weekdates = [$weekdates[$stg_normalloc_upcounry_slot_generate_days]];
  831.                                 
  832.                             } else {
  833.                                 $stg_normalloc_upcounry_slot_generate_days = ($cur_time > $settingsInfo['stg_delslot_upcountryloc_morethan_fromtime'] && $cur_time < $settingsInfo['stg_delslot_upcountryloc_lessthaneq_totime'])?$settingsInfo['stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays']:$settingsInfo['stg_delslot_upcountryloc_after_totime_extra_generate_slotdays'];
  834.                             } */
  835.                             /* if(($slot_generate_days > 0)){
  836.                                 for($ii=0; $ii<$stg_normalloc_upcounry_slot_generate_days; $ii++)
  837.                                 {
  838.                                     $weekdates = array_values(array_diff($weekdates,[$weekdates[0]]));
  839.                                 }
  840.                             } else 
  841.                             $weekdates = [$weekdates[$stg_normalloc_upcounry_slot_generate_days]]; */
  842.                             /*
  843.                             if(($slot_generate_days > 0)){
  844.                                 if($stg_normalloc_upcounry_slot_generate_days>1)
  845.                                 {
  846.                                     for($ii=0; $ii<$stg_normalloc_upcounry_slot_generate_days-1; $ii++)
  847.                                     {
  848.                                         $weekdates = array_values(array_diff($weekdates,[$weekdates[0]]));
  849.                                     }
  850.                                 }
  851.                                 $cur_weekdates = [];
  852.                                 if($cur_slot_generate_days > 0){
  853.                                     for($jj=0; $jj < $cur_slot_generate_days; $jj++)
  854.                                     {
  855.                                         array_push($cur_weekdates,$weekdates[$jj]);
  856.                                     }
  857.                                 }
  858.                                 $weekdates = $cur_weekdates;
  859.                             } else 
  860.                             $weekdates = [$weekdates[$stg_normalloc_upcounry_slot_generate_days]];
  861.                             */
  862.                             $log_data $api_log_info." | slot_generate_days:".json_encode($slot_generate_days)."| cur_slot_generate_days:".json_encode($cur_slot_generate_days);
  863.                             SELF::createApiLog($log_data);
  864.                             if(($slot_generate_days 0)){
  865.                                 $cur_weekdates = [];
  866.                                 if($cur_slot_generate_days 0){
  867.                                     for($jj=0$jj $cur_slot_generate_days$jj++)
  868.                                     {
  869.                                         $log_data $api_log_info." | jj:".json_encode($jj)."| cur_weekdates:".json_encode($cur_weekdates)."| weekdates:".json_encode($weekdates);
  870.                                         SELF::createApiLog($log_data);
  871.                                         array_push($cur_weekdates,$weekdates[$jj]);
  872.                                     }
  873.                                 }
  874.                                 $weekdates $cur_weekdates;
  875.                             } else 
  876.                             $weekdates = [$weekdates[$stg_normalloc_upcounry_slot_generate_days]];
  877.                             $log_data $api_log_info." | stg_normalloc_upcounry_slot_generate_days:".json_encode($stg_normalloc_upcounry_slot_generate_days)."| weekdates:".json_encode($weekdates);
  878.                             SELF::createApiLog($log_data);
  879.                             // $weekdates = ($slot_generate_days > 0)?$weekdates:[$weekdates[0]];
  880.                             // echo 'weekdates:<pre>:'; print_r($weekdates);
  881.                             
  882.                             $slot_generate_days_date  date('Y-m-d'strtotime($today_date ' +'.$slot_generate_days.' day'));
  883.                             $delivery_modes $setting_deliveryModes;//['standard','express'];//['courier','standard','express'];
  884.                             $locationSlotRule = new DataObject\Deliveryslotrules\Listing();
  885.                             $locationSlotRule->setCondition(" FIND_IN_SET('".$parentLoc_id."',location_ids) ");
  886.                             $locationSlotRule $locationSlotRule->getData();
  887.                             if (count($locationSlotRule)) {
  888.                                 $delivery_modes = array();
  889.                                 foreach ($locationSlotRule as $slv) {
  890.                                     $delivery_modes[] = $slv->getdelivery_mode();
  891.                                 }
  892.                             }
  893.                             $log_data $api_log_info." | slot_generate_days_date:".json_encode($slot_generate_days_date)."| delivery_modes:".json_encode($delivery_modes);
  894.                             SELF::createApiLog($log_data);
  895.                             $delivery_mode_slots_all = [];
  896.                             foreach($delivery_modes as $delivery_mode)
  897.                             {
  898.                                 $log_data $api_log_info." | delivery_mode:".json_encode($delivery_mode)."| delSlotTimes Title:".json_encode($delSlotTimes->gettitle());
  899.                                 SELF::createApiLog($log_data);
  900.                                 if($delSlotTimes->gettitle() == 'customized' && (!in_array($delivery_mode,['standard'])))
  901.                                 {
  902.                                     $delivery_mode_slots_all[$delivery_mode] = [];
  903.                                 } else if($delSlotTimes->gettitle() == 'Confectionery' && (!in_array($delivery_mode,['standard','express'])))
  904.                                 {
  905.                                     $delivery_mode_slots_all[$delivery_mode] = [];
  906.                                 } else {
  907.                                     $slotsList DataObject\Slots::getList();
  908.                                     if($cur_time $setting_slot_time_flag)//if($cur_time > '18:00')
  909.                                     {
  910.                                         $slotsList->setCondition("slotdate >= :tomdate AND delivery_mode = :delivery_mode AND loc_id = :parentLoc_id AND slotdate IN (:slotdates)", ["slotdate" => $today_date"prior_time" => $cur_time"delivery_mode" => $delivery_mode"parentLoc_id" => $parentLoc_id"tomdate" => $delSlot_date1"slotdates" => $weekdates]);
  911.                                     } else {
  912.                                         if($delivery_mode == 'standard')
  913.                                         {
  914.                                             $slotsList->setCondition("((slotdate = :slotdate AND fromtime <= :prior_time AND totime >= :prior_time) || slotdate >= :tomdate) AND delivery_mode = :delivery_mode AND loc_id = :parentLoc_id AND slotdate IN (:slotdates)", ["slotdate" => $today_date"prior_time" => $cur_time"delivery_mode" => $delivery_mode"parentLoc_id" => $parentLoc_id"tomdate" => $delSlot_date1"slotdates" => $weekdates]);
  915.                                         } else
  916.                                         {
  917.                                             $slotsList->setCondition("((slotdate = :slotdate AND prior_time >= :prior_time) || slotdate >= :tomdate) AND delivery_mode = :delivery_mode AND loc_id = :parentLoc_id AND slotdate IN (:slotdates)", ["slotdate" => $today_date"prior_time" => $cur_time"delivery_mode" => $delivery_mode"parentLoc_id" => $parentLoc_id"tomdate" => $delSlot_date1"slotdates" => $weekdates]);
  918.                                         }
  919.                                     }
  920.                                     $slotsList->setOrderKey("slotdate");
  921.                                     $slotsList->setOrder("asc");
  922.                                     $slotsList->load();
  923.                                     // if($slot_generate_days == 3)
  924.                                     // {
  925.                                     //     echo '<pre>';
  926.                                     //     print_r($slotsList); die;
  927.                                     // }
  928.                                     /*---------- Slots Loop Starts ----------*/
  929.                                     $log_data $api_log_info." | slotsList count:".json_encode(count($slotsList))."| cur_slot_generate_days:".json_encode($cur_slot_generate_days);
  930.                                     SELF::createApiLog($log_data);
  931.                                     $delivery_mode_slots = [];
  932.                                     if(count($slotsList) > && $cur_slot_generate_days>0){
  933.                                         foreach($slotsList as $slot)
  934.                                         {
  935.                                             $log_data $api_log_info." | slot:".json_encode($slot);
  936.                                             SELF::createApiLog($log_data);
  937.                                             $slotLocationData DataObject\Locations::getById($slot->getLoc_id());
  938.                                             $loc_name $slotLocationData->getlocation_name();
  939.                                             $delivery_mode_slot1 = array(
  940.                                                 "slotId" => $slot->getId(),
  941.                                                 "prior_time" => $slot->getprior_time(),
  942.                                                 "slotdate" => date("Y-m-d"strtotime($slot->getslotdate())),//$slot->getslotdate(),//$delSlot_date1,//
  943.                                                 "loc_name" => $loc_name,
  944.                                                 "fromtime" => $slot->getfromtime(),
  945.                                                 "totime" => $slot->gettotime(),
  946.                                                 "maxorder" => $slot->getmaxorder(),
  947.                                                 "ordercount" => $slot->getordercount(),
  948.                                                 "delivery_mode" => $slot->getdelivery_mode(),
  949.                                             );
  950.                                             array_push($delivery_mode_slots$delivery_mode_slot1);
  951.                                             $log_data $api_log_info." | delivery_mode_slot1:".json_encode($delivery_mode_slot1)."| delivery_mode_slots:".json_encode($delivery_mode_slots);
  952.                                             SELF::createApiLog($log_data);
  953.                                         }
  954.                                     }
  955.                                     /*---------- Slots Loop Starts ----------*/
  956.                                     $delivery_mode_slot2 = array($delivery_mode=>$delivery_mode_slots);
  957.                                     $log_data $api_log_info." | delivery_mode_slot2:".json_encode($delivery_mode_slot2);
  958.                                     SELF::createApiLog($log_data);
  959.                                     // array_push($delivery_mode_slots_all, $delivery_mode_slot2);
  960.                                     if ($fastDelivery) {
  961.                                         if ($delivery_mode == 'standard') {
  962.                                             $delivery_mode_slots_all[$delivery_mode] = $delivery_mode_slots;
  963.                                         } else {
  964.                                             $delivery_mode_slots_all[$delivery_mode] = (!empty($delivery_mode_slots[0]) ? array($delivery_mode_slots[0]) : array());
  965.                                         }
  966.                                     } else {
  967.                                         $delivery_mode_slots_all[$delivery_mode] = $delivery_mode_slots;
  968.                                     }
  969.                                     $log_data $api_log_info." | delivery_mode:".json_encode($delivery_mode)."| delivery_mode_slots:".json_encode($delivery_mode_slots);
  970.                                     SELF::createApiLog($log_data);
  971.                                 }
  972.                             }
  973.                             $data[] = array(
  974.                                 // "LocationName" => $parentLocationName,
  975.                                 // "LocationCode" => $parentLocationCode,
  976.                                 // "Is_location_up_country" => $Is_location_up_country,
  977.                                 "location_type" => $location_type,
  978.                                 "is_upcountry_configuration_applicable" => $is_upcountry_configuration_applicable,
  979.                                 "stg_normalloc_upcounry_slot_generate_days" => $stg_normalloc_upcounry_slot_generate_days,
  980.                                 "deliverytype_id" => $delSlotTimes->gettitle(),
  981.                                 "label" => $delSlotTimes->getdeliverytype_id()->getdeliverytype(),
  982.                                 "prepare_days" => $slot_prepare_days,//$delSlotTimes->getprepare_days(),
  983.                                 "slot_generate_days" => $cur_slot_generate_days,//$slot_generate_days,
  984.                                 "delSlot_date" => $delSlot_date1,
  985.                                 "slots"=>$delivery_mode_slots_all);
  986.                                 $log_data $api_log_info." | data:".json_encode($data);
  987.                                 SELF::createApiLog($log_data);
  988.                         }
  989.                     } else $data[] = ['message'=>$message];
  990.                 // }
  991.             } else $data[] = ['message'=>$message];
  992.             
  993.         } else $data[] = ['message'=>$message];
  994.         $return_data = ["success" => true"Is_location_up_country" => $Is_location_up_country"data" => $data];
  995.         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  996.         SELF::createApiLog($log_data);
  997.         return $this->json(["success" => true"Is_location_up_country" => $Is_location_up_country"data" => $data]);
  998.     }
  999.     /**
  1000.      * @Route("/api/allslots")
  1001.      */
  1002.     public function allslotsAction()
  1003.     {
  1004.         $api_log_info "API:All Available Slots - ".date("YmdHis")." ".time();
  1005.         $log_data "Started - ".$api_log_info;
  1006.         SELF::createApiLog($log_data);
  1007.         $message SELF::verifyauthToken($api_log_info);
  1008.         $log_data $api_log_info." | message:".json_encode($message);
  1009.         SELF::createApiLog($log_data);
  1010.         if($message == "No data found")
  1011.         {
  1012.             $delSlotTimesList DataObject\Deliveryslottimes::getList();
  1013.             $delSlotTimesList->load();
  1014.             // $delivery_modes = ['courier','standard','express'];
  1015.             // $slotsList = DataObject\Slots::getList();
  1016.             // $slotsList->setCondition("delivery_mode = 'courier'");
  1017.             // // if ($slotsList->getClass()->getFieldDefinition('delivery_mode')->isFilterable()) {
  1018.             // //     $slotsList->filterBydelivery_mode($courier_mode, '=');
  1019.             // // }
  1020.             // $slotsList->load();
  1021.             // echo '<pre>kk'; print_r($slotsList); die;
  1022.             $log_data $api_log_info." | delSlotTimesList count:".json_encode(count($delSlotTimesList));
  1023.             SELF::createApiLog($log_data);
  1024.             if(count($delSlotTimesList) > 0){
  1025.                 foreach($delSlotTimesList as $delSlotTimes)
  1026.                 {
  1027.                     $log_data $api_log_info." | delSlotTimes:".json_encode($delSlotTimes);
  1028.                     SELF::createApiLog($log_data);
  1029.                     $prepare_days $delSlotTimes->getprepare_days();
  1030.                     $delSlot_date date('Y-m-d H:i:s'strtotime(' +'.$prepare_days.' day'));
  1031.                     $delSlot_date1 date("Y-m-d");//date("Y-m-d", strtotime($delSlot_date));
  1032.                     $cur_time date("H:i");
  1033.                     // $delSlotTimes->delSlot_date = $delSlot_date;
  1034.                     $delivery_modes = ['courier','standard','express'];
  1035.                     $log_data $api_log_info." | prepare_days:".json_encode($prepare_days)." | delSlot_date:".json_encode($delSlot_date)." | delSlot_date1:".json_encode($delSlot_date1)." | cur_time:".json_encode($cur_time)." | delivery_modes:".json_encode($delivery_modes);
  1036.                     SELF::createApiLog($log_data);
  1037.                     $delivery_mode_slots_all = [];
  1038.                     foreach($delivery_modes as $delivery_mode)
  1039.                     {
  1040.                         $log_data $api_log_info." | delivery_mode:".json_encode($delivery_mode);
  1041.                         SELF::createApiLog($log_data);
  1042.                         $slotsList DataObject\Slots::getList();
  1043.                         // $slotsList->setCondition("delivery_mode = '".$delivery_mode."'");
  1044.                         if ($slotsList->getClass()->getFieldDefinition('slotdate')->isFilterable()) {
  1045.                             $slotsList->filterBySlotdate($delSlot_date1'>=');
  1046.                         }
  1047.                         // if ($slotsList->getClass()->getFieldDefinition('prior_time')->isFilterable()) {
  1048.                         //     $slotsList->filterByprior_time($cur_time, '>=');
  1049.                         // }
  1050.                         if ($slotsList->getClass()->getFieldDefinition('delivery_mode')->isFilterable()) {
  1051.                             $slotsList->filterBydelivery_mode($delivery_mode'>=');
  1052.                         }
  1053.                         $slotsList->setLimit(100);
  1054.                         $slotsList->setOrderKey("slotdate");
  1055.                         $slotsList->setOrder("asc");
  1056.                         $slotsList->load();
  1057.                         /*---------- Slots Loop Starts ----------*/
  1058.                         $log_data $api_log_info." | slotsList count:".json_encode(count($slotsList));
  1059.                         SELF::createApiLog($log_data);
  1060.                         $delivery_mode_slots = [];
  1061.                         if(count($slotsList) > 0){
  1062.                             foreach($slotsList as $slot)
  1063.                             {
  1064.                                 $log_data $api_log_info." | slot:".json_encode($slot);
  1065.                                 SELF::createApiLog($log_data);
  1066.                                 // $loc_name = (!empty($slot->getLoc_id()))?$slot->getLoc_id()->getlocation_name():'';
  1067.                                 // $loc_code = (!empty($slot->getLoc_id()))?$slot->getLoc_id()->getlocation_code():'';
  1068.                                 $slotLocationData DataObject\Locations::getById($slot->getLoc_id());
  1069.                                 $loc_name $slotLocationData->getlocation_name();
  1070.                                 $loc_code $slotLocationData->getlocation_code();
  1071.                                 $log_data $api_log_info." | slotLocationData:".json_encode($slotLocationData)." | loc_name:".json_encode($loc_name)." | loc_code:".json_encode($loc_code);
  1072.                                 SELF::createApiLog($log_data);
  1073.                                 $delivery_mode_slot1 = array(
  1074.                                     "slotId" => $slot->getId(),
  1075.                                     "prior_time" => $slot->getprior_time(),
  1076.                                     // "picking_time" => $slot->getpicking_time(),
  1077.                                     // "charge" => $slot->getcharge(),
  1078.                                     "slotdate" => $slot->getslotdate(),
  1079.                                     "loc_name" => $loc_name,
  1080.                                     "loc_code" => $loc_code,
  1081.                                     "fromtime" => $slot->getfromtime(),
  1082.                                     "totime" => $slot->gettotime(),
  1083.                                     "maxorder" => $slot->getmaxorder(),
  1084.                                     "ordercount" => $slot->getordercount(),
  1085.                                     "delivery_mode" => $slot->getdelivery_mode()
  1086.                                 );
  1087.                                 $log_data $api_log_info." | delivery_mode_slot1:".json_encode($delivery_mode_slot1);
  1088.                                 SELF::createApiLog($log_data);
  1089.                                 array_push($delivery_mode_slots$delivery_mode_slot1);
  1090.                                 $log_data $api_log_info." | delivery_mode_slots:".json_encode($delivery_mode_slots);
  1091.                                 SELF::createApiLog($log_data);
  1092.                             }
  1093.                         }
  1094.                         /*---------- Slots Loop Starts ----------*/
  1095.                         $delivery_mode_slot2 = array($delivery_mode=>$delivery_mode_slots);
  1096.                         $log_data $api_log_info." | delivery_mode_slot2:".json_encode($delivery_mode_slot2);
  1097.                         SELF::createApiLog($log_data);
  1098.                         // array_push($delivery_mode_slots_all, $delivery_mode_slot2);
  1099.                         $delivery_mode_slots_all[$delivery_mode] = $delivery_mode_slots;
  1100.                         $log_data $api_log_info." | delivery_mode:".json_encode($delivery_mode)." | delivery_mode_slots_all:".json_encode($delivery_mode_slots_all);
  1101.                         SELF::createApiLog($log_data);
  1102.                     }
  1103.                     $data[] = array(
  1104.                         "deliverytype_id" => $delSlotTimes->gettitle(),
  1105.                         "label" => $delSlotTimes->getdeliverytype_id()->getdeliverytype(),
  1106.                         "prepare_days" => $delSlotTimes->getprepare_days(),
  1107.                         "delSlot_date" => $delSlot_date,
  1108.                         "slots"=>$delivery_mode_slots_all);
  1109.                     
  1110.                     $log_data $api_log_info." | data:".json_encode($data);
  1111.                     SELF::createApiLog($log_data);
  1112.                 }
  1113.             } else $data[] = [];
  1114.         } else $data[] = ['message'=>$message];
  1115.         $data = (empty($data))?$message:$data;
  1116.                 
  1117.         $log_data "Ended - ".$api_log_info." | data:".json_encode($data);
  1118.         SELF::createApiLog($log_data);
  1119.         return $this->json(["success" => true"data" => $data]);
  1120.     }
  1121.     /*------------------------------ End of Slots Related APIs -------------------------*/
  1122.     /*---------------------------------- Delivery Slot Time Related APIs ----------------------------*/
  1123.     /**
  1124.      * @Route("/deliveryslottime/getslottimes")
  1125.      */
  1126.     public function getslottimesAction()
  1127.     {
  1128.         $api_log_info "API:Retriving all Delivery Slot times / Confencery Days - ".date("YmdHis")." ".time();
  1129.         $log_data "Started - ".$api_log_info;
  1130.         SELF::createApiLog($log_data);
  1131.         $message SELF::verifyauthToken($api_log_info);
  1132.         $log_data $api_log_info." | message:".json_encode($message);
  1133.         SELF::createApiLog($log_data);
  1134.         
  1135.         if($message == "No data found")
  1136.         {
  1137.             $delSlotTimesList DataObject\Deliveryslottimes::getList();
  1138.             $delSlotTimesList->load();
  1139.             $log_data $api_log_info." | delSlotTimesList Count ; ".count($delSlotTimesList);
  1140.             SELF::createApiLog($log_data);
  1141.             if(count($delSlotTimesList) > 0){
  1142.                 foreach($delSlotTimesList as $delSlotTimes)
  1143.                 {
  1144.                     $log_data $api_log_info." | delSlotTimes ; ".json_encode($delSlotTimes);
  1145.                     SELF::createApiLog($log_data);
  1146.                     $prepare_days $delSlotTimes->getprepare_days();
  1147.                     $delSlot_date date('Y-m-d H:i:s'strtotime(' +'.$prepare_days.' day'));
  1148.                     $data[] = array(
  1149.                         "title" => $delSlotTimes->gettitle(),
  1150.                         "deliverytype_id" => $delSlotTimes->getdeliverytype_id()->getdeliverytype(),
  1151.                         "prepare_days" => $delSlotTimes->getprepare_days(),
  1152.                         "delSlot_date" => $delSlot_date);
  1153.                         $log_data $api_log_info." | data ; ".json_encode($data);
  1154.                         SELF::createApiLog($log_data);
  1155.                 }
  1156.             } else $data "No data found";
  1157.         }else $data[] = ['message'=>$message];
  1158.         $data = (empty($data))?$message:$data;
  1159.         $log_data "Ended - ".$api_log_info." | data ; ".json_encode($data);
  1160.         SELF::createApiLog($log_data);
  1161.         return $this->json(["success" => true"data" => $data]);
  1162.     }
  1163.     /**
  1164.      * @Route("/deliveryslottime/getslottimeslist")
  1165.      */
  1166.     public function getslottimeslistAction()
  1167.     {
  1168.         $api_log_info "API:Retriving all Delivery Slots - ".date("YmdHis")." ".time();
  1169.         $log_data "Started - ".$api_log_info;
  1170.         SELF::createApiLog($log_data);
  1171.         $message SELF::verifyauthToken($api_log_info);
  1172.         $log_data $api_log_info." | message:".json_encode($message);
  1173.         SELF::createApiLog($log_data);
  1174.         
  1175.         if($message == "No data found")
  1176.         {
  1177.             $delSlotTimesList DataObject\Deliveryslottimes::getList();
  1178.             $delSlotTimesList->load();
  1179.             // $delivery_modes = ['courier','standard','express'];
  1180.             // $slotsList = DataObject\Slots::getList();
  1181.             // $slotsList->setCondition("delivery_mode = 'courier'");
  1182.             // // if ($slotsList->getClass()->getFieldDefinition('delivery_mode')->isFilterable()) {
  1183.             // //     $slotsList->filterBydelivery_mode($courier_mode, '=');
  1184.             // // }
  1185.             // $slotsList->load();
  1186.             // echo '<pre>kk'; print_r($slotsList); die;
  1187.             $log_data $api_log_info." | delSlotTimesList:".json_encode(count($delSlotTimesList));
  1188.             SELF::createApiLog($log_data);
  1189.             if(count($delSlotTimesList) > 0){
  1190.                 foreach($delSlotTimesList as $delSlotTimes)
  1191.                 {
  1192.                     $log_data $api_log_info." | delSlotTimes:".json_encode($delSlotTimes);
  1193.                     SELF::createApiLog($log_data);
  1194.                     $prepare_days $delSlotTimes->getprepare_days();
  1195.                     $delSlot_date date('Y-m-d H:i:s'strtotime(' +'.$prepare_days.' day'));
  1196.                     $delSlot_date1 date("Y-m-d"strtotime($delSlot_date));
  1197.                     $cur_time date("H:i");
  1198.                     // $delSlotTimes->delSlot_date = $delSlot_date;
  1199.                     $delivery_modes = ['courier','standard','express'];
  1200.                     $log_data $api_log_info." | prepare_days:".json_encode($prepare_days)." | delSlot_date:".json_encode($delSlot_date)." | delSlot_date1:".json_encode($delSlot_date1)." | cur_time:".json_encode($cur_time)." | delivery_modes:".json_encode($delivery_modes);
  1201.                     SELF::createApiLog($log_data);
  1202.                     $delivery_mode_slots_all = [];
  1203.                     foreach($delivery_modes as $delivery_mode)
  1204.                     {
  1205.                         $log_data $api_log_info." | delivery_mode:".json_encode($delivery_mode);
  1206.                         SELF::createApiLog($log_data);
  1207.                         $slotsList DataObject\Slots::getList();
  1208.                         // $slotsList->setCondition("delivery_mode = '".$delivery_mode."'");
  1209.                         if ($slotsList->getClass()->getFieldDefinition('slotdate')->isFilterable()) {
  1210.                             $slotsList->filterBySlotdate($delSlot_date1'=');
  1211.                         }
  1212.                         if ($slotsList->getClass()->getFieldDefinition('prior_time')->isFilterable()) {
  1213.                             $slotsList->filterByprior_time($cur_time'>=');
  1214.                         }
  1215.                         if ($slotsList->getClass()->getFieldDefinition('delivery_mode')->isFilterable()) {
  1216.                             $slotsList->filterBydelivery_mode($delivery_mode'>=');
  1217.                         }
  1218.                         $slotsList->setLimit(100);
  1219.                         $slotsList->setOrderKey("slotdate");
  1220.                         $slotsList->setOrder("asc");
  1221.                         $slotsList->load();
  1222.                         /*---------- Slots Loop Starts ----------*/
  1223.                         $log_data $api_log_info." | slotsList count:".json_encode(count($slotsList));
  1224.                         SELF::createApiLog($log_data);
  1225.                         $delivery_mode_slots = [];
  1226.                         if(count($slotsList) > 0){
  1227.                             foreach($slotsList as $slot)
  1228.                             {
  1229.                                 $log_data $api_log_info." | slot:".json_encode($slot);
  1230.                                 SELF::createApiLog($log_data);
  1231.                                 // $loc_name = (!empty($slot->getLoc_id()))?$slot->getLoc_id()->getlocation_name():'';
  1232.                                 // $loc_code = (!empty($slot->getLoc_id()))?$slot->getLoc_id()->getlocation_code():'';
  1233.                                 $slotLocationData DataObject\Locations::getById($slot->getLoc_id());
  1234.                                 $loc_name $slotLocationData->getlocation_name();
  1235.                                 $loc_code $slotLocationData->getlocation_code();
  1236.                                 $delivery_mode_slot1 = array(
  1237.                                     "slotId" => $slot->getId(),
  1238.                                     "prior_time" => $slot->getprior_time(),
  1239.                                     // "picking_time" => $slot->getpicking_time(),
  1240.                                     // "charge" => $slot->getcharge(),
  1241.                                     "slotdate" => $slot->getslotdate(),
  1242.                                     "loc_name" => $loc_name,
  1243.                                     "loc_code" => $loc_code,
  1244.                                     "fromtime" => $slot->getfromtime(),
  1245.                                     "totime" => $slot->gettotime(),
  1246.                                     "maxorder" => $slot->getmaxorder(),
  1247.                                     "ordercount" => $slot->getordercount(),
  1248.                                     "delivery_mode" => $slot->getdelivery_mode()
  1249.                                 );
  1250.                                 array_push($delivery_mode_slots$delivery_mode_slot1);
  1251.                                 $log_data $api_log_info." | delivery_mode_slot1:".json_encode($delivery_mode_slot1)." | delivery_mode_slots:".json_encode($delivery_mode_slots);
  1252.                                 SELF::createApiLog($log_data);
  1253.                             }
  1254.                         }
  1255.                         /*---------- Slots Loop Starts ----------*/
  1256.                         $delivery_mode_slot2 = array($delivery_mode=>$delivery_mode_slots);
  1257.                         $log_data $api_log_info." | delivery_mode_slot2:".json_encode($delivery_mode_slot2);
  1258.                         SELF::createApiLog($log_data);
  1259.                         // array_push($delivery_mode_slots_all, $delivery_mode_slot2);
  1260.                         $delivery_mode_slots_all[$delivery_mode] = $delivery_mode_slots;
  1261.                         $log_data $api_log_info." | delivery_mode:".json_encode($delivery_mode)." | delivery_mode_slots_all:".json_encode($delivery_mode_slots_all);
  1262.                         SELF::createApiLog($log_data);
  1263.                     }
  1264.                     $data[] = array(
  1265.                         "deliverytype_id" => $delSlotTimes->gettitle(),
  1266.                         "label" => $delSlotTimes->getdeliverytype_id()->getdeliverytype(),
  1267.                         "prepare_days" => $delSlotTimes->getprepare_days(),
  1268.                         "delSlot_date" => $delSlot_date,
  1269.                         "slots"=>$delivery_mode_slots_all);
  1270.                         
  1271.                     $log_data $api_log_info." | data:".json_encode($data);
  1272.                     SELF::createApiLog($log_data);
  1273.                 }
  1274.             } else $data[] = [];
  1275.         }else $data[] = ['message'=>$message];
  1276.         $data = (empty($data))?$message:$data;
  1277.         $log_data "Ended - ".$api_log_info." | data:".json_encode($data);
  1278.         SELF::createApiLog($log_data);
  1279.         return $this->json(["success" => true"data" => $data]);
  1280.     }
  1281.     /*------------------------------ End of Delivery Slot Time Related APIs -------------------------*/
  1282.     /*----------------------------------- AWS S3 Bucket Related APIs ---------------------------*/
  1283.     /**
  1284.      * @Route("/awss3bucket/gets3bucketlist")
  1285.      */
  1286.     public function gets3bucketlistAction()
  1287.     {
  1288.         putenv('AWS_DEFAULT_REGION=us-east-2');
  1289.         putenv('AWS_ACCESS_KEY_ID=AKIAUY45FDQLWT32YTPJ');
  1290.         putenv('AWS_SECRET_ACCESS_KEY=IyaHsvQqIdeyDvUrpmlm4T/xizd5999KCpuBP8vg');
  1291.         // $output = shell_exec('aws s3 ls');
  1292.         try
  1293.         {
  1294.             $output shell_exec('aws s3api create-bucket --bucket snap2web-13 --region us-east-2 --create-bucket-configuration LocationConstraint=us-east-2');
  1295.         } catch(Exception $e)
  1296.         {
  1297.             echo $e->getMessage(); die;
  1298.         }
  1299.         // echo "<pre>$output</pre>";
  1300.         echo '<pre>'print_r($output); die;
  1301.         return $this->json(["success" => true"data" => $data]);
  1302.     }
  1303.     /**
  1304.      * @Route("/awss3bucket/uploadFileToS3")
  1305.      */
  1306.     public function uploadFileToS3()
  1307.     {
  1308.         $curl curl_init();
  1309.         curl_setopt_array($curl, array(
  1310.         CURLOPT_URL => 'https://itc-test.s3.ap-south-1.amazonaws.com/public/test.txt?X-Amz-Expires=86400&X-Amz-Date=20230320T054345Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAUY45FDQLWT32YTPJ%252F20230320%252Fap-south-1%252Fs3%252Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=8911af2498f4c48c8b0192a17fa4b8261946d1a7bb482f901091fb96760b2181',
  1311.         CURLOPT_RETURNTRANSFER => true,
  1312.         CURLOPT_ENCODING => '',
  1313.         CURLOPT_MAXREDIRS => 10,
  1314.         CURLOPT_TIMEOUT => 0,
  1315.         CURLOPT_FOLLOWLOCATION => true,
  1316.         CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  1317.         CURLOPT_CUSTOMREQUEST => 'PUT',
  1318.         CURLOPT_POSTFIELDS => "<file contents here>",
  1319.         CURLOPT_HTTPHEADER => array(
  1320.             'Content-Type: text/plain'
  1321.         ),
  1322.         ));
  1323.         $response curl_exec($curl);
  1324.         curl_close($curl);
  1325.         echo $response;
  1326.     }
  1327.     /*------------------------------ End of AWS S3 Bucket Related APIs -------------------------*/
  1328.     /**
  1329.      * @Route("/user/login", methods={"POST"})
  1330.      */
  1331.     public function userLogin(Request $request)
  1332.     {
  1333.         $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  1334.         $userName = (isset($reqparams['username']))?$reqparams['username']:'';
  1335.         $password = (isset($reqparams['password']))?$reqparams['password']:'';
  1336.         if($userName == '' || $password == '')
  1337.         {
  1338.             $data "Username and Password are mandatory!";
  1339.         } else {
  1340.             $user User::getByName($userName);
  1341.             if($user) {
  1342.                 $validateUser \Pimcore\Tool\Authentication::authenticatePlaintext($userName,$password);
  1343.                 if($validateUser) {
  1344.                     $userInfo = ['id'=>$validateUser->getId(),
  1345.                                 'firstname'=>$validateUser->getfirstname(),
  1346.                                 'lastname'=>$validateUser->getlastname(),
  1347.                                 'email'=>$validateUser->getemail(),
  1348.                                 ];
  1349.                     $generateAuthTokenInfo SELF::generateAuthToken($userInfo);
  1350.                     $generateAuthToken $generateAuthTokenInfo['generateAuthToken'];
  1351.                     $jwtToken = (!empty($generateAuthTokenInfo['jwt']))?$generateAuthTokenInfo['jwt']:'';
  1352.                     $userId $validateUser->getId(); 
  1353.                     $dbConnection \Pimcore\Db::get();
  1354.                     $dbConnection->query("UPDATE users SET `authToken` = ? WHERE id = ?", [$generateAuthToken$userId]);
  1355.                     $userData User::getById($userId);
  1356.                     $authTokenVal $dbConnection->fetchOne("SELECT authToken FROM users WHERE id = ".$userId);
  1357.                     $data = ["message"=>'Login successfull'"authToken"=>$authTokenVal];
  1358.                     if($jwtToken!='')
  1359.                         $data = ["message"=>'Login successfull'"authToken"=>$authTokenVal"jwtToken"=>$jwtToken];
  1360.                     
  1361.                 } else {
  1362.                     $data 'Wrong password';
  1363.                 }
  1364.             } else {
  1365.                 $data 'User not found';
  1366.             }
  1367.         }
  1368.         return $this->json(["success" => true"data" => $data]);
  1369.     }
  1370.     /*---------------------------------- JWT Related APIs ----------------------------*/
  1371.     /**
  1372.      * @Route("/api/gernerateJwtToken")
  1373.      */
  1374.     public function gernerateJwtTokenAction()
  1375.     {
  1376.         $id 1024;
  1377.         $firstname 'Tex';
  1378.         $lastname 'Hardrock';
  1379.         $email 'dino@stone.age';
  1380.         $secret_key "951e345a17ab26f80ec0e16b1d2a0c2a";
  1381.         $issuer_claim "pimcore6.local"// this can be the servername
  1382.         $audience_claim "Babu";
  1383.         $issuedat_claim time(); // issued at
  1384.         $notbefore_claim $issuedat_claim 10//not before in seconds
  1385.         $expire_claim $issuedat_claim 60// expire time in seconds
  1386.         $token = array(
  1387.             "iss" => $issuer_claim,
  1388.             "aud" => $audience_claim,
  1389.             "iat" => $issuedat_claim,
  1390.             "nbf" => $notbefore_claim,
  1391.             "exp" => $expire_claim,
  1392.             "data" => array(
  1393.                 "id" => $id,
  1394.                 "firstname" => $firstname,
  1395.                 "lastname" => $lastname,
  1396.                 "email" => $email
  1397.         ));
  1398.         $jwt JWT::encode($token$secret_key'HS256');
  1399.         // echo json_encode(
  1400.         //     array(
  1401.         //         "message" => "Successful login.",
  1402.         //         "jwt" => $jwt,
  1403.         //         "email" => $email,
  1404.         //         "expireAt" => $expire_claim
  1405.         //     )); die;
  1406.         $data = array(
  1407.             "message" => "Successful login.",
  1408.             "jwt" => $jwt,
  1409.             "email" => $email,
  1410.             "expireAt" => $expire_claim
  1411.         );
  1412.         return $this->json(["success" => true"data" => $data]);
  1413.     }
  1414.     /**
  1415.      * @Route("/api/verifyJwtToken")
  1416.      */
  1417.     public function verifyJwtTokenAction()
  1418.     {
  1419.         $secret_key "951e345a17ab26f80ec0e16b1d2a0c2a";
  1420.         $jwt null;
  1421.         
  1422.         $data json_decode(file_get_contents("php://input"));
  1423.         $authHeader $_SERVER['HTTP_AUTHORIZATION'];
  1424.         $arr explode(" "$authHeader);
  1425.         $jwt $arr[1];
  1426.         if($jwt){
  1427.             try {
  1428.                 $decoded JWT::decode($jwt, new Key($secret_key'HS256'));
  1429.                 // Access is granted. Add code of the operation here 
  1430.                 $data = array(
  1431.                     "message" => "Access granted"
  1432.                 );
  1433.                 return $this->json(["success" => true"data" => $data]);
  1434.             }catch (Exception $e){
  1435.                 $data = array(
  1436.                     "message" => "Access denied"
  1437.                 );
  1438.                 return $this->json(["success" => true"data" => $data]);
  1439.             }
  1440.         }
  1441.     }
  1442.     /*------------------------------ End of JWT Related APIs -------------------------*/
  1443.     /*---------------------------------- Personal Statement Related APIs ----------------------------*/
  1444.     /**
  1445.      * @Route("personalitystatement/getperstmtlist", methods={"POST"})
  1446.      */
  1447.     public function getperstmtlistAction(Request $request)
  1448.     {
  1449.         $api_log_info "API:Get Personality Statements list with or without params - ".date("YmdHis")." ".time();
  1450.         $log_data "Started - ".$api_log_info;
  1451.         SELF::createApiLog($log_data);
  1452.         $message SELF::verifyauthToken($api_log_info);
  1453.         $log_data $api_log_info." | message:".json_encode($message);
  1454.         SELF::createApiLog($log_data);
  1455.         // $data[] = ['message'=>$message];
  1456.         $data = [];
  1457.         if($message == "No data found")
  1458.         {
  1459.             $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  1460.             // print_r($reqparams); die;
  1461.             // print_r($request->get->all());
  1462.             $log_data $api_log_info." | reqparams:".json_encode($reqparams);
  1463.             SELF::createApiLog($log_data);
  1464.             $title = (isset($reqparams['title']))?$reqparams['title']:'';
  1465.             $gender = (isset($reqparams['gender']))?$reqparams['gender']:'';
  1466.             $standout_fitin = (isset($reqparams['standout_fitin']))?$reqparams['standout_fitin']:'';
  1467.             $describe_yourself = (isset($reqparams['describe_yourself']))?$reqparams['describe_yourself']:'';
  1468.             $occasion = (isset($reqparams['occasion']))?$reqparams['occasion']:'';
  1469.             $priceband = (isset($reqparams['priceband']))?$reqparams['priceband']:'';
  1470.             $blank1 = (isset($reqparams['blank1']))?$reqparams['blank1']:'';
  1471.             $blank2 = (isset($reqparams['blank2']))?$reqparams['blank2']:'';
  1472.             $log_data $api_log_info." | title:".json_encode($title)." | gender:".json_encode($gender)." | standout_fitin:".json_encode($standout_fitin)." | describe_yourself:".json_encode($describe_yourself)." | occasion:".json_encode($occasion)." | priceband:".json_encode($priceband)." | blank1:".json_encode($blank1)." | blank2:".json_encode($blank2);
  1473.             SELF::createApiLog($log_data);
  1474.             $perstmtList DataObject\Personalitystatements::getList();
  1475.             if($title || $blank1 || $blank2 || $priceband || $gender || $standout_fitin || $describe_yourself || $occasion)
  1476.             {
  1477.                 $whr_condition " personality_statement != '' "$whr_condition_array = [];
  1478.                 if($title){
  1479.                     $whr_condition .= " AND personality_statement = '".$title."'";
  1480.                 }
  1481.                 if($priceband){
  1482.                     $whr_condition .= " AND priceband = '".$priceband."'";
  1483.                 }
  1484.                 if($blank1){
  1485.                     $whr_condition .= " AND blank1 = '".$blank1."'";
  1486.                 }
  1487.                 if($blank2){
  1488.                     $whr_condition .= " AND blank2 = '".$blank2."'";
  1489.                 }
  1490.                 if($gender){
  1491.                     $whr_condition .= " AND gender LIKE '%,".$gender.",%'";
  1492.                 }
  1493.                 if($standout_fitin){
  1494.                     $whr_condition .= " AND standout_fitin LIKE '%,".$standout_fitin.",%'";
  1495.                 }
  1496.                 if($describe_yourself){
  1497.                     $whr_condition .= " AND describe_yourself LIKE '%,".$describe_yourself.",%'";
  1498.                 }
  1499.                 if($occasion){
  1500.                     $whr_condition .= " AND occasion LIKE '%,".$occasion.",%'";
  1501.                 }
  1502.                 // echo "whr_condition:".$whr_condition;
  1503.                 // echo "whr_condition_array:";
  1504.                 // print_r($whr_condition_array); die;
  1505.                 $log_data $api_log_info." | whr_condition:".json_encode($whr_condition);
  1506.                 SELF::createApiLog($log_data);
  1507.                 $perstmtList->setCondition($whr_condition);
  1508.                 
  1509.             }
  1510.             
  1511.             $perstmtList->load();
  1512.             $log_data $api_log_info." | perstmtList count:".json_encode(count($perstmtList));
  1513.             SELF::createApiLog($log_data);
  1514.             foreach ($perstmtList as $key => $perstmtObj) {
  1515.                 $log_data $api_log_info." | perstmtObj:".json_encode($perstmtObj);
  1516.                 SELF::createApiLog($log_data);
  1517.                 $data[] = array(
  1518.                     "id" => $perstmtObj->getId(),
  1519.                     "personality_statement" => $perstmtObj->getpersonality_statement(),
  1520.                     "standout_fitin" => $perstmtObj->getstandout_fitin(),
  1521.                     "describe_yourself" => $perstmtObj->getdescribe_yourself(),
  1522.                     "occasion" => $perstmtObj->getoccasion(),
  1523.                     "priceband" => $perstmtObj->getpriceband(),
  1524.                     "blank2" => $perstmtObj->getblank2(),
  1525.                     "blank1" => $perstmtObj->getblank1());
  1526.                 $log_data $api_log_info." | data:".json_encode($data);
  1527.                 SELF::createApiLog($log_data);
  1528.             }
  1529.         } else $data[] = ['message'=>$message];
  1530.         $data = (empty($data))?$message:$data;
  1531.         // return $slotsList;
  1532.         $return_data = ["success" => true"data" => $data];
  1533.         $log_data $api_log_info." | return_data:".json_encode($return_data);
  1534.         SELF::createApiLog($log_data);
  1535.         return $this->json(["success" => true"data" => $data]);
  1536.     }
  1537.     /**
  1538.      * @Route("personalitystatement/perstmtlist")
  1539.      */
  1540.     public function perstmtlistAction()
  1541.     {
  1542.         $api_log_info "API:Get All Personality Statements - ".date("YmdHis")." ".time();
  1543.         $log_data "Started - ".$api_log_info;
  1544.         SELF::createApiLog($log_data);
  1545.         $message SELF::verifyauthToken($api_log_info);
  1546.         $log_data $api_log_info." | message:".json_encode($message);
  1547.         SELF::createApiLog($log_data);
  1548.         if($message == "No data found")
  1549.         {
  1550.             $perstmtList DataObject\Personalitystatements::getList();
  1551.             $perstmtList->load();
  1552.             $log_data $api_log_info." | perstmtList count:".json_encode(count($perstmtList));
  1553.             SELF::createApiLog($log_data);
  1554.             if(count($perstmtList)>0){
  1555.                 foreach ($perstmtList as $key => $perstmtObj) {
  1556.                     $log_data $api_log_info." | perstmtObj:".json_encode($perstmtObj);
  1557.                     SELF::createApiLog($log_data);
  1558.                     $data[] = array(
  1559.                         "id" => $perstmtObj->getId(),
  1560.                         "personality_statement" => $perstmtObj->getpersonality_statement(),
  1561.                         "standout_fitin" => $perstmtObj->getstandout_fitin(),
  1562.                         "describe_yourself" => $perstmtObj->getdescribe_yourself(),
  1563.                         "occasion" => $perstmtObj->getoccasion(),
  1564.                         "priceband" => $perstmtObj->getpriceband(),
  1565.                         "blank2" => $perstmtObj->getblank2(),
  1566.                         "blank1" => $perstmtObj->getblank1());
  1567.                     $log_data $api_log_info." | data:".json_encode($data);
  1568.                     SELF::createApiLog($log_data);
  1569.                 }
  1570.             } else $data[] = ['message'=>$message];
  1571.         } else $data[] = ['message'=>$message];
  1572.         $return_data = ["success" => true"data" => $data];
  1573.         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  1574.         SELF::createApiLog($log_data);
  1575.         return $this->json(["success" => true"data" => $data]);
  1576.     }
  1577.     /**
  1578.      * @Route("personalitystatement/perstmtinfo/{id}")
  1579.      */
  1580.     public function perstmtinfoAction($id)
  1581.     {
  1582.         $api_log_info "API:Get Personality Statement Info by ID - ".date("YmdHis")." ".time();
  1583.         $log_data "Started - ".$api_log_info;
  1584.         SELF::createApiLog($log_data);
  1585.         $log_data $api_log_info." | ID:".$id;
  1586.         SELF::createApiLog($log_data);
  1587.         $message SELF::verifyauthToken($api_log_info);
  1588.         $log_data $api_log_info." | message:".json_encode($message);
  1589.         SELF::createApiLog($log_data);
  1590.         if($message == "No data found")
  1591.         {
  1592.             $perstmtObject DataObject\Personalitystatements::getById($id);
  1593.             $log_data $api_log_info." | perstmtObject:".json_encode($perstmtObject);
  1594.             SELF::createApiLog($log_data);
  1595.             if(!empty($perstmtObject) && $perstmtObject->getpersonality_statement()){
  1596.                 $log_data $api_log_info." | perstmtObject getpersonality_statement:".json_encode($perstmtObject->getpersonality_statement());
  1597.                 SELF::createApiLog($log_data);
  1598.                 $data[] = array(
  1599.                     "id" => $perstmtObject->getId(),
  1600.                     "personality_statement" => $perstmtObject->getpersonality_statement(),
  1601.                     "standout_fitin" => $perstmtObject->getstandout_fitin(),
  1602.                     "describe_yourself" => $perstmtObject->getdescribe_yourself(),
  1603.                     "occasion" => $perstmtObject->getoccasion(),
  1604.                     "priceband" => $perstmtObject->getpriceband(),
  1605.                     "blank2" => $perstmtObject->getblank2(),
  1606.                     "blank1" => $perstmtObject->getblank1());
  1607.                 $log_data $api_log_info." | data:".json_encode($data);
  1608.                 SELF::createApiLog($log_data);
  1609.             } else $data[] = ['message'=>$message];
  1610.         } else $data[] = ['message'=>$message];
  1611.         $returnData = ["success" => true"data" => $data];
  1612.         $log_data "Ended - ".$api_log_info." | returnData:".json_encode($returnData);
  1613.         SELF::createApiLog($log_data);
  1614.         return $this->json(["success" => true"data" => $data]);
  1615.     }
  1616.     /*------------------------------ End of Personal Statement Related APIs -------------------------*/
  1617.     /*---------------------------------- Shipping Rate / Delivery Fee Related APIs ----------------------------*/
  1618.     /**
  1619.      * @Route("api/shippingchargeslist")
  1620.      */
  1621.     public function shippingchargeslistAction()
  1622.     {
  1623.         $api_log_info "API:Get Shipping Charges List - ".date("YmdHis")." ".time();
  1624.         $log_data "Started - ".$api_log_info;
  1625.         SELF::createApiLog($log_data);
  1626.         $message SELF::verifyauthToken($api_log_info);
  1627.         $log_data $api_log_info." | message:".json_encode($message);
  1628.         SELF::createApiLog($log_data);
  1629.         if($message == "No data found")
  1630.         {
  1631.             $shippingchargesList DataObject\Shippingcharges::getList();
  1632.             $shippingchargesList->load();
  1633.             $log_data $api_log_info." | shippingchargesList count:".json_encode(count($shippingchargesList));
  1634.             SELF::createApiLog($log_data);
  1635.             if(count($shippingchargesList)>0){
  1636.                 foreach ($shippingchargesList as $key => $shippingchargeObj) {
  1637.                     $log_data $api_log_info." | shippingchargeObj:".json_encode($shippingchargeObj);
  1638.                     SELF::createApiLog($log_data);
  1639.                     $data[] = array(
  1640.                         "id" => $shippingchargeObj->getId(),
  1641.                         "minimum_order" => $shippingchargeObj->getminimum_order(),
  1642.                         "maximum_order" => $shippingchargeObj->getmaximum_order(),
  1643.                         "discount_percentage" => $shippingchargeObj->getdiscount_percentage(),
  1644.                         "location" => $shippingchargeObj->getlocationId()->getLocation_name());
  1645.                     $log_data $api_log_info." | data:".json_encode($data);
  1646.                     SELF::createApiLog($log_data);
  1647.                 }
  1648.             } else $data[] = ['message'=>$message];
  1649.         } else $data[] = ['message'=>$message];
  1650.         $returnData = ["success" => true"data" => $data];
  1651.         $log_data "Ended - ".$api_log_info." | returnData:".json_encode($returnData);
  1652.         SELF::createApiLog($log_data);
  1653.         return $this->json(["success" => true"data" => $data]);
  1654.     }
  1655.     /**
  1656.      * @Route("api/shippingrateslist", methods={"POST"})
  1657.      */
  1658.     public function shippingrateslistAction()
  1659.     {
  1660.         $api_log_info "API:Shipping Rate / Delivery Fee List - ".date("YmdHis")." ".time();
  1661.         $log_data "Started - ".$api_log_info;
  1662.         SELF::createApiLog($log_data);
  1663.         $message SELF::verifyauthToken($api_log_info);
  1664.         $log_data $api_log_info." | message:".json_encode($message);
  1665.         SELF::createApiLog($log_data);
  1666.         if($message == "No data found")
  1667.         {
  1668.             $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  1669.             $log_data $api_log_info." | reqparams:".json_encode($reqparams);
  1670.             SELF::createApiLog($log_data);
  1671.             $weight_cart = (isset($reqparams['weight_cart']))?$reqparams['weight_cart']:'';
  1672.             $req_weight_cart $weight_cart;
  1673.             $locationCode = (isset($reqparams['locationCode']))?$reqparams['locationCode']:'';
  1674.             $shipping_state_code = (isset($reqparams['shipping_state_code']))?$reqparams['shipping_state_code']:'';
  1675.             $pincode = (isset($reqparams['pincode']))?$reqparams['pincode']:'';
  1676.             $order_amount = (isset($reqparams['order_amount']))?$reqparams['order_amount']:'';
  1677.             $log_data $api_log_info." | weight_cart:".json_encode($weight_cart)." | req_weight_cart:".json_encode($req_weight_cart)." | locationCode:".json_encode($locationCode)." | shipping_state_code:".json_encode($shipping_state_code)." | pincode:".json_encode($pincode)." | order_amount:".json_encode($order_amount);
  1678.             SELF::createApiLog($log_data);
  1679.             if($weight_cart == '' || $locationCode == '' || $shipping_state_code == '' || $pincode == '' || $order_amount == '')
  1680.             {
  1681.                 $data "weight_cart, locationCode, shipping_state_code, pincode and order_amount are mandatory!";
  1682.                 $log_data $api_log_info." | data:".json_encode($data);
  1683.                 SELF::createApiLog($log_data);
  1684.             } else {
  1685.                 /*------ Get Shipping Rate Card Class data --------*/
  1686.                 $dbConnection \Pimcore\Db::get();
  1687.                 $shippingRatecardClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'Shippingratecards' ");
  1688.                 $shippingRatecardObject "object_".$shippingRatecardClassId;
  1689.                 $log_data $api_log_info." | shippingRatecardObject:".json_encode($shippingRatecardObject);
  1690.                 SELF::createApiLog($log_data);
  1691.                 // $shippingRatecardId = $dbConnection->fetchOne(" select * from object_12 order by abs(no_of_kgs - ".$weight_cart.")");
  1692.                 $shippingRatecardId $dbConnection->fetchOne(" select * from ".$shippingRatecardObject." order by abs(no_of_kgs - ".$weight_cart.")");
  1693.                 $log_data $api_log_info." | shippingRatecardId:".json_encode($shippingRatecardId);
  1694.                 SELF::createApiLog($log_data);
  1695.                 /*----- End of ---------*/
  1696.                 /*---- Check Location by Location Code ---------*/
  1697.                 $locData DataObject\Locations::getBylocation_code($locationCode1);
  1698.                 $pincodeInfo DataObject\ItcAddPincode::getBypincode($pincode1);
  1699.                 $stateInfo DataObject\States::getBystate_code($shipping_state_code1);
  1700.                 $shipChargeInfo DataObject\Shippingratecards::getById($shippingRatecardId); //DataObject\Shippingratecards::getByno_of_kgs($weight_cart, 1);
  1701.                 $log_data $api_log_info." | locData:".json_encode($locData)." | pincodeInfo:".json_encode($pincodeInfo)." | stateInfo:".json_encode($stateInfo)." | shipChargeInfo:".json_encode($shipChargeInfo);
  1702.                 SELF::createApiLog($log_data);
  1703.                 if(empty($locData) || empty($locData->getId()) || empty($pincodeInfo) || empty($pincodeInfo->getId()) || empty($shipChargeInfo) || empty($shipChargeInfo->getId()))// || empty($stateInfo) || empty($stateInfo->getId()) 
  1704.                 {
  1705.                     if(empty($locData) || empty($locData->getId()))
  1706.                         $message "Location is not exited, please try with valid location code!";
  1707.                     
  1708.                     if(empty($pincodeInfo) || empty($pincodeInfo->getId()))
  1709.                         $message "Pincode is not exited, please try with valid pincode!";
  1710.                 
  1711.                     if(empty($shipChargeInfo) || empty($shipChargeInfo->getId()))
  1712.                         $message "Shipping Charge is not exited for ".$weight_cart." Kgs, please try with valid No of Kgs!";
  1713.                     $data[] = ['message'=>$message];
  1714.                     
  1715.                     $log_data $api_log_info." | data:".json_encode($data);
  1716.                     SELF::createApiLog($log_data);
  1717.                 } else {
  1718.                     $locationId $locData->getId();
  1719.                     $locationName $locData->getLocation_name();
  1720.                     $message SELF::verifyauthToken();
  1721.                     
  1722.                     $log_data $api_log_info." | locationId:".json_encode($locationId)." | locationName:".json_encode($locationName)." | message:".json_encode($message);
  1723.                     SELF::createApiLog($log_data);
  1724.                     if($message == "No data found")
  1725.                     {
  1726.                         /*------ Check Location is Up Country or not --------*/
  1727.                         $Is_location_up_country = (strpos(strtolower($locationName),"up country"))?1:0;
  1728.                     
  1729.                         $log_data $api_log_info." | Is_location_up_country:".json_encode($Is_location_up_country);
  1730.                         SELF::createApiLog($log_data);
  1731.         
  1732.                         /*------ Get Settings Class, Object and ID data --------*/
  1733.                         $dbConnection \Pimcore\Db::get();
  1734.                         $settingsClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'Settings' ");
  1735.                         $settingsObject "object_".$settingsClassId;
  1736.                     
  1737.                         $log_data $api_log_info." | settingsObject:".json_encode($settingsObject);
  1738.                         SELF::createApiLog($log_data);
  1739.                         $settingsObjectId $dbConnection->fetchOne("select * from ".$settingsObject." order by oo_id asc");
  1740.                     
  1741.                         $log_data $api_log_info." | settingsObjectId:".json_encode($settingsObjectId);
  1742.                         SELF::createApiLog($log_data);
  1743.                         /*---- Get Settings Data ---------*/
  1744.                         $settingsData DataObject\Settings::getById($settingsObjectId);
  1745.                         $log_data $api_log_info." | settingsData:".json_encode($settingsData);
  1746.                         SELF::createApiLog($log_data);
  1747.                         // echo '<pre>settingsObjectId:'.$settingsObjectId;
  1748.                         // echo '<pre>settingsData:';
  1749.                         // print_r($settingsData->getis_deliveryfee_config_applicable());
  1750.                         $is_shippingapplicable=$pincodeInfo->getis_shipping_applicable();
  1751.                     
  1752.                         $log_data $api_log_info." | is_shippingapplicable:".json_encode($is_shippingapplicable);
  1753.                         SELF::createApiLog($log_data);
  1754.                         $pincode_data['pincode'] = $pincodeInfo->getpincode();
  1755.                         $pincode_data['state'] = $pincodeInfo->getstate();
  1756.                         $pincode_data['is_shipping_applicable'] = $pincodeInfo->getis_shipping_applicable();
  1757.                         $pincode_data['deliverytype'] = $pincodeInfo->getdeliverytype();
  1758.                     
  1759.                         $log_data $api_log_info." | pincode_data:".json_encode($pincode_data);
  1760.                         SELF::createApiLog($log_data);
  1761.                         /*----------- End of Check Is Shipping Applicable or Not based on Pincode from Pincode Table ----------*/
  1762.                         /*------------- Get Shipping Discount Based on Is Shipping Applicable Fee Shipping Rule(Shipping Charges) Table------------*/
  1763.                         $final_cost=0$rate_discount_perc=0$cur_noofkgs $shipChargeInfo->getno_of_kgs();
  1764.                         $zone_name=(!empty($stateInfo) && $stateInfo->getZoneId())?$stateInfo->getZoneId()->getzone_name():'';
  1765.                     
  1766.                         $log_data $api_log_info." | final_cost:".json_encode($final_cost)." | rate_discount_perc:".json_encode($rate_discount_perc)." | cur_noofkgs:".json_encode($cur_noofkgs)." | zone_name:".json_encode($zone_name);
  1767.                         SELF::createApiLog($log_data);
  1768.                         /*----------- End of Get Zone based on State Code from States Table ----------*/
  1769.                         /*------------- Get Shipping rate data based on state code and weight cart ------------*/
  1770.                         $shippingratesList DataObject\Shippingratecards::getList();
  1771.                         if ($shippingratesList->getClass()->getFieldDefinition('no_of_kgs')->isFilterable()) {
  1772.                             $shippingratesList->filterByno_of_kgs($cur_noofkgs'=');
  1773.                         }
  1774.                         $shippingratesList->setOrderKey("no_of_kgs");
  1775.                         $shippingratesList->setOrder("desc");
  1776.                         $shippingratesList->load();
  1777.                     
  1778.                         $log_data $api_log_info." | shippingratesList count:".json_encode(count($shippingratesList));
  1779.                         SELF::createApiLog($log_data);
  1780.                         if(count($shippingratesList)>0){
  1781.                             $ii=0;
  1782.                             foreach ($shippingratesList as $key => $shippingrateObj) {
  1783.                     
  1784.                                 $log_data $api_log_info." | key:".json_encode($key)." | shippingrateObj:".json_encode($shippingrateObj);
  1785.                                 SELF::createApiLog($log_data);
  1786.                                 $data_key $data_val $data_key2 $data_val2 '';
  1787.                                 $data[] = array(
  1788.                                     "id" => $shippingrateObj->getId(),
  1789.                                     "no_of_kgs" => $req_weight_cart,
  1790.                                     "inter_region_cost" => $shippingrateObj->getintera_region_cost(),
  1791.                                     "j_k_cost" => $shippingrateObj->getj_and_k_cost(),
  1792.                                     "ne_and_andaman_cost" => $shippingrateObj->getne_and_andaman()
  1793.                                 );
  1794.                     
  1795.                                 $log_data $api_log_info." | Initialise data_key, data_val, data_key2 and data_val2 values as null | data:".json_encode($data);
  1796.                                 SELF::createApiLog($log_data);
  1797.                                 
  1798.                                 if($is_shippingapplicable == 'Yes')
  1799.                                 {
  1800.                                     if($zone_name == 'J and K')
  1801.                                     {
  1802.                                         $final_cost $shippingrateObj->getj_and_k_cost();
  1803.                                     }
  1804.                                     else if($zone_name == 'NE and Andaman')
  1805.                                     {
  1806.                                         $final_cost $shippingrateObj->getne_and_andaman();  
  1807.                                     }
  1808.                                     else 
  1809.                                     {
  1810.                                         $final_cost $shippingrateObj->getintera_region_cost();
  1811.                                     }
  1812.                                 }
  1813.                                 $log_data $api_log_info." | zone_name:".json_encode($zone_name)." | final_cost:".json_encode($final_cost);
  1814.                                 SELF::createApiLog($log_data);
  1815.                                 $data[$ii]['locationCode'] = $locationCode;
  1816.                                 $data[$ii]['pincode'] = $pincode_data;
  1817.                     
  1818.                                 $log_data $api_log_info." | ii:".json_encode($ii)." | data:".json_encode($data);
  1819.                                 SELF::createApiLog($log_data);
  1820.                                 
  1821.                             }
  1822.                             $minimum_order $maximum_order $discount_percentage 0$shippingRules = [];
  1823.                     
  1824.                             $log_data $api_log_info." | Initialise minimum_order, maximum_order, discount_percentage and shippingRules values as null | is_shippingapplicable:".json_encode($is_shippingapplicable);
  1825.                             SELF::createApiLog($log_data);
  1826.                             
  1827.                             if($is_shippingapplicable == 'Yes')//&& $loc_code_error == ''
  1828.                             {
  1829.                                 $shippingchargesList DataObject\Shippingcharges::getList();
  1830.                                 $shippingchargesList->setCondition("locationId__Id = ? AND (minimum_order <= ? AND maximum_order >= ?)",[$locationId$order_amount$order_amount]);
  1831.                                 $shippingchargesList->load();
  1832.                     
  1833.                                 $log_data $api_log_info." | shippingchargesList count:".json_encode(count($shippingchargesList));
  1834.                                 SELF::createApiLog($log_data);
  1835.                                 if(count($shippingchargesList)>0)
  1836.                                 {
  1837.                                     foreach($shippingchargesList as $shippingchargeObj)
  1838.                                     {
  1839.                                         $log_data $api_log_info." | shippingchargeObj:".json_encode($shippingchargeObj);
  1840.                                         SELF::createApiLog($log_data);
  1841.                                         $minimum_order $shippingchargeObj->getminimum_order();
  1842.                                         $maximum_order $shippingchargeObj->getmaximum_order();
  1843.                                         $discount_percentage $shippingchargeObj->getdiscount_percentage();
  1844.                                         $log_data $api_log_info." | minimum_order:".json_encode($minimum_order)." | maximum_order:".json_encode($maximum_order)." | discount_percentage:".json_encode($discount_percentage);
  1845.                                         SELF::createApiLog($log_data);
  1846.                                         $shippingRules['shippingRuleId'] = $shippingchargeObj->getId();
  1847.                                         $shippingRules['minimum_order_amount'] = $minimum_order;
  1848.                                         $shippingRules['maximum_order_amount'] = $maximum_order;
  1849.                                         $shippingRules['discount_percentage'] = $discount_percentage;
  1850.                                         $log_data $api_log_info." | shippingRules:".json_encode($shippingRules);
  1851.                                         SELF::createApiLog($log_data);
  1852.                                     }
  1853.                                     $data[$ii]['shippingRules'] = $shippingRules;
  1854.                                     $log_data $api_log_info." | ii:".json_encode($ii)." | data:".json_encode($data);
  1855.                                     SELF::createApiLog($log_data);
  1856.                                     $rate_discount_perc = ($minimum_order <= $order_amount && $maximum_order >= $order_amount)?$discount_percentage:0;
  1857.                                     $final_cost $final_cost - (($final_cost*$rate_discount_perc)/100);
  1858.                                     $log_data $api_log_info." | rate_discount_perc:".json_encode($rate_discount_perc)." | final_cost:".json_encode($final_cost);
  1859.                                     SELF::createApiLog($log_data);
  1860.                                 }
  1861.                                 
  1862.                             }
  1863.                             /*----------- Delivery Fee Configuration Condition --------------*/
  1864.                             $log_data $api_log_info." | settingsData getis_deliveryfee_config_applicable:".json_encode($settingsData->getis_deliveryfee_config_applicable());
  1865.                             SELF::createApiLog($log_data);
  1866.                             if($settingsData->getis_deliveryfee_config_applicable() == 'Yes')
  1867.                             {
  1868.                                 $stg_deliveryfee_config $settingsData->getdeliveryfee_config();
  1869.                                 $stg_deliveryfee_config_location_lessthan_charge $settingsData->getdeliveryfee_config_location_lessthan_charge();
  1870.                                 $stg_deliveryfee_config_location_greaterthanequal_charge $settingsData->getdeliveryfee_config_location_greaterthanequal_charge();
  1871.                                 $stg_deliveryfee_config_upcountry_lessthan_charge $settingsData->getdeliveryfee_config_upcountry_lessthan_charge();
  1872.                                 $stg_deliveryfee_config_upcountry_greaterthanequal_charge $settingsData->getdeliveryfee_config_upcountry_greaterthanequal_charge();
  1873.                                 $log_data $api_log_info." | stg_deliveryfee_config:".json_encode($stg_deliveryfee_config)." | stg_deliveryfee_config_location_lessthan_charge:".json_encode($stg_deliveryfee_config_location_lessthan_charge)." | stg_deliveryfee_config_location_greaterthanequal_charge:".json_encode($stg_deliveryfee_config_location_greaterthanequal_charge)." | stg_deliveryfee_config_upcountry_lessthan_charge:".json_encode($stg_deliveryfee_config_upcountry_lessthan_charge)." | stg_deliveryfee_config_upcountry_greaterthanequal_charge:".json_encode($stg_deliveryfee_config_upcountry_greaterthanequal_charge);
  1874.                                 SELF::createApiLog($log_data);
  1875.                                 if($Is_location_up_country == && $order_amount $stg_deliveryfee_config && $stg_deliveryfee_config_location_lessthan_charge != -1$final_cost $stg_deliveryfee_config_location_lessthan_charge;
  1876.                                 else if($Is_location_up_country == && $order_amount >= $stg_deliveryfee_config && $stg_deliveryfee_config_location_greaterthanequal_charge != -1$final_cost $stg_deliveryfee_config_location_greaterthanequal_charge;
  1877.                                 else if($Is_location_up_country == && $order_amount $stg_deliveryfee_config && $stg_deliveryfee_config_upcountry_lessthan_charge != -1$final_cost $stg_deliveryfee_config_upcountry_lessthan_charge;
  1878.                                 else if($Is_location_up_country == && $order_amount >= $stg_deliveryfee_config && $stg_deliveryfee_config_upcountry_greaterthanequal_charge != -1$final_cost $stg_deliveryfee_config_upcountry_greaterthanequal_charge;
  1879.                                 else $final_cost $final_cost;
  1880.                                 $log_data $api_log_info." | final_cost:".json_encode($final_cost);
  1881.                                 SELF::createApiLog($log_data);
  1882.                             }
  1883.                             
  1884.                             $data[$ii]['final_cost'] = $final_cost;
  1885.                             // 2 hours fast delivery code
  1886.                             if($is_shippingapplicable == 'Yes')
  1887.                             {
  1888.                                 $fdsett DataObject\FastDeliverySetting::getList();
  1889.                                 $fdsett->setCondition("locationId__Id = ?",[$locationId]);
  1890.                                 $fdsett->load();
  1891.                                 $data[$ii]['platform_fee'] = 0;
  1892.                                 $data[$ii]['low_order_fee'] = 0;
  1893.                                 if(count($fdsett->getData()) > 0) {
  1894.                                     $fdsett $fdsett->getData()[0];
  1895.                                     $data[$ii]['platform_fee'] = $fdsett->getplatFormFee();
  1896.                                     $cartValue $fdsett->getcartValue();
  1897.                                     if($cartValue $order_amount) {
  1898.                                         $data[$ii]['low_order_fee'] = $fdsett->getminLowOrderFee();
  1899.                                     } else {
  1900.                                         $data[$ii]['low_order_fee'] = $fdsett->getlowOrderFee();
  1901.                                     }
  1902.                                 }
  1903.                             }
  1904.                             $log_data $api_log_info." | final_cost:".json_encode($final_cost)." | ii:".json_encode($ii)." | data:".json_encode($data);
  1905.                             SELF::createApiLog($log_data);
  1906.                         } else $data[] = ['message'=>$message];
  1907.                         /*----------- End of Get Shipping rate data based on state code and weight cart ----------*/
  1908.                     } else $data[] = ['message'=>$message];
  1909.                 }
  1910.             }
  1911.         } else $data[] = ['message'=>$message];
  1912.         $log_data "Ended - ".$api_log_info." | data:".json_encode($data);
  1913.         SELF::createApiLog($log_data);
  1914.         return $this->json(["success" => true"data" => $data]);
  1915.     }
  1916.     /*------------------------------ End of Shipping Rate / Delivery Fee Related APIs -------------------------*/
  1917.     /*---------------------------------- Factory Related APIs ----------------------------*/
  1918.     /**
  1919.      * @Route("/factory/getfactories")
  1920.      */
  1921.     public function getfactories()
  1922.     {
  1923.         $api_log_info "API:Get All Factories - ".date("YmdHis")." ".time();
  1924.         $log_data "Started - ".$api_log_info;
  1925.         SELF::createApiLog($log_data);
  1926.         $message SELF::verifyauthToken($api_log_info);
  1927.         $log_data $api_log_info." | message:".json_encode($message);
  1928.         SELF::createApiLog($log_data);
  1929.         if($message == "No data found")
  1930.         {
  1931.             $factoriesList DataObject\Factories::getList();
  1932.             $factoriesList->load();
  1933.             $log_data $api_log_info." | factoriesList count:".json_encode(count($factoriesList));
  1934.             SELF::createApiLog($log_data);
  1935.             if(count($factoriesList) > 0){
  1936.                 foreach ($factoriesList as $key => $blog) {
  1937.                     $log_data $api_log_info." | key:".json_encode($key)." | blog:".json_encode($blog);
  1938.                     SELF::createApiLog($log_data);
  1939.                     $bestbefore_date '';
  1940.                     if($blog->getbestbefore()){
  1941.                         $bestbefore_dt date("m/d/y"strtotime($blog->getbestbefore()));
  1942.                         $bestbefore_date Carbon::createFromFormat('m/d/y'$bestbefore_dt);
  1943.                         $log_data $api_log_info." | bestbefore_dt:".json_encode($bestbefore_dt)." | bestbefore_date:".json_encode($bestbefore_date);
  1944.                         SELF::createApiLog($log_data);
  1945.                     }
  1946.                     $data[] = array(
  1947.                         "code" => $blog->getcode(),
  1948.                         "name" => $blog->getname(),
  1949.                         "address" => $blog->getaddress(),
  1950.                         "street" => $blog->getstreet(),
  1951.                         "landmark" => $blog->getlandmark(),
  1952.                         "city" => $blog->getcity(),
  1953.                         "state" => $blog->getstate(),
  1954.                         "country" => $blog->getcountry(),
  1955.                         "pincode" => $blog->getpincode(),
  1956.                         "bestbefore" => $bestbefore_date);
  1957.                     $log_data $api_log_info." | data:".json_encode($data);
  1958.                     SELF::createApiLog($log_data);
  1959.                 }
  1960.             } else $data[] = ['message'=>$message];
  1961.         } else $data[] = ['message'=>$message];
  1962.         $log_data "Ended - ".$api_log_info." | data:".json_encode($data);
  1963.         SELF::createApiLog($log_data);
  1964.         
  1965.         return $this->json(["success" => true"data" => $data]);
  1966.     }
  1967.     /**
  1968.      * @Route("api/getfactorydata", methods={"POST"})
  1969.      */
  1970.     public function getfactorydataAction(Request $request)
  1971.     {
  1972.         $api_log_info "API:Get factory Info by Code - ".date("YmdHis")." ".time();
  1973.         $log_data "Started - ".$api_log_info;
  1974.         SELF::createApiLog($log_data);
  1975.         $factorycode $request->get('factorycode');
  1976.         $log_data $api_log_info." | factorycode:".json_encode($factorycode);
  1977.         SELF::createApiLog($log_data);
  1978.         if($factorycode == "")
  1979.         {
  1980.             $data "Factory Code is mandatory!";
  1981.             $log_data $api_log_info." | data:".json_encode($data);
  1982.             SELF::createApiLog($log_data);
  1983.         } else 
  1984.         {
  1985.             $data SELF::verifyauthToken($api_log_info);
  1986.             $log_data $api_log_info." | data:".json_encode($data);
  1987.             SELF::createApiLog($log_data);
  1988.             if($data == "No data found")
  1989.             {
  1990.                 /*---- Check Factory by Code ---------*/
  1991.                 $factoryData DataObject\Factories::getBycode($factorycode1);
  1992.                 $log_data $api_log_info." | factoryData:".json_encode($factoryData);
  1993.                 SELF::createApiLog($log_data);
  1994.                 if(!empty($factoryData) && $factoryData->getId()){
  1995.                         
  1996.                     $log_data $api_log_info." | factoryData getId:".json_encode($factoryData->getId());
  1997.                     SELF::createApiLog($log_data);
  1998.                     $data = array(
  1999.                         "id" => $factoryData->getId(),
  2000.                         "code" => $factoryData->getCode(),
  2001.                         "name" => $factoryData->getname(),
  2002.                         "address" => $factoryData->getaddress(),
  2003.                         "street" => $factoryData->getstreet(),
  2004.                         "landmark" => $factoryData->getlandmark(),
  2005.                         "city" => $factoryData->getcity(),
  2006.                         "state" => $factoryData->getstate(),
  2007.                         "country" => $factoryData->getcountry(),
  2008.                         "pincode" => $factoryData->getpincode(),
  2009.                         "bestbefore" => $factoryData->getbestbefore());
  2010.                     $log_data $api_log_info." | data:".json_encode($data);
  2011.                     SELF::createApiLog($log_data);
  2012.                 } else {
  2013.                     $data "No data found!";
  2014.                     $log_data $api_log_info." | data:".json_encode($data);
  2015.                     SELF::createApiLog($log_data);
  2016.                 }
  2017.             }
  2018.         }
  2019.         $log_data "Ended - ".$api_log_info." | data:".json_encode($data);
  2020.         SELF::createApiLog($log_data);
  2021.         return $this->json(["success" => true"data" => $data]);
  2022.     }
  2023.     /**
  2024.      * @Route("api/getfactoriesdata", methods={"POST"})
  2025.      */
  2026.     public function getfactoriesdataAction(Request $request)
  2027.     {
  2028.         $api_log_info "API:Get Factories list by multiple Factory codes - ".date("YmdHis")." ".time();
  2029.         $log_data "Started - ".$api_log_info;
  2030.         SELF::createApiLog($log_data);
  2031.         $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  2032.         $log_data $api_log_info." | reqparams:".json_encode($reqparams);
  2033.         SELF::createApiLog($log_data);
  2034.         $factorycodes = (isset($reqparams['factorycodes']))?$reqparams['factorycodes']:'';
  2035.         $log_data $api_log_info." | factorycodes:".json_encode($factorycodes);
  2036.         SELF::createApiLog($log_data);
  2037.         // $factorycode = $request->get('factorycode');
  2038.         if($factorycodes == "")
  2039.         {
  2040.             $data "Factory Code(s) is(are) mandatory!";
  2041.             $log_data $api_log_info." | data:".json_encode($data);
  2042.             SELF::createApiLog($log_data);
  2043.         } else 
  2044.         {
  2045.             $data SELF::verifyauthToken($api_log_info);
  2046.             $log_data $api_log_info." | data:".json_encode($data);
  2047.             SELF::createApiLog($log_data);
  2048.             if($data == "No data found")
  2049.             {
  2050.                 /*---- Check Factory by Code ---------*/
  2051.                 $factoriesData = new DataObject\Factories\Listing();
  2052.                 $factoriesData->setCondition("code IN (?)", [$factorycodes]);
  2053.                 $factoriesData->load();
  2054.                 $log_data $api_log_info." | factoriesData count:".json_encode(count($factoriesData));
  2055.                 SELF::createApiLog($log_data);
  2056.                 if(!empty($factoriesData) && count($factoriesData)>0){
  2057.                     $data = [];
  2058.                     foreach($factoriesData as $factoryData){
  2059.                         $log_data $api_log_info." | factoryData:".json_encode($factoryData);
  2060.                         SELF::createApiLog($log_data);
  2061.                         $curdata = array(
  2062.                             "id" => $factoryData->getId(),
  2063.                             "code" => $factoryData->getCode(),
  2064.                             "name" => $factoryData->getname(),
  2065.                             "address" => $factoryData->getaddress(),
  2066.                             "street" => $factoryData->getstreet(),
  2067.                             "landmark" => $factoryData->getlandmark(),
  2068.                             "city" => $factoryData->getcity(),
  2069.                             "state" => $factoryData->getstate(),
  2070.                             "country" => $factoryData->getcountry(),
  2071.                             "pincode" => $factoryData->getpincode(),
  2072.                             "bestbefore" => $factoryData->getbestbefore());
  2073.                         $log_data $api_log_info." | curdata:".json_encode($curdata);
  2074.                         SELF::createApiLog($log_data);
  2075.                         array_push($data$curdata);
  2076.                     }
  2077.                 } else {
  2078.                     $data "No data found!";
  2079.                     $log_data $api_log_info." | data:".json_encode($data);
  2080.                     SELF::createApiLog($log_data);
  2081.                 }
  2082.             }
  2083.         }
  2084.         $return_data = ["success" => true"data" => $data];
  2085.         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  2086.         SELF::createApiLog($log_data);
  2087.         return $this->json(["success" => true"data" => $data]);
  2088.     }
  2089.     /*------------------------------ End of Factory Related APIs -------------------------*/
  2090.     /*---------------------------------- Faq Related APIs ----------------------------*/
  2091.     /**
  2092.      * @param Request $request
  2093.      * 
  2094.      * @Route("/faqApi1",methods={"POST"})
  2095.      * 
  2096.      * @return Response
  2097.      * 
  2098.      */
  2099.     
  2100.      public function faqApi1Action(Request $request)
  2101.      {
  2102.         $api_log_info "API:Get Faq List by locationcode with or without type - ".date("YmdHis")." ".time();
  2103.         $log_data "Started - ".$api_log_info;
  2104.         SELF::createApiLog($log_data);
  2105.         $data SELF::verifyauthToken($api_log_info);
  2106.         $log_data $api_log_info." | data:".json_encode($data);
  2107.         SELF::createApiLog($log_data);
  2108.         if($data == "No data found")
  2109.         {
  2110.             $locationcode = (!empty($request->get('location_code')))?$request->get('location_code'):'';
  2111.             if($locationcode == "")
  2112.             {
  2113.                 $data "Location Code is mandatory";
  2114.             } else {
  2115.                 $getlocationInfo DataObject\Locations::getBylocation_code($locationcode1);
  2116.                 $log_data $api_log_info." | getlocationInfo :".json_encode($getlocationInfo);
  2117.                 SELF::createApiLog($log_data);
  2118.                 if((!empty($getlocationInfo))){
  2119.                     $loc_name = (!empty($getlocationInfo->getlocation_name()))?$getlocationInfo->getlocation_name():'';
  2120.                     $loc_code = (!empty($getlocationInfo->getlocation_code()))?$getlocationInfo->getlocation_code():'';
  2121.                     $log_data $api_log_info." | loc_name :".json_encode($loc_name)." | loc_code :".json_encode($loc_code);
  2122.                     SELF::createApiLog($log_data);
  2123.                     $faqType = (!empty($request->get('type')) && $request->get('type') == 'All')?'':((!empty($request->get('type')) && $request->get('type') != 'All')?$request->get('type'):'General');
  2124.                     $log_data $api_log_info." | locationcode:".json_encode($locationcode)." | faqType:".json_encode($faqType);
  2125.                     SELF::createApiLog($log_data);
  2126.                     $faqTypes_list = ['','All','General''Loyalty'];
  2127.                     if(!in_array($faqType$faqTypes_list)){
  2128.                         $data "You are entered Type is Invalid, Please try again";
  2129.                         $return_data = ["success" => true"data" => $data];
  2130.                         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  2131.                         SELF::createApiLog($log_data);
  2132.                         
  2133.                         return $this->json(["success" => true"data" => $data]);
  2134.                     }
  2135.             
  2136.                     $entries = new DataObject\ItcAddFaq\Listing();
  2137.                     $whr_condition " faqQuestion!= '' ";
  2138.                     if($locationcode != '')
  2139.                     $whr_condition .= " AND location_code= '".$loc_name."' ";
  2140.                     if($faqType != '')
  2141.                     $whr_condition .= " AND faqType= '".$faqType."' ";
  2142.                     // if($locationcode != '')
  2143.                     // $entries->setCondition("location_name = :location_name", ["location_name" => $locationcode]);
  2144.                     // if($faqType != '')
  2145.                     // $entries->setCondition("faqType = :faqType", ["faqType" => $faqType]);
  2146.                     $entries->setCondition($whr_condition);
  2147.                     $entries->load();
  2148.                     $log_data $api_log_info." | faq entries count :".json_encode(count($entries));
  2149.                     SELF::createApiLog($log_data);
  2150.                     $data = (count($entries)>0)?array():"No data found";
  2151.                     foreach($entries as $key => $entrie){
  2152.                         $log_data $api_log_info." | faq key :".json_encode($key)." | faq entrie :".json_encode($entrie);
  2153.                         SELF::createApiLog($log_data);
  2154.             
  2155.                         if($entrie->getlocation_code()){
  2156.                             $locationInfo DataObject\Locations::getBylocation_name($entrie->getlocation_code(), 1);
  2157.                             $log_data $api_log_info." | locationInfo :".json_encode($locationInfo);
  2158.                             SELF::createApiLog($log_data);
  2159.                             
  2160.                             $loc_name = (!empty($locationInfo->getlocation_name()))?$locationInfo->getlocation_name():'';
  2161.                             $loc_code = (!empty($locationInfo->getlocation_code()))?$locationInfo->getlocation_code():'';
  2162.                             $log_data $api_log_info." | loc_name :".json_encode($loc_name)." | loc_code :".json_encode($loc_code);
  2163.                             SELF::createApiLog($log_data);
  2164.                         }
  2165.                         $data[] = array("faqId" => $entrie->getfaqId(),
  2166.                                 "location_code" => $loc_code,
  2167.                                 "location_name" => $loc_name,
  2168.                                 "faqQuestion" => $entrie->getfaqQuestion(),
  2169.                                 "faqAnswer" => $entrie->getfaqAnswer(),
  2170.                                 "Type" => $entrie->getfaqType(),
  2171.                         );
  2172.                         $log_data $api_log_info." | data :".json_encode($data);
  2173.                         SELF::createApiLog($log_data);
  2174.                     }
  2175.                 } else {
  2176.                     $data "Invalid Location Code, Please enter valid Location Code";
  2177.                     $log_data $api_log_info." | data :".json_encode($data);
  2178.                     SELF::createApiLog($log_data);
  2179.                 }
  2180.             }
  2181.         }
  2182.         $return_data = ["success" => true"data" => $data];
  2183.         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  2184.         SELF::createApiLog($log_data);
  2185.         
  2186.         return $this->json(["success" => true"data" => $data]);
  2187.         
  2188.      }
  2189.      /**
  2190.      * @param Request $request
  2191.      * 
  2192.      * @Route("/faqApi",methods={"POST"})
  2193.      * 
  2194.      * @return Response
  2195.      * 
  2196.      */
  2197.      public function faqApiAction(Request $request)
  2198.      {
  2199.         $api_log_info "API:Get Faq List by locationcode with or without type - ".date("YmdHis")." ".time();
  2200.         $log_data "Started - ".$api_log_info;
  2201.         SELF::createApiLog($log_data);
  2202.         $data SELF::verifyauthToken($api_log_info);
  2203.         $log_data $api_log_info." | data:".json_encode($data);
  2204.         SELF::createApiLog($log_data);
  2205.         if($data == "No data found")
  2206.         {
  2207.             $locationcode = (!empty($request->get('location_code')))?$request->get('location_code'):'';
  2208.             // if($locationcode == "")
  2209.             // {
  2210.             //     $data = "Location Code is mandatory";
  2211.             // } else {
  2212.                 $getlocationInfo = (isset($locationcode) && $locationcode!='')?DataObject\Locations::getBylocation_code($locationcode1):[];
  2213.                 $log_data $api_log_info." | getlocationInfo :".json_encode($getlocationInfo);
  2214.                 SELF::createApiLog($log_data);
  2215.                 // if((!empty($getlocationInfo))){
  2216.                     $loc_name = (!empty($getlocationInfo) && !empty($getlocationInfo->getlocation_name()))?$getlocationInfo->getlocation_name():'';
  2217.                     $loc_code = (!empty($getlocationInfo) && !empty($getlocationInfo->getlocation_code()))?$getlocationInfo->getlocation_code():'';
  2218.                     $log_data $api_log_info." | loc_name :".json_encode($loc_name)." | loc_code :".json_encode($loc_code);
  2219.                     SELF::createApiLog($log_data);
  2220.                     $faqType = (!empty($request->get('type')) && $request->get('type') == 'All')?'':((!empty($request->get('type')) && $request->get('type') != 'All')?$request->get('type'):'General');
  2221.                     $log_data $api_log_info." | locationcode:".json_encode($locationcode)." | faqType:".json_encode($faqType);
  2222.                     SELF::createApiLog($log_data);
  2223.                     $faqTypes_list = ['','All','General''Loyalty'];
  2224.                     if(!in_array($faqType$faqTypes_list)){
  2225.                         $data "You are entered Type is Invalid, Please try again";
  2226.                         $return_data = ["success" => true"data" => $data];
  2227.                         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  2228.                         SELF::createApiLog($log_data);
  2229.                         
  2230.                         return $this->json(["success" => true"data" => $data]);
  2231.                     }
  2232.             
  2233.                     $entries = new DataObject\ItcAddFaq\Listing();
  2234.                     $whr_condition " faqQuestion!= '' ";
  2235.                     if($locationcode != '')
  2236.                     $whr_condition .= " AND location_code= '".$loc_name."' ";
  2237.                     if($faqType != '')
  2238.                     $whr_condition .= " AND faqType= '".$faqType."' ";
  2239.                     // if($locationcode != '')
  2240.                     // $entries->setCondition("location_name = :location_name", ["location_name" => $locationcode]);
  2241.                     // if($faqType != '')
  2242.                     // $entries->setCondition("faqType = :faqType", ["faqType" => $faqType]);
  2243.                     $entries->setCondition($whr_condition);
  2244.                     $entries->load();
  2245.                     $log_data $api_log_info." | faq entries count :".json_encode(count($entries));
  2246.                     SELF::createApiLog($log_data);
  2247.                     $data = (count($entries)>0)?array():"No data found";
  2248.                     foreach($entries as $key => $entrie){
  2249.                         $log_data $api_log_info." | faq key :".json_encode($key)." | faq entrie :".json_encode($entrie);
  2250.                         SELF::createApiLog($log_data);
  2251.             
  2252.                         if($entrie->getlocation_code()){
  2253.                             $locationInfo DataObject\Locations::getBylocation_name($entrie->getlocation_code(), 1);
  2254.                             $log_data $api_log_info." | locationInfo :".json_encode($locationInfo);
  2255.                             SELF::createApiLog($log_data);
  2256.                             
  2257.                             $loc_name = (!empty($locationInfo->getlocation_name()))?$locationInfo->getlocation_name():'';
  2258.                             $loc_code = (!empty($locationInfo->getlocation_code()))?$locationInfo->getlocation_code():'';
  2259.                             $log_data $api_log_info." | loc_name :".json_encode($loc_name)." | loc_code :".json_encode($loc_code);
  2260.                             SELF::createApiLog($log_data);
  2261.                         }
  2262.                         $data[] = array("faqId" => $entrie->getfaqId(),
  2263.                                 "location_code" => $loc_code,
  2264.                                 "location_name" => $loc_name,
  2265.                                 "faqQuestion" => $entrie->getfaqQuestion(),
  2266.                                 "faqAnswer" => $entrie->getfaqAnswer(),
  2267.                                 "Type" => $entrie->getfaqType(),
  2268.                         );
  2269.                         $log_data $api_log_info." | data :".json_encode($data);
  2270.                         SELF::createApiLog($log_data);
  2271.                     }
  2272.                 // } else {
  2273.                 //     $data = "Invalid Location Code, Please enter valid Location Code";
  2274.                 //     $log_data = $api_log_info." | data :".json_encode($data);
  2275.                 //     SELF::createApiLog($log_data);
  2276.                 // }
  2277.             // }
  2278.         }
  2279.         $return_data = ["success" => true"data" => $data];
  2280.         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  2281.         SELF::createApiLog($log_data);
  2282.         
  2283.         return $this->json(["success" => true"data" => $data]);
  2284.         
  2285.      }
  2286.     /*------------------------------ End of Faq Related APIs -------------------------*/
  2287.     /*--------------------------------- Pincode Related APIs -----------------------------*/
  2288.     /**
  2289.      * @param Request $request
  2290.      * 
  2291.      * @Route("/wearhouseDetectionApi",methods={"POST"})
  2292.      * 
  2293.      * @return Response
  2294.      * 
  2295.      */
  2296.      public function wearhouseDetectionApiAction(Request $request)
  2297.      { 
  2298.         $api_log_info "API:Get Wearhouse data by Pincode - ".date("YmdHis")." ".time();
  2299.         $log_data "Started - ".$api_log_info;
  2300.         SELF::createApiLog($log_data);
  2301.         $message SELF::verifyauthToken();
  2302.         $log_data $api_log_info." | message:".json_encode($message);
  2303.         SELF::createApiLog($log_data);
  2304.  
  2305.         if($message == "No data found")
  2306.         {
  2307.             if($request->get('pincode')){
  2308.                 $pincode $request->get('pincode');
  2309.                 $log_data $api_log_info." | pincode:".json_encode($pincode);
  2310.                 SELF::createApiLog($log_data);
  2311.                 // $entries = new DataObject\ItcAddPincode\Listing();
  2312.                 // $entries->setCondition("pincode = :name", ["name" => $pincode]);
  2313.                 // $entries->load();
  2314.                 $getpincodeInfo DataObject\ItcAddPincode::getBypincode($pincode1);
  2315.                 $log_data $api_log_info." | getpincodeInfo :".json_encode($getpincodeInfo);
  2316.                 SELF::createApiLog($log_data);
  2317.                 if((!empty($getpincodeInfo))){
  2318.                     $loc_name $loc_code '';
  2319.                     $location_name = (!empty($getpincodeInfo->getlocation_code()))?$getpincodeInfo->getlocation_code():"";
  2320.                     $log_data $api_log_info." | location_name:".json_encode($location_name);
  2321.                     SELF::createApiLog($log_data);
  2322.                     if(!empty($location_name)){
  2323.                         $getlocationInfo DataObject\Locations::getBylocation_name($location_name1);
  2324.                         $log_data $api_log_info." | getlocationInfo :".json_encode($getlocationInfo);
  2325.                         SELF::createApiLog($log_data);
  2326.                         if((!empty($getlocationInfo))){
  2327.                             $loc_name = (!empty($getlocationInfo->getlocation_name()))?$getlocationInfo->getlocation_name():'';
  2328.                             $loc_code = (!empty($getlocationInfo->getlocation_code()))?$getlocationInfo->getlocation_code():'';
  2329.                         } 
  2330.                         $log_data $api_log_info." | loc_name :".json_encode($loc_name)." | loc_code :".json_encode($loc_code);
  2331.                         SELF::createApiLog($log_data);                     
  2332.                     }
  2333.                     $data = array("pincode" => $getpincodeInfo->getpincode(),
  2334.                                     "store_code" => $loc_code,
  2335.                                     "location_name" => $loc_name,
  2336.                                     "city_name" => $getpincodeInfo->getcity(),
  2337.                                     "state" => $getpincodeInfo->getstate(),
  2338.                                     "delivery_type" => $getpincodeInfo->getdeliverytype(),
  2339.                                     "is_shipping_applicable" => $getpincodeInfo->getis_shipping_applicable(),
  2340.                                     "merichakki_available" => $getpincodeInfo->getmerichakki_available(),
  2341.                                     "nammachakki_available" => $getpincodeInfo->getnammachakki_available(),
  2342.                                     "vin_instance" => $getpincodeInfo->getvin_instance(),
  2343.                                 );
  2344.                 } else {
  2345.                     $data "You are entered Pincode is Invalid, Please try again";
  2346.                 }
  2347.                 $log_data $api_log_info." | data :".json_encode($data);
  2348.                 SELF::createApiLog($log_data);  
  2349.             }elseif($request->get('city_name')){
  2350.                 $city $request->get('city_name');
  2351.                 $log_data $api_log_info." | city :".json_encode($city);
  2352.                 SELF::createApiLog($log_data);  
  2353.                 $entries = new DataObject\ItcAddPincode\Listing();
  2354.                 $entries->setCondition("city = :name OR location_code = :name", ["name" => $city,"location_code" => $city]);
  2355.                 $entries->setLimit(1);
  2356.                 $entries->load();
  2357.                 $log_data $api_log_info." | entries count :".json_encode(count($entries));
  2358.                 SELF::createApiLog($log_data);  
  2359.                 foreach($entries as $key => $entrie){
  2360.                     $log_data $api_log_info." | entrie :".json_encode($entrie);
  2361.                     SELF::createApiLog($log_data); 
  2362.                     $loc_name $loc_code '';
  2363.                     $location_name = (!empty($entrie->getlocation_code()))?$entrie->getlocation_code():"";
  2364.                     $log_data $api_log_info." | location_name:".json_encode($location_name);
  2365.                     SELF::createApiLog($log_data);
  2366.                     if(!empty($location_name)){
  2367.                         $getlocationInfo DataObject\Locations::getBylocation_name($location_name1);
  2368.                         $log_data $api_log_info." | getlocationInfo :".json_encode($getlocationInfo);
  2369.                         SELF::createApiLog($log_data);
  2370.                         if((!empty($getlocationInfo))){
  2371.                             $loc_name = (!empty($getlocationInfo->getlocation_name()))?$getlocationInfo->getlocation_name():'';
  2372.                             $loc_code = (!empty($getlocationInfo->getlocation_code()))?$getlocationInfo->getlocation_code():'';
  2373.                         } 
  2374.                         $log_data $api_log_info." | loc_name :".json_encode($loc_name)." | loc_code :".json_encode($loc_code);
  2375.                         SELF::createApiLog($log_data);                     
  2376.                     }
  2377.                     $data = array("pincode" => $entrie->getpincode(),
  2378.                                     "store_code" => $loc_code,
  2379.                                     "location_name" => $loc_name,
  2380.                                     "city_name" => $entrie->getcity(),
  2381.                                     "state" => $entrie->getstate(),
  2382.                                     "delivery_type" => $entrie->getdeliverytype(),
  2383.                                     "is_shipping_applicable" => $entrie->getis_shipping_applicable(),
  2384.                                     "merichakki_available" => $entrie->getmerichakki_available(),
  2385.                                     "nammachakki_available" => $entrie->getnammachakki_available(),
  2386.                                     "vin_instance" => $entrie->getvin_instance(),
  2387.                                 );
  2388.                 }
  2389.             }  else {
  2390.                 $data "Pincode is mandatory";
  2391.             }      
  2392.         } 
  2393.         else
  2394.             $data[] = ['message'=>$message];
  2395.         if(!empty($data)){
  2396.             $success = (empty($data['pincode'])) ? false true;
  2397.             if ($success) {
  2398.                 return $this->json(["success" => $success"data" => $data]);
  2399.             } else {
  2400.                 return $this->json(["success" => $success'message' => $data]);
  2401.             }
  2402.         }else{
  2403.             return $this->json(["success" => false"message" => "Service not available"]);
  2404.         }
  2405.       
  2406.      }
  2407.     /*------------------------------ End of Pincode Related APIs -------------------------*/
  2408.     /*---------------------------------- Voucher Related APIs ----------------------------*/
  2409.     /**
  2410.      * @Route("api/getvouchersdata", methods={"POST"})
  2411.      */
  2412.     public function getvouchersdataAction(Request $request)
  2413.     {
  2414.         $api_log_info "API:Get Vouchers list by multiple voucher codes - ".date("YmdHis")." ".time();
  2415.         $log_data "Started - ".$api_log_info;
  2416.         SELF::createApiLog($log_data);
  2417.         $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  2418.         $log_data $api_log_info." | reqparams:".json_encode($reqparams);
  2419.         SELF::createApiLog($log_data);
  2420.         $vouchercodes = (isset($reqparams['vouchercodes']))?$reqparams['vouchercodes']:'';
  2421.         $vouchertype = (isset($reqparams['vouchertype']))?$reqparams['vouchertype']:'';
  2422.         $log_data $api_log_info." | vouchercodes:".json_encode($vouchercodes)." | vouchertype:".json_encode($vouchertype);
  2423.         SELF::createApiLog($log_data);
  2424.         // $factorycode = $request->get('factorycode');
  2425.         if(($vouchercodes == "" || !is_array($vouchercodes)) && ($vouchertype == '' || ($vouchertype && !in_array($vouchertype, ["Master""all"]))))
  2426.         {
  2427.             
  2428.             $data "Voucher Code(s) OR Voucher Type is(are) mandatory, Voucher Type must be like Master OR all!";
  2429.             $log_data $api_log_info." | data:".json_encode($data);
  2430.             SELF::createApiLog($log_data);
  2431.         } else 
  2432.         {
  2433.             // die;
  2434.             $data SELF::verifyauthToken($api_log_info);
  2435.             $log_data $api_log_info." | data:".json_encode($data);
  2436.             SELF::createApiLog($log_data);
  2437.             if($data == "No data found")
  2438.             {
  2439.                 $vouchertype = ($vouchertype == 'all')?'Voucher':$vouchertype;
  2440.                 /*---- Get Master Voucher data by Master Voucher Code ---------*/
  2441.                 $master_voucher "Master_Voucher";
  2442.                 $masterVoucherData DataObject\Vouchers::getByvoucher_code($master_voucher1);
  2443.                 
  2444.                 $projectUrl  = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' 'https://' 'http://';
  2445.                 $projectUrl .= $_SERVER['SERVER_NAME'];
  2446.                 $log_data $api_log_info." | projectUrl:".json_encode($projectUrl);
  2447.                 SELF::createApiLog($log_data);
  2448.                 /*---- Check Factory by Code ---------*/
  2449.                 $vouchersData = new DataObject\Vouchers\Listing();
  2450.                 if($vouchercodes)
  2451.                 $vouchersData->setCondition("voucher_code IN (?)", [$vouchercodes]);
  2452.                 else if($vouchertype)
  2453.                 $vouchersData->setCondition("voucher_type IN (?)", [$vouchertype]);
  2454.                 $vouchersData->load();
  2455.                 $log_data $api_log_info." | vouchersData count:".json_encode(count($vouchersData));
  2456.                 SELF::createApiLog($log_data);
  2457.                 if(!empty($vouchersData) && count($vouchersData)>0){
  2458.                     $data = [];
  2459.                     foreach($vouchersData as $voucherData){
  2460.                         $log_data $api_log_info." | voucherData:".json_encode($voucherData);
  2461.                         SELF::createApiLog($log_data);
  2462.                         $voucher_logo_path = ($voucherData->getvoucher_type() == "Master")?$masterVoucherData->getvoucher_logo():$voucherData->getvoucher_logo();
  2463.                         $voucher_logo_path $projectUrl."/uploads/".$voucher_logo_path;
  2464.                         $voucher_background_image_path $projectUrl."/uploads/".($voucherData->getvoucher_type() == "Master")?$masterVoucherData->getvoucher_background_image():$voucherData->getvoucher_background_image();
  2465.                         $voucher_background_image_path $projectUrl."/uploads/".$voucher_background_image_path;
  2466.                         $curdata = array(
  2467.                             "id" => $voucherData->getId(),
  2468.                             "voucher_code" => $voucherData->getvoucher_code(),
  2469.                             "about_offer" => ($voucherData->getvoucher_type() == "Master")?$masterVoucherData->getabout_offer():$voucherData->getabout_offer(),
  2470.                             "avail_offer" => ($voucherData->getvoucher_type() == "Master")?$masterVoucherData->getavail_offer():$voucherData->getavail_offer(),
  2471.                             "voucher_logo_path" => $voucher_logo_path,
  2472.                             "voucher_background_image_path" => $voucher_background_image_path);
  2473.                         $log_data $api_log_info." | curdata:".json_encode($curdata);
  2474.                         SELF::createApiLog($log_data);
  2475.                         array_push($data$curdata);
  2476.                     }
  2477.                 } else {
  2478.                     $data "No data found!";
  2479.                     $log_data $api_log_info." | data:".json_encode($data);
  2480.                     SELF::createApiLog($log_data);
  2481.                 }
  2482.             }
  2483.         }
  2484.         $return_data = ["success" => true"data" => $data];
  2485.         $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  2486.         SELF::createApiLog($log_data);
  2487.         return $this->json(["success" => true"data" => $data]);
  2488.     }
  2489.     /*------------------------------ End of Voucher Related APIs -------------------------*/
  2490.     /*---------------------------------- Log Related APIs ----------------------------*/
  2491.     /**
  2492.      * @Route("/api/log_info/{date?}")
  2493.      */
  2494.     public function log_infoAction($date)
  2495.     {
  2496.         // $date = ($date == '')?date("Y-m-d", strtotime("-1 day")):$date;
  2497.         $date = ($date == '')?date("Y-m-d"):$date;
  2498.         if($date == '')
  2499.         {
  2500.             $data "Date is mandatory!";
  2501.         } else {
  2502.             $file '../var/log/slot-api-log_'.$date.'.txt';
  2503.             if(file_exists($file)){
  2504.                 $myfile fopen($file"r") or die("Unable to open file!");
  2505.                 $data fread($myfile,filesize($file));
  2506.                 fclose($myfile);
  2507.             } else {
  2508.                 $data "The file is not exited!";
  2509.             }
  2510.         }
  2511.         return $this->json(["success" => true"date" => $date"data" => $data]);
  2512.     }
  2513.     /**
  2514.      * @Route("/api/log_info_data")
  2515.      */
  2516.     public function log_info_dataAction(Request $requet)
  2517.     {
  2518.         $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  2519.         $date = (isset($reqparams['date']))?$reqparams['date']:'';
  2520.         $from_line = (isset($reqparams['from_line']))?$reqparams['from_line']:'';
  2521.         $to_line = (isset($reqparams['to_line']))?$reqparams['to_line']:'';
  2522.         $date = ($date == '')?date("Y-m-d"):$date;
  2523.         if($date == '' || $from_line == '' || $to_line == '')
  2524.         {
  2525.             $data "Date, from_line and to_line are mandatory!";
  2526.         } else {
  2527.             $file '../var/log/slot-api-log_'.$date.'.txt';
  2528.             if(file_exists($file)){
  2529.                 $splitdata array_slice(file($file), $from_line$to_line);
  2530.                 echo $data implode(''$splitdata); die;
  2531.             } else {
  2532.                 $data "The file is not exited!";
  2533.             }
  2534.         }
  2535.         return $this->json(["success" => true"date" => $date"data" => $data]);
  2536.     }
  2537.     /**
  2538.      * @Route("/api/delete_log_file/{date}")
  2539.      */
  2540.     public function delete_log_fileAction($date)
  2541.     {
  2542.         if($date == '')
  2543.         {
  2544.             $data "Date is mandatory!";
  2545.         } else {
  2546.             $message SELF::verifyauthToken();
  2547.         
  2548.             if($message == "No data found")
  2549.             {
  2550.                 $file '../var/log/slot-api-log_'.$date.'.txt';
  2551.                 if(file_exists($file)){
  2552.                     unlink($file);
  2553.                     $data "Deleted the file successfully!";
  2554.                 } else {
  2555.                     $data "The file is not exited!";
  2556.                 }
  2557.             }else $data[] = ['message'=>$message];
  2558.         }
  2559.         return $this->json(["success" => true"date" => $date"data" => $data]);
  2560.     }
  2561.     /**
  2562.      * @Route("/api/delete_log_files")
  2563.      */
  2564.     public function delete_log_filesAction(Request $request)
  2565.     {
  2566.         $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  2567.         $fromdate = (isset($reqparams['fromdate']))?$reqparams['fromdate']:'';
  2568.         $todate = (isset($reqparams['todate']))?$reqparams['todate']:'';
  2569.         if($fromdate == '' || $todate == '')
  2570.         {
  2571.             $data "From Date and To Date are mandatory!";
  2572.         } else {
  2573.             $message SELF::verifyauthToken();
  2574.         
  2575.             if($message == "No data found")
  2576.             {
  2577.                 $rangeDates SELF::getDatesFromRange($fromdate$todate);
  2578.                 // echo 'rangeDates:<pre>';
  2579.                 // print_r($rangeDates); die;
  2580.                 foreach($rangeDates as $rangeDateInfo){
  2581.                     $file '../var/log/slot-api-log_'.$rangeDateInfo.'.txt';
  2582.                     if(file_exists($file)){
  2583.                         unlink($file);
  2584.                         $data "Deleted the file successfully!";
  2585.                     } else {
  2586.                         $data = (isset($data) && $data == "Deleted the file successfully!")?$data:"The file is not exited!";
  2587.                     }
  2588.                 }
  2589.             }else $data[] = ['message'=>$message];
  2590.         }
  2591.         return $this->json(["success" => true"fromdate" => $fromdate"todate" => $todate"data" => $data]);
  2592.     }
  2593.     /**
  2594.      * @Route("/api/get_log_files")
  2595.      */
  2596.     public function get_log_filesAction(Request $request)
  2597.     {
  2598.         $reqparams = (array) json_decode(file_get_contents('php://input'), TRUE);
  2599.         $fromdate = (isset($reqparams['fromdate']))?$reqparams['fromdate']:'';
  2600.         $todate = (isset($reqparams['todate']))?$reqparams['todate']:'';
  2601.         $filenames = [];
  2602.         if($fromdate == '' || $todate == '')
  2603.         {
  2604.             $data "From Date and To Date are mandatory!";
  2605.         } else {
  2606.             $message SELF::verifyauthToken();
  2607.         
  2608.             if($message == "No data found")
  2609.             {
  2610.                 $rangeDates SELF::getDatesFromRange($fromdate$todate);
  2611.                 // echo 'rangeDates:<pre>';
  2612.                 // print_r($rangeDates); die;
  2613.                 foreach($rangeDates as $rangeDateInfo){
  2614.                     $file '../var/log/slot-api-log_'.$rangeDateInfo.'.txt';
  2615.                     if(file_exists($file)){
  2616.                         array_push($filenames'slot-api-log_'.$rangeDateInfo.'.txt');
  2617.                     } else {
  2618.                         $msg = (!empty($filenames))?'':"The file is not exited!";
  2619.                     }
  2620.                 }
  2621.                 $data = (!empty($filenames))?$filenames:$msg;
  2622.             }else $data[] = ['message'=>$message];
  2623.         }
  2624.         return $this->json(["success" => true"fromdate" => $fromdate"todate" => $todate"data" => $data]);
  2625.     }
  2626.     /*------------------------------ End of Log Related APIs -------------------------*/
  2627.     /**
  2628.      * @Route("/location/locationslist")
  2629.      */
  2630.     public function locationslist()
  2631.     {
  2632.         $log_data "Started - API:Get All Locations";
  2633.         SELF::createApiLog($log_data);
  2634.         $message SELF::verifyauthToken();
  2635.         $log_data "API:Get All Locations | message:".json_encode($message);
  2636.         SELF::createApiLog($log_data);
  2637.         if($message == "No data found")
  2638.         {
  2639.             $locationsList DataObject\Locations::getList();
  2640.             $locationsList->load();
  2641.             $log_data "API:Get All Locations | locationsList count :".json_encode(count($locationsList));
  2642.             SELF::createApiLog($log_data);
  2643.             if(count($locationsList) > 0){
  2644.                 foreach ($locationsList as $key => $location) {
  2645.                     $log_data "API:Get All Locations | location :".json_encode($location);
  2646.                     SELF::createApiLog($log_data);
  2647.                     $data[] = array(
  2648.                         "Id" => $location->getId(),
  2649.                         "location_name" => $location->getLocation_name(),
  2650.                         "location_code" => $location->getLocation_code());
  2651.                     $log_data "API:Get All Locations | data :".json_encode($data);
  2652.                     SELF::createApiLog($log_data);
  2653.                 }
  2654.             } else $data[] = ['message'=>$message];
  2655.         } else $data[] = ['message'=>$message];
  2656.         $log_data "Ended - API:Get All Locations | data :".json_encode($data);
  2657.         SELF::createApiLog($log_data);
  2658.         
  2659.         return $this->json(["success" => true"data" => $data]);
  2660.     }
  2661.     /*--------------- Authentication related methods ----------------*/
  2662.     public function generateAuthToken($userInfo=[])
  2663.     {
  2664.         /*------------- Generate MDF encode --------------*/
  2665.         $generateAuthToken md5(time());
  2666.         $jwtdata = array(
  2667.             "generateAuthToken" => $generateAuthToken
  2668.         );
  2669.         /*------------- Generate JWT Token ---------------*/
  2670.         $jwt_check 0;
  2671.         if(!empty($userInfo)){
  2672.             $id $userInfo['id'];//1024;
  2673.             $firstname $userInfo['firstname'];//'Tex';
  2674.             $lastname $userInfo['lastname'];//'Hardrock';
  2675.             $email $userInfo['email'];//'dino@stone.age';
  2676.             $secret_key "951e345a17ab26f80ec0e16b1d2a0c2a";
  2677.             $issuer_claim "pimcore6.local"// this can be the servername
  2678.             $audience_claim "Babu";
  2679.             $issuedat_claim time(); // issued at
  2680.             $notbefore_claim $issuedat_claim 10//not before in seconds
  2681.             $expire_claim $issuedat_claim 60*5// expire time in seconds
  2682.             $token = array(
  2683.                 "iss" => $issuer_claim,
  2684.                 "aud" => $audience_claim,
  2685.                 "iat" => $issuedat_claim,
  2686.                 "nbf" => $notbefore_claim,
  2687.                 "exp" => $expire_claim,
  2688.                 "data" => array(
  2689.                     "id" => $id,
  2690.                     "firstname" => $firstname,
  2691.                     "lastname" => $lastname,
  2692.                     "email" => $email
  2693.             ));
  2694.             $jwt JWT::encode($token$secret_key'HS256');
  2695.             
  2696.             $jwtdata = array(
  2697.                 "generateAuthToken" => $generateAuthToken,
  2698.                 "jwt" => $jwt,
  2699.                 "email" => $email,
  2700.                 "expireAt" => $expire_claim
  2701.             );
  2702.         }
  2703.         return $jwtdata;
  2704.     }
  2705.     public function verifyauthToken1()
  2706.     {
  2707.         $message "No data found"$tokenCheck 0;
  2708.         $headers=array();
  2709.         foreach (getallheaders() as $name => $value) {
  2710.             $headers[$name] = $value;
  2711.             if($name == 'Authtoken'$tokenCheck 1;
  2712.         }
  2713.         if($tokenCheck == 0){
  2714.             $message "Authentication Token is missing";;
  2715.         } else {
  2716.             $Authtoken $headers['Authtoken'];
  2717.         
  2718.             $dbConnection \Pimcore\Db::get();
  2719.             $authTokencheck $dbConnection->fetchOne("SELECT id FROM users WHERE authToken = '".$Authtoken."' ");
  2720.             if(empty($authTokencheck)){
  2721.                 $message "Authentication Token is mismatch";
  2722.             } else {
  2723.             }
  2724.         }
  2725.         return $message;
  2726.     }
  2727.     public function verifyauthToken2()
  2728.     {
  2729.         $api_key 'api-key';
  2730.         $api_key_value 'cGltY29yZWFwaWtleXZhbHVl';//base64encode('pimcoreapikeyvalue);
  2731.         $message "No data found"$tokenCheck 0$apikeyCheck 0$jwtCheck 0;$tokenMsg ''$apikeyMsg ''$jwtMsg '';
  2732.         $headers=array();
  2733.         foreach (getallheaders() as $name => $value) {
  2734.             $headers[$name] = $value;
  2735.             if($name == 'Authtoken'$tokenCheck 1;
  2736.             if($name == 'Api-Key'$apikeyCheck 1;
  2737.             if($name == 'Authorization'$jwtCheck 1;
  2738.         }
  2739.         // echo 'arr:<pre>';
  2740.         // print_r($headers); 
  2741.         // die;
  2742.         if($tokenCheck == && $apikeyCheck == && $jwtCheck == 0){
  2743.             $message "Fill any one of the Authentication Token, Api-Key Or JWT token!";;
  2744.         } else {
  2745.             $tokenCheck_valid 0$apikeyCheck_valid 0$jwtTokenCheck_valid 0;
  2746.             /*--------------------- Validating Auth Token -----------------*/
  2747.             if($tokenCheck == 1)
  2748.             {
  2749.                 $Authtoken $headers['Authtoken'];
  2750.         
  2751.                 $dbConnection \Pimcore\Db::get();
  2752.                 $authTokencheck $dbConnection->fetchOne("SELECT id FROM users WHERE authToken = '".$Authtoken."' ");
  2753.                 if(empty($authTokencheck)){
  2754.                     $tokenMsg "Authentication Token is mismatch";
  2755.                 } else {
  2756.                     $tokenCheck_valid 1;
  2757.                 }
  2758.             }
  2759.             /*--------------------- Validating Api Key -----------------*/
  2760.             if($apikeyCheck == 1)
  2761.             {
  2762.                 $AuthApikey $headers['Api-Key'];
  2763.                 if(empty($AuthApikey)){
  2764.                     $apikeyMsg "Key is mismatch";
  2765.                 } else if($AuthApikey != $api_key_value){
  2766.                     $apikeyMsg "key is mismatch";
  2767.                 } else {
  2768.                     $apikeyCheck_valid 1;
  2769.                 }
  2770.             }
  2771.             /*--------------------- Validating JWT Token -----------------*/
  2772.             if($jwtCheck == 1)
  2773.             {
  2774.                 $secret_key "951e345a17ab26f80ec0e16b1d2a0c2a";
  2775.                 $jwt null;
  2776.                 $authHeader $_SERVER['HTTP_AUTHORIZATION'];
  2777.                 $arr explode(" "$authHeader);
  2778.                 $jwt $arr[1];
  2779.                 if($jwt){
  2780.                     try {
  2781.                         $decoded JWT::decode($jwt, new Key($secret_key'HS256'));
  2782.                         $jwtTokenCheck_valid 1;
  2783.                     }catch (ExpiredException $e){
  2784.                         $jwtMsg "Expired JWT Token!";//$e->getMessage();
  2785.                     }catch (Exception $e){
  2786.                         $jwtTokenCheck_valid 0;
  2787.                         $jwtMsg "Expired JWT Token!";//$e->getMessage();
  2788.                     }
  2789.                 } else {
  2790.                     $jwtMsg "JWT Token is missing";
  2791.                 }
  2792.             }
  2793.             $message '';
  2794.             if($tokenMsg != '' || $apikeyMsg != '' || $jwtMsg != '')
  2795.             {
  2796.                 $message = ($tokenMsg != '')?"Token Message:".$message.$tokenMsg:$message;
  2797.                 $message = ($apikeyMsg != '')?"".$message." | Api-Key Message:".$apikeyMsg:$message;
  2798.                 $message = ($jwtMsg != '')?"".$message." | JWT Message:".$jwtMsg:$message;
  2799.             }
  2800.             $message = ($tokenCheck_valid == || $apikeyCheck_valid == || $jwtTokenCheck_valid == 1)?"No data found":$message;
  2801.         }
  2802.         return $message;
  2803.     }
  2804.     public function verifyauthToken($api_log_info='')
  2805.     {        
  2806.         $start_method_log_info "Verify Auth Token Method";
  2807.         $api_log_method_info = (!empty($api_log_info))?$api_log_info." | Started - ".$start_method_log_info:"Started - ".$start_method_log_info;
  2808.         $log_data $api_log_method_info;
  2809.         SELF::createApiLog($log_data);
  2810.         $api_log_method_info = (!empty($api_log_info))?$api_log_info." | ".$start_method_log_info:$start_method_log_info;
  2811.         $api_key 'api-key';
  2812.         $api_key_value 'cGltY29yZWFwaWtleXZhbHVl';//base64encode('pimcoreapikeyvalue);
  2813.         $message "No data found"$apikeyCheck 0$apikeyMsg '';
  2814.         $headers=array();
  2815.         foreach (getallheaders() as $name => $value) {
  2816.             $headers[$name] = $value;
  2817.             if($name == 'Api-Key'$apikeyCheck 1;
  2818.         }
  2819.         
  2820.         if($apikeyCheck == 0){
  2821.             $message "Api-Key is mandatory!";;
  2822.         } else {
  2823.             $apikeyCheck_valid 0;
  2824.             /*--------------------- Validating Api Key -----------------*/
  2825.             if($apikeyCheck == 1)
  2826.             {
  2827.                 $AuthApikey $headers['Api-Key'];
  2828.                 if(empty($AuthApikey)){
  2829.                     $message "Key is empty, Api-Key is mandatory";
  2830.                 } else if($AuthApikey != $api_key_value){
  2831.                     $message "key is mismatch";
  2832.                 } else {
  2833.                     $apikeyCheck_valid 1;
  2834.                 }
  2835.             }
  2836.         }
  2837.         $apikeyCheck_valid 1;
  2838.         $message "No data found";
  2839.         $api_log_method_info = (!empty($api_log_info))?$api_log_info." | Ended - ".$start_method_log_info:"Ended - ".$start_method_log_info;
  2840.         $log_data $api_log_method_info." | message:".$message;
  2841.         SELF::createApiLog($log_data);
  2842.         return $message;
  2843.     }
  2844.     /*--------------- End of Authentication related methods ------------*/
  2845.     /*-------------------------- Sub methods ---------------------------*/
  2846.     public function generateObjFolder($folderName,$location_code){
  2847.         $yr date("Y");
  2848.         $mt date("M");
  2849.         $dy date("d");
  2850.         $path "/".$folderName."/".$yr."/".$mt."/".$dy;
  2851.         $path "/".$folderName."/".$location_code;
  2852.         $object DataObject::getByPath($path);
  2853.         if(!$object){
  2854.             $path1 "/".$folderName."/".$yr."/".$mt;
  2855.             $object1 DataObject::getByPath($path1);
  2856.             if(!$object1){
  2857.                 $path2 "/".$folderName."/".$yr;
  2858.                 $object2 DataObject::getByPath($path2);                
  2859.                 if(!$object2){
  2860.                     $path3 "/".$folderName;
  2861.                     $object3 DataObject::getByPath($path3);                
  2862.                     if(!$object3){
  2863.                         $createAssetFolder DoService::createFolderByPath($path3);
  2864.                         $createAssetFolder DoService::createFolderByPath($path2);
  2865.                         $createAssetFolder DoService::createFolderByPath($path1);
  2866.                         $createAssetFolder DoService::createFolderByPath($path);
  2867.                         $objParentId $createAssetFolder->getId();
  2868.                     }else {
  2869.                         $createAssetFolder DoService::createFolderByPath($path2);
  2870.                         $createAssetFolder DoService::createFolderByPath($path1);
  2871.                         $createAssetFolder DoService::createFolderByPath($path);
  2872.                         $objParentId $createAssetFolder->getId();
  2873.                     }
  2874.                 }else {
  2875.                     $createAssetFolder DoService::createFolderByPath($path1);
  2876.                     $createAssetFolder DoService::createFolderByPath($path);
  2877.                     $objParentId $createAssetFolder->getId();
  2878.                 }
  2879.             } else {
  2880.                 $createAssetFolder DoService::createFolderByPath($path);
  2881.                 $objParentId $createAssetFolder->getId();
  2882.             }
  2883.         } else
  2884.         $objParentId $object->getId();
  2885.         return $objParentId;
  2886.     }
  2887.     public function generateSlotObjFolder($folderName,$delivery_mode,$location_code){
  2888.         $yr date("Y");
  2889.         $mt date("M");
  2890.         $dy date("d");
  2891.         $path "/".$folderName."/".$delivery_mode."/".$location_code;//."/".$date.'-'.$location_code;
  2892.         $object DataObject::getByPath($path);
  2893.         if(!$object){
  2894.             $path1 "/".$folderName."/".$delivery_mode;//."/".$location_code."/".$date;
  2895.             $object1 DataObject::getByPath($path1);
  2896.             if(!$object1){
  2897.                 $path2 "/".$folderName;//."/".$delivery_mode."/".$location_code;
  2898.                 $object2 DataObject::getByPath($path2);                
  2899.                 if(!$object2){
  2900.                     $createAssetFolder DoService::createFolderByPath($path2);
  2901.                     $createAssetFolder DoService::createFolderByPath($path1);
  2902.                     $createAssetFolder DoService::createFolderByPath($path);
  2903.                     $objParentId $createAssetFolder->getId();
  2904.                 }else {
  2905.                     $createAssetFolder DoService::createFolderByPath($path1);
  2906.                     $createAssetFolder DoService::createFolderByPath($path);
  2907.                     $objParentId $createAssetFolder->getId();
  2908.                 }
  2909.             } else {
  2910.                 $createAssetFolder DoService::createFolderByPath($path);
  2911.                 $objParentId $createAssetFolder->getId();
  2912.             }
  2913.         } else
  2914.         $objParentId $object->getId();
  2915.         return $objParentId;
  2916.     }
  2917.     public function getWeekDates($holidaysList$todaydate$delSlotTimesAvailibility){
  2918.         $jj=0$weekdates = [];
  2919.         $slot_prepare_days $delSlotTimesAvailibility['slot_prepare_days'];
  2920.         $slot_generate_days $delSlotTimesAvailibility['slot_generate_days'];
  2921.         $saturday_slot_availability $delSlotTimesAvailibility['saturday_slot_availability'];
  2922.         $sunday_slot_availability $delSlotTimesAvailibility['sunday_slot_availability'];
  2923.         $todaydate date('Y-m-d'strtotime($todaydate ' +'.$slot_prepare_days.' day'));
  2924.         $totDays $slot_generate_days+7;
  2925.         for($ii=1$ii<$totDays$ii++)
  2926.         {
  2927.             if($jj >= $slot_generate_days) break;
  2928.             if(empty($holidaysList) || !in_array($todaydate$holidaysList)){
  2929.                 $weekDay date('w'strtotime($todaydate));
  2930.                 if(($weekDay == && $sunday_slot_availability == 'Yes') || ($weekDay == && $saturday_slot_availability == 'Yes') || !in_array($weekDay, [0,6]))
  2931.                 {
  2932.                     $weekdates[] = $todaydate;
  2933.                     $jj=$jj+1;
  2934.                 }
  2935.             }
  2936.             $todaydate date('Y-m-d'strtotime($todaydate ' +1 day'));
  2937.         }
  2938.         // echo '<pre>'; print_r($weekdates); die;
  2939.         return $weekdates;
  2940.     }
  2941.     public function getSettingInfo($api_log_info='')
  2942.     {
  2943.         $start_method_log_info "Setting info Method";
  2944.         $api_log_method_info = (!empty($api_log_info))?$api_log_info." | Started - ".$start_method_log_info:"Started - ".$start_method_log_info;
  2945.         $log_data $api_log_method_info;
  2946.         SELF::createApiLog($log_data);
  2947.         $api_log_method_info = (!empty($api_log_info))?$api_log_info." | ".$start_method_log_info:$start_method_log_info;
  2948.         /*------ Get Settings Class data --------*/
  2949.         $dbConnection \Pimcore\Db::get();
  2950.         $settingsClassId $dbConnection->fetchOne(" SELECT id FROM classes WHERE LOWER(name) = 'Settings' ");
  2951.         $settingsObject "object_".$settingsClassId;
  2952.         
  2953.         $log_data $api_log_method_info." | settingsObject:".json_encode($settingsObject);
  2954.         SELF::createApiLog($log_data);
  2955.         
  2956.         $settingsId $dbConnection->fetchOne(" select * from ".$settingsObject." WHERE setting_flag = 1");
  2957.         
  2958.         $log_data $api_log_method_info." | settingsId:".json_encode($settingsId);
  2959.         SELF::createApiLog($log_data);
  2960.         /*----- End of Get Settings Class data ---------*/
  2961.         /*--------------- Settings info ----------------*/
  2962.         $settingsInfo DataObject\Settings::getById($settingsId);
  2963.         
  2964.         $log_data $api_log_method_info." | settingsInfo:".json_encode($settingsInfo);
  2965.         SELF::createApiLog($log_data);
  2966.         $settingDataId $settingsInfo->getId();
  2967.         $setting_deliveryModes $settingsInfo->getdelivery_modes();
  2968.         $setting_slot_time_flag = (!empty($settingsInfo->getslottime()))?$settingsInfo->getslottime():"18:00";
  2969.         $stg_deliveryslot_config_is_upcountry_configuration_applicable = ($settingsInfo->getdeliveryslot_config_is_upcountry_configuration_applicable())?$settingsInfo->getdeliveryslot_config_is_upcountry_configuration_applicable():'No';
  2970.         $stg_deliveryslot_config_is_darkstore_configuration_applicable = ($settingsInfo->getdeliveryslot_config_is_darkstore_configuration_applicable())?$settingsInfo->getdeliveryslot_config_is_darkstore_configuration_applicable():'No';
  2971.         $stg_delslot_normalloc_morethan_fromtime = ($settingsInfo->getdelslot_normalloc_morethan_fromtime())?$settingsInfo->getdelslot_normalloc_morethan_fromtime():"00:00";
  2972.         $stg_delslot_normalloc_lessthaneq_totime = ($settingsInfo->getdelslot_normalloc_lessthaneq_totime())?$settingsInfo->getdelslot_normalloc_lessthaneq_totime():"18:00";
  2973.         $stg_delslot_normalloc_bw_from_to_time_extra_generate_slotdays = ($settingsInfo->getdelslot_normalloc_bw_from_to_time_extra_generate_slotdays())?$settingsInfo->getdelslot_normalloc_bw_from_to_time_extra_generate_slotdays():1;
  2974.         $stg_delslot_normalloc_after_totime_extra_generate_slotdays = ($settingsInfo->getdelslot_normalloc_after_totime_extra_generate_slotdays())?$settingsInfo->getdelslot_normalloc_after_totime_extra_generate_slotdays():2;
  2975.         $stg_normalloc_slot_generate_days = ($stg_delslot_normalloc_after_totime_extra_generate_slotdays>$stg_delslot_normalloc_bw_from_to_time_extra_generate_slotdays)?$stg_delslot_normalloc_after_totime_extra_generate_slotdays:$stg_delslot_normalloc_bw_from_to_time_extra_generate_slotdays;
  2976.         $stg_delslot_upcountryloc_morethan_fromtime = ($settingsInfo->getdelslot_upcountryloc_morethan_fromtime())?$settingsInfo->getdelslot_upcountryloc_morethan_fromtime():"00:00";
  2977.         $stg_delslot_upcountryloc_lessthaneq_totime = ($settingsInfo->getdelslot_upcountryloc_lessthaneq_totime())?$settingsInfo->getdelslot_upcountryloc_lessthaneq_totime():"11:00";
  2978.         $stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays = ($settingsInfo->getdelslot_upcountryloc_bw_from_to_time_extra_generate_slotdays())?$settingsInfo->getdelslot_upcountryloc_bw_from_to_time_extra_generate_slotdays():4;
  2979.         $stg_delslot_upcountryloc_after_totime_extra_generate_slotdays = ($settingsInfo->getdelslot_upcountryloc_after_totime_extra_generate_slotdays())?$settingsInfo->getdelslot_upcountryloc_after_totime_extra_generate_slotdays():5;
  2980.         $stg_upcountryloc_slot_generate_days = ($stg_delslot_upcountryloc_after_totime_extra_generate_slotdays>$stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays)?$stg_delslot_upcountryloc_after_totime_extra_generate_slotdays:$stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays;
  2981.         $stg_delslot_darkstoreloc_morethan_fromtime = ($settingsInfo->getdelslot_darkstoreloc_morethan_fromtime())?$settingsInfo->getdelslot_darkstoreloc_morethan_fromtime():"00:00";
  2982.         $stg_delslot_darkstoreloc_lessthaneq_totime = ($settingsInfo->getdelslot_darkstoreloc_lessthaneq_totime())?$settingsInfo->getdelslot_darkstoreloc_lessthaneq_totime():"11:00";
  2983.         $stg_delslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays $settingsInfo->getdelslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays();//($settingsInfo->getdelslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays())?$settingsInfo->getdelslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays():4;
  2984.         $stg_delslot_darkstoreloc_after_totime_extra_generate_slotdays = ($settingsInfo->getdelslot_darkstoreloc_after_totime_extra_generate_slotdays())?$settingsInfo->getdelslot_darkstoreloc_after_totime_extra_generate_slotdays():5;
  2985.         $stg_darkstoreloc_slot_generate_days = ($stg_delslot_darkstoreloc_after_totime_extra_generate_slotdays>$stg_delslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays)?$stg_delslot_darkstoreloc_after_totime_extra_generate_slotdays:$stg_delslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays;
  2986.         $stg_is_deliveryfee_config_applicable $settingsInfo->getis_deliveryfee_config_applicable();
  2987.         $stg_deliveryfee_config $settingsInfo->getdeliveryfee_config();
  2988.         $stg_deliveryfee_config $settingsInfo->getdeliveryfee_config();
  2989.         $stg_deliveryfee_config_location_lessthan_charge $settingsInfo->getdeliveryfee_config_location_lessthan_charge();
  2990.         $stg_deliveryfee_config_location_greaterthanequal_charge $settingsInfo->getdeliveryfee_config_location_greaterthanequal_charge();
  2991.         $stg_deliveryfee_config_upcountry_lessthan_charge $settingsInfo->getdeliveryfee_config_upcountry_lessthan_charge();
  2992.         $stg_deliveryfee_config_upcountry_greaterthanequal_charge $settingsInfo->getdeliveryfee_config_upcountry_greaterthanequal_charge();
  2993.         /*----------- End of Settings Info -------------*/
  2994.         $settingsdata = ['settingDataId'=>$settingDataId,
  2995.                         'setting_deliveryModes'=>$setting_deliveryModes,
  2996.                         'setting_slot_time_flag'=>$setting_slot_time_flag,
  2997.                         'stg_deliveryslot_config_is_upcountry_configuration_applicable'=>$stg_deliveryslot_config_is_upcountry_configuration_applicable,
  2998.                         'stg_deliveryslot_config_is_darkstore_configuration_applicable'=>$stg_deliveryslot_config_is_darkstore_configuration_applicable,
  2999.                         'stg_delslot_normalloc_morethan_fromtime'=>$stg_delslot_normalloc_morethan_fromtime,
  3000.                         'stg_delslot_normalloc_lessthaneq_totime'=>$stg_delslot_normalloc_lessthaneq_totime,
  3001.                         'stg_delslot_normalloc_bw_from_to_time_extra_generate_slotdays'=>$stg_delslot_normalloc_bw_from_to_time_extra_generate_slotdays,
  3002.                         'stg_delslot_normalloc_after_totime_extra_generate_slotdays'=>$stg_delslot_normalloc_after_totime_extra_generate_slotdays,
  3003.                         'stg_normalloc_slot_generate_days'=>$stg_normalloc_slot_generate_days,
  3004.                         'stg_delslot_upcountryloc_morethan_fromtime'=>$stg_delslot_upcountryloc_morethan_fromtime,
  3005.                         'stg_delslot_upcountryloc_lessthaneq_totime'=>$stg_delslot_upcountryloc_lessthaneq_totime,
  3006.                         'stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays'=>$stg_delslot_upcountryloc_bw_from_to_time_extra_generate_slotdays,
  3007.                         'stg_delslot_upcountryloc_after_totime_extra_generate_slotdays'=>$stg_delslot_upcountryloc_after_totime_extra_generate_slotdays,
  3008.                         'stg_upcountryloc_slot_generate_days'=>$stg_upcountryloc_slot_generate_days,
  3009.                         'stg_is_deliveryfee_config_applicable'=>$stg_is_deliveryfee_config_applicable,
  3010.                         'stg_deliveryfee_config'=>$stg_deliveryfee_config,
  3011.                         'stg_deliveryfee_config_location_lessthan_charge'=>$stg_deliveryfee_config_location_lessthan_charge,
  3012.                         'stg_deliveryfee_config_location_greaterthanequal_charge'=>$stg_deliveryfee_config_location_greaterthanequal_charge,
  3013.                         'stg_deliveryfee_config_upcountry_lessthan_charge'=>$stg_deliveryfee_config_upcountry_lessthan_charge,
  3014.                         'stg_deliveryfee_config_upcountry_greaterthanequal_charge'=>$stg_deliveryfee_config_upcountry_greaterthanequal_charge,
  3015.                         'stg_delslot_darkstoreloc_morethan_fromtime'=>$stg_delslot_darkstoreloc_morethan_fromtime,
  3016.                         'stg_delslot_darkstoreloc_lessthaneq_totime'=>$stg_delslot_darkstoreloc_lessthaneq_totime,
  3017.                         'stg_delslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays'=>$stg_delslot_darkstoreloc_bw_from_to_time_extra_generate_slotdays,
  3018.                         'stg_delslot_darkstoreloc_after_totime_extra_generate_slotdays'=>$stg_delslot_darkstoreloc_after_totime_extra_generate_slotdays,
  3019.                         'stg_darkstoreloc_slot_generate_days'=>$stg_darkstoreloc_slot_generate_days,
  3020.                         ];
  3021.         
  3022.         $api_log_method_info = (!empty($api_log_info))?$api_log_info." | Ended - ".$start_method_log_info:"Ended - ".$start_method_log_info;
  3023.         $log_data $api_log_method_info." | settingsdata:".json_encode($settingsdata);
  3024.         SELF::createApiLog($log_data);
  3025.         
  3026.         return $settingsdata;
  3027.     }
  3028.     function getDatesFromRange($start$end$dateformat="Y-m-d"){
  3029.         $dates = array($start);
  3030.         while(end($dates) < $end){
  3031.             $dates[] = date($dateformatstrtotime(end($dates).' +1 day'));
  3032.         }
  3033.         return $dates;
  3034.     }
  3035.     public function getSlotTimeDates($slot_generate_days$todaydate){
  3036.         $jj=0$weekdates = [];
  3037.         for($ii=1$ii<15$ii++)
  3038.         {
  3039.             if($jj >= 7) break;
  3040.             if(empty($holidaysList) || !in_array($todaydate$holidaysList)){
  3041.                 $weekdates[] = $todaydate;
  3042.                 $jj=$jj+1;
  3043.             }
  3044.             $todaydate date('Y-m-d'strtotime($todaydate ' +1 day'));
  3045.         }
  3046.         // echo '<pre>'; print_r($weekdates); die;
  3047.         return $weekdates;
  3048.     }
  3049.     public function getWorkingDate($slot_generate_days$todaydate){
  3050.         $jj=0$weekdates = [];
  3051.         for($ii=1$ii<$slot_generate_days$ii++)
  3052.         {
  3053.             if(empty($holidaysList) || !in_array($todaydate$holidaysList)){
  3054.                 $weekdates[] = $todaydate;
  3055.                 $jj=$jj+1;
  3056.             }
  3057.             $todaydate date('Y-m-d'strtotime($todaydate ' +1 day'));
  3058.         }
  3059.         // echo '<pre>'; print_r($weekdates); die;
  3060.         return $weekdates;
  3061.     }
  3062.     public function createApiLog($content)
  3063.     {
  3064.         $file '../var/log/slot-api-log_'.date("Y-m-d").'.txt';
  3065.         // chmod($file, 0755);
  3066.         // if(!is_file($file)){
  3067.             // $contents = 'This is a test!';           // Some simple example content.
  3068.             // file_put_contents($file, $content);     // Save our content to the file.
  3069.             file_put_contents($filedate("Y-m-d H:i:s")." | ".$content."\n"FILE_APPEND);
  3070.             chmod($file0755);
  3071.         // }
  3072.     }
  3073.     /*----------------------- End of Sub methods -----------------------*/
  3074.    /*------------------------------ Manufacture Related APIs -------------------------*/
  3075.     /**
  3076.      * @param Request $request
  3077.      * 
  3078.      * @Route("/manufacturers/{skucode?}")
  3079.      * 
  3080.      * @return Response
  3081.      * 
  3082.      */
  3083.     public function manufacturersAction($skucode='')
  3084.     {
  3085.        $api_log_info "API:Get Manufacturers List with or without skucode - ".date("YmdHis")." ".time();
  3086.        $log_data "Started - ".$api_log_info;
  3087.        SELF::createApiLog($log_data);
  3088.        $data SELF::verifyauthToken($api_log_info);
  3089.        $log_data $api_log_info." | data:".json_encode($data);
  3090.        SELF::createApiLog($log_data);
  3091.        if($data == "No data found")
  3092.        {
  3093.             $log_data $api_log_info." | skucode:".json_encode($skucode);
  3094.             SELF::createApiLog($log_data);
  3095.     
  3096.             $entries = new DataObject\Manufacture\Listing();
  3097.             $whr_condition " msku_code!= '' ";
  3098.             if($skucode != '')
  3099.             $whr_condition .= " AND msku_code= '".$skucode."' ";
  3100.             
  3101.             $entries->setCondition($whr_condition);
  3102.             $entries->load();
  3103.             $log_data $api_log_info." | Manufacturers entries count :".json_encode(count($entries));
  3104.             SELF::createApiLog($log_data);
  3105.             $data = (count($entries)>0)?array():"No data found";
  3106.             foreach($entries as $key => $entrie){
  3107.                 $log_data $api_log_info." | Manufacture key :".json_encode($key)." | Manufacture entrie :".json_encode($entrie);
  3108.                 SELF::createApiLog($log_data);
  3109.                 if($skucode) {
  3110.                     $data = array("Id" => $entrie->getId(),
  3111.                         "msku_code" => $entrie->getmsku_code(),
  3112.                         "sku_name" => $entrie->getsku_name(),
  3113.                         "primary_barcode" => $entrie->getprimary_barcode(),
  3114.                         "manufacture_details" => $entrie->getmanufacture_details(),
  3115.                     );
  3116.                 } else {
  3117.                     $data[] = array("Id" => $entrie->getId(),
  3118.                         "msku_code" => $entrie->getmsku_code(),
  3119.                         "sku_name" => $entrie->getsku_name(),
  3120.                         "primary_barcode" => $entrie->getprimary_barcode(),
  3121.                         "manufacture_details" => $entrie->getmanufacture_details(),
  3122.                     );
  3123.                 }
  3124.                 $log_data $api_log_info." | data :".json_encode($data);
  3125.                 SELF::createApiLog($log_data);
  3126.             }
  3127.        }
  3128.        $return_data = ["success" => true"data" => $data];
  3129.        $log_data "Ended - ".$api_log_info." | return_data:".json_encode($return_data);
  3130.        SELF::createApiLog($log_data);
  3131.        
  3132.        return $this->json(["success" => true"data" => $data]);
  3133.        
  3134.     }
  3135.    /*------------------------------ End of Manufacture Related APIs -------------------------*/
  3136.     
  3137. }