@extends($activeTemplate . 'layouts.frontend')
@section('content')
    <!-- booking history Starts Here -->
    <section class="dashboard-section padding-top padding-bottom">
        <div class="container">
            <div class="dashboard-wrapper">
                <div class="row pb-60 gy-4 justify-content-center">
                    <div class="col-lg-6 col-md-6 col-sm-10">
                        <div class="dashboard-widget">
                            <div class="dashboard-widget__content">
                                <p>@lang('Total Booked Ticket')</p>
                                <h3 class="title">{{ __($widget['booked']) }}</h3>
                            </div>
                            <div class="dashboard-widget__icon">
                                <i class="las la-ticket-alt"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-10">
                        <div class="dashboard-widget">
                            <div class="dashboard-widget__content">
                                <p>@lang('Total Pending Ticket')</p>
                                <h3 class="title">{{ __($widget['pending']) }}</h3>
                            </div>
                            <div class="dashboard-widget__icon">
                                <i class="las la-ticket-alt"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-10">
                        <div class="dashboard-widget">
                            <div class="dashboard-widget__content">
                                <p>@lang('Total Payment Failed Ticket')</p>
                                <h3 class="title">{{ __($widget['rejected']) }}</h3>
                            </div>
                            <div class="dashboard-widget__icon">
                                <i class="las la-ticket-alt"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-10">
                        <div class="dashboard-widget">
                            <div class="dashboard-widget__content">
                                <p>@lang('Total Canceled Ticket')</p>
                                <h3 class="title">{{ __($widget['canceled']) }}</h3>
                            </div>
                            <div class="dashboard-widget__icon">
                                <i class="las la-ticket-alt"></i>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="booking-table-wrapper">
                    <table class="booking-table">
                        <thead>
                            <tr>
                                <th>@lang('PNR Number')</th>
                                <th>@lang('Starting Point')</th>
                                <th>@lang('Dropping Point')</th>
                                <th>@lang('Boarding Point')</th>
                                <th>@lang('Journey Date')</th>
                                <th>@lang('Pickup Time')</th>
                                <th>@lang('Booked Seats')</th>
                                <th>@lang('Booking Status')</th>
                                <th>@lang('Trip Status')</th>
                                <th>@lang('Total Fare')</th>
                                <th>@lang('Action')</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse ($bookedTickets as $bookedTicket)
                                <tr>
                                    <td class="ticket-no" data-label="@lang('PNR Number')">{{ __($bookedTicket->pnr_number) }}</td>
                                    <td class="pickup" data-label="@lang('Starting Point')">{{ __($bookedTicket?->pickup?->name) }}</td>
                                    <td class="drop" data-label="@lang('Dropping Point')">{{ __($bookedTicket?->drop?->name) }}</td>
                                    <td class="drop" data-label="@lang('Boarding Point')">{{ __($bookedTicket?->boarding?->name) }}</td>
                                    <td class="date" data-label="@lang('Journey Date')">{{ showDateTime($bookedTicket->date_of_journey, 'd M, Y') }}</td>
                                    <td class="time" data-label="@lang('Pickup Time')">{{ showDateTime($bookedTicket?->trip?->start_time, 'h:i a') }}</td>
                                    <td class="seats" data-label="@lang('Booked Seats')">{{ __(implode(',', $bookedTicket->seats)) }}</td>
                                    <td data-label="@lang('Status')">
                                        @php
                                            echo $bookedTicket->statusBadge
                                        @endphp
                                    </td>
                                    <td data-label="@lang('Trip Status')">
                                        @php
                                            echo $bookedTicket->trip->statusBadge
                                        @endphp
                                    </td>
                                    <td class="fare" data-label="@lang('Fare')">{{ showAmount($bookedTicket->sub_total) }}</td>
                                    <td class="action" data-label="@lang('Action')">
                                        <div class="action-button-wrapper text-end">
                                            <a href="{{ route('user.booking.detail', $bookedTicket->pnr_number) }}" class="checkinfo me-1" data-bs-toggle="tooltip" data-bs-title="@lang('Booking Detail')"><i class="las la-desktop"></i></a>
                                            @if($bookedTicket->status == Status::BOOKED_APPROVED)
                                                <a href="{{ route('user.ticket.print', $bookedTicket->id) }}" target="_blank" class="print" data-bs-toggle="tooltip" data-bs-title="@lang('Download Ticket')"><i class="las la-file-download"></i></a>
                                            @else
                                                @if($bookedTicket->status == Status::BOOKED_PENDING)
                                                    <a href="{{ route('user.booking.repayment',  encrypt($bookedTicket->id)) }}" class="print" target="_blank" class="print" data-bs-toggle="tooltip" data-bs-title="@lang('Complete Payment')"><i class="la la-money-bill"></i></button>
                                                @else
                                                    <button type="button" class="print btn btn--sm px-2 py-2" disabled><i class="las la-file-download"></i></button>
                                                @endif
                                            @endif
                                        </div>
                                    </td>
                                </tr>
                            @empty
                                <tr>
                                    <td class="text-center" colspan="100%">{{ __($emptyMessage) }}</td>
                                </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
                @if ($bookedTickets->hasPages())
                    <div class="custom-pagination">
                        {{ paginateLinks($bookedTickets) }}
                    </div>
                @endif
            </div>
        </div>
    </section>
    <!-- booking history end Here -->
@endsection
