@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')
    <!-- Ajax Sourced Server-side -->
    <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">Edit Kontak Pegawai Penerima Broadcast Whatsapp</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
                    <form method="POST" enctype="multipart/form-data" action="{{ url('pegawai/edit_pegawai') }}">
                        @csrf
                        @method('PUT')
                        <input type="hidden" name="id" value="{{ $main->no }}">
                        <div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-6 col-12">
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Nama*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="text"
                                                    class="form-control @error('name')
                              is-invalid
                          @enderror"
                                                    placeholder="Nama" name="name" required
                                                    value="{{ $main->name }}" />
                                            </div>
                                            @error('name')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>NIP/NIK*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="number"
                                                    class="form-control @error('nip_nik')
                              is-invalid
                          @enderror"
                                                    placeholder="NIP/NIK" name="nip_nik" required
                                                    value="{{ $main->nip_nik }}" />
                                            </div>
                                            @error('nip_nik')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label class="form-label" for="select2-nested">
                                                <h5>Jenis*</h5>
                                            </label>
                                            <select
                                                class="select2 form-select @error('jenis')
                            is-invalid
                        @enderror"
                                                id="select2-nested-empat{{ $main->no }}" name="jenis" required>
                                                <option value="">Pilih</option>
                                                <option value="PNS" {{ $main->jenis == 'PNS' ? 'selected' : '' }}>PNS
                                                </option>
                                                <option value="Non PNS"
                                                    {{ $main->jenis == 'Non PNS' ? 'selected' : '' }}>Non PNS</option>
                                            </select>
                                            @error('jenis')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label class="form-label" for="select2-nested">
                                                <h5>Jabatan*</h5>
                                            </label>
                                            <select
                                                class="select2 form-select @error('uuid_jabatan')
                            is-invalid
                        @enderror"
                                                id="select2-nested-tiga{{ $main->no }}" name="uuid_jabatan" required>
                                                <option value="">Pilih</option>
                                                @foreach ($jabatan_dua as $jabatans)
                                                    <option value="{{ $jabatans->uuid }}"
                                                        {{ $main->uuid_jabatan == $jabatans->uuid ? 'selected' : '' }}>
                                                        {{ $jabatans->jabatan }}</option>
                                                @endforeach
                                            </select>
                                            @error('uuid_jabatan')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label class="form-label" for="select2-nested">
                                                <h5>Pangkat*</h5>
                                            </label>
                                            <select
                                                class="select2 form-select @error('uuid_pangkat')
                            is-invalid
                        @enderror"
                                                id="select2-nested-dua{{ $main->no }}" name="uuid_pangkat" required>
                                                <option value="">Pilih</option>
                                                @foreach ($pangkat_dua as $main_tiga)
                                                    <option value="{{ $main_tiga->uuid }}"
                                                        {{ $main->uuid_pangkat == $main_tiga->uuid ? 'selected' : '' }}>
                                                        {{ $main_tiga->pangkat }}</option>
                                                @endforeach
                                            </select>
                                            @error('uuid_pangkat')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-12">

                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Eselon*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="text"
                                                    class="form-control @error('eselon')
                              is-invalid
                          @enderror"
                                                    placeholder="Eselon" name="eselon" value="{{ $main->eselon }}"
                                                    required>
                                            </div>
                                            @error('eselon')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Email*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="email"
                                                    class="form-control @error('email')
                              is-invalid
                          @enderror"
                                                    placeholder="Email" value="{{ $main->email }}" name="email"
                                                    required>
                                            </div>
                                            @error('email')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>No Hp*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="number"
                                                    class="form-control @error('no_hp')
                              is-invalid
                          @enderror"
                                                    placeholder="No Hp" value="{{ $main->no_hp }}" name="no_hp"
                                                    required>
                                            </div>
                                            @error('no_hp')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>No Whatsapp*</h5>
                                            </label>
                                            <div class="input-group">
                                                <input type="number"
                                                    class="form-control @error('no_wa')
                              is-invalid
                          @enderror"
                                                    value="{{ $main->no_wa }}" placeholder="No Whatsapp" name="no_wa"
                                                    required>
                                            </div>
                                            @error('no_wa')
                                                <small class="text-danger">{{ $message }}</small>
                                            @enderror
                                        </div>
                                        <div class="mb-1">
                                            <label for="" style="margin-bottom: 5px !important;">
                                                <h5>Status</h5>
                                            </label>
                                            <div class="d-flex flex-column">
                                                <div class="form-check form-check-primary form-switch">
                                                    <input type="checkbox" {{ $main->active == 1 ? 'checked' : '' }}
                                                        name="active" class="form-check-input" id="customSwitch3"
                                                        value="1">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <a href="{{ url('pegawai/index') }}" class="btn btn-warning">Kembali</a>
                                        <button type="submit" class="btn btn-primary">Simpan</button>
                            </div>
                        </div>
                    </form>
                </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
