@extends('layouts.master')

@section('title')
    Penyelenggaraan Seminar/Conference
@endsection

@section('header')
<div class="page-title">
    <h3>Penyelenggaraan Seminar/Conference</h3>
</div>
@endsection

@section('contents')
@php
 $menu = 'dashboard';
@endphp
    <div class="row layout-top-spacing" id="cancel-row">
        <div class="col-xl-12 col-lg-12 col-sm-12  layout-spacing">
            <div class="widget-content widget-content-area br-6">
                <div class="table-responsive mb-4 mt-4">
                <a href="{{ url('penyelenggaraseminar/create') }}" class="btn btn-primary mb-2"><i data-feather="file-plus"></i> Tambah</a>
                    <table id="zero-config" class="table table-hover" style="width:100%">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>Nama Seminar</th>
                                <th>Unit Pelaksana</th>
                                <th>Mitra</th>
                                <th>Skala Conference</th>
                                <th>Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                        @php $no = 1; @endphp
                        @foreach ($penyelenggaraseminar as $value)
                            <tr>
                                <td>{{$no++}}</td>
                                <td>{{$value->nama_seminar}}</td>
                                <td>{{$value->unit_pelaksana}}</td>
                                <td>{{$value->mitra}}</td>
                                <td>{{$value->skala}}</td>
                                <td>
                                    <a href="{{ url('penyelenggaraseminar/'.$value->id.'/edit') }}" class="btn btn-warning mb-2"><i data-feather="edit"></i> Edit</a> |
                                    <button class="btn btn-danger mb-2 delete" data-id="{{ $value->id }}" data-file="{{$value->id}}"><i data-feather="trash-2"></i> Delete</button>
                                    {{ Form::open(['url'=>route('penyelenggaraseminar.destroy', [Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                    {{ csrf_field() }}
                                    {{ Form::close() }}
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>

@endsection

@section('js')
    <script src="{{ url('theme/plugins/table/datatable/datatables.js') }}"></script>
    <script>
        $('#zero-config').DataTable({
            "oLanguage": {
                "oPaginate": { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
                "sInfo": "Showing page _PAGE_ of _PAGES_",
                "sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
                "sSearchPlaceholder": "Search...",
               "sLengthMenu": "Results :  _MENU_",
            },
            "stripeClasses": [],
            "lengthMenu": [10, 20, 50],
            "pageLength": 10
        });

        var url = "{{ route('penyelenggaraseminar.index') }}";

            $("body").on("click", ".delete", function (e) {
                e.preventDefault();
                var id = $(this).data('id');

                Swal.fire({
                    title: "Apakah Anda Yakin?",
                    text: "Anda akan menghapus data ini!",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "Yes",
                    cancelButtonText: "No"
                }).then((result) => {
                    if (result.value) {
                        Swal.close();
                        $("#"+id).submit();
                    } else if (result.dismiss === Swal.DismissReason.cancel) {
                        Swal.fire('Dibatalkan', 'Data batal dihapus', 'error');
                    }
                });
            });
    </script>
@endsection
