@extends('backend.layouts.app')

@section('content')
    <div class="row page-titles">
        <div class="col-md-5 align-self-center">
            <h4 class="text-themecolor">Service Manager</h4>
        </div>
        <div class="col-md-7 align-self-center text-right">
            <div class="d-flex justify-content-end align-items-center">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Dashboard</a></li>
                    <li class="breadcrumb-item"><a href="{{ route('service.index') }}">Service Manager</a></li>
                    <li class="breadcrumb-item active">Booking List</li>
                </ol>
            </div>
        </div>
    </div>
    <div class="container-fluid">
        <div id="deleteModal" class="modal fade" role='dialog'>
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <p>Are you sure you want to delete this?</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <span id='deleteButton'></span>
                    </div>
                </div>
            </div>
        </div>
        {{-- Status model --}}
        <div id="statusModal" class="modal fade" role='dialog'>
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <p>Are you sure you want to change the status?</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <span id='changestatus'></span>
                    </div>
                </div>
            </div>
        </div>
        {{-- end --}}

        <div class="content-wrapper">
            @if (session('status'))
                <div class="alert alert-success alert-dismissible fade show" role="alert">
                    <i class="far fa-check-circle"></i> {{ session('status') }}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            @endif
            @if (count($errors) > 0)
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            <section class="content">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <br>
                                <div class="table-responsive">
                                    <table id="pages" class="table table-bordered table-hover">
                                        <thead>
                                            <tr>
                                                <th>S. No.</th>
                                                <th>@sortablelink('user.userInformations', 'Company Name')</th>
                                                <th>@sortablelink('total_price', 'Total Price')</th>
                                                <th>@sortablelink('created_at', 'Created At')</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if (count($bookings) > 0)
                                                @foreach ($bookings as $key => $booking)
                                                    <tr>
                                                        <td>{{ ++$key }}</td>
                                                        <td>{{ $booking->user?->userInformations?->company_name }}</td>
                                                        <td>${{ $booking->total_price }}</td>
                                                        <td>
                                                            {{ $booking->created_at ? $booking->created_at->format(config('GET.admin_date_time_format') ?? 'Y-m-d ') : '-' }}
                                                        </td>
                                                        <td>
                                                            <a href="{{ route('service.booking.detail', ['serviceid' => $booking->service_id,'boookingid'=>$booking->id]) }}">
                                                                <button class="btn btn-info btn-sm" title="view">
                                                                    <i class="fas fa-eye"></i></button>
                                                            </a>
                                                        </td>
                                                    </tr>
                                                @endforeach
                                            @else
                                                <tr>
                                                    <td colspan="9" class="text-center " style="font-weight: bold;">No
                                                        Record Found !</td>
                                                </tr>
                                            @endif

                                        </tbody>
                                    </table>

                                </div>
                                @if ($bookings->total() > 0)
                                    <div class="d-flex justify-content-between align-items-center">
                                        <!-- Display custom number of entries -->
                                        <div class="entries-info">
                                            Showing {{ $bookings->firstItem() }} to
                                            {{ $bookings->lastItem() }} of {{ $bookings->total() }}
                                            entries
                                        </div>

                                        <!-- Pagination -->
                                        <div class="pagination-wrapper float-right">
                                            {{ $bookings->links('vendor.pagination.bootstrap-4') }}
                                        </div>
                                    </div>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
@stop
