<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php


$from;
$to;

if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {
        $from=date("Y-m-d",strtotime($_REQUEST['from']));  

      }else {
        $from=date("Y-m-01");  
      }
     
      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {
        $to=date("Y-m-d",strtotime($_REQUEST['to']));
      }else {
        $to=date("Y-m-t");  
      } 



        $branch=$_SESSION['branch']; 
   $sql = "SELECT * FROM eduportal_canteen_salebills_config as cnfg ";

   $sql .= "where cnfg.branch_id='$branch' and cnfg.invoice_date BETWEEN '" .$from. "' AND '" .$to. "' ";  

   $sql .= " Order by bill_id desc";          
      
    $salesbills = $m->query($sql);

// print_r($sql);


     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Struck Of Students | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
<style>

.thStyle{background-color:lightgray;text-align:center;}

</style>   
  </head>
 

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="" style="background-color: white;">
           
<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
      
      
      <div class="clearfix"></div>
    </div>
   

     
<table id="excelexpo" class="table table-striped table-bordered" style="width:100%">
  
          <thead>
             <tr>

              
                <th width="1%">S.No</th>
                <th width="15%">Customer Name</th>
                <th width="10%">Month</th>
                <th width="8%">Bill No</th>
                <th width="8%">Bill Date</th>                        
                <th width="8%">Net Amount</th>  
                
            </tr>
        </thead>
        <tbody>

                       
<?php  $count1=1;
$date= date("Y-m-d");

foreach($salesbills as $salesbill){

  $m->where("student_id", $salesbill['student_id']);
  $studentName=$m->get("edu_student_details");

  $m->where("Month_Id", $salesbill['month_id']);
  $months=$m->get("eduportal_month_config");

  $m->where("revenue_id", $revenue['revenue_id']);
  $PaidBy=$m->get("eduportal_revenue_details");

  
$totalAmount+=$salesbill['total_amount'];
//echo $count1++;
?>
<tr>
<td style="text-align:center;"><?php echo $count1++;?></td>
<td> <?php  if ($studentName[0]['first_name']!=NULL) {
  echo $studentName[0]['first_name'];
} else {
  echo "Other";
} ?></td>
<td><?php echo $months[0]['Month_Name'];?></td>
<td><?php echo $salesbill['bill_id'];?></td>
<td><?php echo date("d-M-Y",strtotime($salesbill['invoice_date']));?></td>
<td><?php echo $salesbill['total_amount'];?></td>
</tr>
<?php } ?>

        </tbody>
        
    </table>








  </div>
  <div class="clearfix"></div>
</section>            
    

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  

    
  <?php include('RootMe/js_linksscript.php');?>
  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
   
   <script src="js/FileSaver.min.js" type="text/javascript"></script>
  <script src="js/tableexport.min.js" type="text/javascript"></script>

  <script type="text/javascript">
    $('#excelexpo').tableExport();
  </script>
  </body>
</html>
