career_dashboard.php 5.2 KB

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