<!-- Extend Layout -->
@extends('layout.app_guest',['title' => $title])
@push('css')
<link rel="stylesheet" href="{{asset('/')}}plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="{{asset('/')}}plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
<link rel="stylesheet" href="{{asset('/')}}plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
@endpush
@section('content')

<!-- Main content -->
<section class="content">
  <div class="container-fluid">
    <!-- SELECT2 EXAMPLE -->
    <div class="card card-default">
      <div class="card-header">
        <h3 class="card-title">{{$title}}</h3>
      </div>
      <!-- /.card-header -->
      <div class="card-body">
        @if ($errors->any())
            <div class="alert alert-danger">
              <ul>
                @foreach ($errors->all() as $error )
                  <li>{{ $error }}</li>
                @endforeach
              </ul>
            </div>
          @endif
          @if(session('success'))
          <div class="alert alert-success">
            <ul>
                <li>{{ session('success') }}</li>
            </ul>
          </div>
          @endif
          @if(session('error'))
          <div class="alert alert-danger">
            <ul>
                <li>{{ session('error') }}</li>
            </ul>
          </div>
          @endif
        <div class="alert alert-info alert-dismissible">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
          <h5><i class="icon fas fa-info"></i> Perhatian!</h5>
          <span>Data yang tampil disini adalah data Real time. Jika Belum melakukan pengisian maka data tidak akan muncul</span>
        </div>
        <table id="example1" class="table table-bordered table-striped">
            <thead>
              <tr>
                <th>CaseID</th>
                <th>Program Studi</th>
                <th>Mata Kuliah</th>
                <th>Dosen Pengampu</th>
                <th>Ruang Kuliah</th>
                <th>Tanggal</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              @foreach($data as $item)
                <tr>
                    <td>{{$item->caseid}}</td>
                    <td>{{$item->program_studi}}</td>
                    <td>{{$item->mata_kuliah}}</td>
                    <td>{{$item->dosen_pengampu}}</td>
                    <td>{{$item->ruang_kelas}}</td>
                    <td>{{$item->tanggal_kelas}}</td>
                    <td>@if($item->status_operator === null)<span class="badge badge-warning">Diproses</span> @elseif($item->keterangan_operator != "0")<span class="badge badge-danger"><a data-toggle="modal" data-target="#alasan{{ $item->caseid }}">Ditolak</a></span> @else <span class="badge badge-success">Selesai</span>  @endif</td>
                </tr>
                <div class="modal fade" id="alasan{{$item->caseid}}">
                  <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                      <div class="modal-header">
                        <h4 class="modal-title">Alasan Penolakan <b>{{ $item->caseid }}</b></h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                        </button>
                      </div>
                      <div class="modal-body">
                          <div class="row">
                            <div class="col">
                              <label for="keterangan_operator">Alasan:</label>
                              <textarea disabled name="keterangan_operator" class="form-control" id="keterangan_operator" cols="30" rows="10" 
                              >{{$item->keterangan_operator}}</textarea>
                            </div>
                          </div>
                      </div>
                      <div class="modal-footer justify-content-between">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
                      </form>
                      </div>
                    </div>
                    <!-- /.modal-content -->
                  </div>
                  <!-- /.modal-dialog -->
                </div>
             @endforeach
            </tbody>
            <tfoot>
              <tr>
                <th>CaseID</th>
                <th>Program Studi</th>
                <th>Mata Kuliah</th>
                <th>Dosen Pengampu</th>
                <th>Ruang Kuliah</th>
                <th>Tanggal</th>
                <th>Status</th>
              </tr>
            </tfoot>
        </table>
      </div>
    </div>
    <!-- /.card -->
  </div>
  <!-- /.container-fluid -->
</section>
<!-- /.content -->

@endsection
@push('js')
<!-- DataTables  & Plugins -->
<script src="{{asset('/')}}plugins/datatables/jquery.dataTables.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="{{asset('/')}}plugins/jszip/jszip.min.js"></script>
<script src="{{asset('/')}}plugins/pdfmake/pdfmake.min.js"></script>
<script src="{{asset('/')}}plugins/pdfmake/vfs_fonts.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.colVis.min.js"></script>

<script>
    $(function () {
      $("#example1").DataTable({
        "pageLength": 50,
        "responsive": true, "lengthChange": false, "autoWidth": false,
        "order": [[5, 'desc']],
        "buttons": ["csv", "excel", "pdf", "print", "colvis"]
      }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
  
    });
</script>
@endpush