From edda7c38e2a0a32ddfc3d1fe0eb50e390974f3ad Mon Sep 17 00:00:00 2001 From: Matteo Date: Wed, 10 Apr 2024 17:15:20 +0200 Subject: [PATCH] Fix per api cleanup checklist --- modules/checklists/components/edit-check.php | 1 + modules/checklists/edit.php | 2 ++ plugins/checks.php | 2 ++ src/API/App/v1/Checklists.php | 17 ++++++++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/checklists/components/edit-check.php b/modules/checklists/components/edit-check.php index db172eeb9..5e854925e 100644 --- a/modules/checklists/components/edit-check.php +++ b/modules/checklists/components/edit-check.php @@ -64,6 +64,7 @@ if ($main_check) { $.post('/modules/checklists/ajax.php', { op: "edit_check", + id_module: globals.id_module, id_record: "", content: input('content_edit').get(), is_titolo: input('is_titolo').get(), diff --git a/modules/checklists/edit.php b/modules/checklists/edit.php index f036e84c9..592dfe2d5 100755 --- a/modules/checklists/edit.php +++ b/modules/checklists/edit.php @@ -211,6 +211,8 @@ function delete_check(id){ op: "delete_check", id: id, main_check: 1, + id_module: globals.id_module, + id_record: id, }, function(){ location.reload(); }); diff --git a/plugins/checks.php b/plugins/checks.php index bab7a006e..de6364627 100644 --- a/plugins/checks.php +++ b/plugins/checks.php @@ -162,6 +162,8 @@ function delete_check(id){ $.post("'.$checklist_module->fileurl('ajax.php').'", { op: "delete_check", id: id, + id_module: globals.id_module, + id_record: id, }, function(){ location.reload(); }); diff --git a/src/API/App/v1/Checklists.php b/src/API/App/v1/Checklists.php index 8e68e70ba..c9e2f2f8d 100755 --- a/src/API/App/v1/Checklists.php +++ b/src/API/App/v1/Checklists.php @@ -90,7 +90,22 @@ class Checklists extends AppResource $da_interventi = array_column($records, 'id'); } - $mancanti = $this->getMissingIDs('zz_checks', 'id', $last_sync_at); + $rs_mancanti = database() + ->table('zz_operations') + ->select('zz_operations.id_record') + ->distinct() + ->join('zz_modules', 'zz_modules.id', '=', 'zz_operations.id_module') + ->leftJoin('zz_modules_lang', function ($join) { + $join->on('zz_modules.id', '=', 'zz_modules_lang.id_record') + ->where('zz_modules_lang.id_lang', '=', \Models\Locale::getDefault()->id); + }) + ->where('zz_modules_lang.name', '=', 'Interventi') + ->where('zz_operations.op', '=', 'delete_check') + ->where('zz_operations.created_at', '>', $last_sync_at) + ->pluck('id_record') + ->toArray(); + + $mancanti = array_column($rs_mancanti, 'id_record'); $results = array_unique(array_merge($da_interventi, $mancanti));