Fix for error in JO creation. #473

This commit is contained in:
Korina Cordero 2020-08-24 03:47:43 +00:00
parent ed22eebdc2
commit 9fe4098ac4

View file

@ -449,6 +449,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$jo = $em->getRepository(JobOrder::class)->find($id);
$old_jo_status = null;
$old_rider = null;
if (empty($jo))
{
// new job order
@ -642,16 +643,22 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
// retain old jo status if it's an update JO
// check old rider if it is also a reassignment
// old_rider should be null if JO has been rejected
$new_rider = $jo->getRider();
if ($new_rider != $old_rider)
{
// reassignment
if (($old_rider == null) && ($old_jo_status == null))
$jo->setStatus(JOStatus::ASSIGNED);
}
else
{
if ($old_jo_status != null)
$jo->setStatus($old_jo_status);
error_log('not a new JO');
$new_rider = $jo->getRider();
if ($new_rider != $old_rider)
{
// reassignment
$jo->setStatus(JOStatus::ASSIGNED);
}
else
{
if ($old_jo_status != null)
$jo->setStatus($old_jo_status);
}
}
// check if user is null, meaning call to create came from API