diff --git a/app/common/service/SubjectHomeworkService.php b/app/common/service/SubjectHomeworkService.php index 0569223..30ccbd0 100644 --- a/app/common/service/SubjectHomeworkService.php +++ b/app/common/service/SubjectHomeworkService.php @@ -82,6 +82,7 @@ class SubjectHomeworkService 'teacher_id' => $teacher->id, 'teacher_schedule_time_id' => $data['teacher_schedule_time_id'], 'date' => $teacher_schedule_time->date, + 'en_date' => $teacher_schedule_time->en_date, 'time' => $teacher_schedule_time->time, 'en_time' => $teacher_schedule_time->en_time, 'hour' => $teacher_schedule_time->hour, @@ -90,6 +91,7 @@ class SubjectHomeworkService 'en_start_time' => $teacher_schedule_time->en_start_time, 'en_end_time' => $teacher_schedule_time->en_end_time, 'month' => $teacher_schedule_time->month, + 'en_month' => $teacher_schedule_time->en_month, 'subject_id' => $teacher_schedule_time->subject_id, 'content' => isset($data['content']) ? $data['content'] : '', 'homework_web_url' => isset($data['homework_web_url']) ? $data['homework_web_url'] : '', diff --git a/app/common/service/TeacherFreeTimeService.php b/app/common/service/TeacherFreeTimeService.php index 4963471..3e1009c 100644 --- a/app/common/service/TeacherFreeTimeService.php +++ b/app/common/service/TeacherFreeTimeService.php @@ -46,14 +46,23 @@ class TeacherFreeTimeService foreach ($free_time as $item) { $free_date = $item['day']; foreach ($item['times'] as $val) { + + $time = $val['zh']; - $en_time = $val['en']; $time_period = explode('-', $time); - $en_time_period = explode('-', $en_time); $firstDate = new DateTime($free_date . ' ' . trim($time_period[0])); $secondDate = new DateTime($free_date . ' ' . trim($time_period[1])); + + + $en_time = $val['en']; + $en_time_period = explode('-', $en_time); $enFirstDate = new DateTime($free_date . ' ' . trim($en_time_period[0])); $enSecondDate = new DateTime($free_date . ' ' . trim($en_time_period[1])); + //根据时区计算教师国内时间 + $start_time = date('Y-m-d H:i:s', strtotime( $teacher['time_zone_offset'] . ' hour', $enFirstDate->getTimestamp())); + $end_time = date('Y-m-d H:i:s', strtotime( $teacher['time_zone_offset'] . ' hour', $enSecondDate->getTimestamp())); + + $diff = $secondDate->diff($firstDate); $h = $diff->h; $m = round($diff->i / 60, 2); @@ -61,20 +70,23 @@ class TeacherFreeTimeService $time = $time_period[0] . ' - ' . $time_period[1]; $free_data = [ 'teacher_id' => $request->teacher->id, - 'date' => $free_date, + 'date' => date('Y-m-d', strtotime($start_time)), + 'en_date' => $free_date, 'time' => $time, 'en_time' => implode(' - ', $en_time_period), 'hour' => $hour, - 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), - 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), + 'start_time' => $start_time, + 'end_time' => $end_time, 'en_start_time' => date('Y-m-d H:i:s', $enFirstDate->getTimestamp()), 'en_end_time' => date('Y-m-d H:i:s', $enSecondDate->getTimestamp()), - 'month' => date('Y-m', strtotime($free_date)), + 'en_month' => date('Y-m', strtotime($free_date)), + 'month' => date('Y-m', strtotime($start_time)), 'time_zone_id' => $teacher['time_zone_id'], 'time_zone_name' => $teacher['time_zone_name'], 'time_zone_offset' => $teacher['time_zone_offset'], ]; + //判断是否已经存在 $exit = TeacherFreeTime::where($free_data)->findOrEmpty(); @@ -204,6 +216,11 @@ class TeacherFreeTimeService if ($teacher_free_time->isEmpty()) { throw new Exception('未找到数据'); } +// $teacher = Teacher::where(['id' => $request->teacher->id])->findOrEmpty(); +// +// if ($teacher->isEmpty()) { +// throw new Exception('未找到教师信息,设置失败'); +// } $data = $request->post(); @@ -223,17 +240,31 @@ class TeacherFreeTimeService $en_time_period = explode('-', $en_time); $firstDate = new DateTime($free_date . ' ' . trim($time_period[0])); $secondDate = new DateTime($free_date . ' ' . trim($time_period[1])); - $diff = $secondDate->diff($firstDate); + $enFirstDate = new DateTime($free_date . ' ' . trim($en_time_period[0])); + $enSecondDate = new DateTime($free_date . ' ' . trim($en_time_period[1])); + + //根据时区计算教师国内时间 + $start_time = date('Y-m-d H:i:s', strtotime( $teacher_free_time['time_zone_offset'] . ' hour', $enFirstDate->getTimestamp())); + $end_time = date('Y-m-d H:i:s', strtotime( $teacher_free_time['time_zone_offset'] . ' hour', $enSecondDate->getTimestamp())); + + $diff = $enSecondDate->diff($enFirstDate); $h = $diff->h; $m = round($diff->i / 60, 2); $hour = round($h + $m, 2); $time = $time_period[0] . ' - ' . $time_period[1]; $teacher_free_time->save([ - 'date' => $free_date, + 'date' => date('Y-m-d', strtotime($start_time)), + 'en_date' => $free_date, 'time' => $time, - 'hour' => $hour, 'en_time' => implode(' - ', $en_time_period), + 'hour' => $hour, + 'start_time' => $start_time, + 'end_time' => $end_time, + 'en_start_time' => date('Y-m-d H:i:s', $enFirstDate->getTimestamp()), + 'en_end_time' => date('Y-m-d H:i:s', $enSecondDate->getTimestamp()), + 'en_month' => date('Y-m', strtotime($free_date)), + 'month' => date('Y-m', strtotime($start_time)), ]); return [ diff --git a/plugin/admin/app/controller/TeacherFreeTimeController.php b/plugin/admin/app/controller/TeacherFreeTimeController.php index 8cefe48..a397e95 100644 --- a/plugin/admin/app/controller/TeacherFreeTimeController.php +++ b/plugin/admin/app/controller/TeacherFreeTimeController.php @@ -95,6 +95,7 @@ class TeacherFreeTimeController extends Crud if ($request->method() === 'POST') { $postData = $request->post(); + try { $teacher = Teacher::where(['id'=> $request->post('teacher_id')])->findOrEmpty(); if($teacher->isEmpty()){ @@ -104,7 +105,9 @@ class TeacherFreeTimeController extends Crud $teacher_free_time = \app\common\model\TeacherFreeTime::where([ 'teacher_id' => $postData['teacher_id'], 'date' => $postData['date'], + 'en_date' => $postData['en_date'], 'month' => $postData['month'], + 'en_month' => $postData['en_month'], 'time' => $postData['time'], 'en_time' => $postData['en_time'], 'time_zone_id' => $teacher['time_zone_id'], @@ -120,20 +123,26 @@ class TeacherFreeTimeController extends Crud $en_time_period = explode('-', $postData['en_time']); $firstDate = new DateTime($postData['date'] . ' ' . trim($time_period[0])); $secondDate = new DateTime($postData['date'] . ' ' . trim($time_period[1])); - $enFirstDate = new DateTime($postData['date'] . ' ' . trim($en_time_period[0])); - $enSecondDate = new DateTime($postData['date'] . ' ' . trim($en_time_period[1])); + $enFirstDate = new DateTime($postData['en_date'] . ' ' . trim($en_time_period[0])); + $enSecondDate = new DateTime($postData['en_date'] . ' ' . trim($en_time_period[1])); + //根据时区计算教师国内时间 + $start_time = date('Y-m-d H:i:s', strtotime( $teacher['time_zone_offset'] . ' hour', $enFirstDate->getTimestamp())); + $end_time = date('Y-m-d H:i:s', strtotime( $teacher['time_zone_offset'] . ' hour', $enSecondDate->getTimestamp())); + \app\common\model\TeacherFreeTime::create([ 'teacher_id' => $request->post('teacher_id'), 'date' => $request->post('date'), + 'en_date' => $request->post('en_date'), 'month' => $request->post('month'), + 'en_month' => $request->post('en_month'), 'time' => $request->post('time'), 'en_time' => $request->post('en_time'), 'hour' => $request->post('hour'), - 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), - 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), + 'start_time' => $start_time, + 'end_time' => $end_time, 'en_start_time' => date('Y-m-d H:i:s', $enFirstDate->getTimestamp()), 'en_end_time' => date('Y-m-d H:i:s', $enSecondDate->getTimestamp()), 'time_zone_id' => $teacher['time_zone_id'], @@ -183,18 +192,26 @@ class TeacherFreeTimeController extends Crud $en_time_period = explode('-', $postData['en_time']); $firstDate = new DateTime($postData['date'] . ' ' . trim($time_period[0])); $secondDate = new DateTime($postData['date'] . ' ' . trim($time_period[1])); - $enFirstDate = new DateTime($postData['date'] . ' ' . trim($en_time_period[0])); - $enSecondDate = new DateTime($postData['date'] . ' ' . trim($en_time_period[1])); + $enFirstDate = new DateTime($postData['en_date'] . ' ' . trim($en_time_period[0])); + $enSecondDate = new DateTime($postData['en_date'] . ' ' . trim($en_time_period[1])); + + + + //根据时区计算教师国内时间 + $start_time = date('Y-m-d H:i:s', strtotime( $teacher_free_time['time_zone_offset'] . ' hour', $enFirstDate->getTimestamp())); + $end_time = date('Y-m-d H:i:s', strtotime( $teacher_free_time['time_zone_offset'] . ' hour', $enSecondDate->getTimestamp())); $teacher_free_time->save([ 'teacher_id' => $postData['teacher_id'], - 'date' => $postData['date'], - 'month' => $postData['month'], - 'time' => $postData['time'], - 'en_time' => $postData['en_time'], - 'hour' => $postData['hour'], - 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), - 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), + 'date' => $request->post('date'), + 'en_date' => $request->post('en_date'), + 'month' => $request->post('month'), + 'en_month' => $request->post('en_month'), + 'time' => $request->post('time'), + 'en_time' => $request->post('en_time'), + 'hour' => $request->post('hour'), + 'start_time' => $start_time, + 'end_time' => $end_time, 'en_start_time' => date('Y-m-d H:i:s', $enFirstDate->getTimestamp()), 'en_end_time' => date('Y-m-d H:i:s', $enSecondDate->getTimestamp()), ]); diff --git a/plugin/admin/app/controller/TeacherScheduleTimeController.php b/plugin/admin/app/controller/TeacherScheduleTimeController.php index a902a94..ffcc217 100644 --- a/plugin/admin/app/controller/TeacherScheduleTimeController.php +++ b/plugin/admin/app/controller/TeacherScheduleTimeController.php @@ -167,9 +167,8 @@ class TeacherScheduleTimeController extends Crud foreach ($data['schedule_en_time'] as $item) { $time_period = explode(' - ', $item); - $start_time = strtotime($free_time->date . ' ' . trim($time_period[0])); - $end_time = strtotime($free_time->date . ' ' . trim($time_period[1])); - + $start_time = strtotime($free_time->en_date . ' ' . trim($time_period[0])); + $end_time = strtotime($free_time->en_date . ' ' . trim($time_period[1])); if (!(strtotime($free_time->en_start_time) <= $start_time && strtotime($free_time->en_end_time) >= $end_time)) { throw new Exception('时间' . $item . '不在老师空闲范围内'); } @@ -213,8 +212,8 @@ class TeacherScheduleTimeController extends Crud $en_time_period = explode(' - ', $data['schedule_en_time'][$index]); $start_time = $free_time->date . ' ' . trim($time_period[0]); $end_time = $free_time->date . ' ' . trim($time_period[1]); - $en_start_time = $free_time->date . ' ' . trim($en_time_period[0]); - $en_end_time = $free_time->date . ' ' . trim($en_time_period[1]); + $en_start_time = $free_time->en_date . ' ' . trim($en_time_period[0]); + $en_end_time = $free_time->en_date . ' ' . trim($en_time_period[1]); $firstDate = new DateTime($start_time); $secondDate = new DateTime($end_time); @@ -229,6 +228,7 @@ class TeacherScheduleTimeController extends Crud $teacher_schedule_time->save([ 'teacher_id' => $free_time->teacher_id, 'date' => $free_time->date, + 'en_date' => $free_time->en_date, 'time' => $time, 'en_time' => $data['schedule_en_time'][$index], 'hour' => $hour, @@ -237,6 +237,7 @@ class TeacherScheduleTimeController extends Crud 'en_start_time' => $en_start_time, 'en_end_time' => $en_end_time, 'month' => $free_time->month, + 'en_month' => $free_time->en_month, 'subject_id' => $data['subject_id'][$index], 'free_time_id' => $free_time->id, ]); @@ -244,6 +245,7 @@ class TeacherScheduleTimeController extends Crud $teacher_schedule_time = \app\common\model\TeacherScheduleTime::create([ 'teacher_id' => $free_time->teacher_id, 'date' => $free_time->date, + 'en_date' => $free_time->en_date, 'time' => $time, 'en_time' => $data['schedule_en_time'][$index], 'hour' => $hour, @@ -252,6 +254,7 @@ class TeacherScheduleTimeController extends Crud 'en_start_time' => $en_start_time, 'en_end_time' => $en_end_time, 'month' => $free_time->month, + 'en_month' => $free_time->en_month, 'subject_id' => $data['subject_id'][$index], 'free_time_id' => $free_time->id, ]); @@ -274,6 +277,7 @@ class TeacherScheduleTimeController extends Crud 'teacher_id' => $free_time->teacher_id, 'subject_id' => $data['subject_id'][$index], 'date' => $free_time->date, + 'en_date' => $free_time->en_date, 'time' => $time, 'en_time' => $data['schedule_en_time'][$index], 'hour' => $hour, @@ -282,6 +286,7 @@ class TeacherScheduleTimeController extends Crud 'en_start_time' => $en_start_time, 'en_end_time' => $en_end_time, 'month' => $free_time->month, + 'en_month' => $free_time->en_month, ]); } else { $student_schedule->save([ @@ -291,6 +296,7 @@ class TeacherScheduleTimeController extends Crud 'teacher_id' => $free_time->teacher_id, 'subject_id' => $data['subject_id'][$index], 'date' => $free_time->date, + 'en_date' => $free_time->en_date, 'time' => $time, 'en_time' => $data['schedule_en_time'][$index], 'hour' => $hour, @@ -299,6 +305,7 @@ class TeacherScheduleTimeController extends Crud 'en_start_time' => $en_start_time, 'en_end_time' => $en_end_time, 'month' => $free_time->month, + 'en_month' => $free_time->en_month, ]); } } diff --git a/plugin/admin/app/view/student-homework/index.html b/plugin/admin/app/view/student-homework/index.html index 4034290..683e18c 100644 --- a/plugin/admin/app/view/student-homework/index.html +++ b/plugin/admin/app/view/student-homework/index.html @@ -152,24 +152,35 @@ },{ title: "学生",align: "center", field: "student_name", + width: 120 },{ title: "教师",align: "center", field: "teacher_name", + width: 120 },{ - title: "日期",align: "center", - field: "date", + title: "本地日期",align: "center", + field: "en_date", + width: 120 },{ title: "本地时间",align: "center", field: "en_time", + width: 120 + },{ + title: "中国日期",align: "center", + field: "date", + width: 120 },{ title: "中国时间",align: "center", field: "time", + width: 120 },{ title: "课程English",align: "center", field: "english_name", + width: 120 },{ title: "课程",align: "center", field: "subject_name", + width: 120 },{ title: "家庭作业反馈地址",align: "center", field: "feedback_file_url", @@ -205,6 +216,7 @@ },{ title: "创建时间",align: "center", field: "created_at", + width: 160 },{ title: "更新时间",align: "center", field: "update_at", diff --git a/plugin/admin/app/view/student-schedule/index.html b/plugin/admin/app/view/student-schedule/index.html index 0a31010..27b3b2c 100644 --- a/plugin/admin/app/view/student-schedule/index.html +++ b/plugin/admin/app/view/student-schedule/index.html @@ -203,23 +203,29 @@ field: "week", width: 80 }, { - title: "日期", align: "center", - field: "date", + title: "本地日期", align: "center", + field: "en_date", width: 150 - }, { - title: "中国时间", align: "center", - field: "time", - width: 120 }, { title: "本地时间", align: "center", field: "en_time", width: 120 + }, { + title: "中国日期", align: "center", + field: "date", + width: 120 + }, { + title: "中国时间", align: "center", + field: "time", + width: 120 }, { title: "学科", align: "center", field: "subject_name", + width: 120 }, { title: "教师", align: "center", field: "teacher_name", + width: 120 },{ title: "学生", align: "center", field: "student_name", @@ -244,11 +250,13 @@ field: "end_time", hide: true }, { - title: "月份", align: "center", + title: "中国月份", align: "center", field: "month", + width: 120 }, { title: "是否发布", align: "center", field: "is_publish", + width: 120, templet: function (d) { let field = "is_publish"; form.on("switch(" + field + ")", function (data) { diff --git a/plugin/admin/app/view/teacher-free-time/index.html b/plugin/admin/app/view/teacher-free-time/index.html index 9e063d6..3ddf6df 100644 --- a/plugin/admin/app/view/teacher-free-time/index.html +++ b/plugin/admin/app/view/teacher-free-time/index.html @@ -147,17 +147,23 @@ title: "教师",align: "center", field: "teacher_name", },{ - title: "月份",align: "center", + title: "当地月份",align: "center", + field: "en_month", + },{ + title: "当地日期",align: "center", + field: "en_date", + },{ + title: "当地时间",align: "center", + field: "en_time", + },{ + title: "中国月份",align: "center", field: "month", },{ - title: "日期",align: "center", - field: "date", - },{ + title: "中国日期",align: "center", + field: "date", + },{ title: "中国时间",align: "center", field: "time", - },{ - title: "当地时间",align: "center", - field: "en_time", },{ title: "课时/h",align: "center", field: "hour", @@ -186,6 +192,7 @@ },{ title: "创建时间",align: "center", field: "created_at", + width: 160 },{ title: "更新时间",align: "center", field: "updated_at", diff --git a/plugin/admin/app/view/teacher-free-time/insert.html b/plugin/admin/app/view/teacher-free-time/insert.html index 2693119..1148153 100644 --- a/plugin/admin/app/view/teacher-free-time/insert.html +++ b/plugin/admin/app/view/teacher-free-time/insert.html @@ -1,244 +1,425 @@ -
- -