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

  $year;

  $branch=$_SESSION['branch'];

  $sql = "SELECT * FROM  eduportal_school_billing  WHERE branch_id='$branch' ";

  if(isset($_REQUEST['year'])){

  $sql .= " AND year ='" . $_REQUEST['year']. "' ";
   }

   $sql .= " order by bill_id desc";


   $branchbills = $m->query($sql);



   if(isset($_REQUEST['year'])){

    $year=$_REQUEST['year'];

   } else {

    $year=date("Y");
   }
  

 ?>

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

  </head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
 <!-- jQuery -->
  <script src="js/ajax_functions.js"></script> 

  <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">

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
          Monthly Invoice List
                  <br><br> 
                  
          <div class="row" style="background-color: white;">
           

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

            <div class="row">
              <div class="col-md-12">
                <div class="x_panel">
                  
                  <div class="x_content">

            <form class="form-style-7" action="monthly_invoices.php" method="Get">
              
              <div class="col-md-3 col-sm-12 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Year</label>
                    <select name="year" class="form-control"  style="height:40px;">
                                                      
                        <?php
                       
                       for ($i=2020; $i < 2050 ; $i++) { ?>
                          
                          <option <?php if($year==$i){echo 'selected';}?> value="<?php echo $i; ?>"><?php echo $i; ?></option>

                       <?php } ?>

                           



                    </select>
                </div>
              </div>


              <div class="col-md-4 " style="padding:2px;">
    
        
                <div class="form-group ">
                   
                <button id="month"  type="submit" class="btn btn-primary" style="margin-top: 34px;">Search</button>
                
                </div>

        
              </div>
             
          </form>
    <section class="content invoice">
     <h3>Monthly Invoice List View</h3>
        <!-- Table row -->
        <div class="row">
          <div class="col-xs-12 table">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>S.No</th>
                  <th>Month</th>
                  <th>Total Amount</th>
                  <th>Paid Status</th>
                  <th>Paid Amount</th>
                  <th>Paid Date</th>
                  <th>Print</th>
                </tr>
 <?php 
$count=1;
      foreach($branchbills as $branchbill)
      { 

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

      $sessions_id=$branchbill['session_id'];
        
      ?>

          </thead>
          <tbody>
            <tr>
              <td><?php echo $count++;?></td>
              <td><?php echo $month[0]['Month_Name']; ?></td>
              <td><?php echo $branchbill['net_total'];?></td>
              <td>
                                  
               <?php if($branchbill['paid_status']==0 ){ ?>    

              <a style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-danger">

                  Not Paid
                  
              </a> 

                 <?php } else { ?>    
                
               <a style="padding: 0px 5px; font-size:14px;" class="btn btn-success">
                    Paid <i class="fa fa-check" aria-hidden="true"></i>

                    </a> 


                 <?php } ?> 

      </td>
      <td><?php echo $branchbill['paid_amount'];?></td>
      <td><?php if ($branchbill['paid_date']!=NULL) {
        echo date("d-M-Y",strtotime($branchbill['paid_date']));} ?></td>


      <td> 

        <a style="padding: 0px 5px; font-size:14px;"

        href="branch_invoices.php?<?php echo session_id(); ?>&branch=<?php echo $branch; ?>&month=<?php echo $branchbill['month_id'];?>&year=<?php echo $branchbill['year'];?>" class="btn btn-primary">
      Print</a>

      </td>

    </tr>
        <?php } ?>
                                                        
                             
                            </tbody>
                          </table>
                        </div>
                        <!-- /.col -->
                      </div>
                                          
                    </section>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

          

          </div>
        </div>

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

  
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
