$(document).ready(function(){
    $("#calender").click(function(){       
       $(".spindis").show();
        var fromd = $("#input_from").val();
        var tod = $("#input_to").val();
        var customer = $("#customerAdd").val();    
        console.log(customer);         
        $.ajax({
         type: "POST",
         dataType: "json",
         url: "ajaxreport1/fetch_customer_statement.php",
         data: { customer: customer,fromdate:fromd,todate:tod },
                success:function(data){
                   console.log(data);
                   let tbodyDisplay="";
                   let miniTbodyDisplay="";
                   data.statement.map((list,index)=>{
                     tbodyDisplay+=`<tr><td>${index+1}</td><td>${list.date}</td><td>${list.tripno}</td><td>${list.customercode}</td><td>${list.customername}</td><td>${list.salescode}</td><td>${list.process}</td><td>${list.product}</td><td>${list.quantity}</td><td>${list.salesamount}</td><td>${list.collectionby}</td><td>${list.cash}</td><td>${list.bank}</td><td>${list.collection}</td><td>${list.financialyear}</td><td>${list.remark}</td></tr>`;
                   });
                      miniTbodyDisplay = `<tr><th>Opening Balance</th><td>${data.ministatement.opening}</td></tr><tr><th>Sales Amount</th><td>${data.ministatement.sales}</td></tr><tr><th>collection</th><td>${data.ministatement.collection}</td></tr><tr><th>Pending Balance</th><td>${data.ministatement.pending}</td></tr>`;
                console.log(tbodyDisplay);
           $("#tbodyValue").append(tbodyDisplay);  
           $("#openingBalanceTable").append(miniTbodyDisplay);
           $(".spintext").hide();
           
            },error:function(error){
                   console.log("error"+error.responseText);
            }
               });  
               $("#modaldis").click();
                }); 
                $("#excel").click(function(){
                   $("#fullreport").table2excel({
                   exclude:".noExl",
                  name:"Customer Statement",
                  filename:"Customer Statement ",//do not include extension
                  fileext:".xls" // file extension
                });
              });
               });





