@extends('template.app')

@section('meta')
@endsection

@section('title')
    Vendor Profile
@endsection 

@section('styles')
<link href="{{ asset('assets/css/dropify.min.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/sweetalert2.bundle.css') }}" rel="stylesheet">
@endsection

@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">Vendor</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('vendor.profile')}}" class="text-muted">Profile</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">View</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">
                    
                @foreach($vendor_data as $vendor)

                    <form action="{{ route('vendor.profile')}}" name="form" id="form" method="post" enctype="multipart/form-data">
                        @csrf
                          @method('PATCH')
   <input type="hidden" name="id" value="{{ $vendor->id ?? '' }}">
                        <div class="row">
                        <div class="form-group col-sm-3">
                                <label for="vendor_code">Name of Comany</label>
                                <input type="text" name="name_of_company" class="form-control" placeholder="Enter Vendor Code" value="{{$vendor->name_of_company ?? '' }}" disabled>
                                <span class="kt-form__help error vendor_code"></span>
                            </div> 
                             <div class="form-group col-sm-3">
                                <label for="vendor_code">Vendor Code:</label>
                                <input type="text" name="vendor_code" class="form-control" placeholder="Enter Vendor Code" value="{{$vendor->vendor_code ?? '' }}" disabled>
                                <span class="kt-form__help error vendor_code"></span>
                            </div> 
                           <div class="form-group col-sm-3">
                                <label for="tally_heading">Tally Heading:</label>
                                <input type="text" name="tally_heading" class="form-control" placeholder="Enter Tally Heading" value="{{$vendor->tally_heading ?? '' }}" disabled>
                                <span class="kt-form__help error tally_heading"></span>
                            </div> 
                             <div class="form-group col-sm-3">
                                <label for="tan_number">TAN Number:</label>
                                <input type="text" name="tan_number" class="form-control" placeholder="Enter TAN Number"  value="{{$vendor->tan_number ?? '' }}" disabled>
                                <span class="kt-form__help error tan_number"></span>
                            </div>
                              <div class="form-group col-sm-3">
                                <label for="location">Location:</label>
                                <input type="text" name="location" class="form-control" placeholder="Enter Location" value="{{$vendor->location ?? '' }}" disabled>
                                <span class="kt-form__help error location"></span>
                            </div>
                            
                            <div class="form-group col-sm-3">
                                <label for="description_goods">Description of Goods/Services:</label>
                                <textarea name="description_goods" class="form-control" placeholder="Enter Description of Goods/Services" rows="4" disabled>{{$vendor->description_goods ?? '' }}</textarea>
                                <span class="kt-form__help error description_goods"></span>
                            </div> 
                         
                        </div><br/>
                        <div class="row">
                        <div class="form-group col-sm-3">
                                <label for="department" name="department" placeholder="Plese select department">Department</label>
                                <select class="form-control " name="department" id="department" disabled="disabled">
                                    @if(isset($department) && $department->isNotEmpty())
                                        @foreach($department AS $row)
                                            <option value="{{ $row->id }}" @if($vendor->department_id == $row->d_id) selected @endif> {{ $row->d_name }} </option>
                                        @endforeach
                                    @endif
                                </select>
                                <span class="kt-form__help error department"></span>
                            </div>
                           <div class="form-group col-sm-3">
                                <label for="authorised_person">Authoried Peroson:</label>
                                <input type="text" name="authorised_person" class="form-control" placeholder="Enter Authorised Person Name" value="{{$vendor->authorised_person ?? '' }}" disabled>
                                <span class="kt-form__help error authorised_person"></span>
                            </div> 
                            
                           <div class="form-group col-sm-3">
                                <label for="ex_showroom_price">Authoried Person Contact Number:</label>
                                <input type="text" name="person_contactno" class="form-control" placeholder="Enter Authoried Person Contact Number:" value="{{$vendor->person_contactno ?? '' }}" disabled>
                                <span class="kt-form__help error person_contactno"></span>
                            </div> 
                              <div class="form-group col-sm-3">
                                <label for="ex_showroom_price">Vendor List: </label>
                                <input type="text" name="vendor_list" class="form-control" placeholder="Enter Vendor List" value="{{$vendor->vendor_list ?? '' }}" disabled>
                                <span class="kt-form__help error vendor_list"></span>
                            </div> 
                         
                        </div>
                        <br/>
                        <div class="row">
                             <div class="form-group col-sm-3">
                                <label for="contact_person">Contact Person:</label>
                                <input type="text" name="contact_person" class="form-control" placeholder="Enter Contact Person Name" value="{{$vendor->contact_person ?? '' }}" disabled>
                                <span class="kt-form__help error contact_person"></span>
                            </div> 
                           <div class="form-group col-sm-3">
                                <label for="ex_showroom_price">Mobile No:</label>
                                <input type="text" name="contact_number" class="form-control" placeholder="Enter Mobile Number" value="{{$vendor->contact_number ?? '' }}" disabled>
                                <span class="kt-form__help error contact_number"></span>
                            </div> 
                            
                           <div class="form-group col-sm-3">
                                <label for="email">Email ID:</label>
                                <input type="email" name="email" class="form-control" placeholder="Enter Email Address" value="{{$vendor->email ?? '' }}" disabled>
                                <span class="kt-form__help error email"></span>
                            </div> 
                              <div class="form-group col-sm-3">
                                <label for="gst_no">GST No:</label>
                                <input type="text" name="gst_no" class="form-control" placeholder="Enter Gst Number" value="{{$vendor->gst_no ?? '' }}" disabled>
                                <span class="kt-form__help error gst_no"></span>
                            </div> 
                            <div class="form-group col-sm-3">
                                <label for="gross_annual_sales">Gross Annual Sales:</label>
                                <input type="text" name="gross_annual_sales" class="form-control" placeholder="Enter Gross Annual Sales" value="{{$vendor->gross_annual_sales ?? '' }}" disabled>
                                <span class="kt-form__help error gross_annual_sales"></span>
                            </div> 
                        </div>
                        <br/>
                        <div class="row">
                             <div class="form-group col-sm-3">
                                <label for="pan_no">Pan No:</label>
                                <input type="text" name="pan_no" class="form-control" placeholder="Enter Pan Number" value="{{$vendor->pan_no ?? '' }}" disabled>
                                <span class="kt-form__help error pan_no"></span>
                            </div> 
                           <div class="form-group col-sm-3">
                                <label for="address">Address</label>
                                <textarea name="address" rows="4" class="form-control" placeholder="Enter Address" disabled>{{$vendor->address ?? '' }}</textarea>
                                <span class="kt-form__help error address"></span>
                            </div> 
                            
                           <div class="form-group col-sm-3">
                                <label for="bank_name">Bank Name</label>
                                <input type="text" name="bank_name" class="form-control" placeholder="Enter Bank Name" value="{{$vendor->bank_name ?? '' }}" disabled>
                                <span class="kt-form__help error bank_name"></span>
                            </div> 
                              <div class="form-group col-sm-3">
                                <label for="account_no">Account No:</label>
                                <input type="text" name="account_no" class="form-control" placeholder="Enter Account Number" value="{{$vendor->account_no ?? '' }}" disabled>
                                <span class="kt-form__help error account_no"></span>
                            </div> 
                         
                        </div>
                        <br/>
                        <div class="row">
                             <div class="form-group col-sm-3">
                                <label for="ifsc_code">IFSC Code:</label>
                                <input type="text" name="ifsc_code" class="form-control" placeholder="Enter IFSC Code" value="{{$vendor->ifsc_code ?? '' }}" disabled>
                                <span class="kt-form__help error ifsc_code"></span>
                            </div> 
                           <div class="form-group col-sm-3">
                                <label for="acc_holder_name">Account Holder Name:</label>
                                <input type="text" name="acc_holder_name" class="form-control" placeholder="Enter Account Holder Name" value="{{$vendor->acc_holder_name ?? '' }}" disabled>
                                <span class="kt-form__help error acc_holder_name"></span>
                            </div> 
                            
                           <div class="form-group col-sm-3">
                                <label for="account_type">Account Type:</label>
                                <input type="TEXT" name="account_type" class="form-control" placeholder="Enter Account Type" value="{{$vendor->account_type ?? '' }}" disabled>
                                <span class="kt-form__help error account_type"></span>
                            </div> 
                              <div class="form-group col-sm-3">
                                <label for="branch">Branch</label>
                                
                                <select class="form-control" name="branch" id="branch" disabled>
                                    <option value="">Select Branch</option>
                                    @if(isset($branch) && $branch->isNotEmpty())
                                        @foreach($branch AS $row)
                                            <option value="{{ $row->id }}" @if($vendor->branch == $row->id) selected @endif> {{ $row->name }} </option>
                                        @endforeach
                                    @endif
                                </select>
                                <span class="kt-form__help error branch"></span>
                            </div> 
                         
                        </div>
                        <br/>
                        <div class="row">
                             <div class="form-group col-sm-3">
                                <label for="district">Distrcit:</label>
                                <input type="text" name="district" class="form-control" placeholder="Enter District" value="{{$vendor->district ?? '' }}" disabled>
                                <span class="kt-form__help error district"></span>
                            </div> 
                           <div class="form-group col-sm-3">
                                <label for="state">State:</label>
                                <input type="text" name="state" class="form-control" placeholder="Enter State" value="{{$vendor->state ?? '' }}" disabled>
                                <span class="kt-form__help error state"></span>
                            </div> 
                            
                           <div class="form-group col-sm-3">
                                <label for="payment_mode">Mode of Payment:</label>
                                <input type="text" name="payment_mode" class="form-control" placeholder="Enter Mode of Payment" value="{{$vendor->payment_mode ?? '' }}" disabled>
                                <span class="kt-form__help error payment_mode"></span>
                            </div> 
                              <div class="form-group col-sm-3">
                                <label for="working_year">Working Year:</label>
                                <input type="text" name="working_year" class="form-control" placeholder="Enter Working Year" value="{{$vendor->working_year ?? '' }}" disabled>
                                <span class="kt-form__help error working_year"></span>
                            </div> 
                         
                        </div>
                        <div class="row">
                             <div class="form-group col-sm-3">
                                <label for="remark_1">Remark_1:</label>
                                <input type="text" name="remark_1" class="form-control" placeholder="Enter Remarks1" value="{{$vendor->remark_1 ?? '' }}" disabled>
                                <span class="kt-form__help error remark_1"></span>
                            </div> 
                           <div class="form-group col-sm-3">
                                <label for="remark_2">Remark_2:</label>
                                <input type="text" name="remark_2" class="form-control" placeholder="Enter Remarks2" value="{{$vendor->remark_2 ?? '' }}" disabled>
                                <span class="kt-form__help error remark_2"></span>
                            </div> 
                            
                        </div>
                        <br/>
                        
                        <div class="form-group">
                            
                            <!--<button type="submit" class="btn waves-effect waves-light btn-rounded btn-outline-primary">Submit</button>-->
                            <a href="{{ route('vendor.profile') }}" class="btn waves-effect waves-light btn-rounded btn-outline-secondary">Back</a>
                        </div>
                       
                    </form>
                    @endforeach

                </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