@extends('layouts.Layout')

@section('content')
 <div class="col-md-12">
  <div class="card">
      <div class="header">
         <h3>Tahun ajaran</h3>
      </div>
        <div class="panel-body">
          @if(Session::has('alert-success'))
              <div class="alert alert-success">
                    {{ Session::get('alert-success') }}
                </div>
          @endif
        <div class="content table-responsive table-full-width" >
          <button type="button" class="Add-tahun btn btn-info pull-right btn-sm" ><span class="glyphicon glyphicon-plus"></span>Tambah Data</button><br><br>
          <table class="table table-striped" id="table">
            <tr>
              <th>ID</th>
              <th>Kode</th>
              <th>Keterangan</th>
              <th>Action</th>
            </tr>
            @foreach($tahunajaran as $thn)
            <tr class="item{{$thn->id}}">
              <td>{{$thn->id}}</td>
              <td>{{$thn->kode}}</td>
              <td>{{$thn->keterangan}}</td>
              <td>
                <button class="update-modal btn btn-info btn-sm" data-id="{{$thn->id}}" data-kode="{{$thn->kode}}" data-keterangan="{{$thn->keterangan}}"><span class="glyphicon glyphicon-edit"></span> Ubah</button>
                <button class="delete-modal btn btn-danger btn-sm" data-id="{{$thn->id}}"><span class="glyphicon glyphicon-trash"></span> Delete</button>

                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <a href="{{ route('tahunajaran.show',$thn->id)}}" class="btn btn-info pull-right btn-sm"><span class="glyphicon glyphicon-list"></span> Lihat Daftar Pendaftar</a>
              </td>
            </tr>
            @endforeach
          </table>
          
        </div>
      </div>
    </div>
  </div>
@endsection
          <!-- Edit modal -->
          <div class="modal fade bs-example-modal-sm2" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
              <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                      </button>
                      <h4 class="modal-title">Ubah Data</h4>
                    </div>
                    <div class="modal-body">
                      <div class="form-group">
                        {{ csrf_field() }}
                        <input type="hidden" name="id" id="id-edit">
                        <input type="text" name="kode-edit" id="kode-edit" class="form-control" placeholder="Kode">
                      </div>
                      <div class="form-group">
                        <input type="text" name="keterangan-edit" id="keterangan-edit" class="form-control" placeholder="Keterangan">
                      </div>
                      <div class="form-group" align="right">
                        <button type="button" id="Ubah" class="btn btn-primary" data-dismiss="modal">Ubah</button>
                      </div>
                    </div>
                </div>
              </div>
          </div>

          <!-- Delete modal -->
          <div class="modal fade bs-example-modal-sm3" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
              <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                      <h4 class="modal-title">Delete Data</h4>
                    </div>
                    <div class="modal-body">
                      <div class="form-group">
                        {{ csrf_field() }}
                        <input type="hidden" name="id-delete" id="id-delete">
                        <p>Yakin Ingin Menghapus Data? </p>
                      </div>
                      <div class="form-group" align="right">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <button type="button" id="delete" class="btn btn-danger" data-dismiss="modal">Delete</button>
                      </div>
                    </div>
                </div>
              </div>
          </div>
          <div class="modal fade bs-example-modal-sm1" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
              <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                      <h4 class="modal-title">Tambah Data</h4>
                    </div>
                    <div class="modal-body">
                      <div class="form-group">
                        {{ csrf_field() }}
                        <input type="text" name="kode" id="kode" class="form-control" placeholder="Kode">
                      </div>
                      <div class="form-group">
                        <input type="text" name="keterangan" id="keterangan" class="form-control" placeholder="Keterangan">
                      </div>
                      <div class="form-group" align="right">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <button type="button" id="add" class="btn btn-primary" data-dismiss="modal">Simpan</button>
                      </div>
                    </div>
                </div>
              </div>
          </div>
