@extends($activeTemplate . 'layouts.master')
@section('content')
    <div class="transaction-section padding-top padding-bottom">
        <div class="container">
            <div class="row justify-content-center">

                @if (!request()->routeIs('user.recharge.log'))
                    <div class="col-md-12">
                        <div class="show-filter mb-3 text-end">
                            <button type="button" class="btn btn--base showFilterBtn btn-sm"><i class="las la-filter"></i>
                                @lang('Filter')</button>
                        </div>
                        <div class="card responsive-filter-card mb-4 primary-bg">
                            <div class="card-body">
                                <form action="">
                                    <div class="d-flex flex-wrap gap-4">
                                        <div class="flex-grow-1 contact-form-group">
                                            <label>@lang('Name')</label>
                                            <input type="text" name="search" value="{{ request()->search }}"
                                                class="form-control form--control">
                                        </div>
                                        <div class="flex-grow-1">
                                            <div class="contact-form-group">
                                                <label>@lang('Date')</label>
                                                <input name="date" type="text" data-range="true"
                                                    data-multiple-dates-separator=" - " data-language="en"
                                                    class="datepicker-here form-control" data-position='bottom right'
                                                    placeholder="@lang('Start date - End date')" autocomplete="off"
                                                    value="{{ request()->date }}">
                                            </div>
                                        </div>
                                        <div class="flex-grow-1 align-self-end">
                                            <div class="contact-form-group">
                                                <button class="btn btn--base w-100"><i class="las la-filter"></i>
                                                    @lang('Filter')</button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                @endif
            </div>

            <div class="primary-bg item-rounded">
                <table class="deposite-table">
                    <thead class="custom--table">
                        <tr>
                            <th>@lang('Sl No.')</th>
                            <th>@lang('Name of file')</th>
                            <th>@lang('Description')</th>
                            <th>@lang('File')</th>
                            <th>@lang('Created at')</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($pdflist as $trx)
                            <tr>
                                <td>
                                    {{ $loop->iteration }}
                                </td>

                                <td>
                                    {{ $trx->name }}
                                </td>

                                <td>
                                    <div class="fw-bold">
                                        {{ Str::limit($trx->desc, 20) }}
                                    </div>
                                    @if (Str::length($trx->desc) > 20)
                                        <a href="#" data-bs-toggle="modal"
                                            data-bs-target="#descModal{{ $trx->id }}">@lang('Read More')</a>
                                    @endif

                                    <!-- Modal -->
                                    <div class="modal fade" id="descModal{{ $trx->id }}" tabindex="-1"
                                        aria-labelledby="descModalLabel" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="descModalLabel">@lang('Description')</h5>
                                                    <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                        aria-label="Close"></button>
                                                </div>
                                                <div class="modal-body">
                                                    <p style="word-break: break-word; white-space: pre-line; color:black">
                                                        {{ $trx->desc }}</p>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-secondary"
                                                        data-bs-dismiss="modal">@lang('Close')</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>

                                <td>
                                    {{-- <a href="{{ getFilePath('withdrawMethod') . '/' . $trx->file }}" target="_blank" ><i
                                        class="fa fa-file"></i>@lang('Download File')   </a> --}}
                                    {{--
                                    <a href="{{ route('user.file.download', $trx->id) }}">
                                        <i class="fa fa-file"></i>@lang('Download File')
                                    </a> --}}
                                    <a href="/{{ getFilePath('withdrawMethod') . '/' . $trx->file }}" download><i
                                            class="fa fa-file"></i> @lang('Download File') </a>
                                    {{-- <a href="{{ route('file.download', $trx->id) }}">
                                            <i class="fa fa-file"></i> @lang('Download File')
                                        </a> --}}
                                </td>

                                <td>
                                    {{ $trx->created_at->format('d M Y') }}
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="100%">{{ __($emptyMessage) }}</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
                @if ($pdflist->hasPages())
                    <div class="py-3">
                        {{ paginateLinks($pdflist) }}
                    </div>
                @endif
            </div>
        </div>
    </div>
@endsection
@push('style-lib')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/vendor/datepicker.min.css') }}">
@endpush


@push('script-lib')
    <script src="{{ asset('assets/admin/js/vendor/datepicker.min.js') }}"></script>
    <script src="{{ asset('assets/admin/js/vendor/datepicker.en.js') }}"></script>
@endpush
@push('script')
    <script>
        (function($) {
            "use strict";
            if (!$('.datepicker-here').val()) {
                $('.datepicker-here').datepicker();
            }
        })(jQuery)
    </script>
@endpush
