@extends('layouts.master')

@section('title')
    Publikasi Artikel Dalam Prosiding
@endsection

@section('header')
<div class="page-title">
    <h3>Publikasi Artikel Dalam Prosiding</h3>
</div>
@endsection

@section('contents')
@php
 $menu = 'dashboard';
@endphp
    <div class="account-settings-container layout-top-spacing">
        <form id="general-info" class="section general-info" action="{{ $edit ? route('publikasiartikel.update', ['publikasiartikel' => encrypt($data->id)]) : route('publikasiartikel.store') }}" method="POST">
            @csrf
            @if ($edit)
                {{ method_field('PUT') }}
            @endif
        <div class="account-content">
            <div class="scrollspy-example" data-spy="scroll" data-target="#account-settings-scroll" data-offset="-100">
                <div class="row">

                    <div class="col-xl-12 col-lg-12 col-md-12 layout-spacing">
                            <div class="info">
                                <h6 class="">Pemakalah</h6>
                                <div class="row">
                                    <div class="col-lg-11 mx-auto">
                                        <div class="input-group mb-4">
                                            <input type="text" class="form-control" id="input_nidn_dosen" value="{{ $edit ? $data->nidn : old('nidn') }}" placeholder="NIDN" aria-label="nidn">
                                            <input type="text" class="form-control" name="nidn" value="{{ $edit ? $data->nidn : old('nidn') }}" id="nidn_dosen" placeholder="NIDN" aria-label="nidn" hidden>
                                            <div class="input-group-append">
                                                <button class="btn btn-info" onclick="checkNidn('nidn_dosen')" type="button">Cek</button>
                                            </div>
                                        </div>
                                        <div class="form-row mb-4">
                                                <div class="form-group col-md-6">
                                                    <label for="inputEmail4">Nama Dosen</label>
                                                    <input type="text" id="nama_nidn_dosen" class="form-control" id="namadosen" disabled>
                                                </div>
                                                <div class="form-group col-md-6">
                                                    <label for="inputPassword4">Program Studi</label>
                                                    <input type="text" id="prodi_nidn_dosen" class="form-control" id="programstudi" disabled>
                                                </div>
                                            </div>
                                    </div>
                                </div>
                            </div>
                    </div>

                    <div class="col-xl-12 col-lg-12 col-md-12 layout-spacing">
                            <div class="info">
                                <h5 class="">Pemakalah Forum Ilmiah {{ ucwords($tingkat) }}</h5>
                                <div class="row">
                                    <div class="col-md-11 mx-auto">
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label>Judul Makalah</label>
                                                    <textarea class="form-control" id="judul" name="judul" placeholder="Judul Makalah" rows="2">{{ $edit ? $data->judul : old('judul') }}</textarea>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Nama Forum</label>
                                                    <input type="text" class="form-control mb-4" id="nama_forum" name="nama_forum" value="{{ $edit ? $data->nama_forum : old('nama_forum') }}" placeholder="Nama Forum">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Institusi Penyelenggara</label>
                                                    <input type="text" class="form-control mb-4" id="institusi" name="institusi" value="{{ $edit ? $data->institusi : old('institusi') }}" placeholder="Institusi Penyelenggara">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <label for="date">Waktu Pelaksanaan</label>
                                                 <div class="row">
                                                    <div class="col-xl-5">
                                                        <div class="form-group">
                                                            <input id="date" type="date" name="waktu_pelaksanaan_awal" value="{{ $edit ? $data->waktu_pelaksanaan_awal : old('waktu_pelaksanaan_awal') }}" class="form-control" placeholder="">
                                                        </div>
                                                    </div>
                                                    <div class="col-xl-1">
                                                        <div class="form-group">
                                                            <label for="date2">s/d</label>
                                                        </div>
                                                    </div>
                                                    <div class="col-xl-5">
                                                        <div class="form-group">
                                                            <input id="date" type="date" name="waktu_pelaksanaan_akhir" value="{{ $edit ? $data->waktu_pelaksanaan_akhir : old('waktu_pelaksanaan_akhir') }}" class="form-control" placeholder="">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Tempat Pelaksanaan</label>
                                                    <input type="text" class="form-control mb-4" id="tempat" name="tempat" value="{{ $edit ? $data->tempat : old('tempat') }}" placeholder="Tempat Pelaksanaan">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label>Status</label>
                                                    <select class="form-control" name="status" id="status">
                                                        <option value="1" {{ $edit ? ($data->status == '1' ? 'selected' : '') : (old('status') == '1' ? 'selected' : '') }}>Pemakalah Biasa</option>
                                                        <option value="2" {{ $edit ? ($data->status == '2' ? 'selected' : '') : (old('status') == '2' ? 'selected' : '') }}>Invited/Keynote Speaker</option>
                                                    </select>
                                                    <input type="text" name="jenis" value="{{ $tingkat }}" hidden>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

            <div class="account-settings-footer">
                <div class="as-footer-container">
                    <button id="multiple-reset" class="btn btn-warning">Batal</button>
                    <button id="multiple-messages" type="submit" class="btn btn-primary">Save Changes</button>
                </div>
            </div>
        </form>
    </div>

@endsection

@section('js')
    <script src="{{ url('theme/plugins/apex/apexcharts.min.js') }} "></script>
    <script src="{{ url('theme/assets/js/dashboard/dash_2.js') }} "></script>
    <script>
        function checkNidn(id){
            var value = $('#input_'+id).val();

            var request = $.ajax({
                url: "{{ route('get-biodata') }}",
                type: "get",
                dataType: "json",
                data: {nidn:value},
                success: function(result){
                    $('#nama_'+id).val(result['name']);
                    $('#prodi_'+id).val(result['prodi']);
                    $('#'+id).val(result['nidn']);
                }
            })
        }
    </script>
@endsection
