//=====================================Form Validation | Booking Calendar=========================================
let bookingCalendar = () => {
    let forms = $('.form-validate');
    let fields = ['user_name', 'user_email', 'user_phone', 'address'];

    let isValid = true;
    forms.each(function () {
        if (!this.checkValidity()) {
            isValid = false;
            fields.forEach(field => {
                let value = $(`#${field}`).val();
                (value === '')? $(`#${field}`).addClass('is-invalid').removeClass('is-valid') : $(`#${field}`).addClass('is-valid').removeClass('is-invalid');
            });
        }
    });
    if (isValid) {
        $('#datepickerModal').modal('show');
    }
};
//=====================================Form Validation | Booking Calendar=========================================


    
//=====================================Place Order=========================================
let placeOrder = () => {
    let data = {
        user_name: $('#user_name').val(),
        user_email: $('#user_email').val(),
        user_phone: $('#user_phone').val(),
        address: $('#address').val(),
        user_remarks: $('#user_remarks').val(),
        booking_date: $('#hidden_date').val(),
        requestType: 'placeOrder'
    };
    $.post('datafiles/action.php', data, function (response) {
        let result = JSON.parse(response);
        if (result.status == 1) {
            window.location.href = 'contents/welcome.php';
        } else {
            alert("Something went wrong!");
        }
    });
};
//=====================================Place Order=========================================