Merge branch '162-phase-2-changes' into 'master'
Resolve "Phase 2 changes" Closes #162 See merge request jankstudio/resq!177
This commit is contained in:
commit
ca1781b6c0
2 changed files with 37 additions and 5 deletions
|
|
@ -1489,7 +1489,7 @@ class JobOrderController extends BaseController
|
|||
return $this->render('job-order/form.html.twig', $params);
|
||||
}
|
||||
|
||||
public function openHubSubmit(Request $req, ValidatorInterface $validator, $id)
|
||||
public function openHubSubmit(Request $req, ValidatorInterface $validator, MQTTClient $mclient, $id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1522,7 +1522,17 @@ class JobOrderController extends BaseController
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($error_array)) {
|
||||
if (empty($error_array))
|
||||
{
|
||||
// rider mqtt event
|
||||
// NOTE: need to send this before saving because rider will be cleared
|
||||
$rider_payload = [
|
||||
'event' => 'cancelled',
|
||||
'reason' => 'Reassigned',
|
||||
'jo_id' => $obj->getID(),
|
||||
];
|
||||
$mclient->sendRiderEvent($obj, $rider_payload);
|
||||
|
||||
// coordinates
|
||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||
|
||||
|
|
@ -1571,6 +1581,12 @@ class JobOrderController extends BaseController
|
|||
// validated! save the entity
|
||||
$em->flush();
|
||||
|
||||
// user mqtt event
|
||||
$payload = [
|
||||
'event' => 'outlet_assign'
|
||||
];
|
||||
$mclient->sendEvent($obj, $payload);
|
||||
|
||||
// return successful response
|
||||
return $this->json([
|
||||
'success' => 'Changes have been saved!'
|
||||
|
|
@ -1615,7 +1631,7 @@ class JobOrderController extends BaseController
|
|||
return $this->render('job-order/form.html.twig', $params);
|
||||
}
|
||||
|
||||
public function openRiderSubmit(Request $req, ValidatorInterface $validator, $id)
|
||||
public function openRiderSubmit(Request $req, ValidatorInterface $validator, MQTTClient $mclient, $id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1648,6 +1664,15 @@ class JobOrderController extends BaseController
|
|||
}
|
||||
|
||||
if (empty($error_array)) {
|
||||
// rider mqtt event
|
||||
// NOTE: need to send this before saving because rider will be cleared
|
||||
$rider_payload = [
|
||||
'event' => 'cancelled',
|
||||
'reason' => 'Reassigned',
|
||||
'jo_id' => $obj->getID(),
|
||||
];
|
||||
$mclient->sendRiderEvent($obj, $rider_payload);
|
||||
|
||||
// coordinates
|
||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||
|
||||
|
|
@ -1697,6 +1722,13 @@ class JobOrderController extends BaseController
|
|||
// validated! save the entity
|
||||
$em->flush();
|
||||
|
||||
// send event to mobile app
|
||||
$payload = [
|
||||
'event' => 'driver_assigned'
|
||||
];
|
||||
$mclient->sendEvent($obj, $payload);
|
||||
$mclient->sendRiderEvent($obj, $payload);
|
||||
|
||||
// return successful response
|
||||
return $this->json([
|
||||
'success' => 'Changes have been saved!'
|
||||
|
|
|
|||
|
|
@ -509,9 +509,9 @@ class RAPIController extends Controller
|
|||
$em->flush();
|
||||
|
||||
// send mqtt event
|
||||
// send outlet assign since order should go back to hub and await reassignment to another rider
|
||||
$payload = [
|
||||
'event' => 'cancelled',
|
||||
'reason' => 'mobile cancellation',
|
||||
'event' => 'outlet_assign',
|
||||
'jo_id' => $jo->getID(),
|
||||
];
|
||||
$mclient->sendEvent($jo, $payload);
|
||||
|
|
|
|||
Loading…
Reference in a new issue