@include('header')
@php
$UserId = Session::get('UserId');
@endphp
<div class="container-fluid flex-grow-1 container-p-y">
    <h4 class="font-weight-bold py-3 mb-0">Vendors List
       <span style="float: right;">
            <a href="javascript:void(0)" onclick="addNewVendor()" class="btn btn-secondary btn-round"><i class="ion ion-md-add mr-2"></i> New Vendor</a></span> 
    </h4>
    <div class="card mb-4">
        <div class="card-body">
            <div id="alert_message"></div>
            

            <div class="table-responsive" id="custresult">


            </div>
        </div>
    </div>




</div>

@include('footerscript')
@include('excelscript')
<script type="text/javascript">

function addNewVendor(){
    setTimeout(function() {
            window.open('/{{projectUrl()}}addNewVendor', 'popUpWindow',
                'height=1000,width=1000,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no'
            );
        }, 1);
 }
 
$(document).ready(function() {
    queueList();
$(document).on("click", ".delete", function(event) {
        event.preventDefault();
        var id = $(this).attr("data-id");
        var action = "delete";
        swal({
            title: "Are you sure?",
            text: "You will not be able to recover this Record!",
            type: "warning",
            showCancelButton: true,
            confirmButtonClass: "btn-danger",
            confirmButtonText: "Yes, delete",
            cancelButtonText: "No, cancel",
            closeOnConfirm: false,
            closeOnCancel: false
        }, function(isConfirm) {
            if (isConfirm) {
                $.ajax({
                    url: "{{ url('deletVendor') }}",
                    method: "POST",
                    data: {
                        _token: '{{csrf_token()}}',
                        id: id
                    },
                    beforeSend:function(){
                $('.confirm').attr('disabled','disabled');
                $('.confirm').text('Please Wait...');
                },

                    success: function(data) {
                       
                        swal("Deleted!", "Record has been deleted.", "success");
                        //window.location.href = "/queuemanagement";
                        queueList();



                    }
                });

            } else {
                swal("Cancelled", "Record is safe :)", "error");
            }
        });


    });
});

function queueList() {
    //alert(FromDate);alert(MrdNo);
    $.ajax({
        url: "{{ url('viewVendors') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}'
        },
        success: function(data) {
            console.log(data);
            $('#custresult').html(data);
        }
    });
}


</script>
</script>
