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