@extends('layouts.admin')
@section('content')
@can('referensi_create')
    <div style="margin-bottom: 10px;" class="row">
        <div class="col-lg-12">
            <a class="btn btn-success" href="{{ route("admin.referensis.create") }}">
                {{ trans('global.add') }} {{ trans('cruds.referensi.title_singular') }}
            </a>
        </div>
    </div>
@endcan
<div class="card">
    <div class="card-header">
        {{ trans('cruds.referensi.title_singular') }} {{ trans('global.list') }}
    </div>

    <div class="card-body">
        <div class="table-responsive">
            <table class=" table table-bordered table-striped table-hover datatable">
                <thead>
                    <tr>
                        <th width="10">

                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.jenis_kelamin') }}
                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.agama') }}
                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.pangkat_gol') }}
                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.detail_kegiatan') }}
                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.kegiatan') }}
                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.angka_kredit') }}
                        </th>
                        <th>
                            {{ trans('cruds.referensi.fields.pelaksana_ak_permen') }}
                        </th>
                        <th>
                            &nbsp;
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($referensis as $key => $referensi)
                        <tr data-entry-id="{{ $referensi->id }}">
                            <td>

                            </td>
                            <td>
                                {{ $referensi->jenis_kelamin ?? '' }}
                            </td>
                            <td>
                                {{ $referensi->agama ?? '' }}
                            </td>
                            <td>
                                {{ $referensi->pangkat_gol ?? '' }}
                            </td>
                            <td>
                                {{ $referensi->detail_kegiatan ?? '' }}
                            </td>
                            <td>
                                {{ $referensi->kegiatan ?? '' }}
                            </td>
                            <td>
                                {{ $referensi->angka_kredit ?? '' }}
                            </td>
                            <td>
                                {{ $referensi->pelaksana_ak_permen ?? '' }}
                            </td>
                            <td>
                                @can('referensi_show')
                                    <a class="btn btn-xs btn-primary" href="{{ route('admin.referensis.show', $referensi->id) }}">
                                        {{ trans('global.view') }}
                                    </a>
                                @endcan
                                @can('referensi_edit')
                                    <a class="btn btn-xs btn-info" href="{{ route('admin.referensis.edit', $referensi->id) }}">
                                        {{ trans('global.edit') }}
                                    </a>
                                @endcan
                                @can('referensi_delete')
                                    <form action="{{ route('admin.referensis.destroy', $referensi->id) }}" method="POST" onsubmit="return confirm('{{ trans('global.areYouSure') }}');" style="display: inline-block;">
                                        <input type="hidden" name="_method" value="DELETE">
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                        <input type="submit" class="btn btn-xs btn-danger" value="{{ trans('global.delete') }}">
                                    </form>
                                @endcan
                            </td>

                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection
@section('scripts')
@parent
<script>
    $(function () {
  let deleteButtonTrans = '{{ trans('global.datatables.delete') }}'
  let deleteButton = {
    text: deleteButtonTrans,
    url: "{{ route('admin.referensis.massDestroy') }}",
    className: 'btn-danger',
    action: function (e, dt, node, config) {
      var ids = $.map(dt.rows({ selected: true }).nodes(), function (entry) {
          return $(entry).data('entry-id')
      });

      if (ids.length === 0) {
        alert('{{ trans('global.datatables.zero_selected') }}')

        return
      }

      if (confirm('{{ trans('global.areYouSure') }}')) {
        $.ajax({
          headers: {'x-csrf-token': _token},
          method: 'POST',
          url: config.url,
          data: { ids: ids, _method: 'DELETE' }})
          .done(function () { location.reload() })
      }
    }
  }
  let dtButtons = $.extend(true, [], $.fn.dataTable.defaults.buttons)
@can('referensi_delete')
  dtButtons.push(deleteButton)
@endcan

  $('.datatable:not(.ajaxTable)').DataTable({ buttons: dtButtons })
})

</script>
@endsection