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

     $branch=$_SESSION['branch'];

  $sql = "SELECT * FROM  eduportal_monthly_challan_details  WHERE branch_id='$branch' ";
 
    if (isset($_REQUEST['fee_heads'])) {      
    
    if($_REQUEST['fee_heads']=="All"){
      $sql;
    } else {
    $sql .= " AND feetype_id = '" .$_REQUEST['fee_heads']. "' ";

    }

    }
   
    
      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");  
      } 
      
    $sql .= " AND date BETWEEN '" .$from. "' AND '" .$to. "'";

     // echo $sql;

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

   


 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Datewise Fee Collection | 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>
<!-- <script>
$(document).ready(function(){
  
    $("#div1").fadeOut();
    $("#div2").fadeOut("slow");
    $("#div3").fadeOut(3000);
 
});
</script> -->
  <style>
#snackbar {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #1E90FF;
  color: #fff;
  text-align: right;
  border-radius: 2px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  left: 80%;
  bottom: 30px;
  font-size: 17px;
}

#snackbar.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
  from {bottom: 0; opacity: 0;} 
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
  from {bottom: 30px; opacity: 1;} 
  to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}
</style>
  <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="row" style="background-color: white;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
   <form action="fee_heads_reports.php">
   <div class="col-md-12">
            
              <div class="col-md-3 col-sm-12 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Fee Heads</label>
                    <select name="fee_heads" class="form-control">
                       <option value="All">All</option>                              
                        <?php
                                 
                        $WorkAssignList = $m->get("eduportal_fee_types");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>                         
                           <option <?php if($_REQUEST['fee_heads']==$WorkAssignListVal['feetype_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['feetype_id']; ?>"><?php echo $WorkAssignListVal['feetype_name']; ?></option>


                                <?php
                        } ?>

                    </select>
                </div>
              </div>
              
              
              <div class="col-md-3" style="padding:8px;">

                       <div class="form-group ">

                          <label class="required"> From Date</label>
                              <input name="from"  id="from" value="<?php echo $from;?>" type="date" class="form-control"  >
                       
                          </div>
              </div>

              <div class="col-md-3" style="padding:8px;">

                       <div class="form-group ">

                          <label class="required"> To Date</label>
                              <input name="to" id="to" value="<?php echo $to;?>" type="date" class="form-control"  >
                       
                          </div>
                  </div> 
              
           <div class="col-md-1" style="padding:8px;margin-top: 22px;">
                <div class="form-group ">
                
                <button type="submit" class="btn btn-primary">Search</button>
                </div>
              </div>

 <?php 
 if( isset($_REQUEST['from'])){
?>

 <!--  <a target="_blank" class="btn btn-success fa fa-print" style="height: 34px;padding: 9px;margin-top: 30px;" title="Print Fee Report" href="print_datewise_total_fee_collection.php?<?php echo session_id().session_id().session_id(); ?>&session=<?php echo $_GET['session'];?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>">
   Print Report
  </a> -->

<?php 
}
?> 

            </div>
           </form>  

              

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



     <div class=" col-md-12 col-sm-12 col-xs-12">
                <h3>Head Wise Fee Collection List<small></small></h3>
     </div>


<table id="datatable" class="table table-striped table-bordered"style="background-color: white;">
                      <thead>
                        <tr>
                          <th width="1%">S.No</th>                          
                          <th width="15%">Fee Head Name</th>
                          <th width="15%">Date</th>
                          <th width="15%">Total </th>
                          <th width="15%">Received Amount</th>
                          <th width="15%">Remaining</th>                         
                                                  

                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;



foreach ($WorkAssignListings as $FeeHeadData) { 

$m->where("feetype_id", $FeeHeadData['feetype_id']);
$HeadsName = $m->get("eduportal_fee_types");


$totalAmt+=$FeeHeadData['fee_amount'];
$totalrecevied+=$FeeHeadData['fee_received'];
$totalRem+=$FeeHeadData['remaning'];
?>
                        <tr>
                          <td style="text-align:center;"><?php echo $count; $count++;?></td>
                          <td><?php echo $HeadsName[0]['feetype_name'];?></td>
                          <td><?php echo date("d-M-Y",strtotime($FeeHeadData['date']));?></td>
                          <td><?php echo $FeeHeadData['fee_amount'];?></td>
                          <td><?php echo $FeeHeadData['fee_received'];?></td> 
                          <td><?php echo $FeeHeadData['remaning'];?></td>  
                         

                        </tr>
<?php } ?>

<tr style="background-color: lightgray; font-weight: bold;">
  <td colspan="3" style="text-align: center;">Total</td>
  <td><?php echo $totalAmt;?></td>
  <td><?php echo $totalrecevied;?></td>
  <td><?php echo $totalRem;?></td>
</tr>
                      

                      </tbody>
                    </table>
       
          </div>
        </div>

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

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

   <!-- searchable dropdown -->
    
    <link href="autosearch_select/select2.css" rel="stylesheet">
    <link href="autosearch_select/select2-default.css" rel="stylesheet">
    <script src="autosearch_select/select2.min.js"></script>
    
    <script>
    $(function() {
    $('.chosen-select').select2( { width:'100%', maximumSelectionSize: 1 } );
    $(document).ready(function() {
    $(".chosen-multi-select").select2( { width:'100%', } ); }); }); function slideout(){ setTimeout(function(){
    $(".alert-success").fadeOut("slow", function () { });
    $(".alert-danger").fadeOut("slow", function () { }); }, 4000);}
    </script>
  </body>
</html>
<script>
function toastFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>