function change_ord_stat(new_stat, order_id, indx) {
    var userChoice = confirm("are you sure this order is: " + new_stat);
    if (!userChoice) {
        return fetch("/order/" + order_id).then(response => response.json())
            .then(data => {
                if (data.message == "success")
                    return document.querySelector("#ord_stat_" + indx).value = data.order.status;
                else return false;
            });
    }
    fetch("/order/change_status/" + order_id, {
        method: 'PUT',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ status: new_stat }),
    }).then(response => response.json())
        .then(data => {
            if (data.message == "success"){
                if(data.order.status=="Canceled") document.querySelector("#btn_cancel_" + indx).disabled=true;
                else document.querySelector("#btn_cancel_" + indx).disabled=false;
                return document.querySelector("#ord_stat_" + indx).value = data.order.status;
            }
        });
}