Adding new options in the company report see BT#5778

1.9.x
Julio Montoya 11 years ago
parent 69300e8148
commit 99b4c84518
  1. 26
      main/inc/ajax/model.ajax.php
  2. 36
      main/inc/lib/course.lib.php
  3. 8
      main/mySpace/company_reports.php
  4. 25
      main/mySpace/company_reports_resumed.php

@ -161,7 +161,12 @@ switch ($action) {
if ($action == 'get_user_course_report') {
$count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList);
} else {
$count = CourseManager::get_count_user_list_from_course_code(true, 'ruc', $courseCodeList, $userIdList);
$count = CourseManager::get_count_user_list_from_course_code(
true,
array('ruc'),
$courseCodeList,
$userIdList
);
}
break;
case 'get_course_exercise_medias':
@ -338,8 +343,6 @@ switch ($action) {
case 'get_user_course_report_resumed':
$columns = array(
'extra_ruc',
'extra_razon_social',
'extra_sector_actividad',
'training_hours',
'count_users',
'count_users_registered',
@ -349,8 +352,6 @@ switch ($action) {
$column_names = array(
get_lang('Company'),
get_lang('BusinessName'),
get_lang('Activity'),
get_lang('TrainingHoursAccumulated'),
get_lang('CountOfSubscriptions'),
get_lang('CountOfUsers'),
@ -358,6 +359,18 @@ switch ($action) {
get_lang('CountCertificates')
);
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
if (!empty($extra_fields)) {
foreach ($extra_fields as $extra) {
if ($extra['1'] == 'ruc') {
continue;
}
$columns[] = $extra['1'];
$column_names[] = $extra['3'];
}
}
$result = CourseManager::get_user_list_from_course_code(
null,
null,
@ -367,7 +380,7 @@ switch ($action) {
null,
true,
true,
array('ruc', 'razon_social', 'sector_actividad'),
array('ruc'),
$courseCodeList,
$userIdList
);
@ -414,6 +427,7 @@ switch ($action) {
$courseCodeList,
$userIdList
);
break;
case 'get_user_skill_ranking':
$columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');

@ -1165,7 +1165,7 @@ class CourseManager
* @param bool $resumed_report
* @param array $extra_field
* @param array $courseCodeList
* @param array $userList
* @param array $userIdList
* @param string $filterByActive
* @return array|int
*/
@ -1294,9 +1294,8 @@ class CourseManager
$rs = Database::query($sql);
$users = array();
if ($add_reports) {
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
}
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
$counter = 1;
$count_rows = Database::num_rows($rs);
@ -1330,7 +1329,7 @@ class CourseManager
$course_code = $user['code'];
if ($resumed_report) {
foreach ($extra_fields as $extra) {
if ($extra['1'] == $extra_field) {
if (in_array($extra['1'], $extra_field)) {
$user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']);
break;
}
@ -1370,6 +1369,20 @@ class CourseManager
if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) {
$users[$row_key]['count_certificates']++;
}
foreach ($extra_fields as $extra) {
if ($extra['1'] == 'ruc') {
continue;
}
if (!isset($users[$row_key][$extra['1']])) {
$user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']);
if (!empty($user_data[$extra['1']])) {
$users[$row_key][$extra['1']] = $user_data[$extra['1']];
}
}
}
} else {
$report_info['course'] = $user['title'];
$report_info['user'] = api_get_person_name($user['firstname'], $user['lastname']);
@ -1381,8 +1394,6 @@ class CourseManager
$report_info['certificate'] = Display::label(get_lang('Yes'), 'success');
}
//$report_info['score'] = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), 0);
$progress = intval(Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), 0));
$report_info['progress_100'] = $progress == 100 ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No'));
$report_info['progress'] = $progress."%";
@ -1397,27 +1408,20 @@ class CourseManager
$users[$user['user_id']] = $user_info;
}
}
$counter++;
}
if ($add_reports) {
if ($resumed_report) {
//var_dump($counter);
}
}
return $users;
}
/**
* @param bool $resumed_report
* @param string $extra_field
* @param array $extra_field
* @param array $courseCodeList
* @param array $userIdList
* @return array|int
*/
static function get_count_user_list_from_course_code(
$resumed_report = false,
$extra_field = null,
$extra_field = array(),
$courseCodeList = array(),
$userIdList = array()
) {

@ -40,8 +40,8 @@ $columns = array(
//Column config
$column_model = array(
array('name'=>'course', 'index'=>'title', 'width'=>'180', 'align'=>'left'),
array('name'=>'user', 'index'=>'user', 'width'=>'100', 'align'=>'left','sortable'=>'false'),
array('name'=>'course', 'index'=>'title', 'width'=>'180', 'align'=>'left', 'wrap_cell' => 'true'),
array('name'=>'user', 'index'=>'user', 'width'=>'100', 'align'=>'left','sortable'=>'false', 'wrap_cell' => 'true'),
array('name'=>'time', 'index'=>'time', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'certificate', 'index'=>'certificate', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'progress_100', 'index'=>'progress_100', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
@ -53,9 +53,9 @@ if (!empty($extra_fields)) {
$col = array(
'name' => $extra['1'],
'index' => $extra['1'],
'width' =>'120',
'width' => '120',
'sortable' =>'false',
'wrap_cell' => "true"
'wrap_cell' => 'true'
);
$column_model[] = $col;

@ -30,8 +30,6 @@ $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('BusinessName'),
get_lang('Activity'),
get_lang('TrainingHoursAccumulated'),
get_lang('CountOfSubscriptions'),
get_lang('CountOfUsers'),
@ -41,9 +39,7 @@ $columns = array(
// Column config.
$column_model = array(
array('name' => 'extra_ruc', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => "true"),
array('name' => 'extra_razon_social', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => "true"),
array('name' => 'extra_sector_actividad', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => "true"),
array('name' => 'extra_ruc', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'),
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'),
@ -51,6 +47,25 @@ $column_model = array(
array('name' => 'count_certificates', 'index' => 'count_certificates', 'width' => '100', 'align' => 'left', 'sortable' => 'false'),
);
if (!empty($extra_fields)) {
foreach ($extra_fields as $extra) {
if ($extra['1'] == 'ruc') {
continue;
}
$col = array(
'name' => $extra['1'],
'index' => $extra['1'],
'width' => '120',
'sortable' =>'false',
'wrap_cell' => 'true'
);
$column_model[] = $col;
$columns[] = $extra['3'];
}
}
// Autowidth.
$extra_params['autowidth'] = 'true';
//height auto

Loading…
Cancel
Save