<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{


?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

   <!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        
        <!-- Header-->

        

        <div class="content mt-3">
            <div class="animated fadeIn">
                <div class="row">

                    <div class="col-md-14">
                        <div class="card">
						<div class="page-title">
						<center> <img src="logo1.jpg" align="middle" /></center></strong>
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                            <div class="card-header">
							
                                <strong class="card-title"><center>Daily Fee Collection Details Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$from_date=$_POST["from_date"];
$to_date=$_POST["to_date"];

$class_name=$_POST["class_name"];

$sql1 = "SELECT * FROM addclass where user_id = '$userid'";
$result1=$conn->query($sql1);
$row1 = $result1->fetch_assoc();
$feedisc1=$row1['feedisc1'] ;
$feedisc2=$row1['feedisc2'] ;
$feedisc3=$row1['feedisc3'] ;
$feedisc4=$row1['feedisc4'] ;
$feedisc5=$row1['feedisc5'] ;
$feedisc6=$row1['feedisc6'] ;
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";
									   echo "<th bgcolor=#0099FF> Date </th>";
echo "<th bgcolor=#0099FF> Roll# </th>";
echo "<th bgcolor=#0099FF> Studnet Name </th>";
echo "<th bgcolor=#0099FF> Father Name </th>";
echo "<th bgcolor=#0099FF> Class Name </th>";
echo "<th bgcolor=#0099FF> Month Name </th>";
echo "<th bgcolor=#0099FF> Fee </th>";
echo "<th bgcolor=#0099FF> $feedisc1</th>";
echo "<th bgcolor=#0099FF> $feedisc2</th>";
echo "<th bgcolor=#0099FF> $feedisc3</th>";
echo "<th bgcolor=#0099FF> $feedisc4</th>";
echo "<th bgcolor=#0099FF> $feedisc5</th>";
echo "<th bgcolor=#0099FF> $feedisc6</th>";
echo "<th bgcolor=#0099FF> App No </th>";
echo "<th bgcolor=#0099FF> Fine </th>";
echo "<th bgcolor=#0099FF> Dis Fee </th>";
echo "<th bgcolor=#0099FF> Dis Fee1 </th>";
echo "<th bgcolor=#0099FF> Dis Fee2 </th>";
echo "<th bgcolor=#0099FF> Dis Fee3 </th>";
echo "<th bgcolor=#0099FF> Dis Fee4 </th>";
echo "<th bgcolor=#0099FF> Dis Fee5 </th>";
echo "<th bgcolor=#0099FF> Dis Fee6 </th>";
echo "<th bgcolor=#0099FF> Ref </th>";
echo "<th bgcolor=#0099FF> User </th>";

echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM rec_fee where  rec_date between '$from_date' and '$to_date' and class_name='$class_name' and user_id='$userid' order by class_name,cls_sec,adm_no";
$result=$conn->query($sql);
                                       while($row = $result->fetch_assoc())
 
  {
  $id = $row['id'];	
   echo "<tr>";
   echo "<td>" .$row['rec_date'] . "</td>";

echo "<td>" .$row['portal_id'] . "</td>";

  echo "<td>" .$row['std_name'] .  "</td>";
 echo "<td>" .$row['fname'] . "</td>";
 echo "<td>" .$row['class_name'] . ":" .$row['cls_sec'] .  "</td>";
 echo "<td>" .$row['month_period'] . "</td>";
   echo "<td>" .$row['feerec'] .  "</td>";
   echo "<td>" .$row['fee1rec'] .  "</td>";
   echo "<td>" .$row['fee2rec'] .  "</td>";
   echo "<td>" .$row['fee3rec'] .  "</td>";
   echo "<td>" .$row['fee4rec'] .  "</td>";
   echo "<td>" .$row['fee5rec'] .  "</td>";
   echo "<td>" .$row['fee6rec'] .  "</td>";
    echo "<td>" .$row['appno'] .  "</td>";
	 echo "<td>" .$row['fine'] .  "</td>";
	  echo "<td>" .$row['disfee'] .  "</td>";
	 echo "<td>" .$row['disfee1'] .  "</td>";
	   echo "<td>" .$row['disfee2'] .  "</td>";
	   echo "<td>" .$row['disfee3'] .  "</td>";
	   echo "<td>" .$row['disfee4'] .  "</td>";
	   echo "<td>" .$row['disfee5'] .  "</td>";
	   echo "<td>" .$row['disfee6'] .  "</td>";	
	   echo "<td>" .$row['ref'] .  "</td>";
	  echo "<td>" .$row['username'] .  "</td>";
    echo"<th> <a href ='Print_Receipt.php?id=$id'>"?><button type="button" class="btn btn-primary">  Print Receipt </button><?php "</a>";
  echo "</tr>";

$trecord=$trecord + 1;
$tfeerec=$tfeerec + $row['feerec'];
$tfee1rec=$tfee1rec + $row['fee1rec'];
$tfee2rec=$tfee2rec + $row['fee2rec'];
$tfee3rec=$tfee3rec + $row['fee3rec'];
$tfee4rec=$tfee4rec + $row['fee4rec'];
$tfee5rec=$tfee5rec + $row['fee5rec'];
$tfee6rec=$tfee6rec + $row['fee6rec'];
$fine=$fine + $row['fine'];
$disfee=$disfee + $row['disfee'];
$disfund=$disfund + $row['disfund'];
  }
  $totalbal = $tfeerec + $tfee1rec + $tfee2rec + $tfee3rec + $tfee4rec + $tfee5rec + $tfee6rec; 
   echo "<tr>";
	echo "<td colspan=5 align=right><b>" ."Total Records::". $trecord ."</b></td>";
	
	  
		echo "<td><b>" .$tfeerec . "</b></td>";
		
		echo "<td><b>" .$tfee1rec . "</b></td>";
		
		echo "<td><b>" .$tfee2rec . "</b></td>";
		
		echo "<td><b>" .$tfee3rec . "</b></td>";
		
		echo "<td><b>" .$tfee4rec . "</b></td>";
		
		echo "<td><b>" .$tfee5rec . "</b></td>";
		
		echo "<td><b>" .$tfee6rec . "</b></td>";
		echo "<td><b>" ."-" . "</b></td>";
		echo "<td><b>" .$fine . "</b></td>";
		echo "<td><b>" .$disfee . "</b></td>";
			echo "<td><b>" .$disfund . "</b></td>";
	  echo "</tr>";
	   echo "<tr>";
	echo "<td colspan=8 align=right><b> Net Total </b></td>";
	
	  
		echo "<td><b>" .$totalbal . "</b></td>";
		
		
	  echo "</tr>";
	  $sql = "SELECT `month_period`, SUM(`month_period`) AS `feerec` FROM `rec_fee` GROUP BY `month_period`";
$result=$conn->query($sql);
    
while($row = $result->fetch_assoc()) {
 $mname=$row['month_period'];
// $sql101 = "Insert into monthname (id,mname) values (null,'$mname')";
//$conn->query($sql101);
 $tfee2=0;
 
$trecord2=0;
 $sql2 = "SELECT * FROM rec_fee where month_period='$mname' and  user_id='$userid'";
$result2=$conn->query($sql2);
while($row2 = $result2->fetch_assoc())
 
  {
  $tfee2=$tfee2 + $row2['feerec'];
 
$trecord2=$trecord2 + 1;
  }
  
    if ($tfee2 > 0)
  {
   echo "<tr>";
	echo "<td colspan=8 align=right><b>$mname </b></td>";
		echo "<td><b>" .$tfee2 . "</b></td>";
	  echo "</tr>";
	  }
}
	  
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


                </div>
            </div><!-- .animated -->
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>