$(document).ready(function () {
    var reportValue = [];
    $("#calender").click(function () {
      $(".spindis").show();
      var fromd = $("#input_from").val();
      var tod = $("#input_to").val();
      var customer = $("#customer").val();
      var product = $("#product").val();
      var timeFrom = $("#timefrom").val();
      var timeTo = $("#timeto").val();
      var tktFrom = $("#tktfrom").val();
        var vehicle = $("#vehicle").val();
        var modeTrans = $("#modeTrans").val();
        $.ajax({
          type: "POST",
          url: "ajaxreport1/fetch_loadout_report_deleted.php",
          dataType:"json",
          data: { customer: customer, tod: tod, fromd: fromd, product: product,vehicle:vehicle,timefrom:timeFrom,timeto:timeTo,ticket:tktFrom,modetrans:modeTrans },
          success: function (data) {
              data.map((list)=>{
                   reportValue.push(list);
              });
             let limitedReport= data.splice(0,5000);
            console.log(data);
           var tbodyValue ="";
           limitedReport.map((data,index)=>{
                tbodyValue +=`<tr><td>${index+1}</td><td>${data.ticket}</td><td>${data.tripno}</td><td>${data.customername}</td><td>${data.productname}</td><td>${data.vehicleno}</td><td>${data.chakka}</td><td>${data.delivery}</td><td>${data.entrydate}</td><td>${data.entrytime}</td><td>${data.emptyweight}</td><td>${data.exitdate}</td><td>${data.exittime}</td><td>${data.loadweight}</td><td>${data.netweight}</td><td>${data.capacity}</td><td>${data.netqty}</td><td>${data.adjedqty}</td><td>${data.price}</td><td>${data.priceori}</td><td>${data.totalamount}</td><td>${data.mode}</td><td>${data.adjustment}</td><td>${data.adjkg}</td><td>${data.editby}</td><td>${data.remark}</td><td><a href="salesbillall_deleted.php?print=${
              data.sid
            } && table=second_transaction" target="_blank"><i class="fas fa-print"></i></a></td></tr>`;
            });
            $("#tbodyReport").append(tbodyValue);
            $(".spindiv").hide();
             $("#input_from").val("");
            $("#input_to").val("");
           $("#customer").val(null).trigger("change");
            $("#product").val(null).trigger("change");
            $("#timefrom").val("");
           $("#timeto").val("");
           $("#tktfrom").val(null).trigger("change");
           $("#vehicle").val("");
          },
        });
        $("#modaldis").click();
    });
    $("#excel").click(function(){
        JSONToCSVConvertor(reportValue, `Loadout-Report`, true);
       });
  });
  