Resolve "Add service type to date returns for mobile API calls" #913
1 changed files with 16 additions and 4 deletions
|
|
@ -1364,15 +1364,20 @@ class JobOrderController extends BaseController
|
||||||
|
|
||||||
protected function sendEvent(JobOrder $job_order, $payload)
|
protected function sendEvent(JobOrder $job_order, $payload)
|
||||||
{
|
{
|
||||||
$session = $job_order->getCustomer()->getMobileSessions();
|
$sessions = $job_order->getCustomer()->getMobileSessions();
|
||||||
if (count($session) == 0)
|
if (count($session) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$phone_num = $session[0]->getPhoneNumber();
|
|
||||||
$channel = 'motolite.control.' . $phone_num;
|
|
||||||
$client = new MosquittoClient();
|
$client = new MosquittoClient();
|
||||||
$client->connect('localhost', 1883);
|
$client->connect('localhost', 1883);
|
||||||
$client->publish($channel, json_encode($payload));
|
|
||||||
|
foreach ($sessions as $sess)
|
||||||
|
{
|
||||||
|
$phone_num = $sess->getPhoneNumber();
|
||||||
|
$channel = 'motolite.control.' . $phone_num;
|
||||||
|
$client->publish($channel, json_encode($payload));
|
||||||
|
}
|
||||||
|
|
||||||
$client->disconnect();
|
$client->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1783,6 +1788,13 @@ class JobOrderController extends BaseController
|
||||||
// save
|
// save
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
// send mobile app event
|
||||||
|
$payload = [
|
||||||
|
'event' => 'cancelled',
|
||||||
|
'jo_id' => $obj->getID(),
|
||||||
|
];
|
||||||
|
$this->sendEvent($obj, $payload);
|
||||||
|
|
||||||
// return successful response
|
// return successful response
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'success' => 'Job order has been cancelled!'
|
'success' => 'Job order has been cancelled!'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue