Enable inventory and rider filtering on CRM JO form hub lists #800
This commit is contained in:
parent
aed31f2a33
commit
190ac88153
1 changed files with 37 additions and 2 deletions
|
|
@ -2577,6 +2577,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$hub_criteria->setEmergency(true);
|
||||
}
|
||||
|
||||
// set filter flags for inventory and available riders
|
||||
$hub_criteria->setInventoryCheck();
|
||||
$hub_criteria->setRidersCheck();
|
||||
|
||||
// get JO and customer id for logging purposes
|
||||
$jo_id = $obj->getID();
|
||||
$customer_id = $obj->getCustomer()->getID();
|
||||
|
|
@ -2646,7 +2650,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
// handle inventory data
|
||||
$bcode = $hub['hub']->getBranchCode();
|
||||
$hub['inventory'] = 0;
|
||||
//$hub['inventory'] = 0;
|
||||
if ($bcode != '')
|
||||
{
|
||||
$branch_codes[] = $bcode;
|
||||
|
|
@ -2664,7 +2668,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
// get template to display
|
||||
$params['template'] = $this->getTwigTemplate('jo_processing_form');
|
||||
|
||||
// NOTE: as we have included inventory now from the hub selector, we no longer have to redo it here
|
||||
|
||||
// get battery (if any)
|
||||
/*
|
||||
$skus = [];
|
||||
$invoice = $obj->getInvoice();
|
||||
$inv_items = $invoice->getItems();
|
||||
|
|
@ -2694,6 +2701,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// error_log(print_r($mres, true));
|
||||
|
||||
|
|
@ -2908,6 +2916,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$hub_criteria->setEmergency(true);
|
||||
}
|
||||
|
||||
// set filter flags for inventory and available riders
|
||||
$hub_criteria->setInventoryCheck();
|
||||
$hub_criteria->setRidersCheck();
|
||||
|
||||
// get JO and customer id for logging purposes
|
||||
$jo_id = $obj->getID();
|
||||
$customer_id = $obj->getCustomer()->getID();
|
||||
|
|
@ -2921,6 +2933,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['hubs'] = [];
|
||||
|
||||
$branch_codes = [];
|
||||
$inv_data = [];
|
||||
|
||||
// format duration and distance into friendly time
|
||||
foreach ($hubs as $hub) {
|
||||
// duration
|
||||
|
|
@ -2976,7 +2990,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
// handle inventory data
|
||||
$bcode = $hub['hub']->getBranchCode();
|
||||
$hub['inventory'] = 0;
|
||||
//$hub['inventory'] = 0;
|
||||
if ($bcode != '')
|
||||
{
|
||||
$branch_codes[] = $bcode;
|
||||
|
|
@ -2990,7 +3004,12 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['hubs'][$hub_id] = $hub;
|
||||
}
|
||||
|
||||
// NOTE: as we have included inventory now from the hub selector, we no longer have to redo it here
|
||||
|
||||
//error_log("TOTAL HUBS FOUND WITH BRANCH CODE: " . count($inv_data));
|
||||
|
||||
// get battery (if any)
|
||||
/*
|
||||
$skus = [];
|
||||
$invoice = $obj->getInvoice();
|
||||
$inv_items = $invoice->getItems();
|
||||
|
|
@ -3005,6 +3024,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
|
||||
// get inventory
|
||||
$mres = $motiv->getInventory($branch_codes, $skus);
|
||||
$x = 0;
|
||||
|
||||
error_log("TOTAL RESULTS FROM MOTIV: " . count($mres) . " OUT OF " . count($branch_codes) . " BRANCH CODES AND " . count($skus) . " SKUS");
|
||||
|
||||
foreach ($mres as $mres_item)
|
||||
{
|
||||
// check if we have a valid response from motiv, ignore otherwise
|
||||
|
|
@ -3017,11 +3040,21 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$hub_id = $inv_data[$bcode]['hub_id'];
|
||||
|
||||
$params['hubs'][$hub_id]['inventory'] = $inv_count;
|
||||
|
||||
error_log("SETTING HUB " . $hub_id . " INVENTORY TO " . $inv_count);
|
||||
$x++;
|
||||
} else {
|
||||
error_log("CANNOT FIND BCODE FOR " . $bcode);
|
||||
}
|
||||
} else {
|
||||
error_log("CANNOT FIND BCODE FOR RESULT: " . print_r($mres_item, true));
|
||||
}
|
||||
}
|
||||
|
||||
error_log("SET QUANTITY OF " . $x . " HUBS TO NON ZERO");
|
||||
|
||||
// error_log(print_r($mres, true));
|
||||
*/
|
||||
|
||||
$params['obj'] = $obj;
|
||||
// get template to display
|
||||
|
|
@ -3449,6 +3482,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
// get riders for dropdown
|
||||
$params['riders'] = $this->em->getRepository(Rider::class)->findAll();
|
||||
|
||||
error_log("YEO----------------------------------");
|
||||
|
||||
// get hubs for dropdown
|
||||
$params['hubs'] = $this->em->getRepository(Hub::class)->findBy(['flag_hub_view' => true]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue