@extends('admin.index')
@section('content')

<form action="{{ route('admin.transportations.update', $transportation->id) }}" method="post" enctype="multipart/form-data">
    @csrf
    <input type="hidden" name="id" value="{{$transportation->id}}">
    <div class="card">
        <div class="border-bottom card-header">
            <h4 class="card-title">{{ trans('general.edit_transportation') }}</h4>
        </div>
        <div class="card-body">
            <div class="row pt-2">
                <div class="col-lg-3 col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="title">{{ trans('general.title') }}</label>
                        <input required type="text" name="title" class="form-control" id="title" value="{{old('title')? old('title') : $transportation->title}}">
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="code">{{ trans('general.code') }}</label>
                        <input required name="code" id="code" class="form-control" value="{{old('code')? old('code') : $transportation->code}}">
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="driver">{{ trans('general.driver') }}</label>
                        <input required type="text" name="driver_name" class="form-control" id="driver" value="{{old('driver_name')? old('driver_name') : $transportation->driver_name}}">
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="phone">{{ trans('general.phone') }}</label>
                        <div class="input-group input-group-merge">
                            <input required name="phone" id="phone" class="form-control phone-number-mask" value="{{old('phone')? old('phone') : $transportation->phone}}">
                            <span class="input-group-text">SY (+963)</span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="bus_image">{{ trans('general.bus_image') }}</label>
                        <input  type="file" name="bus_image" class="form-control" id="bus_image" value="{{old('bus_image')? old('bus_image') : $transportation->bus_image}}">
                    </div>
                </div>
                <div class="col-lg-6 col-12">
                    <div class="mb-1">
                        <img  class="img-thumbnail" src="{{Storage::url($transportation->bus_image)}}" alt="img-placeholder">
                    </div>
                </div>

            </div>
        </div>


        <div class="card-footer">
            <button type="submit" class="btn btn-primary waves-effect waves-float waves-light">{{ trans('general.save') }}</button>
            <button type="reset" class="btn btn-outline-secondary waves-effect">{{ trans('general.reset') }}</button>
        </div>
    </div>

</form>
@push('scripts')
<script>
    function stageLevels(stage_id) {
        var jqxhr = $.ajax({
                url: "{{route('admin.stage.levels.all')}}",
                method: "GET",
                timeout: 0,
                data: {
                    stage_id: stage_id
                }
            })
            .done(function(response) {
                setLevelsOptions(response.data);
                console.log(response);
            })
            .fail(function(response) {
                console.log(response);
                setLevelsOptions([]);
                toastr.error(response.responseJSON.msg, '{{ trans("general.error") }}');
            });
    }

    function setLevelsOptions(data) {
        var levelSelect = $('#levelSelect');
        levelSelect.html('');
        levelSelect.append($('<option>', {
            value: '',
            text: '--'
        }));
        $.each(data, function(index, val) {
            levelSelect.append($('<option>', {
                value: val.id,
                text: val.title + '  ' + val.code
            }));
        });
    }
</script>
@endpush

@push('header')


@endpush
@endsection