|
@@ -16,7 +16,7 @@ $em = Database::getManager();
|
|
|
$sessionsInfo = SessionManager::get_sessions_list([], ['name']);
|
|
|
$session = null;
|
|
|
|
|
|
-$form = new FormValidator('teacher_time_report_by_session');
|
|
|
+$form = new FormValidator('teacher_time_report_by_session', 'GET');
|
|
|
$selectSession = $form->addSelect('session', get_lang('Session'), [0 => get_lang('None')]);
|
|
|
$form->addButtonFilter(get_lang('Filter'));
|
|
|
|
|
@@ -24,10 +24,11 @@ foreach ($sessionsInfo as $sessionInfo) {
|
|
|
$selectSession->addOption($sessionInfo['name'], $sessionInfo['id']);
|
|
|
}
|
|
|
|
|
|
-if ($form->validate()) {
|
|
|
+if (isset($_GET['session']) && intval($_GET['session'])) {
|
|
|
+ $form->setDefaults(['session' => intval($_GET['session'])]);
|
|
|
+
|
|
|
$sessionId = $form->exportValue('session');
|
|
|
- $session = $em
|
|
|
- ->find('ChamiloCoreBundle:Session', $sessionId);
|
|
|
+ $session = $em->find('ChamiloCoreBundle:Session', intval($_GET['session']));
|
|
|
}
|
|
|
|
|
|
$data = [];
|
|
@@ -91,6 +92,54 @@ if ($session) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+if (isset($_GET['export']) && $session && $data) {
|
|
|
+ $dataToExport = [];
|
|
|
+ $fileName = get_lang('TeacherTimeReport') . ' ' . api_get_local_time();
|
|
|
+
|
|
|
+ foreach ($data as $row) {
|
|
|
+ $headers = [
|
|
|
+ get_lang('OfficialCode'),
|
|
|
+ get_lang('Name'),
|
|
|
+ get_lang('TimeSpentOnThePlatform'),
|
|
|
+ get_lang('FirstLoginInPlatform'),
|
|
|
+ get_lang('LatestLoginInPlatform')
|
|
|
+ ];
|
|
|
+ $contents = [
|
|
|
+ $row['code'],
|
|
|
+ $row['complete_name'],
|
|
|
+ $row['time_in_platform'],
|
|
|
+ $row['first_connection'],
|
|
|
+ $row['last_connection']
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach ($row['courses'] as $course) {
|
|
|
+ $headers[] = $course['code'];
|
|
|
+ $headers[] = get_lang('NumberOfWorks');
|
|
|
+ $headers[] = get_lang('LastWork');
|
|
|
+ $headers[] = sprintf(get_lang('TimeReportForCourseX'), $course['code']);
|
|
|
+ $contents[] = $course['number_of_students'];
|
|
|
+ $contents[] = $course['number_of_works'];
|
|
|
+ $contents[] = $course['last_work'];
|
|
|
+ $contents[] = $course['time_spent_of_course'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $dataToExport[] = [get_lang('Session'), $session->getName()];
|
|
|
+
|
|
|
+ $dataToExport[] = $headers;
|
|
|
+ $dataToExport[] = $contents;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch ($_GET['export']) {
|
|
|
+ case 'xls':
|
|
|
+ Export::export_table_xls_html($dataToExport, $fileName);
|
|
|
+ break;
|
|
|
+ case 'csv':
|
|
|
+ Export::arrayToCsv($dataToExport, $fileName);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ exit;
|
|
|
+}
|
|
|
+
|
|
|
$this_section = SECTION_PLATFORM_ADMIN;
|
|
|
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
|
|
|
$interbreadcrumb[] = [
|
|
@@ -99,6 +148,21 @@ $interbreadcrumb[] = [
|
|
|
];
|
|
|
$toolName = get_lang('TeacherTimeReportBySession');
|
|
|
|
|
|
+$actions = [];
|
|
|
+
|
|
|
+if ($session) {
|
|
|
+ $actions = [
|
|
|
+ Display::url(
|
|
|
+ Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
|
|
|
+ api_get_self() . '?' . http_build_query(['export' => 'csv', 'session' => $session ? $session->getId() : 0])
|
|
|
+ ),
|
|
|
+ Display::url(
|
|
|
+ Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
|
|
|
+ api_get_self() . '?' . http_build_query(['export' => 'xls', 'session' => $session ? $session->getId() : 0])
|
|
|
+ )
|
|
|
+ ];
|
|
|
+}
|
|
|
+
|
|
|
$view = new Template($toolName);
|
|
|
$view->assign('form', $form->returnForm());
|
|
|
|
|
@@ -111,5 +175,6 @@ $template = $view->get_template('admin/teacher_time_report_by_session.tpl');
|
|
|
$content = $view->fetch($template);
|
|
|
|
|
|
$view->assign('header', $toolName);
|
|
|
+$view->assign('actions', implode(' ', $actions));
|
|
|
$view->assign('content', $content);
|
|
|
$view->display_one_col_template();
|