$(document).ready(function () {
  $("#calender").click(function () {
    $(".spindis").show();
    var fromd = $("#input_from").val();
    var tod = $("#input_to").val();
    var customer = $("#customer").val();
    var product = $("#product").val();
    var customertype = $("#customertype").val();
    var vehicle = $("#vehicle").val();
    //alert(product, customer, customertype, vehicle);
    if (
      customer == "0" &&
      product == "01" &&
      customertype == "0" &&
      vehicle == "0"
    ) {
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportdate.php",
        data: { customer: customer, tod: tod, fromd: fromd, product: product },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
    // customerajax
    if (
      customer != "0" &&
      product == "01" &&
      customertype == "0" &&
      vehicle == "0"
    ) {
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportcustomerdate.php",
        data: { customer: customer, tod: tod, fromd: fromd, product: product },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
    // customerajax
    // productajax
    if (
      customer == "0" &&
      product != "01" &&
      customertype == "0" &&
      vehicle == "0"
    ) {
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportproductdate.php",
        data: { customer: customer, tod: tod, fromd: fromd, product: product },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
    // productajax
    //$("#customer").focus();
    // customerproajax
    if (
      customer != "0" &&
      product != "01" &&
      customertype == "0" &&
      vehicle == "0"
    ) {
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportproductcusdate.php",
        data: { customer: customer, tod: tod, fromd: fromd, product: product },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
    // customerproajax
    // customertypeajax
    if (
      customer == "0" &&
      product == "01" &&
      customertype != "0" &&
      vehicle == "0"
    ) {
      //alert('hai');``
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportcustypedate.php",
        data: {
          customer: customer,
          tod: tod,
          fromd: fromd,
          product: product,
          customertype: customertype,
        },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
    // customertypeajax
    // vehicleajax
    if (
      customer == "0" &&
      product == "01" &&
      customertype == "0" &&
      vehicle != "0"
    ) {
      //alert('hai');``
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportvehicledate.php",
        data: {
          customer: customer,
          tod: tod,
          fromd: fromd,
          product: product,
          customertype: customertype,
          vehicle: vehicle,
        },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
    // vehicleajax
    if (
      customer != "0" &&
      product == "01" &&
      customertype == "0" &&
      vehicle != "0"
    ) {
      $.ajax({
        type: "POST",
        url: "ajaxpathreport/loadreportcusveh.php",
        data: { customer: customer, tod: tod, fromd: fromd, vehicle: vehicle },
        success: function (a) {
          //  alert(a);
          // $("#showquantity-with-color").css("display","block");
          $("#fullreport").html(a);
          //alert(a);
          $("#input_from").val("");
          $("#input_to").val("");
          $("#customer").val(null).trigger("change");
          $("#product").val(null).trigger("change");
        },
      });
      //alert('hai');
      $("#modaldis").click();
    }
  });
});
