From c6bcee3abb18a0c35f5f909b7c0681edba6a0651 Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Sat, 27 Nov 2010 12:21:03 +0300 Subject: [PATCH] Fixed bugs with date ranges --- locallib.php | 11 ++++++----- manage.php | 6 ++++-- report.php | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/locallib.php b/locallib.php index ddc1ba9..1f42c6c 100644 --- a/locallib.php +++ b/locallib.php @@ -299,8 +299,9 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing else set_current_date ($course->id, $current); - list($startdate, $enddate) = - print_filter_controls("view.php", $id, $studentid); + $ret = print_filter_controls("view.php", $id, $studentid); + $startdate = $ret['startdate']; + $enddate = $ret['enddate']; if ($startdate && $enddate) { $where = "ats.courseid={$course->id} AND al.studentid = {$user->id} AND ats.sessdate >= $startdate AND ats.sessdate < $enddate"; @@ -363,7 +364,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect case 'weeks': $format = get_string('strftimedm', 'attforblock'); $startdate = make_timestamp($year, $mon, $mday - $wday + 1); - $enddate = make_timestamp($year, $mon, $mday + 7 - $wday); + $enddate = make_timestamp($year, $mon, $mday + 7 - $wday + 1) - 1; $prevcur = $startdate - WEEKSECS; $nextcur = $startdate + WEEKSECS; $curdatetxt = userdate($startdate, $format)." - ".userdate($enddate, $format); @@ -378,7 +379,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect break; case 'alltaken': $startdate = 1; - $enddate = $current; + $enddate = time(); break; case 'all': $startdate = 0; @@ -520,7 +521,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect echo ""; - return array($startdate, $enddate, $currentgroup); + return array('startdate' => $startdate, 'enddate' => $enddate, 'currentgroup' => $currentgroup); } function plug_yui_calendar($current) { diff --git a/manage.php b/manage.php index d1d9e7a..d61952a 100644 --- a/manage.php +++ b/manage.php @@ -103,8 +103,10 @@ function print_sessions_list($course) { else set_current_date ($course->id, $current); - list($startdate, $enddate, $currentgroup) = - print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR); + $ret = print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR); + $startdate = $ret['startdate']; + $enddate = $ret['enddate']; + $currentgroup = $ret['currentgroup']; if ($startdate && $enddate) { $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; diff --git a/report.php b/report.php index 3fb6820..6f7d80d 100644 --- a/report.php +++ b/report.php @@ -68,8 +68,10 @@ else set_current_date ($course->id, $current); - list($startdate, $enddate, $currentgroup) = - print_filter_controls("report.php", $id, 0, $sort, GROUP_SELECTOR); + $ret = print_filter_controls("report.php", $id, 0, $sort, GROUP_SELECTOR); + $startdate = $ret['startdate']; + $enddate = $ret['enddate']; + $currentgroup = $ret['currentgroup']; if ($startdate && $enddate) { $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate";