career_dashboard.php 4.2 KB

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