@extends('layouts.app')

@section('content')
  <div class="page-content">
    <div class="container-fluid">

      <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-header align-items-center d-flex">
              <h5 class="card-title flex-grow-1 mb-0">Training Type</h5>
              <div class="flex-shrink-0">
                <a href="{{ route('trainingList.create') }}" class="btn btn-success waves-effect waves-light"><i
                    class="ri-add-fill me-1 align-bottom"></i> Create Training List</a>
              </div>
            </div>

            <div class="card-body">
              <div class="table-responsive">
                <table id="buttons-datatables" class="display table-sm table-bordered table" style="width:100%">
                  <thead>
                    <tr>
                      <th>S.N</th>
                      <th>Training Title</th>
                      <th>Trainer</th>
                      <th>Start Date</th>
                      <th>End Date</th>
                      <th>Training Members</th>
                      <th>Shift</th>
                      <th>Action</th>
                    </tr>
                  </thead>
                  <tbody>
                    @forelse ($trainingLists as $key => $trainingList)
                      <tr>
                        <td>{{ $key + 1 }}</td>
                        <td>{{ $trainingList->title }}</td>
                        <td>{{ ($trainingList->trainer)->first_name }}</td>
                        <td>{{ $trainingList->start_date }}</td>
                        <td>{{ $trainingList->end_date }}</td>
                        <td>{{ ($trainingList->employee)->first_name}}</td>
                        <td>{{ $trainingList->shift}}</td>
                        <td>
                          <div class="hstack flex-wrap gap-3">
                            @can('trainingList.show')
                            <a href="{{ route('trainingList.show', $trainingList->id) }}" class="link-info fs-15">
                                <i class="ri-eye-line"></i>
                              </a>
                            @endcan
                            @can('trainingList.edit')
                              <a href="{{ route('trainingList.edit', $trainingList->id) }}"
                                class="link-success fs-15 edit-item-btn"><i class="ri-edit-2-line"></i></a>
                            @endcan
                            @can('trainingList.destroy')
                              <a href="javascript:void(0);" data-link="{{ route('trainingList.destroy', $trainingList->id) }}"
                                data-id="{{ $trainingList->id }}" class="link-danger fs-15 remove-item-btn"><i
                                  class="ri-delete-bin-line"></i></a>
                            @endcan
                          </div>
                        </td>
                      </tr>
                    @empty
                    @endforelse
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--end row-->
    </div>
  </div>
@endsection

@push('js')
  <script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush