From 2df2ca22a14d1acfeedfa03757d76af4b0906875 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 7 Mar 2024 15:33:59 +0100 Subject: [PATCH] added superexpert mode --- Layout/default/footer.php | 107 +++++++++++++++++- Layout/default/topbar.php | 4 +- application/User/User.php | 56 +++++++++ application/User/UserController.php | 74 +++++++++++- ...0_worker_permission_addcan_superexpert.php | 31 +++++ scripts/test.php | 5 +- 6 files changed, 269 insertions(+), 8 deletions(-) create mode 100644 db/migrations/20240305143620_worker_permission_addcan_superexpert.php diff --git a/Layout/default/footer.php b/Layout/default/footer.php index e18e6fa8b..58916a8d7 100644 --- a/Layout/default/footer.php +++ b/Layout/default/footer.php @@ -7,7 +7,7 @@
"> - the tool © Xinon GmbH + the tool © Xinon GmbH
@@ -36,6 +36,111 @@ $(this).parent('li').toggleClass('open').find('.submenu:first').toggleClass('open'); } }); + + can("Superexpert")): ?> + $(".secondO").addClass("pointer"); + + var se_to = 0; + var se_intv; + var se_notf; + $(".footer .secondO").click(function() { + if(!se_to) { + $.post("",{ + do: "sse" + }, + function(success) { + if(!("status" in success)) return; + if(success.status == "OK") { + if(!("result" in success)) return; + if(!("valid_to" in success.result) || !success.result.valid_to) return; + + se_to = success.result.valid_to; + addSeMark(); + se_intv = setInterval(checkSe, 1000); + location.reload(); + } + }, + "json"); + } + }); + + function checkSe() { + var now = Math.floor(Date.now() / 1000); + if(!se_to || se_to < 0) { + clearInterval(se_intv); + se_to = null; + $("#se_notf").remove(); + removeSeMark(); + return; + } + var rest_duration = se_to - now; + + if(rest_duration <= 0) { + clearInterval(se_intv); + se_to = null; + $("#se_notf").remove(); + removeSeMark(); + return; + } + + if(rest_duration < 60*5) { + // show notification + if($("#se_notf").length) { + $("#se_notf .time").text(rest_duration); + } else { + var notf_html = $('
Achtung: Noch ' + rest_duration +' Sekunden. Jetzt verlängern!
'); + $("body").prepend(notf_html); + } + + } + } + + function extSe() { + console.log("in ese"); + $.post("", { + do: "ese" + }, + function(success) { + if(!("result" in success)) return; + if(!("valid_to" in success.result) || !success.result.valid_to) return; + se_to = success.result.valid_to; + }, + "json" + ); + } + + function endSe() { + $.post("", { + do: "endse" + }, + function(success) { + if(!("result" in success)) return; + if(!("valid_to" in success.result)) return; + se_to = success.result.valid_to; + location.reload(); + }, + "json" + ); + } + + function addSeMark() { + if(!$("#se-mark").length) { + $("#topbar").append('
  • '); + } + } + + function removeSeMark() { + $("#SeMark").remove(); + } + + superexpertEnabled()): ?> + addSeMark(); + if(!se_intv) { + se_to = flags["superexpert_lock_date"]?>; + setInterval(checkSe, 1000); + } + + \ No newline at end of file diff --git a/Layout/default/topbar.php b/Layout/default/topbar.php index 1bb203247..07ae03c02 100644 --- a/Layout/default/topbar.php +++ b/Layout/default/topbar.php @@ -1,7 +1,7 @@