diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index aed167aab5..1c374db383 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -244,8 +244,8 @@ switch ($action) { $result = Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $where_condition); break; case 'get_user_course_report_resumed': - $columns = array('extra_ruc', 'training_hours', 'count_users', 'average_hours_per_user', 'count_certificates'); - $column_names = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscribedUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')); + $columns = array('extra_ruc', 'training_hours', 'count_users', 'count_users_registered', 'average_hours_per_user', 'count_certificates'); + $column_names = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscriptions'), get_lang('CountOfUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')); $result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT $start, $limit", " $sidx $sord", null, null, true, true, 'ruc'); $new_result = array(); if (!empty($result)) { diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index f10d1c6ecb..6be16d858e 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1227,7 +1227,7 @@ class CourseManager { } return $result; } - + $table_user_field_value = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES); if ($count_rows) { while ($user = Database::fetch_array($rs)) { $report_info = array(); @@ -1270,6 +1270,20 @@ class CourseManager { $users[$row_key]['extra_'.$extra['1']] = $name; $users[$row_key]['training_hours'] += Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, 0); $users[$row_key]['count_users'] += $counter; + + $registered_users_with_extra_field = 0; + + if (!empty($name) && $name != '-') { + $name = Database::escape_string($name); + $sql = "SELECT count(user_id) as count FROM $table_user_field_value WHERE field_value = '$name'"; + $result_count = Database::query($sql); + if (Database::num_rows($result_count)) { + $row_count = Database::fetch_array($result_count); + $registered_users_with_extra_field = $row_count['count']; + } + } + + $users[$row_key]['count_users_registered'] = $registered_users_with_extra_field; $users[$row_key]['average_hours_per_user'] = $users[$row_key]['training_hours'] / $users[$row_key]['count_users']; $category = Category :: load (null, null, $course_code); diff --git a/main/mySpace/company_reports_resumed.php b/main/mySpace/company_reports_resumed.php index a54a3d9243..3f21b1266d 100644 --- a/main/mySpace/company_reports_resumed.php +++ b/main/mySpace/company_reports_resumed.php @@ -13,7 +13,7 @@ require_once '../inc/global.inc.php'; api_protect_admin_script(); -$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace')); +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('MySpace')); $tool_name = get_lang('Report'); @@ -27,32 +27,18 @@ $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report_resu $extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true); //The order is important you need to check the the $column variable in the model.ajax.php file -$columns = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscribedUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')); +$columns = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscriptions'), get_lang('CountOfUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')); //Column config $column_model = array( - array('name'=>'extra_ruc', 'index'=>'extra_ruc', 'width'=>'100', 'align'=>'left','sortable'=>'false'), - array('name'=>'training_hours', 'index'=>'training_hours', 'width'=>'100', 'align'=>'left'), - array('name'=>'count_users', 'index'=>'count_users', 'width'=>'100', 'align'=>'left','sortable'=>'false'), - array('name'=>'average_hours_per_user', 'index'=>'average_hours_per_user', 'width'=>'100', 'align'=>'left','sortable'=>'false'), - array('name'=>'count_certificates', 'index'=>'count_certificates', 'width'=>'100', 'align'=>'left','sortable'=>'false'), + array('name' => 'extra_ruc', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false'), + array('name' => 'training_hours', 'index' => 'training_hours', 'width' => '100', 'align' => 'left'), + array('name' => 'count_users', 'index' => 'count_users', 'width' => '100', 'align' => 'left', 'sortable' => 'false'), + array('name' => 'count_users_registered', 'index' => 'count_users_registered', 'width' => '100', 'align' => 'left', 'sortable' => 'false'), + array('name' => 'average_hours_per_user', 'index' => 'average_hours_per_user', 'width' => '100', 'align' => 'left', 'sortable' => 'false'), + array('name' => 'count_certificates', 'index' => 'count_certificates', 'width' => '100', 'align' => 'left', 'sortable' => 'false'), ); -/* -if (!empty($extra_fields)) { - foreach($extra_fields as $extra) { - $col = array( - 'name' => $extra['1'], - 'index'=> $extra['1'], - 'width'=>'120', - 'sortable'=>'false' - ); - $column_model[] = $col; - - $columns[] = $extra['3']; - } -}*/ - //Autowidth $extra_params['autowidth'] = 'true'; //height auto @@ -60,8 +46,7 @@ $extra_params['height'] = 'auto'; $htmlHeadXtra[] = '