From 1f741b8d012cf7dc4a86b0749cd6684d241c35ef Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Sun, 15 Nov 2020 14:34:23 +0800 Subject: [PATCH] * Finish task#8198. Add comments. --- module/todo/js/common.js | 2 -- module/todo/model.php | 10 +++++++--- module/todo/view/create.html.php | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/module/todo/js/common.js b/module/todo/js/common.js index a84f4e4239..8f6ccdd08d 100644 --- a/module/todo/js/common.js +++ b/module/todo/js/common.js @@ -136,13 +136,11 @@ function showAppointDate(switcher) { if(switcher.checked) { - $('#date').attr('disabled','disabled'); $('#dayInput').attr('disabled','disabled'); $('.appoint').removeClass('hidden'); } else { - $('#date').removeAttr('disabled'); $('#dayInput').removeAttr('disabled'); $('.appoint').addClass('hidden'); } diff --git a/module/todo/model.php b/module/todo/model.php index 37afdb24a5..8512341086 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -47,7 +47,7 @@ class todoModel extends model if(empty($todo->cycle)) unset($todo->config); if(!empty($todo->cycle)) { - if(isset($todo->config['appointDate'])) $todo->date = date('Y-m-d'); + $todo->date = date('Y-m-d'); $todo->config['begin'] = $todo->date; if($todo->config['type'] == 'day') @@ -194,7 +194,7 @@ class todoModel extends model if(!empty($oldTodo->cycle)) { - if(isset($todo->config['appointDate'])) $todo->date = date('Y-m-d'); + $todo->date = date('Y-m-d'); $todo->config['begin'] = $todo->date; if($todo->config['type'] == 'day') @@ -537,7 +537,7 @@ class todoModel extends model $begin = $todo->config->begin; $end = $todo->config->end; $beforeDays = (int)$todo->config->beforeDays; - if(!empty($beforeDays) && $beforeDays > 0) $begin = date('Y-m-d', strtotime("$today -{$beforeDays} days")); + if(!empty($beforeDays) && $beforeDays > 0) $begin = date('Y-m-d', strtotime("$begin -{$beforeDays} days")); if($today < $begin or (!empty($end) && $today > $end)) continue; $newTodo = new stdclass(); @@ -570,6 +570,7 @@ class todoModel extends model $day = (int)$todo->config->day; if($day <= 0) continue; + /* If no data, judge the interval from the begin time. */ if(empty($lastCycle)) { $todayTime = new DateTime($today); @@ -581,6 +582,7 @@ class todoModel extends model $date = $today; } + /* If have data, judge the interval from the last cycle time. */ if(!empty($lastCycle->date)) { $todayTime = new DateTime($today); @@ -597,8 +599,10 @@ class todoModel extends model $date = $today; $appointDate = $todo->config->appoint->month . '-' . $todo->config->appoint->day; + // If not set cycle every year and have data, continue. if(!empty($lastCycle) and !isset($todo->config->cycleYear)) continue; + // If set appoint date, only judge month and day. if(date('m-d', strtotime($date)) != $appointDate) continue; } } diff --git a/module/todo/view/create.html.php b/module/todo/view/create.html.php index 5a14673107..bd412948f9 100644 --- a/module/todo/view/create.html.php +++ b/module/todo/view/create.html.php @@ -34,7 +34,7 @@
- +