diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 900d211f..0568aeb0 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -1046,8 +1046,10 @@ class APIController extends Controller implements LoggedController // get customer id. No JO id at this point $customer_id = $cust->getID(); + $hub_criteria->setCustomerId($customer_id); + // find nearest hubs - $nearest_hubs = $hub_select->find($hub_criteria, null, $customer_id); + $nearest_hubs = $hub_select->find($hub_criteria); if (!empty($nearest_hubs)) { @@ -2775,8 +2777,10 @@ class APIController extends Controller implements LoggedController // get customer id. No JO id at this point $customer_id = $cust->getID(); + $hub_criteria->setCustomerId($customer_id); + // find nearest hubs - $nearest_hubs = $hub_select->find($hub_criteria, null, $customer_id); + $nearest_hubs = $hub_select->find($hub_criteria); if (!empty($nearest_hubs)) { diff --git a/src/Ramcar/HubCriteria.php b/src/Ramcar/HubCriteria.php index 76f00eb6..61ffcbaa 100644 --- a/src/Ramcar/HubCriteria.php +++ b/src/Ramcar/HubCriteria.php @@ -18,6 +18,8 @@ class HubCriteria protected $payment_method; // payment method of JO protected $flag_emergency; // flag if emergency or not protected $flag_round_robin; // flag if we use round robin or not + protected $jo_id; // JO id. This is null if called from mobile API + protected $customer_id; // customer id public function __construct() { @@ -31,6 +33,8 @@ class HubCriteria $this->payment_method = ''; $flag_emergency = false; $flag_round_robin = false; + $jo_id = null; + $customer_id = null; } public function setPoint(Point $point) @@ -145,5 +149,27 @@ class HubCriteria return $this->flag_round_robin; } + public function setJobOrderId($jo_id) + { + $this->jo_id = $jo_id; + return $this; + } + + public function getJobOrderId() + { + return $this->jo_id; + } + + public function setCustomerId($customer_id) + { + $this->customer_id = $customer_id; + return $this; + } + + public function getCustomerId() + { + return $this->customer_id; + } + } diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index 87dd14d2..ab810c20 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -39,7 +39,7 @@ class HubSelector $this->rt = $rt; } - public function find(HubCriteria $criteria, $jo_id, $customer_id) + public function find(HubCriteria $criteria) { $point = $criteria->getPoint(); $limit_results = $criteria->getLimitResults(); @@ -51,6 +51,8 @@ class HubSelector $payment_method = $criteria->getPaymentMethod(); $flag_emergency = $criteria->isEmergency(); $flag_round_robin = $criteria->isRoundRobin(); + $jo_id = $criteria->getJobOrderId(); + $customer_id = $criteria->getCustomerId(); $results = []; diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index d5aeefd4..971f6903 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -2000,7 +2000,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $jo_id = $obj->getID(); $customer_id = $obj->getCustomer()->getID(); - $hubs = $hub_selector->find($hub_criteria, $jo_id, $customer_id); + $hub_criteria->setJobOrderId($jo_id) + ->setCustomerId($customer_id); + + $hubs = $hub_selector->find($hub_criteria); $params['hubs'] = []; @@ -2301,7 +2304,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $jo_id = $obj->getID(); $customer_id = $obj->getCustomer()->getID(); - $hubs = $hub_selector->find($hub_criteria, $jo_id, $customer_id); + $hub_criteria->setJobOrderId($jo_id) + ->setCustomerId($customer_id); + + $hubs = $hub_selector->find($hub_criteria); $params['status_cancelled'] = JOStatus::CANCELLED; $params['hubs'] = [];