diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index fedc1ed9..9bb1c13d 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -12,7 +12,7 @@ use CrEOF\Spatial\PHP\Types\Geometry\Point; use App\Entity\Hub; use App\Entity\JobOrder; use App\Entity\Battery; - +use App\Ramcar\CustomerClassification; use App\Service\HubDistributor; use App\Service\InventoryManager; use App\Service\HubFilterLogger; @@ -63,8 +63,9 @@ class HubSelector $results = []; - // get the job order object + // get the job order object and customer class $jo = $this->em->getRepository(JobOrder::class)->find($jo_id); + $customer_class = $jo->getCustomer()->getCustomerClassification(); // error_log('payment methods ' . $payment_method); // error_log('distance limit ' . $limit_distance); @@ -81,6 +82,8 @@ class HubSelector // error_log('date_time hubs ' . json_encode($filtered_hubs)); + // TODO: allow toggling of each filter individually for specific conditions (e.g. customer class, emergency) + if (!$flag_emergency) { // filter jo types @@ -98,7 +101,10 @@ class HubSelector //error_log('inventory hubs ' . json_encode($filtered_hubs)); // error_log('round robin hubs ' . json_encode($filtered_hubs)); + } + // only enable rider and inventory checks if not VIP + if ($customer_class !== CustomerClassification::VIP) { // available riders filter $hubs_riders = $this->filterHubsByRiderAvailability($filtered_hubs, $flag_riders_check, $jo_type, $jo, $customer_id); $filtered_hubs = $hubs_riders; @@ -106,7 +112,9 @@ class HubSelector // inventory filter $hubs_inventory = $this->filterHubsByInventory($filtered_hubs, $flag_inventory_check, $jo_type, $items, $jo, $customer_id); $filtered_hubs = $hubs_inventory; + } + if (!$flag_emergency) { // round robin filter $hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin); $filtered_hubs = $hubs_round_robin;