@extends($admin)

@section('title')
 {{ $title }}
@endsection

@push('css')
    <link rel="stylesheet" type="text/css" href="{{ asset('assets/css/datatables.css') }}">
@endpush

@section('content')
    @component('components.breadcrumb')
        @slot('breadcrumb_title')
        <h3>Saran</h3>
        @endslot
        <li class="breadcrumb-item">Saran</li>
        <li class="breadcrumb-item active">List</li>
    @endcomponent

    
    <div class="container-fluid">
        <div class="row">
            <form action="{{ url($url) }}/update/{{ $saran->id }}" method="POST">
                @csrf 
                @method('PUT') 
                {{-- Create Kon Kegiatan --}}
                <div class="col-sm-12">
                    <div class="card">
                        <div class="card-header">
                            <div class="row">
                                <div class="col-lg-6">
                                    <h5 class="card-title">{{ $page }}</h5>
                                </div>
                                <div class="col-lg-6">
                                    <a href="{{ url($url) }}" class="btn btn-sm btn-primary float-end">Kembali</a>
                                </div>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="mb-3">
                                <label class="col-form-label pt-0" for="exampleInputEmail1">Saran :</label>
                                {{ $saran->saran }}
                            </div>
                            <div class="mb-3">
                                <label class="col-form-label pt-0" for="exampleInputEmail1">Tanggapan</label>
                                <textarea name="tanggapan" class="form-control" id="exampleFormControlTextarea4" rows="3"></textarea>
                            </div>
                        </div>
                        <div class="card-footer">
                            <input type="submit" class="btn btn-primary" value="Simpan">
                            <input type="reset" class="btn btn-secondary" value="Cancel">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

@push('scripts')
    <script src="{{ asset('assets/js/datatable/datatables/jquery.dataTables.min.js') }}"></script>
    <script src="{{ asset('assets/js/datatable/datatables/datatable.custom.js') }}"></script>

    <script>
        $(function() {
            let baseUrl     = '{{ url('') }}';
            let idSekolah = "{{ session()->get('idPSekolah') }}";

            $.getJSON(baseUrl+'/getallsekolah', (result) => {
                if (result.error_code == '0') {
                    let opt = '<option value="">- Pilih -</option>';
                    $.each(result.data, function(i, item) {
                        opt += '<option value="'+item.id+'">'+item.nama+'</option>';
                    });
                    $("#select-sekolah").html(opt);
                }else{
                    let opt = '<option value="">- Tidak Bisa -</option>';
                    $("#select-sekolah").html(opt);
                }
                $("#select-sekolah").select2({
                    placeholder: "Pilih Sekolah",
                });
            });

            
        });
    </script>
@endpush

@endsection

