diff --git a/application/modules/requests/models/ApprovalChainModel.php b/application/modules/requests/models/ApprovalChainModel.php index e45c55b50f5a2392e23d715a2c67a90cf52d5b92..1c060a961a7d81d6fa80c8ffb231d68f25b2a519 100644 --- a/application/modules/requests/models/ApprovalChainModel.php +++ b/application/modules/requests/models/ApprovalChainModel.php @@ -202,6 +202,18 @@ class Requests_ApprovalChainModel extends Unl_Model if (count($requests) == 0) { return; } + + // If any advanced requests are completed, drop them from our list + foreach ($requests as $requestId => $request) { + if ($request->isComplete()) { + unset($requests[$requestId]); + } + } + + // If we don't have any requests left to process (after dropping completed requsets), stop. + if (count($requests) == 0) { + return; + } // Find requests which haven't yet started (stack pointer = null and complete = no) $requestsToInit = new Unl_Model_Collection('Requests_RequestModel');