Resolve "Open Scheduling" #1535

Merged
korina.cordero merged 5 commits from 611-open-scheduling into master-fix 2021-08-10 07:20:24 +00:00
4 changed files with 31 additions and 22 deletions

View file

@ -269,7 +269,7 @@ class APIController extends Controller implements LoggedController
$otp_mode = $_ENV['OTP_MODE']; $otp_mode = $_ENV['OTP_MODE'];
// check for hardcoded phone number for app store testing // check for hardcoded phone number for app store testing
if ($phone_number == '639991112233') if ($phone_number == '639221111111')
{ {
$code = '123456'; $code = '123456';
$this->session->setConfirmCode($code) $this->session->setConfirmCode($code)
@ -2653,6 +2653,20 @@ class APIController extends Controller implements LoggedController
$schedule_date = $req->request->get('date_schedule'); $schedule_date = $req->request->get('date_schedule');
$slot_id = $req->request->get('slot_id'); $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'); $advance_order = $req->request->get('flag_advance_order');
// check for 'false' text // check for 'false' text
if ($advance_order === false || $advance_order === 0 || $advance_order === '0' || $advance_order == 'false') 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 // TODO: log hub as cannot be auto rider assigned somewhere
// assign hub // 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->setHub($nearest_hub['hub']);
$jo->setStatus(JOStatus::RIDER_ASSIGN); $jo->setStatus(JOStatus::RIDER_ASSIGN);
$jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED); $jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED);
@ -2921,18 +2935,6 @@ class APIController extends Controller implements LoggedController
} }
else 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->setHub($hub);
$jo->setStatus(JOStatus::RIDER_ASSIGN); $jo->setStatus(JOStatus::RIDER_ASSIGN);
$jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED); $jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED);

View file

@ -27,7 +27,7 @@ class HubCriteria
$this->limit_results = 10; $this->limit_results = 10;
$this->limit_distance = 500; $this->limit_distance = 500;
$this->jo_type = ''; $this->jo_type = '';
$this->date_time = null; $this->date_time = new DateTime();
$this->flag_inventory_check = false; $this->flag_inventory_check = false;
$this->items = []; $this->items = [];
$this->payment_method = ''; $this->payment_method = '';

View file

@ -65,14 +65,14 @@ class HubSelector
error_log('closest hubs ' . json_encode($filtered_hubs)); 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) 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 // filter jo types
$hubs_jo_type = $this->filterHubsByJoType($filtered_hubs, $jo_type, $jo_id, $customer_id); $hubs_jo_type = $this->filterHubsByJoType($filtered_hubs, $jo_type, $jo_id, $customer_id);
$filtered_hubs = $hubs_jo_type; $filtered_hubs = $hubs_jo_type;
@ -167,6 +167,7 @@ class HubSelector
'db_distance' => $hub_data['db_distance'], 'db_distance' => $hub_data['db_distance'],
'distance' => $hub_data['distance'], 'distance' => $hub_data['distance'],
'duration' => $hub_data['duration'], 'duration' => $hub_data['duration'],
'jo_count' => 0,
]; ];
else else
$this->hub_filter_logger->logFilteredHub($hub, 'job_order_type', $jo_id, $customer_id); $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'], 'db_distance' => $hub_data['db_distance'],
'distance' => $hub_data['distance'], 'distance' => $hub_data['distance'],
'duration' => $hub_data['duration'], 'duration' => $hub_data['duration'],
'jo_count' => 0,
]; ];
} }
$flag_found_pmethod = true; $flag_found_pmethod = true;
@ -248,6 +250,7 @@ class HubSelector
'db_distance' => $hub_data['db_distance'], 'db_distance' => $hub_data['db_distance'],
'distance' => $hub_data['distance'], 'distance' => $hub_data['distance'],
'duration' => $hub_data['duration'], 'duration' => $hub_data['duration'],
'jo_count' => 0,
]; ];
} }
else else
@ -282,6 +285,7 @@ class HubSelector
'db_distance' => $hub_data['db_distance'], 'db_distance' => $hub_data['db_distance'],
'distance' => $hub_data['distance'], 'distance' => $hub_data['distance'],
'duration' => $hub_data['duration'], 'duration' => $hub_data['duration'],
'jo_count' => 0,
]; ];
else else
{ {
@ -309,6 +313,7 @@ class HubSelector
'db_distance' => $hub_data['db_distance'], 'db_distance' => $hub_data['db_distance'],
'distance' => $hub_data['distance'], 'distance' => $hub_data['distance'],
'duration' => $hub_data['duration'], 'duration' => $hub_data['duration'],
'jo_count' => 0,
]; ];
else else
{ {

View file

@ -2024,8 +2024,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$long = $obj->getCoordinates()->getLongitude(); $long = $obj->getCoordinates()->getLongitude();
$lat = $obj->getCoordinates()->getLatitude(); $lat = $obj->getCoordinates()->getLatitude();
// set result limit and location // set result limit and location and date_time
$hub_criteria->setPoint($obj->getCoordinates()) $hub_criteria->setPoint($obj->getCoordinates())
->setDateTime($obj->getDateSchedule())
->setLimitResults(50); ->setLimitResults(50);
// check if hub filter is enabled. If not, use default values // check if hub filter is enabled. If not, use default values
@ -2343,6 +2344,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$lat = $obj->getCoordinates()->getLatitude(); $lat = $obj->getCoordinates()->getLatitude();
$hub_criteria->setPoint($obj->getCoordinates()) $hub_criteria->setPoint($obj->getCoordinates())
->setDateTime($obj->getDateSchedule())
->setLimitResults(50); ->setLimitResults(50);
if ($this->hub_geofence->isCovered($long, $lat)) if ($this->hub_geofence->isCovered($long, $lat))