career_dashboard.php 5.7 KB

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