career_dashboard.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 __DIR__.'/../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(
  16. 'url' => 'index.php',
  17. 'name' => get_lang('PlatformAdmin')
  18. );
  19. $interbreadcrumb[] = array(
  20. 'url' => 'career_dashboard.php',
  21. 'name' => get_lang('CareersAndPromotions')
  22. );
  23. $tpl = new Template(get_lang('CareersAndPromotions'));
  24. $html = null;
  25. $form = new FormValidator('filter_form', 'GET', api_get_self());
  26. $career = new Career();
  27. $condition = array('status = ?' => 1);
  28. if ($form->validate()) {
  29. $data = $form->getSubmitValues();
  30. $filter = intval($data['filter']);
  31. if (!empty($filter)) {
  32. $condition = array('status = ? AND id = ? ' => array(1, $filter));
  33. }
  34. }
  35. $careers = $career->get_all(array('status = ?' => 1)); //only status =1
  36. $career_select_list = array();
  37. $career_select_list[0] = ' -- '.get_lang('Select').' --';
  38. foreach ($careers as $item) {
  39. $career_select_list[$item['id']] = $item['name'];
  40. }
  41. $form->addSelect(
  42. 'filter',
  43. get_lang('Career'),
  44. $career_select_list,
  45. array('id' => 'filter_1')
  46. );
  47. $form->addButtonSearch(get_lang('Filter'));
  48. // action links
  49. $actionLeft = Display::url(
  50. Display::return_icon(
  51. 'back.png',
  52. get_lang('BackTo').' '.get_lang('PlatformAdmin'),
  53. null,
  54. ICON_SIZE_MEDIUM
  55. ),
  56. '../admin/index.php'
  57. );
  58. $actionLeft .= Display::url(
  59. Display::return_icon(
  60. 'career.png',
  61. get_lang('Careers'),
  62. null,
  63. ICON_SIZE_MEDIUM
  64. ),
  65. 'careers.php'
  66. );
  67. $actionLeft .= Display::url(
  68. Display::return_icon(
  69. 'promotion.png',
  70. get_lang('Promotions'),
  71. null,
  72. ICON_SIZE_MEDIUM
  73. ),
  74. 'promotions.php'
  75. );
  76. $actions = Display::toolbarAction('toolbar-career', array($actionLeft));
  77. $html .= $form->returnForm();
  78. $careers = $career->get_all($condition); //only status =1
  79. $column_count = 3;
  80. $i = 0;
  81. $grid_js = '';
  82. $career_array = array();
  83. if (!empty($careers)) {
  84. foreach ($careers as $career_item) {
  85. $promotion = new Promotion();
  86. // Getting all promotions
  87. $promotions = $promotion->get_all_promotions_by_career_id(
  88. $career_item['id'],
  89. 'name ASC'
  90. );
  91. $career_content = '';
  92. $promotion_array = array();
  93. if (!empty($promotions)) {
  94. foreach ($promotions as $promotion_item) {
  95. if ($promotion_item['status'] == 0) {
  96. continue; //avoid status = 0
  97. }
  98. // Getting all sessions from this promotion
  99. $sessions = SessionManager::get_all_sessions_by_promotion(
  100. $promotion_item['id']
  101. );
  102. $session_list = array();
  103. foreach ($sessions as $session_item) {
  104. $course_list = SessionManager::get_course_list_by_session_id(
  105. $session_item['id']
  106. );
  107. $session_list[] = array(
  108. 'data' => $session_item,
  109. 'courses' => $course_list,
  110. );
  111. }
  112. $promotion_array[$promotion_item['id']] = array(
  113. 'id' => $promotion_item['id'],
  114. 'name' => $promotion_item['name'],
  115. 'sessions' => $session_list,
  116. );
  117. }
  118. }
  119. $career_array[$career_item['id']] = array(
  120. 'name' => $career_item['name'],
  121. 'promotions' => $promotion_array,
  122. );
  123. $careerList = array(
  124. 'promotions' => $promotion_array,
  125. );
  126. $careers[$career_item['id']]['career'] = $careerList;
  127. }
  128. }
  129. $tpl->assign('actions', $actions);
  130. $tpl->assign('form_filter', $html);
  131. $tpl->assign('data', $careers);
  132. $layout = $tpl->get_template('admin/career_dashboard.tpl');
  133. $tpl->display($layout);