From 5d25d69f178ae8ba4f36d15f62f50d9042253da7 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Thu, 5 Nov 2020 14:26:52 +0100 Subject: [PATCH] FEAT #14949 TIME 2:10 Get workflow when trying to delete --- src/app/user/controllers/UserController.php | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 59f4be66892..0245eda4839 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -406,7 +406,27 @@ class UserController ]; } - return $response->withJson(['isDeletable' => true, 'listTemplates' => $listTemplates, 'listInstances' => $listInstances]); + $rawWorkflowListInstances = ListInstanceModel::get([ + 'select' => ['res_id'], + 'where' => ['item_id = ?', 'difflist_type = ?', 'process_date is null'], + 'data' => [$aArgs['id'], 'VISA_CIRCUIT'], + 'groupBy' => ['res_id'] + ]); + $workflowListInstances = []; + foreach ($rawWorkflowListInstances as $rawWorkflowListInstance) { + $rawListInstances = ListInstanceModel::get([ + 'select' => ['*'], + 'where' => ['res_id = ?', 'difflist_type = ?'], + 'data' => [$rawWorkflowListInstance['res_id'], 'VISA_CIRCUIT'], + 'orderBy' => ['listinstance_id'] + ]); + $workflowListInstances[] = [ + 'resId' => $rawWorkflowListInstance['res_id'], + 'listInstances' => $rawListInstances + ]; + } + + return $response->withJson(['isDeletable' => true, 'listTemplates' => $listTemplates, 'listInstances' => $listInstances, 'workflowListInstances' => $workflowListInstances]); } public function suspend(Request $request, Response $response, array $aArgs) -- GitLab