Add checking for assigned job orders when rider is logging out or going offline. #437
This commit is contained in:
parent
655b632849
commit
95a070051e
1 changed files with 22 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue