@extends('website.layouts.app')

@section('title')
    Data Parameter Ketinggian | Kecamatan
@endsection

@section('content')
    <!-- start page title -->
    <div class="row">
        <div class="col-12">
            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                <h4 class="mb-sm-0">Data Parameter Ketinggian</h4>

                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="javascript: void(0);">Parameters</a></li>
                        <li class="breadcrumb-item active">Kecamatan</li>
                    </ol>
                </div>

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

    <div class="row">
        <div class="col-lg-12">

            <div class="card border card-border-warning">
                <div class="card-header">
                    <h6 class="card-title mb-0">Baca Terlebih Dahulu !!!</h6>
                </div>
                <div class="card-body">
                    <p class="card-text">
                        Berikut adalah pengambilan parameter pada setiap kecamatan di Kabupaten Bondowoso.
                        Parameter dibawah ini terdapat data ketinggian tempat sebagai salah satu parameter.
                        Data ketinggian tempat tersebut bersumber dari publikasi
                        <a href="https://bondowosokab.bps.go.id/id/publication" target="_blank">BPS Kabupaten Bondowoso</a>.
                    </p>
                </div>
            </div>
            <div class="card">
                <div class="card-header d-flex flex-column flex-sm-row align-items-sm-center justify-content-between gap-2">
                    <h4 class="card-title mb-0 flex-grow-1">Data Parameter Ketinggian | Tahun
                        <span id="span-year">2021</span>
                    </h4>
                    <div class="d-flex">
                        <select class="form-select w-100 w-sm-auto" id="choiceYear" aria-label="pilih-tahun">
                            @foreach ($years as $year)
                                <option value="{{ $year }}"> {{ $year }}</option>
                            @endforeach
                        </select>
                        <div class="d-flex w-100 w-sm-auto">
                            <button class="btn btn-md btn-primary ms-2" data-bs-toggle="modal" data-bs-target="#btn-add">
                                tambah
                            </button>
                        </div>
                    </div>
                </div><!-- end card header -->

                <div class="card-body">
                    <div id="table-parameter-list-height-sub-district" class="table-responsive">
                    </div>
                </div><!-- end card-body -->
            </div><!-- end card -->
        </div>
        <!-- end col -->
    </div>

    <!-- add height sub district modals -->
    <div class="modal fade" id="btn-add" tabindex="-1" aria-labelledby="btn-addLabel" aria-modal="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="btn-addLabel">Tambah data ketingian tempat kecamatan (Tahunan)</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="{{ route('parameter-list-height-sub-district.addListHeightSubDistrict') }}"
                        method="POST">
                        @csrf
                        <div class="row g-3">
                            <div class="col-lg-12">
                                <div>
                                    <label for="subDistrictId" class="form-label">Pilih Kecamatan</label>
                                    <select class="form-select mb-3" aria-label="Default select example"
                                        name="subDistrictId" id="subDistrictId">
                                        @foreach ($subDistricts as $subDistrict)
                                            <option value="{{ $subDistrict->id }}">{{ $subDistrict->sub_district }}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div>
                                    <label for="year" class="form-label">Inputkan Tahun</label>
                                    <input type="text" class="form-control mb-1" id="year" name="year"
                                        placeholder="masukkan tahun" required
                                        oninput="this.value = this.value.replace(/[^0-9.-]/g, '').replace(/(?!^)-/g, '').replace(/^\.+|\.\.+/g, '').replace(/(\.\d*)\./g, '$1').slice(0, 4)">
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div>
                                    <label for="height" class="form-label">Inputkan Ketinggian Tempat</label>
                                    <input type="text" class="form-control mb-1" id="height" name="height"
                                        placeholder="masukkan ketinggian" required
                                        oninput="this.value = this.value.replace(/[^0-9.-]/g, '').replace(/(?!^)-/g, '').replace(/^\.+|\.\.+/g, '').replace(/(\.\d*)\./g, '$1')">
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div class="hstack gap-2 justify-content-end">
                                    <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                </div>
                            </div><!--end col-->
                        </div><!--end row-->
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- update alternatif referensi modals -->
    <div class="modal fade" id="modal-edit" tabindex="-1" aria-labelledby="btn-editLabel" aria-modal="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="btn-editLabel">Ubah data ketinggian tempat kecamatan (tahunan)</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="{{ route('parameter-list-height-sub-district.updateListHeightSubDistrict') }}"
                        method="POST">
                        @csrf
                        <div class="row g-3">
                            <input type="hidden" name="heightSubDistrictId" id="heightSubDistrictId">
                            <input type="hidden" name="subDistrictId" id="subDistrictId">
                            <div class="col-lg-12">
                                <div>
                                    <label for="subDistrict" class="form-label">
                                        Kecamatan
                                    </label>
                                    <input type="text" class="form-control mb-1" id="subDistrict" name="subDistrict"
                                        required>
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div>
                                    <label for="year" class="form-label">
                                        Tahun
                                    </label>
                                    <input type="text" class="form-control mb-1" id="year" name="year"
                                        required>
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div>
                                    <label for="height" class="form-label">
                                        Ketinggian Tempat
                                    </label>
                                    <input type="text" class="form-control mb-1" id="height" name="height"
                                        required>
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div class="hstack gap-2 justify-content-end">
                                    <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                </div>
                            </div><!--end col-->
                        </div><!--end row-->
                    </form>
                </div>
            </div>
        </div>
    </div>


    <script src="{{ asset('assets/libs/prismjs/prism.js') }}"></script>
    <script src="{{ asset('assets/libs/gridjs/gridjs.umd.js') }}"></script>
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>

    {{-- <script src="{{ asset('assets/js/pages/gridjs.init.js') }}"></script> --}}

    {{-- custom js --}}
    <script src="{{ asset('assets/js/custom/parameter-list-height-sub-district.js') }}"></script>
@endsection
