career_dashboard.php 4.1 KB

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