@extends('layouts/contentLayoutMaster')

@section('title', 'DataTables')

@section('vendor-style')
    {{-- vendor css files --}}
    <link rel="stylesheet" href="{{ asset(mix('vendors/css/tables/datatable/dataTables.bootstrap5.min.css')) }}">
    <link rel="stylesheet" href="{{ asset(mix('vendors/css/tables/datatable/responsive.bootstrap5.min.css')) }}">
    <link rel="stylesheet" href="{{ asset(mix('vendors/css/pickers/flatpickr/flatpickr.min.css')) }}">
    <link rel="stylesheet" href="{{ asset(mix('vendors/css/forms/select/select2.min.css')) }}">
@endsection

@section('page-style')
    {{-- Page Css files --}}
    <link rel="stylesheet" type="text/css" href="{{ asset('css/base/plugins/forms/pickers/form-flat-pickr.css') }}">
@endsection

@section('content')
    <section id="ajax-datatable">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header border-bottom d-flex " style="justify-content: space-between !important">
                        <h4 class="card-title">Tambah Bantaran Sungai</h4>
                    </div>
                    @if (session()->get('success'))
                        <div class="alert alert-success m-2 p-1">{{ session()->get('success') }}</div>
                    @endif
                    @if (session()->get('error'))
                        <div class="alert alert-danger m-2 p-1">{{ session()->get('error') }}</div>
                    @endif
                    @if ($errors->any())
                        <div class="alert m-2 p-1 alert-danger">
                            <ul>
                                @foreach ($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div>
                    @endif
                    <div class="card-body mt-2">
                        <form method="POST" enctype="multipart/form-data" action="{{ url('bantaran_sungai/created') }}">
                            @csrf
                            <div class="row">
                                <div class="col-md-6 ">
                                    <div class="containers">
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Nama Bantaran Sungai*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="text"
                                                    class="form-control @error('nama')
                                          is-invalid
                                      @enderror"
                                                    placeholder="Nama Bantaran Sungai" name="nama" required />
                                            </div>
                                            @error('nama')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Koordinat Lat*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="text"
                                                    class="form-control @error('lat')
                                          is-invalid
                                      @enderror"
                                                    placeholder="Koordinat Lat" name="lat" required />
                                            </div>
                                            @error('lat')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Koordinat Long*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="text"
                                                    class="form-control @error('long')
                                          is-invalid
                                      @enderror"
                                                    placeholder="Koordinat Long" name="long" required />
                                            </div>
                                            @error('long')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6 col-12">
                                    <div class="containers">
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Hulu Sungai*</h5>
                                            </label>
                                            <div class="inpu">
                                                <select name="hulu" id="12ww"
                                                    class="form-control @error('hulu')
                                                    is-invalid
                                                @enderror select2 w-100"
                                                    required style="width: 100% !important">
                                                    <option value="">Pilih</option>
                                                    @foreach ($device as $row)
                                                        <option value="{{ $row->no }}">{{ $row->nama_device }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            @error('hulu')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Kecamatan*</h5>
                                            </label>
                                            <div class="inputs">
                                                <select name="kecamatan" id="122ww"
                                                    class="form-control @error('kecamatan')
                                                    is-invalid
                                                @enderror select2 w-100"
                                                    required style="width: 100% !important">
                                                    <option value="">Pilih</option>
                                                    @foreach ($kecamatan as $rows)
                                                        <option value="{{ $rows->uuid }}">{{ $rows->nama }}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            @error('kecamatan')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Foto*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="file" name="foto" required class="form-control"
                                                    accept="image/png, image/jpeg, image/jpg">
                                            </div>
                                            @error('kecamatan')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <a href="{{ url('bantaran_sungai/index') }}" class="btn btn-warning">Kembali</a>
                                <button type="submit" class="btn btn-primary">Simpan</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection


@section('vendor-script')
    {{-- vendor files --}}
    <script src="{{ asset(mix('vendors/js/tables/datatable/jquery.dataTables.min.js')) }}"></script>
    <script src="{{ asset(mix('vendors/js/tables/datatable/dataTables.bootstrap5.min.js')) }}"></script>
    <script src="{{ asset(mix('vendors/js/tables/datatable/dataTables.responsive.min.js')) }}"></script>
    <script src="{{ asset(mix('vendors/js/tables/datatable/responsive.bootstrap5.js')) }}"></script>
    <script src="{{ asset(mix('vendors/js/pickers/flatpickr/flatpickr.min.js')) }}"></script>
    <script src="{{ asset(mix('vendors/js/forms/select/select2.full.min.js')) }}"></script>
@endsection

@section('page-script')
    {{-- Page js files --}}
    <script src="{{ asset(mix('js/scripts/tables/table-datatables-advanced.js')) }}"></script>
    <script src="{{ asset(mix('js/scripts/forms/form-select2.js')) }}"></script>
    <script src="{{ asset(mix('js/scripts/components/components-modals.js')) }}"></script>
@endsection