diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 3f0b30037b..4160774217 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -276,7 +276,7 @@ switch ($action) { break; case 'get_session_access_overview': //@TODO replace this for a more efficient function (not retrieving the whole data) - $records = SessionManager::get_user_data_access_tracking_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['student_id']), 0, $options); + $records = SessionManager::get_user_data_access_tracking_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['student_id']), $_GET['profile'], $_GET['date_from'], $_GET['date_to'], $options); $count = count($records); break; case 'get_survey_overview': @@ -792,12 +792,15 @@ switch ($action) { $sessionId = 0; if (!empty($_GET['course_id']) && !empty($_GET['session_id'])) { - $sessionId = intval($_GET['session_id']); - $courseId = intval($_GET['course_id']); + $sessionId = intval($_GET['session_id']); + $courseId = intval($_GET['course_id']); $studentId = intval($_GET['student_id']); + $profile = intval($_GET['profile']); + $date_from = intval($_GET['date_from']); + $date_to = intval($_GET['date_to']); } - $result = SessionManager::get_user_data_access_tracking_overview(intval($sessionId), intval($courseId), intval($studentId), 0, + $result = SessionManager::get_user_data_access_tracking_overview(intval($sessionId), intval($courseId), intval($studentId), intval($profile), $date_to, $date_from, array( 'where' => $where_condition, 'order' => "$sidx $sord", @@ -1056,11 +1059,13 @@ if (in_array($action, $allowed_actions)) { } switch ($export_format) { case 'xls': + //TODO add date if exists $file_name = (!empty($action)) ? $action : 'company_report'; Export::export_table_xls($array, $file_name); break; case 'csv': default: + //TODO add date if exists $file_name = (!empty($action)) ? $action : 'company_report'; Export::export_table_csv($array, $file_name); break; diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 0fbcd92927..3f13a36d0a 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -1035,7 +1035,7 @@ class SessionManager * @author César Perales , Beeznest Team * @version Chamilo 1.9.6 */ - function get_user_data_access_tracking_overview($sessionId, $courseId, $studentId = 0, $profile = 0, $options) { + function get_user_data_access_tracking_overview($sessionId, $courseId, $studentId = 0, $profile = '', $date_from = '', $date_to = '', $options) { global $_configuration; // database table definition $user = Database :: get_main_table(TABLE_MAIN_USER); @@ -1063,6 +1063,14 @@ class SessionManager { $where .= sprintf(" AND u.user_id = %d", $studentId); } + if (!empty($date_to) && !empty($date_from)) + { + //FIX THIS + $to = substr($date_to, 0, 4) .'-' . substr($date_to, 4, 2) . '-' . substr($date_to, 6, 2); + $from = substr($date_from, 0, 4) . '-' . substr($date_from, 4, 2) . '-' . substr($date_from, 6, 2); + $where .= sprintf(" AND a.login_course_date >= '%s 00:00:00' + AND a.login_course_date <= '%s 23:59:59'", $to, $from); + } $limit = null; if (!empty($options['limit'])) { $limit = " LIMIT ".$options['limit']; @@ -1097,7 +1105,6 @@ class SessionManager INNER JOIN $user u ON a.user_id = u.user_id INNER JOIN $course c ON a.course_code = c.code $where $order $limit"; - $result = Database::query(sprintf($sql, $sessionId, $courseId)); $clicks = Tracking::get_total_clicks_by_session(); diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 18930df553..2aa3070ad7 100644 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -659,6 +659,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst //Student Filter if (in_array($display, array('accessoverview'))) { + $courseListUrl = api_get_self(); $studentFilter = new FormValidator('student_filter', 'get', '', '', array('class'=> 'form-search'), false); $url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_user_by_course&session_id=' . $_GET['session_id'] . '&course_id=' . $_GET['course_id']; $studentList = array(); @@ -669,24 +670,69 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst $studentList[] = array('id' => $studentInfo['id'], 'text' => $studentInfo['username']); } - $studentFilter->addElement('select_ajax', 'student_name', get_lang('SearchStudent'), null, array('url' => $url, 'defaults' => $studentList)); - //$studentFilter->addElement('datepicker', 'startdate', get_lang('StartDate'), array('form_name'=>'lp_add'), 5); - //$studentFilter->addElement('datepicker', 'enddate', get_lang('EndDate'), array('form_name'=>'lp_add', 'class' => 'block'), 3); - $courseListUrl = api_get_self(); + $studentFilter->addElement('text', 'from', get_lang('From'), array('id' => 'date_from'), array('defaults' => $_GET['date_from'])); + $studentFilter->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to'), $_GET['date_to']); + + $studentFilter->addElement('select_ajax', 'student_name', get_lang('SearchStudent'), null, array('url' => $url, 'defaults' => $studentList), array('class' => 'pull-left')); + $options = array( + '' => get_lang('Select'), + STUDENT => get_lang('Student'), + COURSEMANAGER => get_lang('CourseManager'), + DRH => get_lang('Drh'), + ); + $studentFilter->addElement('select', 'profile', get_lang('Profile'),$options, array('id' => 'profile')); echo '
'; echo $studentFilter->return_form(); echo '
'; + //TODO fix this hack + $date_to = (!empty($_GET['date_to'])) ? ' $(\'#date_to\').val(\'' . $_GET['date_to'] . '\'); ' : ''; + $date_from = (!empty($_GET['date_from'])) ? ' $(\'#date_from\').val(\'' . $_GET['date_from'] . '\'); ' : ''; echo ''; /*//profile filter @@ -728,7 +774,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst $exerciseInfo = survey_manager::get_survey($surveyId, 0, $course['code']); $surveyList[] = array('id' => $exerciseInfo['id'], 'text' => $exerciseInfo['title']); } - $surveyOverview->addElement('select_ajax', 'survey_name', get_lang('SearchExercise'), null, array('url' => $url, 'defaults' => $surveyList)); + $surveyOverview->addElement('select_ajax', 'survey_name', get_lang('SearchSurvey'), null, array('url' => $url, 'defaults' => $surveyList)); $courseListUrl = api_get_self(); echo '
'; @@ -814,12 +860,21 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst { if (!empty($_GET['course_id'])) { - if (!empty($_GET['student_id'])) + if(!empty($_GET['date_to']) && (!empty($_GET['date_from']))) { - echo MySpace::display_tracking_access_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['student_id']));; - } else + if (!empty($_GET['student_id'])) + { + echo MySpace::display_tracking_access_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['student_id']), '', $_GET['date_to'], $_GET['date_from']); + } else if (!empty($_GET['profile'])) + { + echo MySpace::display_tracking_access_overview(intval($_GET['session_id']), intval($_GET['course_id']), '', $_GET['profile'], $_GET['date_to'], $_GET['date_from']); + } else + { + Display::display_warning_message(get_lang('ChooseStudentOrProfile')); + } + } else { - Display::display_warning_message(get_lang('ChooseStudent')); + Display::display_warning_message(get_lang('ChooseStartDateAndEndDate')); } } else { @@ -883,7 +938,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst echo MySpace::display_survey_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['survey_id'])); } else { - Display::display_warning_message(get_lang('ChooseExercise')); + Display::display_warning_message(get_lang('ChooseSurvey')); } } else { diff --git a/main/mySpace/myspace.lib.php b/main/mySpace/myspace.lib.php index 99a94c0793..dcd0dbc0ea 100644 --- a/main/mySpace/myspace.lib.php +++ b/main/mySpace/myspace.lib.php @@ -578,7 +578,7 @@ class MySpace { * @author César Perales , Beeznest Team * @version Chamilo 1.9.6 */ - function display_tracking_access_overview($sessionId = 0, $courseId = 0, $studentId = 0) { + function display_tracking_access_overview($sessionId = 0, $courseId = 0, $studentId = '', $profile = '', $date_to, $date_from) { //The order is important you need to check the the $column variable in the model.ajax.php file $columns = array( get_lang('LoginDate'), @@ -602,7 +602,7 @@ class MySpace { $action_links = ''; // jqgrid will use this URL to do the selects - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_access_overview&session_id=' . $sessionId . '&course_id=' . $courseId . '&student_id=' . $studentId; + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_access_overview&session_id=' . $sessionId . '&course_id=' . $courseId . '&student_id=' . $studentId . '&profile=' . $profile . '&date_to=' . $date_to . '&date_from=' . $date_from; $tableId = 'accessOverview'; $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);