@extends(ucfirst(activeGuard()).'.'.layout())

@section('pagetitle', __('trans.advertisements'))
@section('content')

<div class="row">
    @if(hasPermission('add_advertisements'))
        <div class="my-2 col-6 text-sm-start">
            <a href="{{ route(activeGuard().'.advertisements.create') }}" class="main-btn">@lang('trans.add_new')</a>
        </div>
    @endif
    @if(hasPermission('delete_advertisements'))
        <div class="my-2 col-6 text-sm-end">
            <button type="button" id="DeleteSelected" onclick="DeleteSelected('advertisements')" class="btn btn-danger" disabled>@lang('trans.Delete_Selected')</button>
        </div>
    @endif
</div>
<table class="table table-bordered data-table" >
    <thead>
        <tr>
            <th><input type="checkbox" id="ToggleSelectAll" class="main-btn"></th>
            <th>#</th>
            <th>@lang('trans.link')</th>
            <th>@lang('trans.file')</th>
            @if(hasPermission('edit_advertisements'))
            <th>@lang('trans.status')</th>
            @endif
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach ($Models as $Model)
        <tr>
            <td>
                <input type="checkbox" class="DTcheckbox" value="{{ $Model->id }}">
            </td>
            <td>{{ $loop->iteration }}</td>
            <td>{{ $Model->linkable?->title() }}</td>
            <td class="text-center">
                <img src="{{ asset($Model->file ?? setting('logo')) }}" style="max-width: 100px;">
            </td>
            @if(hasPermission('edit_advertisements'))
                <td>
                    <input class="toggle" type="checkbox" onclick="toggleswitch({{ $Model->id }},'advertisements')" @if ($Model->status) checked @endif>
                </td>
            @endif
            <td>
                @if(hasPermission('edit_advertisements'))
                    <a href="{{ route(activeGuard().'.advertisements.edit', $Model) }}"><i class="fa-solid fa-pen-to-square"></i></a>
                @endif
                @if(hasPermission('delete_advertisements'))
                    <form class="formDelete" method="POST" action="{{ route(activeGuard().'.advertisements.destroy', $Model) }}">
                        @csrf
                        <input name="_method" type="hidden" value="DELETE">
                        <button type="button" class="btn btn-flat show_confirm" data-toggle="tooltip" title="Delete">
                            <i class="fa-solid fa-eraser"></i>
                        </button>
                    </form>
                @endif
            </td>
        </tr>
        @endforeach
    </tbody>
</table>

@endsection
