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

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

                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.id') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.name') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.applied_post') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.current_post') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.district') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.assembly_name') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.social_division') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.education') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.profession') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.join_year') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.selected') }}
                    </th>
                    <th>
                        {{ trans('cruds.districtposting.fields.selected_post') }}
                    </th>
                    <th>
                        &nbsp;
                    </th>
                </tr>
            </thead>
        </table>
    </div>
</div>



@endsection
@section('scripts')
@parent
<script>
    $(function () {
  let dtButtons = $.extend(true, [], $.fn.dataTable.defaults.buttons)
@can('districtposting_delete')
  let deleteButtonTrans = '{{ trans('global.datatables.delete') }}';
  let deleteButton = {
    text: deleteButtonTrans,
    url: "{{ route('admin.districtpostings.massDestroy') }}",
    className: 'btn-danger',
    action: function (e, dt, node, config) {
      var ids = $.map(dt.rows({ selected: true }).data(), function (entry) {
          return 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() })
      }
    }
  }
  dtButtons.push(deleteButton)
@endcan

  let dtOverrideGlobals = {
    buttons: dtButtons,
    processing: true,
    serverSide: true,
    retrieve: true,
    aaSorting: [],
    ajax: "{{ route('admin.districtpostings.index') }}",
    columns: [
      { data: 'placeholder', name: 'placeholder' },
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' },
{ data: 'applied_post', name: 'applied_post' },
{ data: 'current_post', name: 'current_post' },
{ data: 'district', name: 'district' },
{ data: 'assembly_name', name: 'assembly_name' },
{ data: 'social_division', name: 'social_division' },
{ data: 'education', name: 'education' },
{ data: 'profession', name: 'profession' },
{ data: 'join_year', name: 'join_year' },
{ data: 'selected', name: 'selected' },
{ data: 'selected_post', name: 'selected_post' },
{ data: 'actions', name: '{{ trans('global.actions') }}' }
    ],
    orderCellsTop: true,
    order: [[ 1, 'asc' ]],
    pageLength: 100,
  };
  let table = $('.datatable-Districtposting').DataTable(dtOverrideGlobals);
  $('a[data-toggle="tab"]').on('shown.bs.tab click', function(e){
      $($.fn.dataTable.tables(true)).DataTable()
          .columns.adjust();
  });
  
});

</script>
@endsection