@extends('template.app')

@section('meta')
@endsection

@section('title')
Vendor Master
@endsection

@section('styles')
<style>
     .highlight {
        background-color: #ffff99; /* Change to desired highlight color */
    }
</style>
@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">Quotation 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('vendor.quatindex') }}" class="text-muted">Quotation Master</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">List</li>
                    </ol>
                </nav>
            </div>
        </div>
        <div class="col-5 align-self-center">
            <div class="customize-input float-right">
                    <a class="btn waves-effect waves-light btn-rounded btn-outline-primary pull-right" href="{{ route('vendor.quotation') }}">Add Quotation</a>
                    
            </div>
        </div>
        <div class="col-sm-8"></div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    
                     <div class="card-body table-responsive" id="datatable">
                    <table class="table table-bordered data-table" id="data-table">
                        <thead>
                            <tr>
                                <th>SR</th>
                                <th>Quotation Name</th>
                                <th>Description</th>
                                <th>Quotation Attachment</th>
                                <th>Quotation Amount</th>
                                <th>Remark</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                    </table>
                </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>
var datatable;

    $(document).ready(function() {
                if ($('#data-table').length > 0) {
                    datatable = $('#data-table').DataTable({
                            processing: true,
                            serverSide: true,

                            "pageLength": 10,
                            "iDisplayLength": 10,
                            "responsive": true,
                            "aaSorting": [],
                               "ajax": {
                                    "url": "{{ route('vendor.quatindex') }}",
                                    "type": "POST",
                                    "dataType": "json",
                                    "data": {
                                        _token: "{{csrf_token()}}"
                                    }
                                },
                                "columnDefs": [{
                                    //"targets": [0, 5], //first column / numbering column
                                    "orderable": true, //set not orderable
                                }, ],
                                columns: [{
                                        data: 'DT_RowIndex',
                                        name: 'DT_RowIndex'
                                    },
                                    {
                                        data: 'name_of_quotation',
                                        name: 'name_of_quotation'
                                    },
                                   
                                    {
                                        data: 'name_of_description',
                                        name: 'name_of_description'
                                    },
                                    {
                                        data: 'attechment',
                                        name: 'attechment'
                                    },
                                    {
                                        data: 'quotation_amount',
                                        name: 'quotation_amount'
                                    },
                                     {
                                        data: 'remark',
                                        name: 'remark'
                                    },
                                    {
                                        data: 'status',
                                        name: 'status'
                                    },
                                    {
                                        data: 'action',
                                        name: 'action',
                                        orderable: false,
                                    },
                                ]
                            });
                    }
                });

           
    $(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