career_dashboard.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. api_protect_admin_script();
  16. $this_section = SECTION_PLATFORM_ADMIN;
  17. //Adds the JS needed to use the jqgrid
  18. $htmlHeadXtra[] = api_get_jqgrid_js();
  19. // setting breadcrumbs
  20. $interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  21. $interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions'));
  22. Display :: display_header($nameTools);
  23. $form = new FormValidator('filter_form','GET', api_get_self());
  24. $career = new Career();
  25. $condition = array('status = ?' => 1);
  26. if ($form->validate()) {
  27. $data = $form->getSubmitValues();
  28. $filter = intval($data['filter']);
  29. if (!empty($filter)) {
  30. $condition = array('status = ? AND id = ? ' => array(1, $filter));
  31. }
  32. }
  33. $careers = $career->get_all(array('status = ?' => 1)); //only status =1
  34. $career_select_list = array();
  35. $career_select_list[0] = ' -- '.get_lang('Select').' --';
  36. foreach ($careers as $item) {
  37. $career_select_list[$item['id']] = $item['name'];
  38. }
  39. $form->addElement('select', 'filter', get_lang('Career'), $career_select_list, array('id'=>'filter_1', 'class'=>'chzn-select'));
  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">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
  44. echo '<a href="careers.php">'.Display::return_icon('career.png',get_lang('Careers'),'',ICON_SIZE_MEDIUM).'</a>';
  45. echo '<a href="promotions.php">'.Display::return_icon('promotion.png',get_lang('Promotions'),'',ICON_SIZE_MEDIUM).'</a>';
  46. echo '</div>';
  47. $form->display();
  48. $careers = $career->get_all($condition); //only status =1
  49. $column_count = 3;
  50. $i = 0;
  51. $grid_js = '';
  52. $career_array = array();
  53. if (!empty($careers)) {
  54. foreach($careers as $career_item) {
  55. $promotion = new Promotion();
  56. //Getting all promotions
  57. $promotions = $promotion->get_all_promotions_by_career_id($career_item['id'], 'name DESC');
  58. $career_content = '';
  59. $promotion_array = array();
  60. if (!empty($promotions)) {
  61. foreach($promotions as $promotion_item) {
  62. if (!$promotion_item['status']) {
  63. continue; //avoid status = 0
  64. }
  65. //Getting all sessions from this promotion
  66. $sessions = SessionManager::get_all_sessions_by_promotion($promotion_item['id']);
  67. $session_list = array();
  68. foreach($sessions as $session_item) {
  69. $course_list = SessionManager::get_course_list_by_session_id($session_item['id']);
  70. $session_list[] = array('data'=>$session_item,'courses'=>$course_list);
  71. }
  72. $promotion_array[$promotion_item['id']] =array('name'=>$promotion_item['name'], 'sessions'=>$session_list);
  73. }
  74. }
  75. $career_array[$career_item['id']] = array('name'=>$career_item['name'],'promotions'=>$promotion_array);
  76. }
  77. }
  78. echo '<table class="data_table">';
  79. foreach($career_array as $career_id => $data) {
  80. $career = $data['name'];
  81. $promotions = $data['promotions'];
  82. $career = Display::url($career,'careers.php?action=edit&id='.$career_id);
  83. $career = Display::tag('h3',$career);
  84. echo '<tr><td style="background-color:#eee" colspan="3">'.$career.'</td></tr>';
  85. foreach($promotions as $promotion_id => $promotion) {
  86. $promotion_name = $promotion['name'];
  87. $promotion_url = Display::url($promotion_name,'promotions.php?action=edit&id='.$promotion_id);
  88. $sessions = $promotion['sessions'];
  89. echo '<tr>';
  90. $count = count($sessions);
  91. $rowspan = '';
  92. if (!empty($count)) {
  93. $count++;
  94. $rowspan = 'rowspan="'.$count.'"';
  95. }
  96. echo '<td '.$rowspan.'>';
  97. //echo $promotion_url;
  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'].'/?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();