<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php");
  
$branch=$_SESSION['branch']; 
   


$period = new DatePeriod(
 new DateTime($_GET["from"]),
 new DateInterval('P1D'),
 new DateTime($_GET["to"])
);


 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>User Fee Collection | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
  
<script type="text/javascript">

function getSubCat(id){
  //alert(id);

    if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {

        document.getElementById("subcatgory").innerHTML=xmlhttp.responseText;
       //alert(xmlhttp.responseText);

      }

    }
    xmlhttp.open("GET","get_exp_subcategory.php?id="+id,true);
    xmlhttp.send();
  }
</script> 
  </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="all_fee_collection.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">Session</label>
                    <select name="session" class="form-control"  style="height:40px;">

                              
                        <?php

                       $match;
                        if(!isset($_REQUEST['session'])){
                          $match=$_SESSION['current_session'];
                        }else { $match=$_REQUEST['session']; }
                       
                                 
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></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 $_GET['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 $_GET['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['user_id'])){
?>

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

<?php 
}
?> 

            </div>
           </form>  

              

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



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

        <div class="col-md-12">

          
           <div id="check_std_msg" style="color:white;font-size:18px;" class="alert alert-danger alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning!</strong> Please Select From & To date And Click Search Button!!!
            </div>
    

        </div>

  <?php   }?>


     <div class=" col-md-12 col-sm-12 col-xs-12">
                <h3>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%">Date</th>
                          <th width="15%">Received</th>
                          <th width="15%">Received Again</th>
                          <th width="15%">Total</th>                         
                                                  

                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;




foreach ($period as $Dates) { 

	$Dates1=$Dates->format('d-m-Y');
	$sessionidd=$_REQUEST['session'];
	//echo $Dates1;

	$sql = "SELECT SUM(collected_amount) as received, SUM(collected_fine) as total_fine FROM eduportal_monthly_challan WHERE branch_id='$branch' and session_id='$sessionidd' and paying_date='$Dates1'";
	$amount = $m->query($sql);

	$sqll = "SELECT SUM(paid_again_amount) as againreceived FROM eduportal_monthly_challan WHERE branch_id='$branch' and session_id='$sessionidd' and paying_date='$Dates1'";
	$amountAgain = $m->query($sqll);
	
$totalReceived+=$amount[0]['received']+$amount[0]['total_fine'];
$totalagainReceived+=$amountAgain[0]['againreceived'];
$total+=$amount[0]['received']+$amount[0]['total_fine']+$amountAgain[0]['againreceived'];

?>
                        <tr>
                          <td style="text-align:center;"><?php echo $count; $count++;?></td>
                         
                         
                          <td><?php echo $Dates->format('d-M-Y');?></td>
                          <td><?php echo $amount[0]['received']+$amount[0]['total_fine'];?></td>
                          <td><?php echo $amountAgain[0]['againreceived'];?></td> 
                          <td><?php echo $amount[0]['received']+$amount[0]['total_fine']+$amountAgain[0]['againreceived'];?></td>  
                         

                        </tr>
<?php } ?>

<tr style="background-color: lightgray; font-weight: bold;">
  <td colspan="2" style="text-align: center;">Total</td>
  <td><?php echo $totalReceived;?></td>
  <td><?php echo $totalagainReceived;?></td>
  <td><?php echo $total;?></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>