career_dashboard.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 '../inc/global.inc.php';
  9. $libpath = api_get_path(LIBRARY_PATH);
  10. api_protect_admin_script();
  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('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  16. $interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions'));
  17. Display :: display_header(null);
  18. $form = new FormValidator('filter_form','GET', api_get_self());
  19. $career = new Career();
  20. $condition = array('status = ?' => 1);
  21. if ($form->validate()) {
  22. $data = $form->getSubmitValues();
  23. $filter = intval($data['filter']);
  24. if (!empty($filter)) {
  25. $condition = array('status = ? AND id = ? ' => array(1, $filter));
  26. }
  27. }
  28. $careers = $career->get_all(array('status = ?' => 1)); //only status =1
  29. $career_select_list = array();
  30. $career_select_list[0] = ' -- '.get_lang('Select').' --';
  31. foreach ($careers as $item) {
  32. $career_select_list[$item['id']] = $item['name'];
  33. }
  34. $form->addSelect(
  35. 'filter',
  36. get_lang('Career'),
  37. $career_select_list,
  38. array('id' => 'filter_1')
  39. );
  40. $form->addButtonSearch(get_lang('Filter'));
  41. // action links
  42. echo '<div class="actions" style="margin-bottom:20px">';
  43. echo '<a href="../admin/index.php">'.
  44. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
  45. echo '<a href="careers.php">'.
  46. Display::return_icon('career.png',get_lang('Careers'),'',ICON_SIZE_MEDIUM).'</a>';
  47. echo '<a href="promotions.php">'.
  48. Display::return_icon('promotion.png',get_lang('Promotions'),'',ICON_SIZE_MEDIUM).'</a>';
  49. echo '</div>';
  50. $form->display();
  51. $careers = $career->get_all($condition); //only status =1
  52. $column_count = 3;
  53. $i = 0;
  54. $grid_js = '';
  55. $career_array = array();
  56. if (!empty($careers)) {
  57. foreach ($careers as $career_item) {
  58. $promotion = new Promotion();
  59. // Getting all promotions
  60. $promotions = $promotion->get_all_promotions_by_career_id(
  61. $career_item['id'],
  62. 'name DESC'
  63. );
  64. $career_content = '';
  65. $promotion_array = array();
  66. if (!empty($promotions)) {
  67. foreach ($promotions as $promotion_item) {
  68. if (!$promotion_item['status']) {
  69. continue; //avoid status = 0
  70. }
  71. // Getting all sessions from this promotion
  72. $sessions = SessionManager::get_all_sessions_by_promotion(
  73. $promotion_item['id']
  74. );
  75. $session_list = array();
  76. foreach ($sessions as $session_item) {
  77. $course_list = SessionManager::get_course_list_by_session_id(
  78. $session_item['id']
  79. );
  80. $session_list[] = array(
  81. 'data' => $session_item,
  82. 'courses' => $course_list,
  83. );
  84. }
  85. $promotion_array[$promotion_item['id']] = array(
  86. 'name' => $promotion_item['name'],
  87. 'sessions' => $session_list,
  88. );
  89. }
  90. }
  91. $career_array[$career_item['id']] = array(
  92. 'name' => $career_item['name'],
  93. 'promotions' => $promotion_array,
  94. );
  95. }
  96. }
  97. echo '<table class="data_table">';
  98. if (!empty($career_arrayer)) {
  99. foreach ($career_array as $career_id => $data) {
  100. $career = $data['name'];
  101. $promotions = $data['promotions'];
  102. $career = Display::url($career, 'careers.php?action=edit&id=' . $career_id);
  103. $career = Display::tag('h4', $career);
  104. echo '<tr><td style="background-color:#ECF0F1" colspan="3">' . $career . '</td></tr>';
  105. if (!empty($promotions)) {
  106. foreach ($promotions as $promotion_id => $promotion) {
  107. $promotion_name = $promotion['name'];
  108. $promotion_url = Display::url($promotion_name, 'promotions.php?action=edit&id=' . $promotion_id);
  109. $sessions = $promotion['sessions'];
  110. echo '<tr>';
  111. $count = count($sessions);
  112. $rowspan = '';
  113. if (!empty($count)) {
  114. $count++;
  115. $rowspan = 'rowspan="' . $count . '"';
  116. }
  117. echo '<td ' . $rowspan . '>';
  118. echo Display::tag('h5', $promotion_url);
  119. echo '</td>';
  120. echo '</tr>';
  121. if (!empty($sessions)) {
  122. foreach ($sessions as $session) {
  123. $course_list = $session['courses'];
  124. $url = Display::url($session['data']['name'],
  125. '../session/resume_session.php?id_session=' . $session['data']['id']);
  126. echo '<tr>';
  127. //Session name
  128. echo Display::tag('td', $url);
  129. echo '<td>';
  130. //Courses
  131. echo '<table>';
  132. if (!empty($course_list)) {
  133. foreach ($course_list as $course) {
  134. echo '<tr>';
  135. $url = Display::url(
  136. $course['title'],
  137. api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . $session['data']['id']
  138. );
  139. echo Display::tag('td', $url);
  140. echo '</tr>';
  141. }
  142. echo '</table>';
  143. echo '</td>';
  144. echo '</tr>';
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. echo '</table>';
  153. Display::display_footer();