career_dashboard.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Careers dashboard
  5. * @package chamilo.admin.career
  6. */
  7. /**
  8. * Code
  9. */
  10. // Language files that should be included.
  11. $language_file = array('courses', 'index', 'admin');
  12. $cidReset = true;
  13. require_once '../inc/global.inc.php';
  14. $libpath = api_get_path(LIBRARY_PATH);
  15. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
  16. require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
  17. require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.class.php';
  18. api_protect_admin_script();
  19. $this_section = SECTION_PLATFORM_ADMIN;
  20. //Adds the JS needed to use the jqgrid
  21. $htmlHeadXtra[] = api_get_jqgrid_js();
  22. // setting breadcrumbs
  23. $interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  24. $interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions'));
  25. Display :: display_header($nameTools);
  26. $form = new FormValidator('filter_form','GET', api_get_self());
  27. $career = new Career();
  28. $condition = array('status = ?' => 1);
  29. if ($form->validate()) {
  30. $data = $form->getSubmitValues();
  31. $filter = intval($data['filter']);
  32. if (!empty($filter)) {
  33. $condition = array('status = ? AND id = ? ' => array(1, $filter));
  34. }
  35. }
  36. $careers = $career->get_all(array('status = ?' => 1)); //only status =1
  37. $career_select_list = array();
  38. $career_select_list[0] = ' -- '.get_lang('Select').' --';
  39. foreach ($careers as $item) {
  40. $career_select_list[$item['id']] = $item['name'];
  41. }
  42. $form->addElement('select', 'filter', get_lang('Career'), $career_select_list, array('id'=>'filter_1', 'class'=>'chzn-select'));
  43. $form->addElement('style_submit_button', 'submit', get_lang('Filter'), 'class="search"');
  44. // action links
  45. echo '<div class="actions" style="margin-bottom:20px">';
  46. echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
  47. echo '<a href="careers.php">'.Display::return_icon('career.png',get_lang('Careers'),'',ICON_SIZE_MEDIUM).'</a>';
  48. echo '<a href="promotions.php">'.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($career_item['id'], 'name DESC');
  61. $career_content = '';
  62. $promotion_array = array();
  63. if (!empty($promotions)) {
  64. foreach($promotions as $promotion_item) {
  65. if (!$promotion_item['status']) {
  66. continue; //avoid status = 0
  67. }
  68. //Getting all sessions from this promotion
  69. $sessions = SessionManager::get_all_sessions_by_promotion($promotion_item['id']);
  70. $session_list = array();
  71. foreach($sessions as $session_item) {
  72. $course_list = SessionManager::get_course_list_by_session_id($session_item['id']);
  73. $session_list[] = array('data'=>$session_item,'courses'=>$course_list);
  74. }
  75. $promotion_array[$promotion_item['id']] =array('name'=>$promotion_item['name'], 'sessions'=>$session_list);
  76. }
  77. }
  78. $career_array[$career_item['id']] = array('name'=>$career_item['name'],'promotions'=>$promotion_array);
  79. }
  80. }
  81. echo '<table class="data_table">';
  82. foreach($career_array as $career_id => $data) {
  83. $career = $data['name'];
  84. $promotions = $data['promotions'];
  85. $career = Display::url($career,'careers.php?action=edit&id='.$career_id);
  86. $career = Display::tag('h3',$career);
  87. echo '<tr><td style="background-color:#eee" colspan="3">'.$career.'</td></tr>';
  88. foreach($promotions as $promotion_id => $promotion) {
  89. $promotion_name = $promotion['name'];
  90. $promotion_url = Display::url($promotion_name,'promotions.php?action=edit&id='.$promotion_id);
  91. $sessions = $promotion['sessions'];
  92. echo '<tr>';
  93. $count = count($sessions);
  94. $rowspan = '';
  95. if (!empty($count)) {
  96. $count++;
  97. $rowspan = 'rowspan="'.$count.'"';
  98. }
  99. echo '<td '.$rowspan.'>';
  100. //echo $promotion_url;
  101. echo Display::tag('h4',$promotion_url);
  102. echo '</td>';
  103. echo '</tr>';
  104. if (!empty($sessions))
  105. foreach($sessions as $session) {
  106. $course_list = $session['courses'];
  107. $url = Display::url($session['data']['name'], 'resume_session.php?id_session='.$session['data']['id']);
  108. echo '<tr>';
  109. //Session name
  110. echo Display::tag('td',$url);
  111. echo '<td>';
  112. //Courses
  113. echo '<table>';
  114. foreach($course_list as $course) {
  115. echo '<tr>';
  116. $url = Display::url($course['title'], api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session='.$session['data']['id']);
  117. echo Display::tag('td',$url);
  118. echo '</tr>';
  119. }
  120. echo '</table>';
  121. echo '</td>';
  122. echo '</tr>';
  123. }
  124. }
  125. }
  126. echo '</table>';
  127. Display::display_footer();