|
16 | 16 | $report = isset($_REQUEST['report']) ? $_REQUEST['report'] : ''; |
17 | 17 | $sessionDuration = isset($_GET['session_duration']) ? (int) $_GET['session_duration'] : ''; |
18 | 18 |
|
19 | | -if ($report) { |
| 19 | +if ($report == 'recentlogins') { |
20 | 20 | $htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js'); |
21 | 21 | $htmlHeadXtra[] = ' |
22 | 22 | <script> |
23 | | - $(document).ready(function() { |
24 | | - $.ajax({ |
25 | | - url: "'.api_get_path(WEB_CODE_PATH).'inc/ajax/statistics.ajax.php?a=recentlogins&session_duration='.$sessionDuration.'", |
26 | | - type: "POST", |
27 | | - success: function(data) { |
28 | | - Chart.defaults.global.responsive = true; |
29 | | - var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(data); |
30 | | - } |
| 23 | + $(document).ready(function() { |
| 24 | + $.ajax({ |
| 25 | + url: "'.api_get_path(WEB_CODE_PATH).'inc/ajax/statistics.ajax.php?a=recentlogins&session_duration='.$sessionDuration.'", |
| 26 | + type: "POST", |
| 27 | + success: function(data) { |
| 28 | + Chart.defaults.global.responsive = true; |
| 29 | + var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(data); |
| 30 | + } |
31 | 31 | }); |
32 | 32 | }); |
33 | 33 | </script>'; |
34 | 34 | } |
35 | 35 |
|
| 36 | +if ($report == 'user_session') { |
| 37 | + $htmlHeadXtra[] = api_get_jqgrid_js(); |
| 38 | +} |
| 39 | + |
36 | 40 | $tool_name = get_lang('Statistics'); |
37 | 41 | Display::display_header($tool_name); |
38 | 42 | echo Display::page_header($tool_name); |
|
62 | 66 | // system ... |
63 | 67 | $tools[$strSystem]['report=activities'] = get_lang('ImportantActivities'); |
64 | 68 |
|
| 69 | +if (api_is_global_platform_admin()) { |
| 70 | + $tools[$strSystem]['report=user_session'] = get_lang('PortalUserSessionStats'); |
| 71 | +} |
| 72 | + |
65 | 73 | // social ... |
66 | 74 | $tools[$strSocial]['report=messagesent'] = get_lang('MessagesSent'); |
67 | 75 | $tools[$strSocial]['report=messagereceived'] = get_lang('MessagesReceived'); |
|
81 | 89 | echo '</tr></table>'; |
82 | 90 |
|
83 | 91 | $course_categories = Statistics::getCourseCategories(); |
84 | | -echo '<br/><br/>'; //@todo: spaces between elements should be handled in the css, br should be removed if only there for presentation |
| 92 | +//@todo: spaces between elements should be handled in the css, br should be removed if only there for presentation |
| 93 | +echo '<br/><br/>'; |
85 | 94 |
|
86 | 95 | switch ($report) { |
| 96 | + case 'user_session': |
| 97 | + $form = new FormValidator('user_session', 'get'); |
| 98 | + $form->addDateRangePicker('range', get_lang('DateRange'), true); |
| 99 | + $form->addHidden('report', 'user_session'); |
| 100 | + $form->addButtonSearch(get_lang('Search')); |
| 101 | + |
| 102 | + $date = new DateTime($now); |
| 103 | + $startDate = $date->format('Y-m-d').' 00:00:00'; |
| 104 | + $endDate = $date->format('Y-m-d').' 23:59:59'; |
| 105 | + $start = $startDate; |
| 106 | + $end = $endDate; |
| 107 | + |
| 108 | + if ($form->validate()) { |
| 109 | + $values = $form->getSubmitValues(); |
| 110 | + $start = $values['range_start']; |
| 111 | + $end = $values['range_end']; |
| 112 | + } |
| 113 | + echo $form->returnForm(); |
| 114 | + |
| 115 | + $url = api_get_path(WEB_AJAX_PATH).'statistics.ajax.php?a=get_user_session&start='.$start.'&end='.$end; |
| 116 | + $columns = [ |
| 117 | + 'URL', |
| 118 | + get_lang('Session'), |
| 119 | + get_lang('CountUsers'), |
| 120 | + ]; |
| 121 | + |
| 122 | + $columnModel = [ |
| 123 | + [ |
| 124 | + 'name' => 'url', |
| 125 | + 'index' => 'url', |
| 126 | + 'width' => '180', |
| 127 | + 'align' => 'left', |
| 128 | + ], |
| 129 | + [ |
| 130 | + 'name' => 'session', |
| 131 | + 'index' => 'session', |
| 132 | + 'width' => '100', |
| 133 | + 'align' => 'left', |
| 134 | + ], |
| 135 | + [ |
| 136 | + 'name' => 'count', |
| 137 | + 'index' => 'count', |
| 138 | + 'width' => '500', |
| 139 | + 'align' => 'left', |
| 140 | + 'sortable' => 'false', |
| 141 | + ], |
| 142 | + ]; |
| 143 | + $extraParams['autowidth'] = 'true'; //use the width of the parent |
| 144 | + $extraParams['height'] = 'auto'; //use the width of the parent |
| 145 | + $actionLinks = ''; |
| 146 | + ?> |
| 147 | + <script> |
| 148 | + $(function() { |
| 149 | + <?php |
| 150 | + echo Display::grid_js( |
| 151 | + 'user_session_grid', |
| 152 | + $url, |
| 153 | + $columns, |
| 154 | + $columnModel, |
| 155 | + $extraParams, |
| 156 | + [], |
| 157 | + $actionLinks, |
| 158 | + true |
| 159 | + ); |
| 160 | + ?> |
| 161 | + }); |
| 162 | + </script> |
| 163 | + <?php |
| 164 | + echo Display::grid_html('user_session_grid'); |
| 165 | + |
| 166 | + break; |
87 | 167 | case 'courses': |
88 | 168 | // total amount of courses |
89 | 169 | foreach ($course_categories as $code => $name) { |
|
0 commit comments