Add motiv call to initializeOpenHubForm. #656
This commit is contained in:
parent
9b50efc9d0
commit
928257ccdc
4 changed files with 48 additions and 6 deletions
|
|
@ -506,13 +506,13 @@ class JobOrderController extends Controller
|
||||||
* @Menu(selected="jo_open")
|
* @Menu(selected="jo_open")
|
||||||
*/
|
*/
|
||||||
public function openHubForm(HubSelector $hub_selector, $id, JobOrderHandlerInterface $jo_handler,
|
public function openHubForm(HubSelector $hub_selector, $id, JobOrderHandlerInterface $jo_handler,
|
||||||
GISManagerInterface $gis)
|
GISManagerInterface $gis, MotivConnector $motiv)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$params = $jo_handler->initializeHubForm($id, $hub_selector);
|
$params = $jo_handler->initializeHubForm($id, $hub_selector, $motiv);
|
||||||
}
|
}
|
||||||
catch (NotFoundHttpException $e)
|
catch (NotFoundHttpException $e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1873,7 +1873,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize hub form
|
// initialize hub form
|
||||||
public function initializeHubForm($id, $map_tools)
|
public function initializeHubForm($id, $map_tools, $motiv)
|
||||||
{
|
{
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2315,7 +2315,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize hub form
|
// initialize hub form
|
||||||
public function initializeHubForm($id, HubSelector $hub_selector)
|
public function initializeHubForm($id, HubSelector $hub_selector, $motiv)
|
||||||
{
|
{
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
||||||
|
|
@ -2445,9 +2445,51 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$params['hubs'][] = $hub;
|
// handle inventory data
|
||||||
|
$bcode = $hub['hub']->getBranchCode();
|
||||||
|
$hub['inventory'] = 0;
|
||||||
|
if ($bcode != '')
|
||||||
|
{
|
||||||
|
$branch_codes[] = $bcode;
|
||||||
|
$inv_data[$bcode] = [
|
||||||
|
'hub_id' => $hub_id,
|
||||||
|
'branch_code' => $bcode,
|
||||||
|
'inventory' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['hubs'][$hub_id] = $hub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get battery (if any)
|
||||||
|
$skus = [];
|
||||||
|
$invoice = $obj->getInvoice();
|
||||||
|
$inv_items = $invoice->getItems();
|
||||||
|
foreach ($inv_items as $inv_item)
|
||||||
|
{
|
||||||
|
$batt = $inv_item->getBattery();
|
||||||
|
if ($batt == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$skus[] = $batt->getSapCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get inventory
|
||||||
|
$mres = $motiv->getInventory($branch_codes, $skus);
|
||||||
|
foreach ($mres as $mres_item)
|
||||||
|
{
|
||||||
|
$bcode = $mres_item['BranchCode'];
|
||||||
|
$inv_count = $mres_item['Quantity'];
|
||||||
|
if (isset($inv_data[$bcode]))
|
||||||
|
{
|
||||||
|
$hub_id = $inv_data[$bcode]['hub_id'];
|
||||||
|
|
||||||
|
$params['hubs'][$hub_id]['inventory'] = $inv_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log(print_r($mres, true));
|
||||||
|
|
||||||
$params['obj'] = $obj;
|
$params['obj'] = $obj;
|
||||||
// get template to display
|
// get template to display
|
||||||
$params['template'] = $this->getTwigTemplate('jo_open_hub_form');
|
$params['template'] = $this->getTwigTemplate('jo_open_hub_form');
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ interface JobOrderHandlerInterface
|
||||||
public function initializeFulfillmentForm(int $id);
|
public function initializeFulfillmentForm(int $id);
|
||||||
|
|
||||||
// initialize hub form
|
// initialize hub form
|
||||||
public function initializeHubForm(int $id, HubSelector $hub_selector);
|
public function initializeHubForm(int $id, HubSelector $hub_selector, $motiv);
|
||||||
|
|
||||||
// initialize rider form
|
// initialize rider form
|
||||||
public function initializeRiderForm(int $id);
|
public function initializeRiderForm(int $id);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue