company_reports.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Special report for corporate users
  5. * @package chamilo.reporting
  6. */
  7. /**
  8. * Code
  9. */
  10. $cidReset = true;
  11. require_once '../inc/global.inc.php';
  12. $userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true);
  13. if ($userNotAllowed) {
  14. api_not_allowed(true);
  15. }
  16. $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
  17. $tool_name = get_lang('Report');
  18. $this_section = SECTION_TRACKING;
  19. $htmlHeadXtra[] = api_get_jqgrid_js();
  20. $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : -1;
  21. //jqgrid will use this URL to do the selects
  22. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report&session_id='.$sessionId;
  23. $extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
  24. //The order is important you need to check the the $column variable in the model.ajax.php file
  25. $columns = array(
  26. get_lang('Course'),
  27. get_lang('User'),
  28. get_lang('ManHours'),
  29. get_lang('CertificateGenerated'),
  30. get_lang('Approved'),
  31. get_lang('CourseAdvance')
  32. );
  33. //Column config
  34. $column_model = array(
  35. array('name'=>'course', 'index'=>'title', 'width'=>'180', 'align'=>'left', 'wrap_cell' => 'true'),
  36. array('name'=>'user', 'index'=>'user', 'width'=>'100', 'align'=>'left','sortable'=>'false', 'wrap_cell' => 'true'),
  37. array('name'=>'time', 'index'=>'time', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
  38. array('name'=>'certificate', 'index'=>'certificate', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
  39. array('name'=>'progress_100', 'index'=>'progress_100', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
  40. array('name'=>'progress', 'index'=>'progress', 'width'=>'50', 'align'=>'left','sortable'=>'false')
  41. );
  42. if (!empty($extra_fields)) {
  43. foreach ($extra_fields as $extra) {
  44. $col = array(
  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[] = array('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, array(), 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('stats.png', get_lang('MyStats'), '', 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('Students'), array(), 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("CompanyReport"), array(), ICON_SIZE_MEDIUM),
  94. "#"
  95. );
  96. $actions .= Display::url(
  97. Display::return_icon(
  98. "certificate_list.png",
  99. get_lang("GradebookSeeListOfStudentsCertificates"),
  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("CompanyReportResumed"),
  112. api_get_path(WEB_CODE_PATH) . "mySpace/company_reports_resumed.php",
  113. array(
  114. 'class' => 'btn btn-success'
  115. )
  116. );
  117. $content .= '</div>';
  118. $content .= '<h1 class="page-header">' . get_lang('CompanyReport') . '</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();