Нет описания

semesters.blade.php 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. @extends('layouts.master')
  2. @section('css')
  3. {{ HTML::style('vendor/datetimepicker-master/jquery.datetimepicker.css') }}
  4. @stop
  5. @section('navigation')
  6. @include('local.managers.admins._navigation')
  7. @stop
  8. @section('main')
  9. <div class="row">
  10. <div class="col-md-8">
  11. <p>Use this page to change the available semesters' start dates, end dates, and visibility. Start dates and end dates determine the range of time within which users enter data for each semester. Visibility determines whether a user can select that semester for viewing and/or entering data. Users cannot enter new data in a closed semester, even if it is visible.</p>
  12. <p><strong>Important: At least one semester must be visible, and must have started. While semesters may have overlapping dates, they cannot have the same dates.</strong></p>
  13. <table class="table table-striped">
  14. <thead>
  15. <tr>
  16. <th>Code</th>
  17. <th>Name</th>
  18. <th>Start Date</th>
  19. <th>End Date</th>
  20. <th>Visible</th>
  21. <th>Save</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. </tbody>
  26. @foreach ($semesters as $semester)
  27. <tr>
  28. <td data-id="{{ $semester->id }}" class="semester-code">{{ $semester->code }}</td>
  29. <td class="semester-name">{{ $semester->name }}</td>
  30. <td class="semester-start"><input class="datetimepicker" type="text" value="{{ date('m/d/y H:i:s', strtotime($semester->start)) }}"></td>
  31. <td class="semester-end"><input class="datetimepicker" type="text" value="{{ date('m/d/y H:i:s', strtotime($semester->end)) }}"></td>
  32. <td class="semester-visible">
  33. <select name="" id="">
  34. @if($semester->is_visible)
  35. <option selected="selected" value="1">Yes</option>
  36. <option value="0">No</option>
  37. @else
  38. <option value="1">Yes</option>
  39. <option selected="selected" value="0">No</option>
  40. @endif
  41. </select>
  42. </td>
  43. <td class="semester-save"><span class="glyphicon glyphicon-floppy-disk"></span></td>
  44. </tr>
  45. @endforeach
  46. </table>
  47. </div>
  48. </div>
  49. @stop
  50. @section('included-js')
  51. <script src="{{ asset('vendor/datetimepicker-master/jquery.datetimepicker.js') }}"></script>
  52. @stop
  53. @section('javascript')
  54. // ------------------------------------------------------------------------
  55. // Page Load
  56. // ------------------------------------------------------------------------
  57. $('.datetimepicker').datetimepicker({
  58. format: 'm/d/y H:i:s'
  59. });
  60. // ------------------------------------------------------------------------
  61. // Events
  62. // ------------------------------------------------------------------------
  63. $('.semester-save').on('click', function(e)
  64. {
  65. e.preventDefault();
  66. var id = ($(this).siblings('.semester-code').data('id'));
  67. var start = ($(this).siblings('.semester-start').find('.datetimepicker').val());
  68. var end = ($(this).siblings('.semester-end').find('.datetimepicker').val());
  69. var visible = ($(this).siblings('.semester-visible').find(':selected').val());
  70. $.post(
  71. "{{ URL::action('SemestersController@update') }}",
  72. {
  73. id: id,
  74. start: start,
  75. end: end,
  76. visible: visible
  77. },
  78. function(data)
  79. {
  80. location.reload(true);
  81. }
  82. ).fail(function() {
  83. alert( "error" );
  84. });
  85. });
  86. // ------------------------------------------------------------------------
  87. // Functions
  88. // ------------------------------------------------------------------------
  89. function selectSchoolandProgram(semester, role)
  90. {
  91. switch(role)
  92. {
  93. case 1:
  94. $('#school option[value="0"]').prop('selected', true);
  95. $('#program option[value="0"]').prop('selected', true);
  96. break;
  97. case 2:
  98. var school_id = semester.find('.semester-school').data('school-id');
  99. $('#school option[value="'+school_id+'"]').prop('selected', true);
  100. fetchPrograms();
  101. $('#program option[value="0"]').prop('selected', true);
  102. break;
  103. case 3:
  104. case 4:
  105. var school_id = semester.find('.semester-school').data('school-id');
  106. var program_id = semester.find('.semester-program').data('program-id');
  107. $('#school option[value="'+school_id+'"]').prop('selected', true);
  108. fetchPrograms();
  109. $('#program option[value="'+program_id+'"]').prop('selected', true);
  110. break;
  111. }
  112. }
  113. @stop