No Description

assign_other_programs.blade.php 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @include('local.managers.admins._new_navigation')
  4. @stop
  5. @section('main')
  6. <div class="row">
  7. <div class="col-md-6">
  8. <div class="panel panel-default panel-button">
  9. <div class="panel-heading">
  10. Create a Course
  11. </div>
  12. <div class="panel-body">
  13. {{ Form::open(['action' => 'ProgramsController@addToOtherProgramTYP','enctype'=>"multipart/form-data"]) }}
  14. <!-- Program -->
  15. <div class="form-group">
  16. {{ Form::label('program', 'Select Program to pair other Program Courses\'') }}
  17. <select id="program" name="program" class="form-control selectpicker">
  18. @foreach ($programs as $program)
  19. @if (Input::old('program') != $program->id)
  20. <option value="{{ $program->id }}">{{ $program->name }}
  21. ({{ $program->school->name }})</option>
  22. @else
  23. <option selected value="{{ $program->id }}">{{ $program->name }}
  24. ({{ $program->school->name }})</option>
  25. @endif
  26. @endforeach
  27. </select>
  28. </div>
  29. <div class="form-group" id = "other_program_div">
  30. {{ Form::label('program', 'Choose other program') }}
  31. <select id="other_program_0" name="other_program[]" class="form-control selectpicker">
  32. @foreach ($programs as $program)
  33. @if (Input::old('program') != $program->id)
  34. <option value="{{ $program->id }}">{{ $program->name }}
  35. ({{ $program->school->name }})</option>
  36. @else
  37. <option selected value="{{ $program->id }}">{{ $program->name }}
  38. ({{ $program->school->name }})</option>
  39. @endif
  40. @endforeach
  41. </select>
  42. </div>
  43. <hr>
  44. <div class ='form-group'>
  45. <button id='add-other-program' class='btn btn-md btn-secondary'
  46. onclick='addOtherProgram("#add-other-program", "#other_program_div")'>
  47. <span class='glyphicon glyphicon-plus'>
  48. </span>
  49. Add another Program
  50. </button>
  51. </div>
  52. <br>
  53. {{ Form::submit('Pair Other Program Courses', ['class' => 'btn btn-primary btn-block', 'name' => 'pair_other_courses']) }}
  54. {{ Form::close() }}
  55. <br>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="col-md-6">
  60. <div class="panel panel-default panel-button">
  61. <div class="panel-heading">
  62. Edit pairing
  63. </div>
  64. <div class="panel-body">
  65. <p>You can enroll students in this setting, by choosing the course and uploading a .txt file with the students numbers</p>
  66. {{ Form::open(['action' => 'ProgramsController@updatePairingInfo', 'enctype'=>"multipart/form-data"]) }}
  67. <div class = "form-group">
  68. {{Form::label('select-program-edit', "Edit Program Courses' Pairing")}}
  69. <select id = "select-program-edit" name = "program" class ='form-control selectpicker'
  70. onchange = "fetchProgramPairing('#select-program-edit')">
  71. @foreach ($programs as $program)
  72. @if (Input::old('program') != $program->id)
  73. <option value="{{ $program->id }}">{{ $program->name }}
  74. ({{ $program->school->name }})</option>
  75. @else
  76. <option selected value="{{ $program->id }}">{{ $program->name }}
  77. ({{ $program->school->name }})</option>
  78. @endif
  79. @endforeach
  80. </select>
  81. </div>
  82. <div class="form-group" id = "other_program_div_edit">
  83. {{ Form::label('program', 'Choose other program') }}
  84. <select id="program-edit" name="other_program[]" class="form-control selectpicker">
  85. @foreach ($programs as $program)
  86. @if (Input::old('program') != $program->id)
  87. <option value="{{ $program->id }}">{{ $program->name }}
  88. ({{ $program->school->name }})</option>
  89. @else
  90. <option selected value="{{ $program->id }}">{{ $program->name }}
  91. ({{ $program->school->name }})</option>
  92. @endif
  93. @endforeach
  94. </select>
  95. </div>
  96. <hr>
  97. <div class ='form-group'>
  98. <button id='add-other-program-edit' class='btn btn-md btn-secondary'
  99. onclick='addOtherProgram("#add-other-program-edit", "#other_program_div_edit")'>
  100. <span class='glyphicon glyphicon-plus'>
  101. </span>
  102. Add another Program
  103. </button>
  104. </div>
  105. <br>
  106. {{ Form::submit("Edit Program Courses' Pairing", ['class' => 'btn btn-primary btn-block', 'name' => 'edit_pair_other_courses']) }}
  107. {{ Form::close() }}
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <script>
  113. $('.filterSection').show();
  114. $('.filterButton').on('click', function() {
  115. var span = $(this).find('span');
  116. if (span.attr('class') == 'glyphicon glyphicon-plus') {
  117. span.attr('class', 'glyphicon glyphicon-minus');
  118. } else {
  119. span.attr('class', 'glyphicon glyphicon-plus');
  120. }
  121. $('.filterSection').toggle(533);
  122. });
  123. $('.filterButton').on('click', function(e) {
  124. // Prevent the default action of the clicked item. In this case that is submit
  125. e.preventDefault();
  126. return false;
  127. });
  128. options = $('#other_program_0').html();
  129. function addOtherProgram(button, div, removable = ''){
  130. master_div = $("<div>",{
  131. 'class':removable
  132. })
  133. div_select = $("<div>", {
  134. 'class':'col-md-11'
  135. })
  136. select = $("<select>", {
  137. 'name': "other_program[]",
  138. 'class':'form-control selectpicker '
  139. }).html(options);
  140. select.appendTo(div_select)
  141. div_button = $("<div>", {
  142. 'class':'col-md-1'
  143. })
  144. rem_button = $('<button>',{
  145. 'type':'button',
  146. 'class':'btn btn-primary',
  147. 'onclick':'$(this).parent().parent().remove();'
  148. }).html("<span class='glyphicon glyphicon-remove'></span>")
  149. div_button.append(rem_button);
  150. master_div.append(div_select);
  151. master_div.append(div_button);
  152. master_div.prepend("<br>")
  153. master_div.append("<br>");
  154. master_div.appendTo($(div));
  155. $('.selectpicker').selectpicker('refresh');
  156. }
  157. function fetchProgramPairing(select){
  158. $.post(
  159. "{{URL::action('ProgramsController@fetchPairingInfo')}}", {
  160. program_id: $(select).val()
  161. },
  162. function(paired_programs){
  163. $('.removable').remove();
  164. $.each(paired_programs, function(index, program_id){
  165. selectPick= $('#other_program_div_edit').find('select.selectpicker').eq(index).val(program_id);
  166. selectPick.val(program_id);
  167. if(paired_programs[index+1]){
  168. addOtherProgram("#add-other-program-edit", "#other_program_div_edit", 'removable')
  169. }
  170. $('.selectpicker').selectpicker('refresh');
  171. })
  172. }
  173. )
  174. }
  175. </script>
  176. @stop
  177. @section('javascript')
  178. // --------------------------------------------------------------------------
  179. // Page load
  180. // --------------------------------------------------------------------------
  181. $("#add-other-program").on("click", function(e){
  182. e.preventDefault();
  183. });
  184. $("#add-other-program-edit").on('click', function(e){
  185. e.preventDefault();
  186. })
  187. fetchProgramPairing('#select-program-edit')
  188. // --------------------------------------------------------------------------
  189. // Functions
  190. // --------------------------------------------------------------------------
  191. // --------------------------------------------------------------------------
  192. // Events
  193. // --------------------------------------------------------------------------
  194. @stop