No Description

assign_other_programs.blade.php 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. <option value="0">Nothing Selected</option>
  86. @foreach ($programs as $program)
  87. @if (Input::old('program') != $program->id)
  88. <option value="{{ $program->id }}">{{ $program->name }}
  89. ({{ $program->school->name }})</option>
  90. @else
  91. <option selected value="{{ $program->id }}">{{ $program->name }}
  92. ({{ $program->school->name }})</option>
  93. @endif
  94. @endforeach
  95. </select>
  96. </div>
  97. <hr>
  98. <div class ='form-group'>
  99. <button id='add-other-program-edit' class='btn btn-md btn-secondary'
  100. onclick='addOtherProgram("#add-other-program-edit", "#other_program_div_edit")'>
  101. <span class='glyphicon glyphicon-plus'>
  102. </span>
  103. Add another Program
  104. </button>
  105. </div>
  106. <br>
  107. {{ Form::submit("Edit Program Courses' Pairing", ['class' => 'btn btn-primary btn-block', 'name' => 'edit_pair_other_courses']) }}
  108. {{ Form::close() }}
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <script>
  114. $('.filterSection').show();
  115. $('.filterButton').on('click', function() {
  116. var span = $(this).find('span');
  117. if (span.attr('class') == 'glyphicon glyphicon-plus') {
  118. span.attr('class', 'glyphicon glyphicon-minus');
  119. } else {
  120. span.attr('class', 'glyphicon glyphicon-plus');
  121. }
  122. $('.filterSection').toggle(533);
  123. });
  124. $('.filterButton').on('click', function(e) {
  125. // Prevent the default action of the clicked item. In this case that is submit
  126. e.preventDefault();
  127. return false;
  128. });
  129. options = $('#other_program_0').html();
  130. function addOtherProgram(button, div, removable = ''){
  131. master_div = $("<div>",{
  132. 'class':removable
  133. })
  134. div_select = $("<div>", {
  135. 'class':'col-md-11'
  136. })
  137. select = $("<select>", {
  138. 'name': "other_program[]",
  139. 'class':'form-control selectpicker '
  140. }).html(options);
  141. select.appendTo(div_select)
  142. div_button = $("<div>", {
  143. 'class':'col-md-1'
  144. })
  145. rem_button = $('<button>',{
  146. 'type':'button',
  147. 'class':'btn btn-primary',
  148. 'onclick':'$(this).parent().parent().remove();'
  149. }).html("<span class='glyphicon glyphicon-remove'></span>")
  150. div_button.append(rem_button);
  151. master_div.append(div_select);
  152. master_div.append(div_button);
  153. master_div.prepend("<br>")
  154. master_div.append("<br>");
  155. master_div.appendTo($(div));
  156. $('.selectpicker').selectpicker('refresh');
  157. }
  158. function fetchProgramPairing(select){
  159. $.post(
  160. "{{URL::action('ProgramsController@fetchPairingInfo')}}", {
  161. program_id: $(select).val()
  162. },
  163. function(paired_programs){
  164. $('.removable').remove();
  165. $('#other_program_div_edit').find('select.selectpicker').eq(0).val(0);
  166. $.each(paired_programs, function(index, program_id){
  167. selectPick= $('#other_program_div_edit').find('select.selectpicker').eq(index).val(program_id);
  168. selectPick.val(program_id);
  169. if(paired_programs[index+1]){
  170. addOtherProgram("#add-other-program-edit", "#other_program_div_edit", 'removable')
  171. }
  172. })
  173. $('.selectpicker').selectpicker('refresh');
  174. }
  175. )
  176. }
  177. </script>
  178. @stop
  179. @section('javascript')
  180. // --------------------------------------------------------------------------
  181. // Page load
  182. // --------------------------------------------------------------------------
  183. $("#add-other-program").on("click", function(e){
  184. e.preventDefault();
  185. });
  186. $("#add-other-program-edit").on('click', function(e){
  187. e.preventDefault();
  188. })
  189. fetchProgramPairing('#select-program-edit')
  190. // --------------------------------------------------------------------------
  191. // Functions
  192. // --------------------------------------------------------------------------
  193. // --------------------------------------------------------------------------
  194. // Events
  195. // --------------------------------------------------------------------------
  196. @stop