|
|
|
@ -24,22 +24,56 @@ $toolName = get_lang('TeacherTimeReport'); |
|
|
|
|
// Access restrictions. |
|
|
|
|
api_protect_admin_script(); |
|
|
|
|
|
|
|
|
|
$form = new FormValidator('teacher_time_report'); |
|
|
|
|
|
|
|
|
|
$startDate = new DateTime(api_get_local_time()); |
|
|
|
|
$startDate->modify('first day of this month'); |
|
|
|
|
|
|
|
|
|
$limitDate = new DateTime(api_get_local_time()); |
|
|
|
|
|
|
|
|
|
$selectedCourse = isset($_REQUEST['course']) ? $_REQUEST['course'] : null; |
|
|
|
|
$selectedSession = isset($_REQUEST['session']) ? $_REQUEST['session'] : 0; |
|
|
|
|
$selectedTeacher = isset($_REQUEST['teacher']) ? $_REQUEST['teacher'] : 0; |
|
|
|
|
$selectedFrom = isset($_REQUEST['from']) && !empty($_REQUEST['from']) ? $_REQUEST['from'] : $startDate->format('Y-m-d'); |
|
|
|
|
$selectedUntil = isset($_REQUEST['from']) && !empty($_REQUEST['until']) ? $_REQUEST['until'] : $limitDate->format('Y-m-d'); |
|
|
|
|
$selectedCourse = null; |
|
|
|
|
$selectedSession = 0; |
|
|
|
|
$selectedTeacher = 0; |
|
|
|
|
$selectedFrom = $startDate->format('Y-m-d'); |
|
|
|
|
$selectedUntil = $limitDate->format('Y-m-d'); |
|
|
|
|
|
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$formValues = $form->getSubmitValues(); |
|
|
|
|
|
|
|
|
|
$selectedCourse = $formValues['course']; |
|
|
|
|
$selectedSession = $formValues['session']; |
|
|
|
|
$selectedTeacher = $formValues['teacher']; |
|
|
|
|
|
|
|
|
|
if (!empty($formValues['from'])) { |
|
|
|
|
$selectedFrom = $formValues['from']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($formValues['until'])) { |
|
|
|
|
$selectedUntil = $formValues['until']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$optionsCourses = [0 => get_lang('None')]; |
|
|
|
|
$optionsSessions = [0 => get_lang('None')]; |
|
|
|
|
$optionsTeachers = [0 => get_lang('None')]; |
|
|
|
|
|
|
|
|
|
$courseList = CourseManager::get_courses_list(0, 0, 'title'); |
|
|
|
|
$sessionsList = SessionManager::get_sessions_list(array(), array('name')); |
|
|
|
|
|
|
|
|
|
$teacherList = UserManager::getTeachersList(); |
|
|
|
|
|
|
|
|
|
foreach ($courseList as $courseItem) { |
|
|
|
|
$optionsCourses[$courseItem['code']] = $courseItem['title']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($sessionsList as $sessionItem) { |
|
|
|
|
$optionsSessions[$sessionItem['id']] = $sessionItem['name']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($teacherList as $teacherItem) { |
|
|
|
|
$optionsTeachers[$teacherItem['user_id']] = $teacherItem['completeName']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$withFilter = false; |
|
|
|
|
|
|
|
|
|
$reportTitle = get_lang('TimeReportIncludingAllCoursesAndSessionsByTeacher'); |
|
|
|
@ -292,19 +326,52 @@ if (isset($_GET['export'])) { |
|
|
|
|
die; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// view |
|
|
|
|
//hack for daterangepicker |
|
|
|
|
$startDate->modify('+1 day'); |
|
|
|
|
$limitDate->modify('+1 day'); |
|
|
|
|
$form->addSelect( |
|
|
|
|
'course', |
|
|
|
|
get_lang('Course'), |
|
|
|
|
$optionsCourses, |
|
|
|
|
['id' => 'courses'] |
|
|
|
|
); |
|
|
|
|
$form->addSelect( |
|
|
|
|
'session', |
|
|
|
|
get_lang('Session'), |
|
|
|
|
$optionsSessions, |
|
|
|
|
['id' => 'session'] |
|
|
|
|
); |
|
|
|
|
$form->addSelect( |
|
|
|
|
'teacher', |
|
|
|
|
get_lang('Teacher'), |
|
|
|
|
$optionsTeachers, |
|
|
|
|
['id' => 'teacher'] |
|
|
|
|
); |
|
|
|
|
$form->addDateRangePicker( |
|
|
|
|
'daterange', |
|
|
|
|
get_lang('Date'), |
|
|
|
|
false, |
|
|
|
|
[ |
|
|
|
|
'id' => 'daterange', |
|
|
|
|
'maxDate' => $limitDate->format('Y-m-d'), |
|
|
|
|
'format' => 'YYYY-MM-DD', |
|
|
|
|
'timePicker' => 'false', |
|
|
|
|
'value' => "$selectedFrom / $selectedUntil" |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$form->addButtonFilter(get_lang('Filter')); |
|
|
|
|
$form->addHidden('from', ''); |
|
|
|
|
$form->addHidden('until', ''); |
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'course' => $selectedCourse, |
|
|
|
|
'session' => $selectedSession, |
|
|
|
|
'teacher' => $selectedTeacher, |
|
|
|
|
'date_range' => "$selectedFrom / $selectedUntil", |
|
|
|
|
'from' => $selectedFrom, |
|
|
|
|
'until' => $selectedUntil |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$tpl = new Template($toolName); |
|
|
|
|
$tpl->assign('reportTitle', $reportTitle); |
|
|
|
|
$tpl->assign('reportSubTitle', $reportSubTitle); |
|
|
|
|
|
|
|
|
|
$tpl->assign('filterStartDate', $startDate->format('Y-m-d')); |
|
|
|
|
$tpl->assign('filterEndDate', $limitDate->format('Y-m-d')); |
|
|
|
|
$tpl->assign('filterMaxDate', $limitDate->format('Y-m-d')); |
|
|
|
|
|
|
|
|
|
$tpl->assign('selectedCourse', $selectedCourse); |
|
|
|
|
$tpl->assign('selectedSession', $selectedSession); |
|
|
|
|
$tpl->assign('selectedTeacher', $selectedTeacher); |
|
|
|
@ -317,6 +384,8 @@ $tpl->assign('courses', $courseList); |
|
|
|
|
$tpl->assign('sessions', $sessionsList); |
|
|
|
|
$tpl->assign('courseCoaches', $teacherList); |
|
|
|
|
|
|
|
|
|
$tpl->assign('form', $form->returnForm()); |
|
|
|
|
|
|
|
|
|
$tpl->assign('rows', $timeReport->data); |
|
|
|
|
|
|
|
|
|
$contentTemplate = $tpl->get_template('admin/teacher_time_report.tpl'); |
|
|
|
|