@extends('template.app')

@section('meta')
@endsection

@section('title')
exchange Update
@endsection

@section('styles')
<link href="{{ asset('assets/css/dropify.min.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/sweetalert2.bundle.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/select2.css') }}" rel="stylesheet">
<style type="text/css">
    /*#galeria{
        display: flex;
    }*/
    #galeria img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

    /*#pan_image_multi{
        display: flex;
    }*/
    #pan_image_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

    /*#adhar_image_multi{
        display: flex;
    }*/
    #adhar_image_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }
/*#rcbook_multi{
        display: flex;
    }*/
    #rcbook_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }
    /*#insurance_multi{
        display: flex;
    }*/
    #insurance_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }
     /*#totto_multi{
        display: flex;
    }*/
    #totto_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }
   /* #documents_multi{
        display: flex;
    }*/
    #documents_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

    /*#licance_image_multi{
        display: flex;
    }*/
    #licance_image_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }
</style>
@section('content')
<div class="page-breadcrumb">
    <div class="row">
        <div class="col-7 align-self-center">
            <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">exchange Master</h4>
            <div class="d-flex align-items-center">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb m-0 p-0">
                        <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-muted">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="{{ route('exchange') }}" class="text-muted">exchange Master</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">Update</li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    @csrf
                    @method('PATCH')
                    <input type="hidden" name="id" value="{{ $data->id }}">
                    <div class="row">
                        <div class="form-group col-sm-3">
                            <label for="obf_id">Select OBF </label>
                            <!-- <input type="text" name="obf_id" id="obf_id" class="form-control" placeholder="Select OBF"> -->
                            <select  class="form-control" id="obf_id" name="obf_id" disabled>
                                <option value="">Select OBF</option>
                                @foreach($obf as $obf1)
                                <option value="{{$obf1->id }}">{{$obf1->customer_name }}</option>
                                @endforeach
                                
                            </select>
                            <span class="kt-form__help error obf_id"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="seller_detail">Seller Ddetail</label>
                            <input type="text" name="seller_detail" id="seller_detail" class="form-control" placeholder="Enter Seller Detail" value="{{ $data->seller_detail ??'' }}" disabled>
                            <span class="kt-form__help error seller_detail"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="company_name">Make</label>
                            <select  class="form-control" id="company_name" name="company_name">
                                <option value="">Select Car Company</option>
                                @foreach($carcompany as $carcompany1)
                                <option value="{{$carcompany1->company_name }}">{{$carcompany1->company_name }}</option>
                                @endforeach
                                
                            </select>
                            <span class="kt-form__help error car_model"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="variant">Variant</label>
                            <input type="text" name="variant" id="variant" class="form-control" placeholder="Enter Variant" value="{{ $data->variant ??'' }}" disabled>
                            <span class="kt-form__help error variant"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="manufacturing_year">Manufacturing Year</label>
                            <input type="number" name="manufacturing_year" id="manufacturing_year" class="form-control" placeholder="Enter Manufacturing Year" value="{{ $data->manufacturing_year ??'' }}" disabled>
                            <span class="kt-form__help error manufacturing_year"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="registration_number">Registration Number</label>
                            <input type="text" name="registration_number" id="registration_number" class="form-control" placeholder="Enter Registration Number" value="{{ $data->registration_number ??'' }}" disabled>
                            <span class="kt-form__help error registration_number"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="chassis_number">Chassis Number</label>
                            <input type="number" name="chassis_number" id="chassis_number" class="form-control" placeholder="Enter Chassis Number" value="{{ $data->chassis_number ??'' }}" disabled>
                            <span class="kt-form__help error chassis_number"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="engine_number">Engine Number</label>
                            <input type="number" name="engine_number" id="engine_number" class="form-control" placeholder="Enter Engine Number" value="{{ $data->engine_number ??'' }}" disabled>
                            <span class="kt-form__help error engine_number"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="colour">Colour</label>
                            <input type="text" name="colour" id="colour" class="form-control" placeholder="Enter Colour" value="{{ $data->colour ??'' }}" disabled>
                            <span class="kt-form__help error colour"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="time">Time</label>
                            <input type="time" name="time" id="time" class="form-control" placeholder="Enter Time" value="{{ $data->time ??'' }}" disabled>
                            <span class="kt-form__help error time"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="date">Date</label>
                            <input type="date" name="date" id="date" class="form-control" placeholder="Enter date" value="{{ $data->relation_with_obf ??'' }}" disabled>
                            <span class="kt-form__help error date"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="date_of_registration">date of registration</label>
                            <input type="date" name="date_of_registration" id="date_of_registration" class="form-control" placeholder="Enter date of registration" value="{{ $data->date ??'' }}" disabled>
                            <span class="kt-form__help error date_of_registration"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="purchase_date">purchase date</label>
                            <input type="date" name="purchase_date" id="purchase_date" class="form-control" placeholder="Enter purchase date" value="{{ $data->purchase_date ??'' }}" disabled>
                            <span class="kt-form__help error purchase_date"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="amount">Amount</label>
                            <input type="number" name="amount" id="amount" class="form-control" placeholder="Enter Amount" value="{{ $data->amount ??'' }}" disabled>
                            <span class="kt-form__help error amount"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="exchange_bonus">Exchange Bonus</label>
                            <input type="number" name="exchange_bonus" id="exchange_bonus" class="form-control" placeholder="Enter Exchange Bonus" value="{{ $data->exchange_bonus ??'' }}" disabled>
                            <span class="kt-form__help error exchange_bonus"></span>
                        </div>
                        
                        <div class="form-group col-sm-3">
                            <label for="amount_in_words">Amount in Words</label>
                            <input type="text" name="amount_in_words" id="amount_in_words" class="form-control" placeholder="Enter Amount in Words" value="{{ $data->amount_in_words ??'' }}" disabled>
                            <span class="kt-form__help error amount_in_words"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="HPA">HPA</label>
                            <input type="text" name="HPA" id="HPA" class="form-control" placeholder="Enter Amount in HPA" value="{{ $data->HPA ??'' }}" disabled>
                            <span class="kt-form__help error HPA"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="car_status">Car Status</label>
                            <select  class="form-control" id="car_status" name="car_status">
                                <option value="">Car Status</option>
                                 <option value="exchange">Exchange</option>
                                 <option value="purchase">Purchase</option>
                            </select>
                            <span class="kt-form__help error car_status"></span>
                        </div>
                        <div class="form-group col-sm-3">
                            <label for="relation_with_obf">Relation With OBF</label>
                            <input type="text" name="relation_with_obf" id="relation_with_obf" class="form-control" placeholder="Enter Relation With Obf" value="{{ $data->relation_with_obf ??'' }}" disabled>
                            <span class="kt-form__help error relation_with_obf"></span>
                        </div>
                        
                        <!-- totto -->
                        <div class="form-group col-md-3">
                            <div class="row">
                                <div class="form-group col-md-12">
                                     <p>Upload pan</p>
                                </div>
                                <div class="form-group col-md-12">
                                    <div id="pan_image_multi">
                                    <?php
                                         if(!empty($data->pan_image))
                                        {
                                            $other_documents_arr = explode(',', $data->pan_image);
                                            foreach ($other_documents_arr as $value) {
                                                if(file_exists(public_path('/uploads/exchange/'.$value))) { ?>
                                                    <img src="{{asset('uploads/exchange/'. $value )}}" class="hover-shadow">
                                                <?php }
                                            }
                                        }
                                    ?>
                                    </div>
                                </div>
                            </div>                                           
                        </div>

                        <!-- adhar -->
                        <div class="form-group col-md-3">
                            <div class="row">
                                <div class="form-group col-md-12">
                                     <p>Upload adhar</p>
                                </div>
                                <div class="form-group col-md-12">
                                    <div id="adhar_image_multi">
                                    <?php
                                         if(!empty($data->adhar_image))
                                        {
                                            $other_documents_arr = explode(',', $data->adhar_image);
                                            foreach ($other_documents_arr as $value) {
                                                if(file_exists(public_path('/uploads/exchange/'.$value))) { ?>
                                                    <img src="{{asset('uploads/exchange/'. $value )}}" class="hover-shadow">
                                                <?php }
                                            }
                                        }
                                    ?>
                                    </div>
                                </div>
                            </div>                                           
                        </div>

                        <!-- rc book -->
                        <div class="form-group col-md-3">
                            <div class="row">
                                <div class="form-group col-md-12">
                                     <p>Upload rcbook</p>
                                </div>
                                <div class="form-group col-md-12">
                                    <div id="rcbook_multi">
                                    <?php
                                         if(!empty($data->rcbook))
                                        {
                                            $other_documents_arr = explode(',', $data->rcbook);
                                            foreach ($other_documents_arr as $value) {
                                                if(file_exists(public_path('/uploads/exchange/'.$value))) { ?>
                                                    <img src="{{asset('uploads/exchange/'. $value )}}" class="hover-shadow">
                                                <?php }
                                            }
                                        }
                                    ?>
                                    </div>
                                </div>
                            </div>                                           
                        </div>

                        <!-- insurance -->
                        <div class="form-group col-md-3">
                            <div class="row">
                                <div class="form-group col-md-12">
                                     <p>Upload insurance</p>
                                </div>
                                <div class="form-group col-md-12">
                                    <div id="insurance_multi">
                                    <?php
                                         if(!empty($data->insurance))
                                        {
                                            $other_documents_arr = explode(',', $data->insurance);
                                            foreach ($other_documents_arr as $value) {
                                                if(file_exists(public_path('/uploads/exchange/'.$value))) { ?>
                                                    <img src="{{asset('uploads/exchange/'. $value )}}" class="hover-shadow">
                                                <?php }
                                            }
                                        }
                                    ?>
                                    </div>
                                </div>
                            </div>                                           
                        </div>

                        <!-- totto -->
                        <div class="form-group col-md-3">
                            <div class="row">
                                <div class="form-group col-md-12">
                                     <p>Upload TTO</p>
                                </div>
                                <div class="form-group col-md-12">
                                    <div id="totto_multi">
                                    <?php
                                         if(!empty($data->totto))
                                        {
                                            $other_documents_arr = explode(',', $data->totto);
                                            foreach ($other_documents_arr as $value) {
                                                if(file_exists(public_path('/uploads/exchange/'.$value))) { ?>
                                                    <img src="{{asset('uploads/exchange/'. $value )}}" class="hover-shadow">
                                                <?php }
                                            }
                                        }
                                    ?>
                                    </div>
                                </div>
                            </div>                                           
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('scripts')
<script src="{{ asset('assets/js/promise.min.js') }}"></script>
<script src="{{ asset('assets/js/sweetalert2.bundle.js') }}"></script>

<script>
    $(document).ready(function() {
        var form = $('#form');
        $('.kt-form__help').html('');
        form.submit(function(e) {
            $('.help-block').html('');
            $('.m-form__help').html('');
            $.ajax({
                url: form.attr('action'),
                type: form.attr('method'),
                data: new FormData($(this)[0]),
                dataType: 'json',
                async: false,
                processData: false,
                contentType: false,
                success: function(json) {
                    return true;
                },
                error: function(json) {
                    if (json.status === 422) {
                        e.preventDefault();
                        var errors_ = json.responseJSON;
                        $('.kt-form__help').html('');
                        $.each(errors_.errors, function(key, value) {
                            $('.' + key).html(value);
                        });
                    }
                }
            });
        });
    });
</script>
@endsection
