const BookingList = () => {
    $('#bookingList').DataTable({
        // stateSave: true,
        destroy: true,
        responsive: true,
        bAutoWidth: true,
        dom: '<"row"<"col-md-4 d-flex align-items-center" l><"col-md-8 d-flex align-items-center justify-content-end" fB>><"table-responsive" t><"table-footer-wrapper" <"divider"> <"row"<"col-md-6 d-flex align-items-center justify-content-start" i><"col-md-6 d-flex align-items-center justify-content-end" p>>>',
        buttons: [
            // 'excelHtml5',
            // 'csvHtml5',
            {
                extend: 'colvis',
                collectionLayout: 'fixed two-column'
            }
        ],
        // dom: '<"row"<"col-md-4 d-flex align-items-center"l><"col-md-8 d-flex align-items-center" fB>><"table-responsive" t><"table-footer-wrapper" <"divider"> <"row"<"col-md-6 d-flex align-items-center" il><"col-md-6 d-flex align-items-center" p>>>',
        // order: [
        //     [0, "desc"]
        // ],
        oLanguage: {
            "sSearch": "Search Bookings:"
        },
        ordering: false,
        rowReorder: true,
        searchDelay: 200,
        processing: true,
        serverSide: false,
        lengthMenu: [
            [10, 50, 100],
            [10, 50, 100]
        ],
        ajax: {
            url: "./datafiles/action.php",
            type: "POST",
            data: {
                requestType: 'bookingList'
            }
        },
        columns: [
            { data: "SNO" },
            { data: "NAME" },
            { data: "PHONE" },
            { data: "EMAIL" },
            { data: "ADDRESS" },
            { data: "REMARKS" },
            { data: "BOOKINGDATE" },
            { data: "PRICE" },
            { data: "PRICEWITHOUTTAX" ,visible: false},
            { data: "TAXPRICE" ,visible: false},
            { data: "PRODUCTDETAIL"},

        ]
    });
}
BookingList();


let productList = (id)=>{
    let data = {
        id : id,
        requestType : 'getproducts'
    };
    $.post('./datafiles/action.php', data, function (response){
          let result = JSON.parse(response);
            $("#edit-order").empty().html(result);
            
     $("#update_order").modal('show');
    })  
}



let bookingCount = ()=>{
    let data = {
        requestType : 'bookingCount'
    };
    $.post('./datafiles/action.php', data, function (response){
        let result = JSON.parse(response);
        if(result.status){
            $('#booking_count').empty().html(`${result.payload.booking_count}`);
        }else{
            $('#booking_count').empty().html('0');
        }
    })  
}
bookingCount();