career_dashboard.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Careers dashboard.
  5. *
  6. * @package chamilo.admin.career
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $allowCareer = api_get_configuration_value('allow_session_admin_read_careers');
  11. api_protect_admin_script($allowCareer);
  12. $this_section = SECTION_PLATFORM_ADMIN;
  13. //Adds the JS needed to use the jqgrid
  14. $htmlHeadXtra[] = api_get_jqgrid_js();
  15. // setting breadcrumbs
  16. $interbreadcrumb[] = [
  17. 'url' => 'index.php',
  18. 'name' => get_lang('PlatformAdmin'),
  19. ];
  20. $interbreadcrumb[] = [
  21. 'url' => 'career_dashboard.php',
  22. 'name' => get_lang('CareersAndPromotions'),
  23. ];
  24. $tpl = new Template(get_lang('CareersAndPromotions'));
  25. $html = null;
  26. $form = new FormValidator('filter_form', 'GET', api_get_self());
  27. $career = new Career();
  28. $condition = ['status = ?' => 1];
  29. if ($form->validate()) {
  30. $data = $form->getSubmitValues();
  31. $filter = intval($data['filter']);
  32. if (!empty($filter)) {
  33. $condition = ['status = ? AND id = ? ' => [1, $filter]];
  34. }
  35. }
  36. $careers = $career->get_all(['status = ?' => 1]); //only status =1
  37. $career_select_list = [];
  38. $career_select_list[0] = ' -- '.get_lang('Select').' --';
  39. foreach ($careers as $item) {
  40. $career_select_list[$item['id']] = $item['name'];
  41. }
  42. $form->addSelect(
  43. 'filter',
  44. get_lang('Career'),
  45. $career_select_list,
  46. ['id' => 'filter_1']
  47. );
  48. $form->addButtonSearch(get_lang('Filter'));
  49. // action links
  50. $actionLeft = Display::url(
  51. Display::return_icon(
  52. 'back.png',
  53. get_lang('BackTo').' '.get_lang('PlatformAdmin'),
  54. null,
  55. ICON_SIZE_MEDIUM
  56. ),
  57. '../admin/index.php'
  58. );
  59. $actionLeft .= Display::url(
  60. Display::return_icon(
  61. 'career.png',
  62. get_lang('Careers'),
  63. null,
  64. ICON_SIZE_MEDIUM
  65. ),
  66. 'careers.php'
  67. );
  68. if (api_is_platform_admin()) {
  69. $actionLeft .= Display::url(
  70. Display::return_icon(
  71. 'promotion.png',
  72. get_lang('Promotions'),
  73. null,
  74. ICON_SIZE_MEDIUM
  75. ),
  76. 'promotions.php'
  77. );
  78. }
  79. $actions = Display::toolbarAction('toolbar-career', [$actionLeft]);
  80. $html .= $form->returnForm();
  81. $careers = $career->get_all($condition); //only status =1
  82. $column_count = 3;
  83. $i = 0;
  84. $grid_js = '';
  85. $career_array = [];
  86. if (!empty($careers)) {
  87. foreach ($careers as $career_item) {
  88. $promotion = new Promotion();
  89. // Getting all promotions
  90. $promotions = $promotion->get_all_promotions_by_career_id(
  91. $career_item['id'],
  92. 'name ASC'
  93. );
  94. $career_content = '';
  95. $promotion_array = [];
  96. if (!empty($promotions)) {
  97. foreach ($promotions as $promotion_item) {
  98. if ($promotion_item['status'] == 0) {
  99. continue; //avoid status = 0
  100. }
  101. // Getting all sessions from this promotion
  102. $sessions = SessionManager::get_all_sessions_by_promotion(
  103. $promotion_item['id']
  104. );
  105. $session_list = [];
  106. foreach ($sessions as $session_item) {
  107. $course_list = SessionManager::get_course_list_by_session_id(
  108. $session_item['id']
  109. );
  110. $session_list[] = [
  111. 'data' => $session_item,
  112. 'courses' => $course_list,
  113. ];
  114. }
  115. $promotion_array[$promotion_item['id']] = [
  116. 'id' => $promotion_item['id'],
  117. 'name' => $promotion_item['name'],
  118. 'sessions' => $session_list,
  119. ];
  120. }
  121. }
  122. $career_array[$career_item['id']] = [
  123. 'name' => $career_item['name'],
  124. 'promotions' => $promotion_array,
  125. ];
  126. $careerList = [
  127. 'promotions' => $promotion_array,
  128. ];
  129. $careers[$career_item['id']]['career'] = $careerList;
  130. }
  131. }
  132. $tpl->assign('actions', $actions);
  133. $tpl->assign('form_filter', $html);
  134. $tpl->assign('data', $careers);
  135. $layout = $tpl->get_template('admin/career_dashboard.tpl');
  136. $tpl->display($layout);