add_teachers_to_session.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. // resetting the course id
  7. $cidReset = true;
  8. // including some necessary files
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. // Setting the section (for the tabs)
  11. $this_section = SECTION_PLATFORM_ADMIN;
  12. // Setting breadcrumbs
  13. $interbreadcrumb[] = [
  14. 'url' => 'session_list.php',
  15. 'name' => get_lang('SessionList'),
  16. ];
  17. // Setting the name of the tool
  18. $tool_name = get_lang('EnrollTrainersFromExistingSessions');
  19. $form_sent = 0;
  20. $errorMsg = '';
  21. $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
  22. SessionManager::protectSession($id);
  23. $htmlResult = '';
  24. if (isset($_POST['form_sent']) && $_POST['form_sent']) {
  25. $form_sent = $_POST['form_sent'];
  26. if ($form_sent == 1 &&
  27. isset($_POST['sessions']) && isset($_POST['courses'])
  28. ) {
  29. $sessions = $_POST['sessions'];
  30. $courses = $_POST['courses'];
  31. $htmlResult = SessionManager::copyCoachesFromSessionToCourse(
  32. $sessions,
  33. $courses
  34. );
  35. }
  36. }
  37. $session_list = SessionManager::get_sessions_list([], ['name']);
  38. $sessionList = [];
  39. foreach ($session_list as $session) {
  40. $sessionList[$session['id']] = $session['name'];
  41. }
  42. $courseList = CourseManager::get_courses_list(0, 0, 'title');
  43. $courseOptions = [];
  44. foreach ($courseList as $course) {
  45. $courseOptions[$course['id']] = $course['title'];
  46. }
  47. Display::display_header($tool_name);
  48. ?>
  49. <form name="formulaire" method="post" action="<?php echo api_get_self().'?id='.$id; ?>">
  50. <?php echo '<legend>'.$tool_name.' </legend>';
  51. echo $htmlResult;
  52. echo Display::input('hidden', 'form_sent', '1');
  53. ?>
  54. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  55. <tr>
  56. <td align="center">
  57. <b><?php echo get_lang('Sessions'); ?> :</b>
  58. </td>
  59. <td></td>
  60. <td align="center">
  61. <b><?php echo get_lang('Courses'); ?> :</b>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td align="center">
  66. <?php
  67. echo Display::select(
  68. 'sessions[]',
  69. $sessionList,
  70. '',
  71. ['style' => 'width:360px', 'multiple' => 'multiple', 'id' => 'sessions', 'size' => '15px'],
  72. false
  73. );
  74. ?>
  75. </td>
  76. <td align="center">
  77. </td>
  78. <td align="center">
  79. <?php
  80. echo Display::select(
  81. 'courses[]',
  82. $courseOptions,
  83. '',
  84. ['style' => 'width:360px', 'id' => 'courses', 'size' => '15px'],
  85. false
  86. );
  87. ?>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td colspan="3" align="center">
  92. <br />
  93. <?php
  94. echo '<button class="btn btn-success" type="submit">'.
  95. get_lang('SubscribeTeachersToSession').'</button>';
  96. ?>
  97. </td>
  98. </tr>
  99. </table>
  100. </form>
  101. <?php
  102. Display::display_footer();