@extends('layout')
@section('title', 'ٹرپس')
@section('page_title', 'ٹرپس')
@section('css')

@endsection
@section('page_sub_title')
    @if(auth()->user()->hasPermissionTo('create trip'))

        <a type="button" onclick="add_new_trip()" class="btn pointer btn-primary btn-sm">نئے ٹرپ کا اندراج</a>
    @endif
@endsection
@section('content')

   <div class="row">
        
    <div class="col-md-12">
        <div class="panel panel-card margin-b-30">
            <div class="panel-body" data-select2-id="select2-data-3-yt46">

                <form action="{{route('update-trip-driver')}}" data-select2-id="select2-data-add_vehicle_form" method="POST">
                    @csrf;
                    <input type="hidden" name="last_driver_id" value="{{$driver_id}}">
                     <input type="hidden" name="trip_history_id" value="{{$trip_history->id}}">
                    
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                               <label for="driver_name">ڈرائیورز
                                            <span class="text-danger">*</span></label>
                                        <select name="new_driver_id" id="driver" onchange="get_driver_detail()"
                                                class="form-control"
                                                multiple autofocus>
                                            @forelse ($drivers as $DriverDetail)
                                                <option value="{{ $DriverDetail->id }}" {{ $DriverDetail->id == $driver_id ? 'selected' : '' }}>{{ $DriverDetail->name }}</option>
                                            @empty
                                            @endforelse
                                        </select>
                                        <span class="text-danger error" id="driver_error"></span>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="vehicle_number"> گاڑی نمبر<span class="text-danger">*</span></label>
                                <input type="text" value="{{$vehicle->vehicle_no}}" id="vehicle_number" placeholder="e.g. ABC-2022" class="form-control" name="vehicle_number" onblur="checkVehicle()">
                                <p id="warning" class="bg-danger blink_me"></p>
                                <p id="error" class="bg-success"></p>
                                <span class="text-danger error" id="vehicle_number_error"></span>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="driver_phone">ٹرپ نمبر
                                    <span class="text-danger">*</span></label>
                                <input type="text" id="" name="trip_number" class="form-control" placeholder="990" readonly="" value="{{$trip->id}}">
                                <span class="text-danger error" id="driver_phone_error"></span>
                            </div>
                        </div>
                    </div>
                   
                    <div class="row">
                        <div class="col-md-12">
                            <div class="">
                                <button name="createVehicleSubmit" id="submit_btn" class="btn btn-sm btn-primary btn-sm m-t-n-xs" type="submit">
                                    <strong>محفوظ</strong>
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
      
</div>


@endsection

@section('javascript')
    <script></script>
    @include('vehicles.js')
@endsection

