@extends('website.layouts.app')

@section('title')
    Data Parameter Ketinggian | Desa / Kelurahan
@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">Desa / Kelurahan</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 desa / kelurahan 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 flex-column flex-sm-row justify-content-between gap-2 w-100">
                        <div class="d-flex flex-column flex-sm-row gap-2 w-100">
                            <select class="form-select w-100" id="choiceYear" aria-label="pilih-tahun">
                                @foreach ($years as $year)
                                    <option value="{{ $year }}"> {{ $year }}</option>
                                @endforeach
                            </select>

                            <select class="form-select w-100" id="choiceSubDistrict" aria-label="pilih-kecamatan">
                                @foreach ($listSubDistrict as $subDistrict)
                                    <option value="{{ $subDistrict->id }}"
                                        {{ $subDistrict->sub_district == 'Kec Cermee' ? 'selected' : '' }}>
                                        {{ $subDistrict->sub_district }}
                                    </option>
                                @endforeach
                            </select>
                        </div>

                        <div class="ms-1 w-sm-auto w-100">
                            <button class="btn btn-md btn-primary ms-2 btn-add-height-village" 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-village" class="table-responsive">
                    </div>
                </div><!-- end card-body -->
            </div><!-- end card -->
        </div>
        <!-- end col -->
    </div>

    <!-- add height village 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 desa / kelurahan (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-village.addListHeightVillage') }}" 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" required>
                                        @foreach ($listSubDistrict as $subDistrict)
                                            <option value="{{ $subDistrict->id }}">{{ $subDistrict->sub_district }}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div>
                                    <label for="villageId" class="form-label">Pilih Desa atau Kelurahan</label>
                                    <select class="form-select mb-3" name="villageId" id="villageId" required>
                                        <option value="">-- Pilih Desa --</option>
                                    </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 height village 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 desa atau kelurahan (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-village.updateListHeightVillage') }}" method="POST">
                        @csrf
                        <div class="row g-3">
                            <input type="hidden" id="heightVillageId" name="heightVillageId">
                            <input type="hidden" id="subDistrictId" name="subDistrictId">
                            <input type="hidden" id="villageId" name="villageId">
                            <div class="col-lg-12">
                                <div>
                                    <label for="subDistrictName" class="form-label">Pilih Kecamatan</label>
                                    <input type="text" class="form-control mb-1" name="subDistrictName"
                                        id="subDistrictName" required>
                                </div>
                            </div><!--end col-->
                            <div class="col-lg-12">
                                <div>
                                    <label for="villageName" class="form-label">Pilih Desa atau Kelurahan</label>
                                    <input type="text" class="form-control mb-1" name="villageName" id="villageName"
                                        required>
                                </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>

    <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-village.js') }}"></script>
@endsection
