Resolve "Allow super admin to do rider assignment regardless of locking" #899
1 changed files with 25 additions and 17 deletions
|
|
@ -1024,27 +1024,35 @@ class JobOrderController extends BaseController
|
||||||
throw $this->createNotFoundException('The job order does not have an assigning status');
|
throw $this->createNotFoundException('The job order does not have an assigning status');
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if hub is assigned to current user
|
// check if super user
|
||||||
$user_hubs = $this->getUser()->getHubs();
|
|
||||||
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
|
||||||
{
|
|
||||||
$em->getConnection()->rollback();
|
|
||||||
throw $this->createNotFoundException('The job order is not on a hub assigned to this user');
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if we are the assignor
|
|
||||||
$assignor = $obj->getAssignedBy();
|
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
if ($user->isSuperAdmin())
|
||||||
if ($assignor != null && $assignor->getID() != $user->getID())
|
|
||||||
{
|
{
|
||||||
$em->getConnection()->rollback();
|
// do nothing, just allow page to be accessed
|
||||||
throw $this->createAccessDeniedException('Not the assignor');
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check if hub is assigned to current user
|
||||||
|
$user_hubs = $this->getUser()->getHubs();
|
||||||
|
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw $this->createNotFoundException('The job order is not on a hub assigned to this user');
|
||||||
|
}
|
||||||
|
|
||||||
// make this user be the assignor
|
// check if we are the assignor
|
||||||
$obj->setAssignedBy($user);
|
$assignor = $obj->getAssignedBy();
|
||||||
$em->flush();
|
|
||||||
|
if ($assignor != null && $assignor->getID() != $user->getID())
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw $this->createAccessDeniedException('Not the assignor');
|
||||||
|
}
|
||||||
|
|
||||||
|
// make this user be the assignor
|
||||||
|
$obj->setAssignedBy($user);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
$em->getConnection()->commit();
|
$em->getConnection()->commit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue