From aa1144da082d9293339705fabde89fc0eb8996bc Mon Sep 17 00:00:00 2001 From: dongpd Date: Fri, 13 Nov 2020 11:33:18 +0700 Subject: [PATCH] =?UTF-8?q?fix=20bugs=20ch=E1=BB=8Dn=20=C4=91=C6=B0?= =?UTF-8?q?=E1=BB=A3c=20m=E1=BB=91c=20th=E1=BB=9Di=20gian=20ch=E1=BB=93ng?= =?UTF-8?q?=20ch=C3=A9o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/web.php | 2 +- views/logs/index.tpl | 4 ++-- web/js/schedule.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/config/web.php b/config/web.php index ebc8ddde..08b6c38b 100644 --- a/config/web.php +++ b/config/web.php @@ -48,7 +48,7 @@ $config = [ ], 'assetManager' => [ 'class' => 'app\\components\\AssetManager', - 'appendVersion' => '1.0.6', + 'appendVersion' => '1.0.11', 'bundles' => [ 'dmstr\web\AdminLteAsset' => [ 'skin' => 'skin-blue', diff --git a/views/logs/index.tpl b/views/logs/index.tpl index be60db56..e360f303 100644 --- a/views/logs/index.tpl +++ b/views/logs/index.tpl @@ -22,13 +22,13 @@
Từ
- +
Đến
- +
diff --git a/web/js/schedule.js b/web/js/schedule.js index 5eaf0a60..2432f64d 100644 --- a/web/js/schedule.js +++ b/web/js/schedule.js @@ -74,6 +74,10 @@ function saveCurrentPos() { alert("Mốc thời gian lựa chọn chưa đúng!"); return false; } + if (!checkTime(currentID)) { + alert("Các mốc thời gian trong ngày không được phép chồng chéo!"); + return false; + } if (f !== "00:00" || t !== "00:00") { var html = `` + f + ` - ` + t + ``; $("#data-" + currentID).html(html); @@ -87,6 +91,35 @@ function saveCurrentPos() { return true; } +function checkTime(currentID) { + var fCheck = convertTime($("input[name='From" + currentID + "']").val()); + var tCheck = convertTime($("input[name='To" + currentID + "']").val()); + + var currentDay = currentID.substring(0, 3); + var currentIdx = currentID.substring(3); + var others = []; + if (currentIdx == 1) + others = [2, 3]; + if (currentIdx == 2) + others = [1, 3]; + if (currentIdx == 3) + others = [1, 2]; + + for (var i = 0; i < others.length; i++) { + var f = convertTime($("input[name='From" + currentDay + others[i] + "']").val()); + var t = convertTime($("input[name='To" + currentDay + others[i] + "']").val()); + if (fCheck > f && fCheck < t) + return false; + if (tCheck > f && tCheck < t) + return false; + if (f > fCheck && f < tCheck) + return false; + if (t > fCheck && t < tCheck) + return false; + } + return true; +} + function convertTime(time) { var split = time.split(":"); return parseInt(split[0]) * 60 + parseInt(split[1]);