company_reports_resumed.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Special report for corporate users.
  5. *
  6. * @package chamilo.reporting
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true);
  11. if ($userNotAllowed) {
  12. api_not_allowed(true);
  13. }
  14. $interbreadcrumb[] = ['url' => api_is_student_boss() ? '#' : 'index.php', 'name' => get_lang('Reporting')];
  15. $tool_name = get_lang('Report');
  16. $this_section = SECTION_TRACKING;
  17. $htmlHeadXtra[] = api_get_jqgrid_js();
  18. $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : -1;
  19. // jqgrid will use this URL to do the selects
  20. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report_resumed&session_id='.$sessionId;
  21. $extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
  22. // The order is important you need to check the the $column variable in the model.ajax.php file.
  23. $columns = [
  24. get_lang('Company'),
  25. get_lang('Hours of accumulated training'),
  26. get_lang('Subscriptions count'),
  27. get_lang('Users count'),
  28. get_lang('Avg hours/student'),
  29. get_lang('Certificates count'),
  30. ];
  31. // Column config.
  32. $column_model = [
  33. ['name' => 'extra_ruc', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'],
  34. ['name' => 'training_hours', 'index' => 'training_hours', 'width' => '100', 'align' => 'left'],
  35. ['name' => 'count_users', 'index' => 'count_users', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
  36. ['name' => 'count_users_registered', 'index' => 'count_users_registered', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
  37. ['name' => 'average_hours_per_user', 'index' => 'average_hours_per_user', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
  38. ['name' => 'count_certificates', 'index' => 'count_certificates', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
  39. ];
  40. if (!empty($extra_fields)) {
  41. foreach ($extra_fields as $extra) {
  42. if ($extra['1'] == 'ruc') {
  43. continue;
  44. }
  45. $col = [
  46. 'name' => $extra['1'],
  47. 'index' => $extra['1'],
  48. 'width' => '120',
  49. 'sortable' => 'false',
  50. 'wrap_cell' => 'true',
  51. ];
  52. $column_model[] = $col;
  53. $columns[] = $extra['3'];
  54. }
  55. }
  56. // Autowidth.
  57. $extra_params['autowidth'] = 'true';
  58. //height auto
  59. $extra_params['height'] = 'auto';
  60. $htmlHeadXtra[] = '<script>
  61. $(function() {
  62. '.Display::grid_js('user_course_report', $url, $columns, $column_model, $extra_params, [], null, true).'
  63. jQuery("#user_course_report").jqGrid("navGrid","#user_course_report_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
  64. jQuery("#user_course_report").jqGrid("navButtonAdd","#user_course_report_pager",{
  65. caption:"",
  66. onClickButton : function () {
  67. jQuery("#user_course_report").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
  68. }
  69. });
  70. });
  71. </script>';
  72. $actions = null;
  73. if (api_is_student_boss()) {
  74. $actions .= Display::url(
  75. Display::return_icon('statistics.png', get_lang('View my progress'), '', ICON_SIZE_MEDIUM),
  76. api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
  77. );
  78. $actions .= Display::url(
  79. Display::return_icon('user.png', get_lang('Learners'), [], ICON_SIZE_MEDIUM),
  80. api_get_path(WEB_CODE_PATH)."mySpace/student.php"
  81. );
  82. $actions .= Display::url(
  83. Display::return_icon("statistics.png", get_lang("Corporate report"), [], ICON_SIZE_MEDIUM),
  84. api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php"
  85. );
  86. $actions .= Display::url(
  87. Display::return_icon(
  88. "certificate_list.png",
  89. get_lang("GradebookSeeListOfLearnersCertificates"),
  90. [],
  91. ICON_SIZE_MEDIUM
  92. ),
  93. api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php"
  94. );
  95. }
  96. $content = '<div class="actions">';
  97. if (!empty($actions)) {
  98. $content .= $actions;
  99. }
  100. if (!api_is_student_boss()) {
  101. $content .= Display::url(
  102. get_lang("Corporate report"),
  103. api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php",
  104. [
  105. 'class' => 'btn btn-success',
  106. ]
  107. );
  108. }
  109. $content .= '</div>';
  110. $content .= '<h1 class="page-header">'.get_lang('Corporate reportResumed').'</h1>';
  111. $content .= Display::grid_html('user_course_report');
  112. $tpl = new Template($tool_name);
  113. $tpl->assign('content', $content);
  114. $tpl->display_one_col_template();