HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/dashboard.orbiwheels.com/resources/views/transporter/request/view.blade.php
@extends('layout.transporter_master')
@section('content')
    <div class="right_col" role="main">
        <div class="">
            {{-- <div class="page-title">
                <div class="title_left">
                    <h3>Staff <small>List</small></h3>
                </div>
            </div> --}}

            <div class="clearfix"></div>
            @include('alerts')
            <div class="row" style="display: block;">
                <div class="col-md-12 col-sm-12 ">
                    <div class="x_title d-flex justify-content-between align-items-center">
                        <div class="gap-2 d-flex">
                            <h2>Request {{ $request->booking->ride_type_name }} Ride</h2>
                            @if ($request->status == \App\Models\RideRequest::PENDING)
                                <span class="badge badge-warning text-white px-3 py-2 display-4 ml-4">Pending</span>
                            @elseif($request->status == \App\Models\RideRequest::REJECTED)
                                <span class="badge badge-danger text-white px-3 py-2 display-4 ml-4">Rejected</span>
                            @elseif($request->status == \App\Models\RideRequest::ACCEPTED)
                                <span class="badge badge-success text-white px-3 py-2 display-4 ml-4">Accepted</span>
                            @else
                                <span class="badge badge-secondary text-white px-3 py-2 display-4 ml-4">Expired</span>
                            @endif
                        </div>
                    </div>

                    <div class="x_content">
                        <div class="row">
                            <div class="col-md-9 col-sm-9  ">

                                <ul class="stats-overview">
                                    <li>
                                        <span class="name"><i class="fa fa-calendar"></i> Date </span>
                                        <span class="value text-success">
                                            {{ implode(
                                                ', ',
                                                array_map(function ($date) {
                                                    return \Carbon\Carbon::parse($date)->format('d M');
                                                }, $trip->dates ?? []),
                                            ) }}</span>
                                    </li>
                                    <li>
                                        <span class="name"><i class="fa fa-road"></i> Distance </span>
                                        <span class="value text-success">{{ $trip->distance_km }} <small>Km</small></span>
                                    </li>
                                    <li>
                                        <span class="name"><i class="fa fa-money"></i> Transporter Earnings </span>
                                        <span class="value text-success">
                                            {{ number_format($trip->pricing_details['fare'] ?? 0, 2) }}</b>
                                            <small>INR</small></span>
                                    </li>
                                </ul>

                                <br />

                                <div id="map" style="height: 350px; width: 100%;"></div>
                            </div>

                            <!-- start project-detail sidebar -->
                            <div class="col-md-3 col-sm-3  ">
                                <section class="panel">
                                    <div class="x_title">
                                        <h2>Info</h2>
                                        <div class="clearfix"></div>
                                    </div>
                                    <div class="panel-body">
                                        <h6 class="green"><i class="fa fa-car"></i>
                                            Ride Info
                                        </h6>
                                        <div class="project_detail d-flex justify-content-between align-items-center">
                                            <p class="title">Ride Type</p>
                                            <p>
                                                @if (isset($request->booking))
                                                    {{ App\Models\Booking::rideTypes()[$request->booking->ride_type] ?? '' }}
                                                @endif
                                            </p>
                                        </div>
                                        <div class="project_detail d-flex justify-content-between align-items-center">
                                            <p class="title">Booking Type</p>
                                            <p>
                                                @if (isset($request->booking))
                                                    @if ($request->booking->booking_type == 1)
                                                        <span class="badge bg-primary text-white">
                                                            <i class="fa fa-long-arrow-right"></i> One Way
                                                        </span>
                                                    @else
                                                        <span class="badge bg-success text-white">
                                                            <i class="fa fa-exchange"></i> Two Way
                                                        </span>
                                                    @endif
                                                @endif
                                            </p>
                                        </div>
                                        <div class="project_detail d-flex justify-content-between align-items-center">
                                            <p class="title">Pickup location</p>
                                            <p class="mb-0">
                                                {{ $trip->locations['pickup_location'] }} </p>
                                        </div>
                                        <div class="project_detail d-flex justify-content-between align-items-center">

                                            <p class="title">
                                                {{ $request->booking->booking_type == 1 ? 'Drop Location' : 'Return Pickup Location' }}
                                            </p>
                                            <p>
                                                {{ $trip->locations['drop_location'] }}
                                            </p>
                                        </div>
                                        {{-- <div class="project_detail d-flex justify-content-between align-items-center">
                                        <p class="title">Date</p>
                                        <p>
                                            {{ isset($request->booking) ? \Carbon\Carbon::parse($request->booking->dates['from_date'])->format('d-m-Y') : '' }}
                                            to
                                            {{ isset($request->booking) ? \Carbon\Carbon::parse($request->booking->dates['to_date'])->format('d-m-Y') : '' }}
                                        </p>
                                    </div> --}}
                                        <div class="project_detail d-flex justify-content-between align-items-center">
                                            <p class="title">Pickup Time</p>
                                            <p>
                                                {{ \Carbon\Carbon::parse($trip->pickup_time)->format('h:i A') }}
                                            </p>
                                        </div>
                                        @if (isset($request->booking) && $request->booking->booking_type == 2)
                                            <div class="project_detail d-flex justify-content-between align-items-center">
                                                <p class="title">Return Pickup Time</p>
                                                <p>
                                                    @if (isset($trip->return_time))
                                                        {{ \Carbon\Carbon::parse($trip->return_time)->format('h:i A') }}
                                                    @endif
                                                </p>
                                            </div>
                                        @endif
                                        <br />
                                        @if ($request->status == \App\Models\RideRequest::PENDING && $request->booking->status == \App\Models\Booking::REQUESTED)
                                            <div class="text-center mtop20">
                                                <a href="javascript:void(0)"
                                                    data-url="{{ route('request.accept', encrypt($request->id)) }}"
                                                    data-vehicle-type="{{ $request->booking->vehicle_preferred ?? 0 }}"
                                                    class="btn btn-sm btn-success accept">Accept</a>

                                                <a href="javascript:void(0)"
                                                    data-url="{{ route('request.reject', encrypt($request->id)) }}"
                                                    class="btn btn-sm btn-danger reject">Reject</a>
                                            </div>
                                        @endif
                                    </div>
                                    <hr>
                                    @if ($request->status == \App\Models\RideRequest::ACCEPTED && $canSeeCustomer)
                                        <div class="panel-body">
                                            <div class="d-flex justify-content-between align-items-center">
                                                <h6 class="green mb-0">
                                                    <i class="fa fa-user me-1"></i> Customer
                                                </h6>
                                                {{-- Profile image on right side --}}
                                                <img src="{{ asset('images/user.png') }}" alt="Customer Profile"
                                                    class="rounded-circle" width="40" height="40">
                                            </div>
                                            <div class="project_detail d-flex justify-content-between align-items-center">
                                                <p class="title">Name</p>
                                                <p>{{ isset($request->booking) ? $request->booking->customer->first_name : '' }}
                                                    {{ isset($request->booking) ? $request->booking->customer->last_name : '' }}
                                                </p>
                                            </div>
                                            <div class="project_detail d-flex justify-content-between align-items-center">
                                                <p class="title">Email</p>
                                                <p>{{ isset($request->booking) ? $request->booking->customer->email : '' }}
                                                </p>
                                            </div>
                                            <div class="project_detail d-flex justify-content-between align-items-center">
                                                <p class="title">Phone</p>
                                                <p>{{ isset($request->booking) ? $request->booking->customer->phone : '' }}
                                                </p>
                                            </div>
                                            <br />
                                        </div>
                                        <hr>
                                    @endif
                                </section>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Modal for Driver & Vehicle -->
    @include('components.transporter.assign-modal')
@endsection

@push('script')
    <script>
        var pickup = [{{ $request->trip->locations['pickup_lat'] }},
            {{ $request->trip->locations['pickup_lng'] }}
        ];
        var drop = [{{ $request->trip->locations['drop_lat'] }},
            {{ $request->trip->locations['drop_lng'] }}
        ];


        var map = L.map('map').setView(pickup, 13);

        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: '© OpenStreetMap contributors'
        }).addTo(map);

        L.marker(pickup).addTo(map).bindPopup("Pickup: {{ $request->trip->locations['pickup_location'] }}")
            .openPopup();

        L.marker(drop).addTo(map).bindPopup("Drop: {{ $request->trip->locations['drop_location'] }}");

        var routeLine = L.polyline([pickup, drop], {
            color: 'blue',
            weight: 5
        }).addTo(map);

        map.fitBounds(routeLine.getBounds());
    </script>
    <script>
        const driverSearchUrl = "{{ route('driver.search') }}";
        const vehicleSearchUrl = "{{ route('vehicle.search') }}";
        const assignUrl = "{{ route('trips.assign', ':id') }}"; // placeholder
        const csrfToken = "{{ csrf_token() }}";
    </script>
    <script src="{{ asset('src/js/transporter/assign-modal.js') }}"></script>

    <script>
        $(document).ready(function() {
            $(document).on('click', '.accept', function() {
                let url = $(this).data('url');
                let rideVehicleType = $(this).data('vehicle-type') ?? 0;

                Swal.fire({
                    title: "Are you sure?",
                    text: "Do you want to accept this request?",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonText: "Yes, accept"
                }).then((result) => {
                    if (result.isConfirmed) {
                        Swal.fire({
                            title: "Assign Driver & Vehicle?",
                            text: "Do you want to assign them now?",
                            icon: "question",
                            showCancelButton: true,
                            confirmButtonText: "Yes, assign now",
                            cancelButtonText: "No, just accept"
                        }).then((assignResult) => {
                            if (assignResult.isConfirmed) {
                                let isAcceptFlow = true;
                                openAssignModal("{{ encrypt($request->id) }}",
                                    null, null, isAcceptFlow);
                            } else {
                                // accept without assignment
                                $.post(url, {
                                    _token: '{{ csrf_token() }}'
                                }, function(res) {
                                    location.reload();
                                });
                            }
                        });
                    }
                });
            });

            $(document).on('click', '.reject', function() {
                var url = $(this).data('url');
                Swal.fire({
                    title: "Are you sure?",
                    text: "You won't be able to revert this!",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "Yes, reject it!"
                }).then((result) => {
                    if (result.isConfirmed) {
                        $.ajax({
                            method: 'POST',
                            url: url,
                            data: {
                                _token: '{{ csrf_token() }}'
                            },
                            success: function(response) {
                                if (response.status) {
                                    Swal.fire({
                                        title: "Rejected!",
                                        text: response.message,
                                        icon: "success"
                                    });
                                    location.reload();
                                } else {
                                    Swal.fire({
                                        title: "Error",
                                        text: response.message,
                                        icon: "error"
                                    });
                                }
                            },
                            error: function(xhr, status, error) {
                                console.log(xhr.responseText);
                                Swal.fire({
                                    title: "Error",
                                    text: "An error occurred. Please try again later.",
                                    icon: "error"
                                });
                            }
                        });
                    }
                });
            });
        });
    </script>
@endpush