diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index c0f23ea8..707e57b1 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -269,7 +269,7 @@ class APIController extends Controller implements LoggedController $otp_mode = $_ENV['OTP_MODE']; // check for hardcoded phone number for app store testing - if ($phone_number == '639991112233') + if ($phone_number == '639221111111') { $code = '123456'; $this->session->setConfirmCode($code) @@ -2653,6 +2653,20 @@ class APIController extends Controller implements LoggedController $schedule_date = $req->request->get('date_schedule'); $slot_id = $req->request->get('slot_id'); + + // process the jo date schedule + $date_schedule = null; + if ((strlen($schedule_date) > 0) && (strlen($slot_id) > 0)) + { + $time_schedule = $this->getTimeFromSlot($slot_id); + if (!empty($time_schedule)) + { + $s_date = $schedule_date . ' ' . $time_schedule; + $date_schedule = DateTime::createFromFormat('Y-m-d H:i', $s_date); + // error_log($date_schedule->format('Y-m-d H:i')); + } + } + $advance_order = $req->request->get('flag_advance_order'); // check for 'false' text if ($advance_order === false || $advance_order === 0 || $advance_order === '0' || $advance_order == 'false') @@ -2898,7 +2912,7 @@ class APIController extends Controller implements LoggedController { // TODO: log hub as cannot be auto rider assigned somewhere // assign hub - error_log('Rider cannot be auto assigned ' . $nearest_hub['hub']->getID()); + // error_log('Rider cannot be auto assigned ' . $nearest_hub['hub']->getID()); $jo->setHub($nearest_hub['hub']); $jo->setStatus(JOStatus::RIDER_ASSIGN); $jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED); @@ -2921,18 +2935,6 @@ class APIController extends Controller implements LoggedController } else { - $date_schedule = null; - if ((strlen($schedule_date) > 0) && (strlen($slot_id) > 0)) - { - $time_schedule = $this->getTimeFromSlot($slot_id); - if (!empty($time_schedule)) - { - $s_date = $schedule_date . ' ' . $time_schedule; - $date_schedule = DateTime::createFromFormat('Y-m-d H:i', $s_date); - //error_log($date_schedule->format('Y-m-d H:i')); - } - } - $jo->setHub($hub); $jo->setStatus(JOStatus::RIDER_ASSIGN); $jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED); diff --git a/src/Ramcar/HubCriteria.php b/src/Ramcar/HubCriteria.php index 61ffcbaa..5a663551 100644 --- a/src/Ramcar/HubCriteria.php +++ b/src/Ramcar/HubCriteria.php @@ -27,7 +27,7 @@ class HubCriteria $this->limit_results = 10; $this->limit_distance = 500; $this->jo_type = ''; - $this->date_time = null; + $this->date_time = new DateTime(); $this->flag_inventory_check = false; $this->items = []; $this->payment_method = ''; diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index ac84b82d..826a45d2 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -65,14 +65,14 @@ class HubSelector error_log('closest hubs ' . json_encode($filtered_hubs)); + // filter the first hub results for date and opening times + $hubs_date_time = $this->filterHubsByDateAndTime($filtered_hubs, $date_time, $jo_id, $customer_id); + $filtered_hubs = $hubs_date_time; + + error_log('date_time hubs ' . json_encode($filtered_hubs)); + if (!$flag_emergency) { - // filter the first hub results for date and opening times - $hubs_date_time = $this->filterHubsByDateAndTime($filtered_hubs, $date_time, $jo_id, $customer_id); - $filtered_hubs = $hubs_date_time; - - //error_log('date_time hubs ' . json_encode($filtered_hubs)); - // filter jo types $hubs_jo_type = $this->filterHubsByJoType($filtered_hubs, $jo_type, $jo_id, $customer_id); $filtered_hubs = $hubs_jo_type; @@ -167,6 +167,7 @@ class HubSelector 'db_distance' => $hub_data['db_distance'], 'distance' => $hub_data['distance'], 'duration' => $hub_data['duration'], + 'jo_count' => 0, ]; else $this->hub_filter_logger->logFilteredHub($hub, 'job_order_type', $jo_id, $customer_id); @@ -201,6 +202,7 @@ class HubSelector 'db_distance' => $hub_data['db_distance'], 'distance' => $hub_data['distance'], 'duration' => $hub_data['duration'], + 'jo_count' => 0, ]; } $flag_found_pmethod = true; @@ -248,6 +250,7 @@ class HubSelector 'db_distance' => $hub_data['db_distance'], 'distance' => $hub_data['distance'], 'duration' => $hub_data['duration'], + 'jo_count' => 0, ]; } else @@ -282,6 +285,7 @@ class HubSelector 'db_distance' => $hub_data['db_distance'], 'distance' => $hub_data['distance'], 'duration' => $hub_data['duration'], + 'jo_count' => 0, ]; else { @@ -309,6 +313,7 @@ class HubSelector 'db_distance' => $hub_data['db_distance'], 'distance' => $hub_data['distance'], 'duration' => $hub_data['duration'], + 'jo_count' => 0, ]; else { diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index eacf6195..82261c4d 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -2024,8 +2024,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $long = $obj->getCoordinates()->getLongitude(); $lat = $obj->getCoordinates()->getLatitude(); - // set result limit and location + // set result limit and location and date_time $hub_criteria->setPoint($obj->getCoordinates()) + ->setDateTime($obj->getDateSchedule()) ->setLimitResults(50); // check if hub filter is enabled. If not, use default values @@ -2343,6 +2344,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $lat = $obj->getCoordinates()->getLatitude(); $hub_criteria->setPoint($obj->getCoordinates()) + ->setDateTime($obj->getDateSchedule()) ->setLimitResults(50); if ($this->hub_geofence->isCovered($long, $lat))