@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')

    <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
    <!-- 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">Broadcast Pesan Peringatan Ke WhatsApp</h4>

                    </div>

                    <div class="card-body">
                        @if (session()->get('success'))
                            <div class="alert alert-success m-1 p-1">{{ session()->get('success') }}</div>
                        @endif
                        @if (session()->get('error'))
                            <div class="alert alert-danger m-1 p-1">{{ session()->get('error') }}</div>
                        @endif
                        @if ($errors->any())
                            <div class="alert m-1 p-1 alert-danger">
                                <ul>
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                        @endif
                        <form method="POST" enctype="multipart/form-data" class="mt-2"
                            action="{{ url('broadcast_peringatan/create') }}">
                            @csrf
                            <div >
                                <div class="containers">
                                    <div class="mb-1">
                                        <label class="form-label" for="select2-nested">
                                            <h5>Nama Perangkat</h5>
                                        </label>
                                        <select
                                            class="select2 form-select @error('perangkat')
                            is-invalid
                        @enderror"
                                            id="select2-nested-empat" name="perangkat" required>
                                            <option value="">Pilih</option>
                                            @foreach ($device_result as $rows)
                                                <option @if (old('perangkat') == $rows->no)
                                                    selected
                                                @endif value="{{ $rows->no }}">{{ $rows->nama_device }}
                                                </option>
                                            @endforeach
                                        </select>
                                        @error('perangkat')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                    <div class="mb-1">
                                        <label class="form-label" for="select2-nested">
                                            <h5>Status Siaga</h5>
                                        </label>
                                        <select
                                            class="select2 form-select @error('siaga')
                            is-invalid
                        @enderror"
                                            id="select2-nested-lima" name="siaga" required>
                                            <option value="">Pilih</option>
                                            <option value="Normal" @if (old('siaga') == "Normal")
                                                selected
                                            @endif>Normal</option>
                                            <option value="Siaga 4" @if (old('siaga') == "Siaga 4")
                                            selected
                                        @endif>Siaga 4</option>
                                            <option value="Siaga 3" @if (old('siaga') == "Siaga 3")
                                            selected
                                        @endif>Siaga 3</option>
                                            <option value="Siaga 2" @if (old('siaga') == "Siaga 2")
                                            selected
                                        @endif>Siaga 2</option>
                                            <option value="Siaga 1" @if (old('siaga') == "Siaga 1")
                                            selected
                                        @endif>Siaga 1</option>
                                        </select>
                                        @error('siaga')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                    <div class="mb-1">
                                        <label class="form-label" for="select2-nested">
                                            <h5>Group</h5>
                                        </label>
                                        <select
                                            class="select2 form-select  @error('group')
                                                is-invalid
                                            @enderror"
                                            multiple="multiple" name="group[]" id="default-select-multi-normal" required>
                                            @foreach ($group as $groups)
                                                <option value="{{ $groups->uuid }}">{{ $groups->group }}</option>
                                            @endforeach
                                        </select>
                                        @error('group')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                    <div class="mb-1">
                                        <label class="form-label" for="select2-nested">
                                            <h5>Judul</h5>
                                        </label>
                                        <input type="text"
                                            class="form-control @error('judul')
                          is-invalid
                        @enderror"
                                            required name="judul" placeholder="Judul" value="{{ old('judul') }}">
                                        @error('judul')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                    <div class="mb-1">
                                        <label class="form-label" for="select2-nested">
                                            <h5>Pesan</h5>
                                        </label>
                                        <textarea name="pesan"
                                            class="form-control @error('pesan')
                          is-invalid
                        @enderror"
                                            id="pesan" required cols="30" rows="5" placeholder="Pesan">{{ old('pesan') }}</textarea>
                                        @error('pesan')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                </div>
                            </div>
                            <div >
                                <a href="{{ url('broadcast_peringatan/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')
    <script src="https://code.jquery.com/jquery-3.6.3.js" integrity="sha256-nQLuAZGRRcILA+6dMBOvcRh5Pe310sBpanc6+QBmyVM="
        crossorigin="anonymous"></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
