Enable inventory retrieval if inventory checks are disabled #800
This commit is contained in:
parent
f8d90cbdcd
commit
8da5381a1c
1 changed files with 73 additions and 42 deletions
|
|
@ -3026,8 +3026,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
//error_log("TOTAL HUBS FOUND WITH BRANCH CODE: " . count($inv_data));
|
||||
|
||||
// get all enabled filters
|
||||
$enabled_filter_str = $_ENV['ENABLED_HUB_FILTERS'];
|
||||
$enabled_filters = explode(",", $enabled_filter_str);
|
||||
|
||||
// if inventory filter is disabled, fetch inventory here
|
||||
if (!in_array('InventoryHubFilter', $enabled_filters) || $this->skipInventoryCheck($obj->getCoordinates())) {
|
||||
error_log("NO INVENTORY CHECKS, GETTING INVENTORY FOR JO " . $obj->getID());
|
||||
|
||||
// get battery (if any)
|
||||
/*
|
||||
$skus = [];
|
||||
$invoice = $obj->getInvoice();
|
||||
$inv_items = $invoice->getItems();
|
||||
|
|
@ -3072,7 +3079,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
error_log("SET QUANTITY OF " . $x . " HUBS TO NON ZERO");
|
||||
|
||||
// error_log(print_r($mres, true));
|
||||
*/
|
||||
}
|
||||
|
||||
$params['obj'] = $obj;
|
||||
// get template to display
|
||||
|
|
@ -4349,4 +4356,28 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $msg);
|
||||
}
|
||||
|
||||
protected function skipInventoryCheck(Point $coordinates): bool
|
||||
{
|
||||
$long = $coordinates->getLongitude();
|
||||
$lat = $coordinates->getLatitude();
|
||||
|
||||
// get supported area given a set of coordinates
|
||||
$query = $this->em->createQuery('SELECT s from App\Entity\SupportedArea s where st_contains(s.coverage_area, point(:long, :lat)) = true');
|
||||
$area = $query->setParameter('long', $long)
|
||||
->setParameter('lat', $lat)
|
||||
->setMaxResults(1)
|
||||
->getOneOrNullResult();
|
||||
|
||||
if ($area !== null) {
|
||||
// get all exceptions
|
||||
$exceptions = $area->getHubFilterExceptions();
|
||||
|
||||
if (isset($exceptions['no_inventory'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// filter is in place
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue