career_dashboard.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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', 'class' => 'chzn-select')
  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. foreach($career_array as $career_id => $data) {
  99. $career = $data['name'];
  100. $promotions = $data['promotions'];
  101. $career = Display::url($career,'careers.php?action=edit&id='.$career_id);
  102. $career = Display::tag('h3',$career);
  103. echo '<tr><td style="background-color:#eee" colspan="3">'.$career.'</td></tr>';
  104. foreach($promotions as $promotion_id => $promotion) {
  105. $promotion_name = $promotion['name'];
  106. $promotion_url = Display::url($promotion_name,'promotions.php?action=edit&id='.$promotion_id);
  107. $sessions = $promotion['sessions'];
  108. echo '<tr>';
  109. $count = count($sessions);
  110. $rowspan = '';
  111. if (!empty($count)) {
  112. $count++;
  113. $rowspan = 'rowspan="'.$count.'"';
  114. }
  115. echo '<td '.$rowspan.'>';
  116. echo Display::tag('h4',$promotion_url);
  117. echo '</td>';
  118. echo '</tr>';
  119. if (!empty($sessions))
  120. foreach($sessions as $session) {
  121. $course_list = $session['courses'];
  122. $url = Display::url($session['data']['name'], 'resume_session.php?id_session='.$session['data']['id']);
  123. echo '<tr>';
  124. //Session name
  125. echo Display::tag('td',$url);
  126. echo '<td>';
  127. //Courses
  128. echo '<table>';
  129. foreach($course_list as $course) {
  130. echo '<tr>';
  131. $url = Display::url(
  132. $course['title'],
  133. api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session='.$session['data']['id']
  134. );
  135. echo Display::tag('td',$url);
  136. echo '</tr>';
  137. }
  138. echo '</table>';
  139. echo '</td>';
  140. echo '</tr>';
  141. }
  142. }
  143. }
  144. echo '</table>';
  145. Display::display_footer();