@extends('layouts.master')

@section('title')
    Dashboard
@endsection

@section('header')
<div class="page-title">
    <h3>Dashboard</h3>
</div>
@endsection

@section('contents')
    <!-- start page title -->
    <div class="page-title-box">
        <div class="row align-items-center">
            <div class="col-md-8">
                <h6 class="page-title">{!! $title !!}</h6>
                <ol class="breadcrumb m-0">
                    <li class="breadcrumb-item">Mahasiswa</li>
                    <li class="breadcrumb-item">{!! $title !!}</li>
                </ol>
            </div>
        </div>
    </div>
    <!-- end page title -->
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <div class="row">
                        <div class="col-10">
                            <h4 class="card-title">Dosen Pembimbing</h4>
                        </div>
                    </div>
                    <br/>
                    <div class="table-responsive">
                        <table class="table table-hover table-centered table-nowrap mb-0">
                            <tbody>
                                <tr class="table-light">
                                    <td>Kode Kelompok</td>
                                    <td>NIDN Dosen</td>
                                    <td>Dosen Pembimbing</td>
                                </tr>
                                <tr>
                                    <td>{{ $kelompok->kode }}</td>
                                    <td>{{ $kelompok->nidn_dosen }}</td>
                                    <td>{{ $kelompok->nama_dosen }}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <br/>
                    <div class="row">
                        <div class="col-10">
                            <h4 class="card-title">Anggota Kelompok</h4>
                        </div>
                        <div class="col-2">
                            <a href="{{ URL::to('mahasiswa/anggota/create') }}" class="btn btn-info btn-sm">Tambah Anggota</a>
                        </div>
                    </div>
                    <br/>
                    <div class="table-responsive">
                        <table class="table table-hover table-centered table-nowrap mb-0">
                            <thead>
                            <tr class="table-light">
                                <td>No</td>
                                <td>Nama</td>
                                <td>NIM</td>
                                <td>Fakultas</td>
                                <td>Program Studi</td>
                                <td>Keterangan</td>
                                <td></td>
                            </tr>
                            <thead>
                            <tbody>
                                @foreach ($kelompok->rAnggota as $item)
                                <tr>
                                    <td>{{ $loop->iteration }}</td>
                                    <td>{{ ucwords(strtolower($item->nama)) }}</td>
                                    <td>{{ $item->nim }}</td>
                                    <td>{{ $item->fakultas }}</td>
                                    <td>{{ $item->prodi }}</td>
                                    <td>
                                        @if($item->status_ketua == 1)
                                            Ketua
                                        @else
                                            Anggota {{ $loop->iteration-1 }}
                                        @endif
                                    </td>
                                    <td></td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>


        {{ Form::open(['url' => route('mahasiswa.kelompok.kirim'), 'method' => 'post', 'id' => 'addKelompok']) }}
        {!! Form::hidden('kelompok_id', $kelompok->kelompok_id) !!}
        {{ Form::close() }}

        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <div class="alert alert-success alert-dismissible fade show" role="alert">
                        <strong>Informasi!</strong> Anggota kelompok minimal 3 dan maksimal 5 </strong>
                    </div>
                    <div class="mb-0">
                        @if($kelompok->rAnggota->count() >= 3)
                            <button type="submit" class="btn btn-primary waves-effect waves-light me-1 btnSimpanKelompok" id="btnSimpanKelompok"> Submit </button>
                        @endif
                        <a href="{{ URL::to('mahasiswa/kelompok') }}" type="reset" class="btn btn-secondary waves-effect"> Kembali </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- end row -->

@endsection

@section('js')
<script>
    $(".btnSimpanKelompok").click(function (e) {
        e.preventDefault();
        $(".btnSimpanKelompok").hide();
        $("#andou").html("<h3>Sedang proses ... </h3>");

        $("#addKelompok").submit();
    });
</script>
@endsection
