$(document).ready(function () {
  // ajax for unit
  var product = $("#productedit").val();
  $.ajax({
    type: "POST",
    url: "ajaxpath/secondtrans_unit.php",
    data: { product: product },
    success: function (c) {
      //  alert(a);
      // $("#showquantity-with-color").css("display","block");
      $("#unitconversionedit").val(c);
      //alert(c);
    },
  });
  // ajax for unit
  $("#showcredit").hide();
  // for customer
  $("#customeredit").on("change", function () {
    var customer = $(this).val();
    //    ajax for sales type
    $.ajax({
      type: "POST",
      url: "ajaxpath/vehiclecustomer.php",
      data: { customer: customer },
      success: function (a) {
        //  alert(a);
        // $("#showquantity-with-color").css("display","block");
        $("#vehiclenoedit").html(a);
        $(".emptyweightedit").val("");
        //alert(a);
      },
    });
  });
  //   for customer
  // for vehicle
  $("#vehiclenoedit").on("change", function () {
    var vehicle = $(this).val();
    //    ajax for sales type
    $.ajax({
      type: "POST",
      url: "ajaxpath/vehicleempty.php",
      data: { vehicle: vehicle },
      success: function (a) {
        //  alert(a);
        // $("#showquantity-with-color").css("display","block");
        $(".emptyweightedit").val(a);
        //alert(a);.
      },
    });
  });
  // for vehicle
  // for customer
  $("#productedit").on("change", function () {
    // ajax for unit
    var product = $("#productedit").val();
    $.ajax({
      type: "POST",
      url: "ajaxpath/secondtrans_unit.php",
      data: { product: product },
      success: function (c) {
        //  alert(a);
        // $("#showquantity-with-color").css("display","block");
        $("#unitconversionedit").val(c);
        var nettwe = $("#netweightedit").val();
        var unitcon = $("#unitconversionedit").val();
        var finaluni = nettwe / unitcon;

        $("#netqtyedit").val(finaluni.toFixed(2));
        $("#netqtyoriedit").val(finaluni.toFixed(2));
        //alert(c);
      },
    });
    // ajax for unit
  });
  //   for customer
});
$(document).ready(function () {
  //alert('hai');
  $(".loadbutedit").click(function () {
    var query = 1;
    $.ajax({
      url: "ajaxpath/search1.php",
      method: "POST",
      data: { query: query },
      success: function (data) {
        //alert(data);
        $(".getloadweightedit").val("");
        $(".getloadweightedit").val(data);

        $("#getweightadd").css("border", "1px solid skyblue");
        $("#getweightadd").css("box-shadow", "2px 1px 3px 1px skyblue");
        var empty = $(".emptyweightedit").val();
        var load = $(".getloadweightedit").val();
        var netweight = load - empty;
        //alert(netweight);
        if (netweight < 0) {
          var netweightt = empty - load;
        } else {
          var netweightt = load - empty;
        }
        $("#netweightedit").val(netweightt);
        var nettwe = $("#netweightedit").val();
        var unitcon = $("#unitconversionedit").val();
        var finaluni = nettwe / unitcon;

        $("#netqtyedit").val(finaluni.toFixed(2));
        $("#netqtyoriedit").val(finaluni.toFixed(2));
      },
    });

    //
  });
  //

  $(".emptybutedit").click(function () {
    var query = 1;
    $.ajax({
      url: "ajaxpath/search.php",
      method: "POST",
      data: { query: query },
      success: function (data) {
        // alert(data);
        $(".emptyweightedit").val("");
        $(".emptyweightedit").val(data);

        $("#getweightadd").css("border", "1px solid skyblue");
        $("#getweightadd").css("box-shadow", "2px 1px 3px 1px skyblue");
        var empty = $(".emptyweightedit").val();
        var load = $(".getloadweightedit").val();
        var netweight = load - empty;
        //alert(netweight);
        if (netweight < 0) {
          var netweightt = empty - load;
        } else {
          var netweightt = load - empty;
        }
        $("#netweightedit").val(netweightt);
        var nettwe = $("#netweightedit").val();
        var unitcon = $("#unitconversionedit").val();
        var finaluni = nettwe / unitcon;

        $("#netqtyedit").val(finaluni.toFixed(2));
        $("#netqtyoriedit").val(finaluni.toFixed(2));
      },
    });

    //
  });
});

$(document).ready(function () {
  $(".emptyweightedit").keyup(function () {
    var empty = $(".emptyweightedit").val();
    var load = $(".getloadweightedit").val();
    var netweight = load - empty;
    //alert(netweight);
    if (netweight < 0) {
      var netweightt = empty - load;
    } else {
      var netweightt = load - empty;
    }
    $("#netweightedit").val(netweightt);
    var nettwe = $("#netweightedit").val();
    var unitcon = $("#unitconversionedit").val();
    var finaluni = nettwe / unitcon;

    $("#netqtyedit").val(finaluni.toFixed(2));
    $("#netqtyedit").val(finaluni.toFixed(2));
  });
});
$(document).ready(function () {
  $(".getloadweightedit").keyup(function () {
      var empty = $(".emptyweightedit").val();
    var load = $(".getloadweightedit").val();
    var netweight = load - empty;
    //alert(netweight);
    if (netweight < 0) {
      var netweightt = empty - load;
    } else {
      var netweightt = load - empty;
    }
    $("#netweightedit").val(netweightt);
    var nettwe = $("#netweightedit").val();
    var unitcon = $("#unitconversionedit").val();
    var finaluni = nettwe / unitcon;

    $("#netqtyedit").val(finaluni.toFixed(2));
    $("#netqtyori").val(finaluni.toFixed(2));
  });
});
