설명 없음

users.blade (4.29.2015 1.43.03 PM).php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @include('local.managers.admins._navigation')
  4. @stop
  5. @section('main')
  6. <div class="row">
  7. <div class="col-md-12">
  8. <table class="table table-striped">
  9. <thead>
  10. <tr>
  11. <th>Name</th>
  12. <th>School</th>
  13. <th>Program</th>
  14. <th>Primary Email</th>
  15. <th>Role</th>
  16. </tr>
  17. </thead>
  18. <tbody>
  19. </tbody>
  20. @foreach ($users as $user)
  21. <tr>
  22. <td>{{ $user->surnames }}, {{ $user->first_name }}</td>
  23. <td>
  24. @if(count($user->school))
  25. {{ $user->school->name }}
  26. @endif
  27. </td>
  28. <td>
  29. @if(count($user->program))
  30. {{ $user->program->name }}
  31. @endif
  32. </td>
  33. <td class="email">{{ $user->email }}</td>
  34. <td>
  35. <select name="role" class="role form-control">
  36. <option value="1" <?php if($user->role==1) echo 'selected="selected"'?>>Administrator</option>
  37. <option value="2" <?php if($user->role==2) echo 'selected="selected"'?>>School Coordinator</option>
  38. <option value="3" <?php if($user->role==3) echo 'selected="selected"'?>>Program Coordinator</option>
  39. <option value="4" <?php if($user->role==4) echo 'selected="selected"'?>>Professor</option>
  40. </select>
  41. </td>
  42. </tr>
  43. @endforeach
  44. </table>
  45. {{ $users->links() }}
  46. <button id="submit_roles" class="btn btn-primary btn pull-right">Update this page</button>
  47. </div>
  48. </div>
  49. @stop
  50. @section('javascript')
  51. $(document).ready(function()
  52. {
  53. // --------------------------------------------------------------------------
  54. // Page load
  55. // --------------------------------------------------------------------------
  56. $('#submit_roles').on('click', function()
  57. {
  58. var userBundle = new Array();
  59. $('tbody tr').each(function()
  60. {
  61. var user = new Object();
  62. user.email= $(this).find('.email').text();
  63. user.role= $(this).find('.role').find(':selected').val();
  64. var clone = jQuery.extend({}, user);
  65. userBundle.push(clone);
  66. });
  67. alert(JSON.stringify(userBundle));
  68. // Save activity to the database
  69. $.post
  70. (
  71. "{{ URL::action('UsersController@update') }}",
  72. {
  73. users: JSON.stringify(userBundle),
  74. submit_roles: true
  75. },
  76. function(data)
  77. {
  78. location.reload();
  79. }
  80. );
  81. });
  82. // --------------------------------------------------------------------------
  83. // Functions
  84. // --------------------------------------------------------------------------
  85. // --------------------------------------------------------------------------
  86. // Events
  87. // --------------------------------------------------------------------------
  88. });
  89. @stop