<link rel="stylesheet" href="tablestyle/tablereportdisplay.css">
<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:"Materialreport",
    filename:"Materialreport ",//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'];
// echo $fromd;
// echo $tod;
    $datefr = date_create($fromd);
    $datefrom = date_format($datefr,"d/m/Y");
    $datet = date_create($tod);
    $dateto = date_format($datet,"d/m/Y");
    $proedit=mysqli_query($connect,"select * from partydetail order by id desc");
while($proshowedi = mysqli_fetch_array($proedit))
{
  $party=  $proshowedi['party'];
}
//echo $customer;
// echo $fromd;
// echo $tod;
echo 

'<div id="fulltable">

<table class="table table-striped">

   <thead style="">
   <tr><th colspan="19" style="text-align:center;">Material Report-GST Between '.$datefrom.' And '.$dateto.'</th></tr>
   <tr><th colspan="19" style="text-align:center;">'.$party.'</th></tr>
   <tr>
   <th>S.no</th>
   ';
   $repp="select *,sum(netqty) from second_transaction  where date
   between '$fromd' and '$tod'&& second_transaction.status !='deleted'  group by product 
   ";
   
   $rep =mysqli_query($connect,$repp);
   $pricefull=0;
   while($repshow = mysqli_fetch_array($rep))
   
   {
   echo'
   
<th>'.$repshow['productname'].'</th>
';
}




   echo'

   <th>Total</th>
   </tr>
   </thead>
   <tbody style="">
   
   <tr>
   <td>
    1
   </td>';
   $repprice="select *,sum(netqty)as price from second_transaction  where date
   between '$fromd' and '$tod' && second_transaction.status !='deleted'  group by product 
   ";
   //echo $repprice;
   $reppri =mysqli_query($connect,$repprice);
   while($repshow = mysqli_fetch_array($reppri))
   
   {
echo'<td>'.number_format($repshow['price'],2,'.','').'</td>';
$pricefull += number_format($repshow['price'],2,'.','');
   }
   echo'
   <td>'.$pricefull.'</td>
   </tr>
   </tbody>
   
   </table>';
?>
