@can('checklist_report_create')

<!--
<div style="margin-bottom: 10px;" class="row">
        <div class="col-lg-12">
            <a class="btn btn-success" href="{{ route('admin.checklist-reports.create') }}">
                {{ trans('global.add') }} {{ trans('cruds.checklistReport.title_singular') }}
            </a>
        </div>
    </div>
-->
@endcan
<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class=" table table-bordered table-striped table-hover datatable datatable-complaintChecklistReports">
                <thead>
                    <tr>
                        <!--
                        <th width="10">

                        </th>

                        <th>
                            {{ trans('cruds.checklistReport.fields.id') }}
                        </th>

                        <th>
                            {{ trans('cruds.checklistReport.fields.complaint') }}
                        </th>
                        -->
                        <th>
                            {{ trans('cruds.checklistReport.fields.checklist_name') }}
                        </th>
                        <!--
                        <th>
                            {{ trans('cruds.checklistReport.fields.checklist_status') }}
                        </th>
                          -->
                        <th>

                            {{ trans('cruds.checklistReport.fields.checklist_value_text_1') }}
                        </th>
                        <th>
                            {{ trans('cruds.checklistReport.fields.checklist_value_text_2') }}
                        </th>
                        <th>
                            {{ trans('cruds.checklistReport.fields.checklist_remarks') }}
                        </th>

                        <!--
                        <th>
                            &nbsp;
                        </th>
                    -->
                    </tr>
                </thead>
                <tbody>
                    @foreach($checklistReports as $key => $checklistReport)
                    @if($checklistReport->checklist_name_id != 1201)
                        <tr data-entry-id="{{ $checklistReport->id }}">
                            <!--
                            <td>

                            </td>
                            <td>
                                {{ $checklistReport->id ?? '' }}
                            </td>

                            <td>
                                {{ $checklistReport->complaint->complaint ?? '' }}
                            </td>
                        -->
                            <td>
                                {{ $checklistReport->checklist_name->name ?? '' }}
                            </td>
                            <!--
                            <td>
                                {{ $checklistReport->checklist_status ?? '' }}
                            </td>
                        -->
                            <td>

                                {{ $checklistReport->checklist_value_text_1 ?? '' }}
                            </td>
                            <td>
                                {{ $checklistReport->checklist_value_text_2 ?? '' }}
                            </td>
                            <td>
                                {{ $checklistReport->Remarks ?? '' }}
                            </td>

                          <!--
                             <td>
                                {{ $checklistReport->checklist_status_fusion_types_2->name ?? '' }}
                            </td>
                            <td>
                                @can('checklist_report_show')
                                    <a class="btn btn-xs btn-primary" href="{{ route('admin.checklist-reports.show', $checklistReport->id) }}">
                                        {{ trans('global.view') }}
                                    </a>
                                @endcan

                                @can('checklist_report_edit')
                                    <a class="btn btn-xs btn-info" href="{{ route('admin.checklist-reports.edit', $checklistReport->id) }}">
                                        {{ trans('global.edit') }}
                                    </a>
                                @endcan

                                @can('checklist_report_delete')
                                    <form action="{{ route('admin.checklist-reports.destroy', $checklistReport->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>
                        @endif
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
</div>

@section('scripts')
@parent
<script>
    $(function () {
  let dtButtons = $.extend(true, [])
@can('checklist_report_delete')
  let deleteButtonTrans = '{{ trans('global.datatables.delete') }}'
  let deleteButton = {
    text: deleteButtonTrans,
    url: "{{ route('admin.checklist-reports.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() })
      }
    }
  }
  dtButtons.push(deleteButton)
@endcan

  $.extend(true, $.fn.dataTable.defaults, {
    orderCellsTop: true,
    order: [[ 1, 'desc' ]],
    pageLength: 100,
  });
  let table = $('.datatable-complaintChecklistReports:not(.ajaxTable)').DataTable({ buttons: dtButtons })
  $('a[data-toggle="tab"]').on('shown.bs.tab click', function(e){
      $($.fn.dataTable.tables(true)).DataTable()
          .columns.adjust();
  });

})

</script>
@endsection
