@extends('admin.layouts.app')

@section('title', 'teams')

@section('content')

@if (session('team_create_message'))
<div class="alert alert-success mb-2">
    {{ session('team_create_message') }}
</div>

@elseif (session('delete_team_msg'))
<div class="alert alert-success mb-2">
    {{ session('delete_team_msg') }}
</div>
@endif

<h1 class="mb-3">{{ awtTrans('Teams') }}</h1>

<form action="{{ route('admin.team.bluck-delete') }}" method="post">
    @csrf
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary text-left">
                <button type="submit" style="display: none;" title="{{ awtTrans('delete') }}" class="btn btn-danger bluck-button btn-circle btn-sm">
                    <i class="fas fa-trash"></i>
                </button>
                <a href="{{ route('admin.teams.create') }}" title="{{ awtTrans('add') }}" class="btn btn-primary btn-circle btn-sm">
                    <i class="fas fa-plus"></i>
                </a>
            </h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTableteams" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>{{ awtTrans('Choose') }} </th>
                            <th>{{ awtTrans('Photo') }} </th>
                            <th>{{ awtTrans('Name Arabic') }} </th>
                            <th>{{ awtTrans('Name English') }} </th>
                            <th>{{ awtTrans('Job Title Arabic') }} </th>
                            <th>{{ awtTrans('Job Title English') }} </th>
                            <th>{{ awtTrans('Email') }} </th>
                            <th>{{ awtTrans('Phone') }} </th>
                            <th>{{ awtTrans('Actions') }} </th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th>{{ awtTrans('Choose') }} </th>
                            <th>{{ awtTrans('Photo') }} </th>
                            <th>{{ awtTrans('Name Arabic') }} </th>
                            <th>{{ awtTrans('Name English') }} </th>
                            <th>{{ awtTrans('Job Title Arabic') }} </th>
                            <th>{{ awtTrans('Job Title English') }} </th>
                            <th>{{ awtTrans('Email') }} </th>
                            <th>{{ awtTrans('Phone') }} </th>
                            <th>{{ awtTrans('Actions') }} </th>
                        </tr>
                    </tfoot>
                    <tbody>
                        @if (! empty($teams))
                        @foreach ($teams as $team)
                        <tr id="row-{{ $team->id }}">
                            <td><input type="checkbox" name="ids[]" value="{{ $team->id }}" class="from-control bluck-delete"> </td>
                            <td>
                                <img height="44" src="{{ $team->photo }}" alt="">
                            </td>
                            <td>{{ $team->name_ar }}</td>
                            <td>{{ $team->name_en }}</td>
                            <td>{{ $team->job_title_ar }}</td>
                            <td>{{ $team->job_title_en }}</td>
                            <td>{{ $team->email }}</td>
                            <td>{{ $team->phone }}</td>

                            <td>
                                <a href="{{ route('admin.teams.destroy', $team->id) }}" data-id="{{$team->id}}" class="btn btn-danger btn-circle btn-sm item-delete">
                                    <i class="fas fa-trash"></i>
                                </a>
                                <a href="#" class="btn btn-info btn-circle btn-sm" data-toggle="modal" data-target="#exampleModalLong{{$team->id}}">
                                    <i class="fas fa-eye"></i>
                                </a>
                                <a href="{{ route('admin.teams.edit', $team->id) }}" class="btn btn-success btn-circle btn-sm">
                                    <i class="fas fa-edit"></i>
                                </a>
                            </td>

                        </tr>

                        <!-- Modal -->
                        <div class="modal fade" id="exampleModalLong{{$team->id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="exampleModalLongTitle">{{ awtTrans('Details') }}</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <div class="row">
                                                    <div class="col-lg-5">
                                                        <b>{{ awtTrans('Name') }} : </b>
                                                    </div>
                                                    <div class="col-lg-7">
                                                        {{$team->name}}
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-5">
                                                        <b>{{ awtTrans('Description') }} : </b>
                                                    </div>
                                                    <div class="col-lg-7">
                                                        {{$team->pio}}
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-5">
                                                        <b>{{ awtTrans('Image') }} : </b>
                                                    </div>
                                                    <div class="col-lg-7">
                                                        <img height="44" src="{{ $team->photo }}" alt="">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" data-dismiss="modal">{{ awtTrans('إغلاق') }}</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        @endforeach
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</form>

@endsection


@section('scripts')
<script>
    // Call the dataTables jQuery plugin
    $(document).ready(function() {
        $('#dataTableteams').DataTable({
            'language': {
                'url': "{{ app()->getLocale() == 'ar' ? 'https://cdn.datatables.net/plug-ins/1.10.12/i18n/Arabic.json' : 'https://cdn.datatables.net/plug-ins/1.10.12/i18n/English.json' }}",
            },
        });
    });
</script>
@endsection