<script src="javascript/jquery.table2excel.js" type="text/javascript"></script>
<script src="javascript/jspdf.min.js"></script>
    <script src="javascript/jspdf.plugin.autotable.min.js"></script>
    <script src="javascript/tableHTMLExport.js"></script>
<button class="btn btn-warning" id="pdf" onclick="printDiv()" style="float:right;margin-right:20px;">Print</button>   <button class="btn btn-primary" id="ex" style="float:right;margin-right:20px;">Excel</button><br><br>
<script type="text/javascript">
$("#ex").click(function(){
    var a = $("#todate").val();
      var b = $("#fromdate").val();
  $("#fullreport").table2excel({
    
            exclude:".noExl",
    name:"Emptyinreport",
    filename:"Emptyinreport ",//do not include extension
    fileext:".xls" // file extension
  });
});

</script>
<script>function printDiv() 
{

  var divToPrint=document.getElementById('fulltable');

  var newWin=window.open('','Print-Window');

  newWin.document.open();

  newWin.document.write('<html><head><link rel="stylesheet" href="tablestyle/tablereport.css"></head><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
  newWin.document.close();
}</script>
<script type="text/javascript">
$("#pf").on("click", function () {
        $("#fullreport").tableHTMLExport({ type: "pdf", filename: "salesreport.pdf",
        
        });
      });
</script>
<?php 
include "../config.php";
error_reporting(0);
//$product = $_POST['product'];
$fromd = $_POST['fromd'];
$tod = $_POST['tod'];
    $datefr = date_create($fromd);
    $datefrom = date_format($datefr,"d/m/Y");
    $datet = date_create($tod);
    $dateto = date_format($datet,"d/m/Y");
//echo $customer;
// echo $fromd;
// echo $tod;
echo 

'<div id="fulltable">

<table class="table table-striped">

   <thead style="background-color:#101820FF;color:#FEE715FF">
   <tr><th colspan="19" style="text-align:center;">Empty-In Report Between '.$datefrom.' And '.$dateto.'</th></tr>
   <th>S.no</th>
<th>Date</th>

<th>Tkt</th>
<th>Customer</th>
<th>VehicleNo</th>
<th>Vehiclename</th>
<th>Material</th>
<th>EmptyWeight</th>

   </thead>
   
   <tbody style="background-color:#FEE715FF;color:#101820FF;font-size:16px">';
   
$rep=mysqli_query($connect,"select * from first_transaction where date
between '$fromd' and '$tod' && status !='deleted'");
  
 

while($repshow = mysqli_fetch_array($rep))

{
    
    $datechk=$repshow['date'];
    $dateval = date_create($datechk);
    $date = date_format($dateval,"d/m/Y");
    $sno+=1; 
    $product = $repshow['product'];
$pro=mysqli_query($connect,"select * from productdetail where status !='deleted' && productcode = '$product'");
while($reppro = mysqli_fetch_array($pro))
{
    
    $customer = $repshow['customer'];
$cus=mysqli_query($connect,"select * from customerdetails where status !='deleted' && code = '$customer'");
while($repcus = mysqli_fetch_array($cus))
{
    

if(mysqli_num_rows($rep) > 0 )
{
   echo '
   
   <tr>
   <td>'.$sno.'</td>
   <td>'.$date.'</td>
   <td>'.$repshow['ticket'].'</td>
   <td>'.$repcus['name'].'</td>
   <td>'.$repshow['vehicleno'].'</td>
   <td>'.$repshow['vehiclename'].'</td>
   <td>'.$reppro['productname'].'</td>
   <td>'.$repshow['weight'].'</td>
  
   
   
   

   </tr>
  ';
  
}

else 
{
    echo' <div class="spinner-border text-primary" style="margin-left:45%;margin-top:20%;margin-bottom:20%;padding:3%"></div>';
}
}
}

}
   echo' 
   </tbody>
   
   </table>
   </div>
   .';

?>
