
$(document).ready(function(){
$("#vehicleNo").on("change",function(){
    let vehicleNo = $(this).val();
    $.ajax({
        type:'POST',
        url:'ajaxpath1/fetch_chakka_type.php',
        data:{vehicleno:vehicleNo},
        success:function(data){

        $("#chakkaType").html(data);
        }
       });  
});
$("#chakkaType").on("change",function(){
    let chakkaType = $(this).val();
    let vehicleNo = $("#vehicleNo").val();
    $.ajax({
        type:'POST',
        url:'ajaxpath1/fetch_cft_value.php',
        data:{chakka:chakkaType,vehicleno:vehicleNo},
        success:function(data){
            let dataVal = Number(data).toFixed(2); 
            console.log(dataVal,'dataVal');
        $("#cftValue").val(dataVal);
        $("#cftValueOri").val(dataVal);
        }
       });  
});
$("#customerAdd").on("change",function(){
    let customerAdd = $(this).val();
    let loadType=$("#loadType").val();
    $("#productAdd").val(null).trigger("change");
    if(customerAdd!=''){
    $.ajax({
        type:'POST',
        url:'ajaxpath1/fetch_block_date.php',
        data:{customer:customerAdd,loadtype:loadType},
        success:function(data){
            console.log(data);
            var output= data.split("||");
            console.log(output);
        $("#blockDate").val(output[0]);
    blockDateValidation(output[0].trim());
        $("#limitValue").val(output[1]);
        $("#advanceLimitValue").val(output[2]);
        } 
       });  
    }
});
$("#productAdd").on("change",function(){
    let customerAdd = $("#customerAdd").val();
    let product = $("#productAdd").val();
    let vehicle_capacity = $("#cftValue").val();
    let loadType=$("#loadType").val();
    console.log(loadType);
    if(product!="")
    {
    $.ajax({
        type:'POST',
        url:'ajaxpath1/fetch_product_rate.php',
        data:{customer:customerAdd,product:product},
        success:function(data){
            let productPrice = data;
            let netAmount = productPrice * vehicle_capacity;
            limitValidation(netAmount);
        }
       });  
    }
});
$("#getweightbutton").click(function(){
       $.ajax({
        type:'POST',
        url:'ajaxpath/search1.php',
        //data:{chakka:chakkaType,vehicleno:vehicleNo},
        success:function(data){
        $("#getweight").val(data);
      //  $("#cftValueOri").val(data);
        }
       });  
});
$(".reloadPage").click(function(){
location.reload();
});
});