<!-- Extend Layout -->
@extends('layout.app')
<!-- Add Custom CSS -->
@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
<!-- Add Content Here -->
@section('content')
<!-- Include Sidebar -->
@include('layout.navbars.sidebar')
<div class="content-wrapper">
    <!-- Main content -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Manajemen Mahasiswa</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">Admin</a></li>
              <li class="breadcrumb-item active">Manajemen Mahasiswa</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
    
    <section class="content">
      <div class="card">
        <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
          <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-default">
            Tambah Data
          </button>
          <table id="example1" class="table table-bordered table-striped">
            <thead>
            <tr>
              <th>NIM</th>
              <th>Nama</th>
              <th>Email</th>
              <th>DPU</th>
              <th>Action</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($user as $users)
            <tr>
              <td>{{ $users->nim }}</td>
              <td>{{ $users->nama }}</td>
              <td>{{ $users->email }}</td>
              <td>{{ $users->dosen_dpu_name }}</td>
              <td class="text-center">
                <button class="btn btn-sm btn-success" data-toggle="modal" data-target="#mhs{{$users->id}}">Edit</button> | 
                <button class="btn btn-sm btn-danger" data-toggle="modal" data-target="#userdestroy{{$users->id}}">Hapus</button></td>
            </tr>
            <!-- MODAL EDIT PERUSER-->
            <div class="modal fade" id="mhs{{$users->id}}">
              <div class="modal-dialog modal-lg">
                <div class="modal-content">
                  <div class="modal-header">
                    <h4 class="modal-title">Edit Data</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">
                        <form action="{{ route('mahasiswa.update')}}" method="post">
                          @method('PUT')
                          @csrf
                        <input type="hidden" name="id" value="{{$users->id}}">
                        <label for="nim">NIM</label>
                        <input type="text" name="nim" id="nim" class="form-control form-control-sm" placeholder="Masukkan NIM Mahasiswa" value="{{ $users->nim }}">
                        <label for="nama">Nama</label>
                        <input type="text" name="nama" id="nama" class="form-control form-control-sm" placeholder="Masukkan Nama Mahasiswa" value="{{ $users->nama }}">
                        <label for="nomor_hp">Nomor HandPhone (WhatsApp)</label>
                        <input type="text" name="nomor_hp" id="nomor_hp" class="form-control form-control-sm" placeholder="Masukkan Nomor HandPhone (WhatsApp) Mahasiswa" value="{{ $users->nomor_hp }}">
                        <label for="email">Email</label>
                        <input type="text" name="email" id="email" class="form-control form-control-sm" placeholder="Masukkan Email Mahasiswa" value="{{ $users->email }}">
                        <label for="judul_seminar_proposal">Judul Karya Untuk Seminar Proposal</label>
                        <input type="text" name="judul_seminar_proposal" id="judul_seminar_proposal" class="form-control form-control-sm" placeholder="Masukkan Judul Karya Untuk Seminar Proposal Mahasiswa" value="{{ $users->judul_seminar_proposal }}">
                        <label for="judul_skripsi_id">Judul Karya Skripsi / Tugas Akhir (Bahasa Indonesia)</label>
                        <input type="text" name="judul_skripsi_id" id="judul_skripsi_id" class="form-control form-control-sm" placeholder="Masukkan Judul Karya Skripsi / Tugas Akhir (Bahasa Indonesia) Mahasiswa" value="{{ $users->judul_skripsi_id }}">
                        <label for="judul_skripsi_en">Judul Karya Skripsi / Tugas Akhir (Bahasa Inggris)</label>
                        <input type="text" name="judul_skripsi_en" id="judul_skripsi_en" class="form-control form-control-sm" placeholder="Masukkan Judul Karya Skripsi / Tugas Akhir (Bahasa Inggris) Mahasiswa" value="{{ $users->judul_skripsi_en }}">
                        <label for="bagian">Bagian Lab</label>
                        <select name="bagian" id="bagian" class="form-control form-control-sm">
                          <option selected>Pilih Laboratorium</option>
                          <option value="1" {{ $users->bagian === '1' ? 'selected' : '' }}>Farmasi Klinik Dan Komunitas</option>
                          <option value="2" {{ $users->bagian === '2' ? 'selected' : '' }}>Farmakologi Dan Hewan Coba</option>
                          <option value="3" {{ $users->bagian === '3' ? 'selected' : '' }}>Farmakognosi dan Fitokimia</option>
                          <option value="4" {{ $users->bagian === '4' ? 'selected' : '' }}>Mikrobiologi dan Bioteknologi Farmasi</option>
                          <option value="5" {{ $users->bagian === '5' ? 'selected' : '' }}>Farmasetika</option>
                          <option value="6" {{ $users->bagian === '6' ? 'selected' : '' }}>Teknologi Farmasi</option>
                          <option value="7" {{ $users->bagian === '7' ? 'selected' : '' }}>Kimia Analisis</option>
                          <option value="8" {{ $users->bagian === '8' ? 'selected' : '' }}>Kimia Medisinal</option>
                      
                        </select>
                      </div>
                    </div>
                    <div class="row">
                      <div class="col">
                        <label for="judul_jurnal">Judul Jurnal</label>
                        <input type="text" name="judul_jurnal" id="judul_jurnal" class="form-control form-control-sm" placeholder="Masukkan Judul Jurnal Mahasiswa" value="{{ $users->judul_jurnal }}">
                      </div>
                      <div class="col">
                        <label for="judul_artikel">Judul Artikel</label>
                        <input type="text" name="judul_artikel" id="judul_artikel" class="form-control form-control-sm" placeholder="Masukkan Judul Artikel Mahasiswa" value="{{ $users->judul_artikel }}">
                      </div>
                      <!-- /.col -->
                    </div>
                    <div class="row">
                      <div class="col">
                          <label for="dosen_dpu_id">Dosen Pembimbing Utama</label>
                          <select name="dosen_dpu_id" id="dosen_dpu_id" class="form-control select2" style="width: 100%;">
                            <option selected>Pilih Dosen Pembimbing Utama</option>
                            @foreach ($dosen as $dosens)
                            <option value="{{$dosens->id}}" {{ $users->dosen_dpu_id === $dosens->id ? 'selected' : '' }}>{{$dosens->nama_gelar}}</option>
                            @endforeach
                          </select>
                      </div>
                      <div class="col">
                        <label for="dosen_dpa_id">Dosen Pembimbing Anggota</label>
                          <select name="dosen_dpa_id" id="dosen_dpa_id" class="form-control select2" style="width: 100%;">
                            <option selected>Pilih Dosen Pembimbing Anggota</option>
                            @foreach ($dosen as $dosens)
                            <option value="{{$dosens->id}}" {{ $users->dosen_dpa_id === $dosens->id ? 'selected' : '' }}>{{$dosens->nama_gelar}}</option>
                            @endforeach
                          </select>
                      </div>
                      <!-- /.col -->
                    </div>
                    <div class="row">
                      <div class="col">
                        <label for="dosen_penguji1_id">Dosen Penguji Utama</label>
                        <select name="dosen_penguji1_id" id="dosen_penguji1_id" class="form-control select2" style="width: 100%;">
                          <option selected>Pilih Dosen Penguji Utama</option>
                          @foreach ($dosen as $dosens)
                          <option value="{{$dosens->id}}" {{ $users->dosen_penguji1_id === $dosens->id ? 'selected' : '' }}>{{$dosens->nama_gelar}}</option>
                          @endforeach
                        </select>
                      </div>
                      <div class="col">
                        <label for="dosen_penguji2_id">Dosen Penguji Anggota</label>
                        <select name="dosen_penguji2_id" id="dosen_penguji2_id" class="form-control select2" style="width: 100%;">
                          <option selected>Pilih Dosen Penguji Anggota</option>
                          @foreach ($dosen as $dosens)
                          <option value="{{$dosens->id}}" {{ $users->dosen_penguji2_id === $dosens->id ? 'selected' : '' }}>{{$dosens->nama_gelar}}</option>
                          @endforeach
                        </select>
                      </div>
                      <!-- /.col -->
                    </div>
                  </div>
                  <div class="modal-footer justify-content-between">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-success">Edit</button>
                  </form>
                  </div>
                </div>
                <!-- /.modal-content -->
              </div>
              <!-- /.modal-dialog -->
            </div>
            <!-- MODAl DELETE PER USER-->
            <div class="modal fade" id="userdestroy{{$users->id}}">
              <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header">
                    <h4 class="modal-title">Hapus Data</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">
                        <form action="{{ route('mahasiswa.destroy')}}" method="post">
                          @csrf
                          @method('DELETE')
                          Anda Yakin ingin Menghapus Data ini ?
                        <input type="hidden" name="id" id="id" value="{{$users->id}}">
                      </div>
                      <!-- /.col -->
                    </div>
                  </div>
                  <div class="modal-footer justify-content-between">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-danger">Delete</button>
                  </form>
                  </div>
                </div>
                <!-- /.modal-content -->
              </div>
              <!-- /.modal-dialog -->
            </div>
            @endforeach
            </tbody>
            <tfoot>
              <tr>
                <th>NIP</th>
                <th>Nama Dengan Gelar</th>
                <th>Email</th>
                <th>User Roles</th>
                <th>Action</th>
              </tr>
            </tfoot>
          </table>
        </div>
        <!-- /.card-body -->
        <div class="card-footer">
          .
        </div>
        <!-- /.card-footer-->
      </div>
      <!-- /.card -->

      <!-- /.Modal ADD DATA -->
      <div class="modal fade" id="modal-default">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Tambah Data</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">
                  <form action="{{ route('mahasiswa.store')}}" method="post">
                    @csrf
                  <label for="nim">NIM</label>
                  <input type="text" name="nim" id="nim" class="form-control form-control-sm" placeholder="Masukkan NIM Mahasiswa">
                  <label for="nama">Nama</label>
                  <input type="text" name="nama" id="nama" class="form-control form-control-sm" placeholder="Masukkan Nama Mahasiswa">
                  <label for="nomor_hp">Nomor HandPhone (WhatsApp)</label>
                  <input type="text" name="nomor_hp" id="nomor_hp" class="form-control form-control-sm" placeholder="Masukkan Nomor HandPhone (WhatsApp) Mahasiswa">
                  <label for="email">Email</label>
                  <input type="text" name="email" id="email" class="form-control form-control-sm" placeholder="Masukkan Email Mahasiswa">
                  <label for="judul_seminar_proposal">Judul Karya Untuk Seminar Proposal</label>
                  <input type="text" name="judul_seminar_proposal" id="judul_seminar_proposal" class="form-control form-control-sm" placeholder="Masukkan Judul Karya Untuk Seminar Proposal Mahasiswa">
                  <label for="judul_skripsi_id">Judul Karya Skripsi / Tugas Akhir (Bahasa Indonesia)</label>
                  <input type="text" name="judul_skripsi_id" id="judul_skripsi_id" class="form-control form-control-sm" placeholder="Masukkan Judul Karya Skripsi / Tugas Akhir (Bahasa Indonesia) Mahasiswa">
                  <label for="judul_skripsi_en">Judul Karya Skripsi / Tugas Akhir (Bahasa Inggris)</label>
                  <input type="text" name="judul_skripsi_en" id="judul_skripsi_en" class="form-control form-control-sm" placeholder="Masukkan Judul Karya Skripsi / Tugas Akhir (Bahasa Inggris) Mahasiswa">
                  <label for="bagian">Bagian Lab</label>
                  <select name="bagian" id="bagian" class="form-control form-control-sm">
                    <option selected>Pilih Laboratorium</option>
                    <option value="1">Farmasi Klinik Dan Komunitas</option>
                    <option value="2">Farmakologi Dan Hewan Coba</option>
                    <option value="3">Farmakognosi dan Fitokimia</option>
                    <option value="4">Mikrobiologi dan Bioteknologi Farmasi</option>
                    <option value="5">Farmasetika</option>
                    <option value="6">Teknologi Farmasi</option>
                    <option value="7">Kimia Analisis</option>
                    <option value="8">Kimia Medisinal</option>
                
                  </select>
                </div>
              </div>
              <div class="row">
                <div class="col">
                  <label for="judul_jurnal">Judul Jurnal</label>
                  <input type="text" name="judul_jurnal" id="judul_jurnal" class="form-control form-control-sm" placeholder="Masukkan Judul Jurnal Mahasiswa">
                </div>
                <div class="col">
                  <label for="judul_artikel">Judul Artikel</label>
                  <input type="text" name="judul_artikel" id="judul_artikel" class="form-control form-control-sm" placeholder="Masukkan Judul Artikel Mahasiswa">
                </div>
                <!-- /.col -->
              </div>
              <div class="row">
                <div class="col">
                    <label for="dosen_dpu_id">Dosen Pembimbing Utama</label>
                    <select name="dosen_dpu_id" id="dosen_dpu_id" class="form-control select2" style="width: 100%;">
                      <option selected>Pilih Dosen Pembimbing Utama</option>
                      @foreach ($dosen as $dosens)
                      <option value="{{$dosens->id}}">{{$dosens->nama_gelar}}</option>
                      @endforeach
                    </select>
                </div>
                <div class="col">
                  <label for="dosen_dpa_id">Dosen Pembimbing Anggota</label>
                    <select name="dosen_dpa_id" id="dosen_dpa_id" class="form-control select2" style="width: 100%;">
                      <option selected>Pilih Dosen Pembimbing Anggota</option>
                      @foreach ($dosen as $dosens)
                      <option value="{{$dosens->id}}">{{$dosens->nama_gelar}}</option>
                      @endforeach
                    </select>
                </div>
                <!-- /.col -->
              </div>
              <div class="row">
                <div class="col">
                  <label for="dosen_penguji1_id">Dosen Penguji Utama</label>
                  <select name="dosen_penguji1_id" id="dosen_penguji1_id" class="form-control select2" style="width: 100%;">
                    <option selected>Pilih Dosen Penguji Utama</option>
                    @foreach ($dosen as $dosens)
                    <option value="{{$dosens->id}}">{{$dosens->nama_gelar}}</option>
                    @endforeach
                  </select>
                </div>
                <div class="col">
                  <label for="dosen_penguji2_id">Dosen Penguji Anggota</label>
                  <select name="dosen_penguji2_id" id="dosen_penguji2_id" class="form-control select2" style="width: 100%;">
                    <option selected>Pilih Dosen Penguji Anggota</option>
                    @foreach ($dosen as $dosens)
                    <option value="{{$dosens->id}}">{{$dosens->nama_gelar}}</option>
                    @endforeach
                  </select>
                </div>
                <!-- /.col -->
              </div>
            </div>
            <div class="modal-footer justify-content-between">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="submit" class="btn btn-primary">Tambah</button>
            </form>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
    </section>
    <!-- /.content -->
</div>
@endsection

<!-- Add Custom JS -->
@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 src="{{asset('/')}}plugins/select2/js/select2.full.min.js"></script>
<!-- Page specific script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
    }).container().appendTo('#example1_wrapper .col-md-6:eq(0)');
    $('.select2').select2();
  });
</script>
@endpush

