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]);