company_reports.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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&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('Course'),
  25. get_lang('User'),
  26. get_lang('e-mail'),
  27. get_lang('Man hours'),
  28. get_lang('Generated certificate'),
  29. get_lang('Completed learning paths'),
  30. get_lang('Course progress'),
  31. ];
  32. //Column config
  33. $column_model = [
  34. ['name' => 'course', 'index' => 'title', 'width' => '180', 'align' => 'left', 'wrap_cell' => 'true'],
  35. ['name' => 'user', 'index' => 'user', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'],
  36. ['name' => 'email', 'index' => 'email', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'],
  37. ['name' => 'time', 'index' => 'time', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
  38. ['name' => 'certificate', 'index' => 'certificate', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
  39. ['name' => 'progress_100', 'index' => 'progress_100', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
  40. ['name' => 'progress', 'index' => 'progress', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
  41. ];
  42. if (!empty($extra_fields)) {
  43. foreach ($extra_fields as $extra) {
  44. $col = [
  45. 'name' => $extra['1'],
  46. 'index' => $extra['1'],
  47. 'width' => '120',
  48. 'sortable' => 'false',
  49. 'wrap_cell' => 'true',
  50. ];
  51. $column_model[] = $col;
  52. $columns[] = $extra['3'];
  53. }
  54. }
  55. if (api_is_student_boss()) {
  56. $column_model[] = ['name' => 'group', 'index' => 'group', 'width' => '50', 'align' => 'left', 'sortable' => 'false'];
  57. $columns[] = get_lang('Group');
  58. }
  59. // Autowidth
  60. $extra_params['autowidth'] = 'true';
  61. // height auto
  62. $extra_params['height'] = 'auto';
  63. $htmlHeadXtra[] = '<script>
  64. $(function() {
  65. '.Display::grid_js('user_course_report', $url, $columns, $column_model, $extra_params, [], null, true).'
  66. jQuery("#user_course_report").jqGrid("navGrid","#user_course_report_pager",{
  67. view:false,
  68. edit:false,
  69. add:false,
  70. del:false,
  71. search:false,
  72. excel:true
  73. });
  74. jQuery("#user_course_report").jqGrid("navButtonAdd","#user_course_report_pager", {
  75. caption:"",
  76. onClickButton : function () {
  77. jQuery("#user_course_report").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
  78. }
  79. });
  80. });
  81. </script>';
  82. $actions = null;
  83. if (api_is_student_boss()) {
  84. $actions .= Display::url(
  85. Display::return_icon('statistics.png', get_lang('View my progress'), '', ICON_SIZE_MEDIUM),
  86. api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
  87. );
  88. $actions .= Display::url(
  89. Display::return_icon('user.png', get_lang('Learners'), [], ICON_SIZE_MEDIUM),
  90. api_get_path(WEB_CODE_PATH)."mySpace/student.php"
  91. );
  92. $actions .= Display::url(
  93. Display::return_icon("statistics.png", get_lang("Corporate report"), [], ICON_SIZE_MEDIUM),
  94. "#"
  95. );
  96. $actions .= Display::url(
  97. Display::return_icon(
  98. "certificate_list.png",
  99. get_lang("GradebookSeeListOfLearnersCertificates"),
  100. [],
  101. ICON_SIZE_MEDIUM
  102. ),
  103. api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php"
  104. );
  105. }
  106. $content = '<div class="actions">';
  107. if (!empty($actions)) {
  108. $content .= $actions;
  109. }
  110. $content .= Display::url(
  111. get_lang("Corporate reportResumed"),
  112. api_get_path(WEB_CODE_PATH)."mySpace/company_reports_resumed.php",
  113. [
  114. 'class' => 'btn btn-success',
  115. ]
  116. );
  117. $content .= '</div>';
  118. $content .= '<h1 class="page-header">'.get_lang('Corporate report').'</h1>';
  119. $content .= Display::grid_html('user_course_report');
  120. $tpl = new Template($tool_name);
  121. $tpl->assign('content', $content);
  122. $tpl->display_one_col_template();