add.blade.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. @extends('layouts.master')
  2. @section('content')
  3. <div class="content">
  4. <div class="row" style="min-height: 500px">
  5. <div class="col-md-8 col-md-offset-2">
  6. <header class="panel-heading" style="height:50px;">
  7. <div class="pull-left">
  8. {{$title}}
  9. </div>
  10. <div>
  11. @if(\Auth::user()->utype==1)
  12. <a href="{{ url('admin/grade') }}" class="btn btn-sm btn-info pull-right"><i class="fa fa-list"></i> Grade List</a> <br><br>
  13. @endif
  14. </div>
  15. </header>
  16. </div>
  17. <div class="col-md-8 col-md-offset-2">
  18. <div class="panel panel-default">
  19. <div class="panel-body">
  20. {{-- action="{{ url('admin/grade/store') }}" enctype="multipart/form-data" method="POST" role="form" --}}
  21. <form>
  22. {{ csrf_field() }}
  23. <div class="col-md-10 col-md-offset-1">
  24. <div class="alert alert-danger print-error-msg" style="display:none">
  25. <ul></ul>
  26. </div>
  27. <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }}">
  28. <label for="name">Grade Name <i class="text-danger">*</i></label>
  29. <input type='text' name="name" id="name" class="form-control" value="{{ old('name') }}" placeholder="Grade Name">
  30. <lebel class="text-danger"> {{ $errors->first('name') }}</lebel>
  31. </div>
  32. </div>
  33. <div class="col-md-10 col-md-offset-1" style="margin-top: 30px;">
  34. <a href="{{ url('admin/grade') }}" class="btn btn-default pull-left">
  35. <span class="btn-icon">
  36. <i class="fa fa-times"></i>
  37. </span>
  38. Cancel
  39. </a>
  40. <span class="btn btn-inline btn-success pull-right btn-submit">
  41. <span class="btn-icon">
  42. <i class="fa fa-save"></i>
  43. </span>
  44. Submit
  45. </span>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </form>
  51. </div>
  52. </div>
  53. @stop
  54. @section('script')
  55. @if(Session::has('msg'))
  56. <div class="alert alert-success center-block msg_alt" >
  57. <a class="close" data-dismiss="alert" href="#">&times;</a>
  58. <strong><i class="fa fa-check"></i></strong>&nbsp;
  59. {{Session::get('msg')}}
  60. </div>
  61. @endif
  62. <script type="text/javascript">
  63. $(document).ready(function() {
  64. $(".btn-submit").click(function(e){
  65. e.preventDefault();
  66. var _token = $("input[name='_token']").val();
  67. var name = $("input[name='name']").val();
  68. $.ajax({
  69. url: "/admin/grade/store",
  70. type:'POST',
  71. data: {_token:_token, name:name},
  72. success: function(data) {
  73. if($.isEmptyObject(data.error)){
  74. location.href = "/admin/grade";
  75. }else{
  76. printErrorMsg(data.error);
  77. }
  78. }
  79. });
  80. });
  81. function printErrorMsg (msg) {
  82. $(".print-error-msg").find("ul").html('');
  83. $(".print-error-msg").css('display','block');
  84. $.each( msg, function( key, value ) {
  85. $(".print-error-msg").find("ul").append('<ol>'+value+'</ol>');
  86. });
  87. }
  88. });
  89. </script>
  90. @stop