
<?php include("conn.php");
$page='Daily Sales';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php")?>

<body>
<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>

            <!--Main body Start-->
            <div class="col-sm-12 mt-2">
            
               <!--search section start-->

           
      <hr class="bg-success">

      </center>
                <!--search section end-->
                <!--Orders start-->
       
            <?php 
            $today= date("F j, Y ");
            $sql2="SELECT * FROM currency ";
            $result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
            $row2=mysqli_fetch_array($result2) ;
            $currency=$row2['curency'];

?>

                    <div style="overflow: scroll;height:100vh"  id="collapseOne" class="  col-sm-12  " data-parent="#accordions">
                    <h3 class="text-center">Sales by  Date</h3>
           

                    <table id="example_table" class="table-customer table-striped   w-100 table-bordered">
                        <thead>
                        <tr>
                            <th>Date</th>
                            <th>Bar System</th>
                            <th>Bar Manual</th>
                            <th>Restaurant System</th>
                            <th>Restaurant Manual</th>
                            <th>Total System</th>
                            <th>Total Manual</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php

$sql8="select date , SUM(total)  FROM orders GROUP BY date ORDER BY date ";
$result8 = mysqli_query($conn,$sql8)or die( mysqli_error($conn));
while ($row8=mysqli_fetch_array($result8)) {
 $date=$row8['date'];
$rtotal=$row8['SUM(total)'];


$sql90="select * FROM account ORDER BY date ";
$result90 = mysqli_query($conn,$sql90)or die( mysqli_error($conn));
$row90=mysqli_fetch_array($result90);








$sql91="select * FROM account where date='$date' ";
$result91 = mysqli_query($conn,$sql91)or die( mysqli_error($conn));
$row91=mysqli_fetch_array($result91);
if (!empty($row91)) {
    $saleBar=$row91['bar'];  
    $saleRes=$row91['restaurant'];

     
}
else{
   $saleBar=0;
   $salePool= 0; 
   $saleRes=0 ;

}




$sql6="select SUM(total)  FROM orders where location='Bar' and date='$date' ";
$result6= mysqli_query($conn,$sql6)or die( mysqli_error($conn));
$row6=mysqli_fetch_array($result6);
$amountb=$row6['SUM(total)'];

$sql7="select SUM(total)  FROM orders where location='Restaurant' and date='$date' ";
$result7= mysqli_query($conn,$sql7)or die( mysqli_error($conn));
$row7=mysqli_fetch_array($result7);
$amountr=$row7['SUM(total)'];

$total_earn=$rtotal;
$total_earnM=$saleBar+ $saleRes;
?>
                        <tr>
                            <td><?php echo $date ?></td>
                            <td><?php echo  $currency."".  number_format($amountb,2) ?></td>
                            <td><?php echo  $currency."".  number_format($saleBar,2) ?></td>                        
                            <td><?php echo  $currency."".  number_format($amountr,2) ?></td>
                            <td><?php echo  $currency."".  number_format($saleRes,2) ?></td>
                             <td><?php echo  $currency."".  number_format($total_earn,2) ?></td>
                            <td><?php echo  $currency."".  number_format($total_earnM,2) ?></td>
        
                       
                        
                        </tr>
                        <?php } ?>
                        </tbody>
                        <thead>
                        <th>Date</th>
                            <th>Bar System</th>
                            <th>Bar Manual</th>
                            <th>Restaurant System</th>
                            <th>Restaurant Manual</th>
                            <th>Total System</th>
                            <th>Total Manual</th>
                            
                        </thead>
                    </table>
    

                </div>

                    <!-- <div id="chart_div" style="width: 100%; height: 500px;"></div>--->
        
                </div>

         
              
            </div>
            <!--Main body end-->

            <!--Invoice Section start-->
          
       

           
            <!--Invoice Section end-->

           
        </div>

    </div>
    
    <!--  isotope plugin cdn  -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>
    <!--  isotope plugin cdn  -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>
     <!-- jQuery js-->
 
  <!-- jQuery Datatable js -->
  <script src="https://cdn.datatables.net/2.0.5/js/dataTables.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/dataTables.buttons.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.html5.min.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.print.min.js"></script>
     <script>
         $(document).ready( function () {
        new DataTable('#example_table', {
            columnDefs: [ { type: 'date', 'targets': [0] } ],
            order: [[ 0, 'desc' ]],
            autoFill: true,
            pageLength : 20,
    lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'Todos']],
    layout: {
        topStart: {
            buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
        }
    }
});
       } );
       </script>
    <!--google graph-->
   



 

</body>

</html>