Add checking for assigned job orders when rider is logging out or going offline. #437

This commit is contained in:
Korina Cordero 2020-07-20 08:21:34 +00:00
parent 655b632849
commit 95a070051e

View file

@ -251,6 +251,17 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
// make rider unavailable
$rider = $this->session->getRider();
// check if rider has assigned JOs
$assigned_jos = $this->em->getRepository(JobOrder::class)->findBy(['rider' => $rider->getID(), 'status' => JOStatus::ASSIGNED]);
if ($assigned_jos != null)
{
$data = [
'title' => 'Failed Logout',
'error' => 'Rider has assigned job orders.'
];
return $data;
}
$rider->setAvailable(false);
$rider->setActive(false);
@ -314,6 +325,17 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
// set rider to unavailable to take on JOs
$rider = $this->session->getRider();
// check if rider has assigned JOs
$assigned_jos = $this->em->getRepository(JobOrder::class)->findBy(['rider' => $rider->getID(), 'status' => JOStatus::ASSIGNED]);
if ($assigned_jos != null)
{
$data = [
'title' => 'Failed Go Offline',
'error' => 'Rider has assigned job orders.'
];
return $data;
}
$rider->setAvailable(false);
$this->em->flush();