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

$month=$_POST["month"];
?>
<!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">
						 <strong class="card-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>Monthly Fee Breakup Details Report</center> </strong> <strong class="card-title"><center><? echo $month; ?></center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];

$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><center> Adm No </th>";
echo "<th bgcolor=#0099FF><center> Roll No </th>";
echo "<th bgcolor=#0099FF><center> Student Name </th>";
echo "<th bgcolor=#0099FF><center> Father Name </th>";

echo "<th bgcolor=#0099FF><center> Class Name </th>";
echo "<th bgcolor=#0099FF><center>Section</th>";
echo "<th bgcolor=#0099FF>Cell No 1</th>";
echo "<th bgcolor=#0099FF>Cell No 2</th>";
echo "<th bgcolor=#0099FF>Cell No 3</th>";

echo "<th bgcolor=#0099FF colspan=3><center>Tution Fee </th>";
echo "<th bgcolor=#0099FF colspan=3><center> $feedisc1</th>";
echo "<th bgcolor=#0099FF colspan=3><center> $feedisc2</th>";
echo "<th bgcolor=#0099FF colspan=3><center> $feedisc3</th>";
echo "<th bgcolor=#0099FF colspan=3><center> $feedisc4</th>";
echo "<th bgcolor=#0099FF colspan=3><center> $feedisc5</th>";
echo "<th bgcolor=#0099FF colspan=3><center> $feedisc6</th>";

echo "</tr>";
echo "<tr>";
echo "<th bgcolor=#0099FF colspan=7>  </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "<th bgcolor=#0099FF><center> Fee Amount </th>";
echo "<th bgcolor=#0099FF><center> Rec Amount </th>";
echo "<th bgcolor=#0099FF><center> Bal Amount </th>";
echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
$sql1 = "select * from admission where status='Active' and user_id='$userid' order by adm_no";
$result1=$conn->query($sql1);
while($ppp = $result1->fetch_assoc())
{

  $ven_name=$ppp["std_name"];
  $adm_no=$ppp["adm_no"];
  $std_rollno=$ppp["std_rollno"];
  $class_name=$ppp["class_name"];
     $cell_2=$ppp["cell_2"]; 
	   $cell_3=$ppp["cell_3"]; 
  $cls_sec=$ppp["cls_sec"];
  $father_name=$ppp["fname"]; 
   $cell_1=$ppp["cell_1"]; 
   $status=$ppp["status"]; 

  $netqty =0;
$qtysale=0;
$qtypur=0;
 $netqty1 =0;
$qtysale1=0;
$qtypur1=0;
 $netqty2 =0;
$qtysale2=0;
$qtypur2=0;
 $netqty3 =0;
$qtysale3=0;
$qtypur3=0;
 $netqty4 =0;
$qtysale4=0;
$qtypur4=0;
 $netqty5 =0;
$qtysale5=0;
$qtypur5=0;
 $netqty6 =0;
$qtysale6=0;
$qtypur6=0;

  $sql2 = "select * from issueslip where std_name='$ven_name' and adm_no='$adm_no' and month_name='$month' and user_id='$userid'";
$result2=$conn->query($sql2);
while($ppp1 = $result2->fetch_assoc())
{
  $qtysale= $qtysale + $ppp1["feebal"];
  $qtysale1= $qtysale1 + $ppp1["fee1bal"];
  $qtysale2= $qtysale2 + $ppp1["fee2bal"];

  $qtysale3= $qtysale3 + $ppp1["fee3bal"];
  $qtysale4= $qtysale4 + $ppp1["fee4bal"];
  $qtysale5= $qtysale5 + $ppp1["fee5bal"]; 
  $qtysale6= $qtysale6 + $ppp1["fee6bal"];  
 } 
  
$sql3 = "select * from rec_fee where std_name='$ven_name' and adm_no='$adm_no' and month_period='$month' and user_id='$userid'";
$result3=$conn->query($sql3);
while($ppp3 = $result3->fetch_assoc())
{
  $qtypur= $qtypur + $ppp3["feerec"];
 $qtypur1= $qtypur1 + $ppp3["fee1rec"];
  $qtypur2= $qtypur2 + $ppp3["fee2rec"];
  $qtypur3= $qtypur3 + $ppp3["fee3rec"];
  $qtypur4= $qtypur4 + $ppp3["fee4rec"];
  $qtypur5= $qtypur5 + $ppp3["fee5rec"];
  $qtypur6= $qtypur6 + $ppp3["fee6rec"];
 } 
 
 
 

$netqty = ($qtysale ) - ($qtypur );
$netqty1 = ($qtysale1 ) - ($qtypur1 );
$netqty2 = ($qtysale2 ) - ($qtypur2 );
$netqty3= ($qtysale3 ) - ($qtypur3 );
$netqty4 = ($qtysale4 ) - ($qtypur4 );
$netqty5 = ($qtysale5 ) - ($qtypur5 );
$netqty6 = ($qtysale6 ) - ($qtypur6 );

 echo "<tr>";
   echo "<td width=10% align=center>"  .$adm_no . "</td>" ;
   echo "<td width=25% align=center>"  .$std_rollno . "</td>" ;
   echo "<td width=25%>"  .$ven_name . "</td>" ;
   echo "<td width=25%>"  .$father_name . "</td>" ;
   echo "<td width=25%>"  .$class_name . "</td>" ;
   echo "<td width=25%>"  .$cls_sec . "</td>" ;
   echo "<td width=25%>"  .$cell_1 . "</td>" ;
    echo "<td width=25%>"  .$cell_2 . "</td>" ;
   echo "<td width=25%>"  .$cell_3 . "</td>" ;
    echo "<td width=10% align=center>"  .number_format($qtysale) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($netqty) . "</td>" ;
   
   echo "<td width=10% align=center>"  .number_format($qtysale1) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur1) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($netqty1) . "</td>" ;
   
   echo "<td width=10% align=center>"  .number_format($qtysale2) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur2) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($netqty2) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtysale3) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur3) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($netqty3) . "</td>" ;
  
   echo "<td width=10% align=center>"  .number_format($qtysale4) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur4) . "</td>" ;
    echo "<td width=10% align=center>"  .number_format($netqty4) . "</td>" ;
   
   echo "<td width=10% align=center>"  .number_format($qtysale5) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur5) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($netqty5) . "</td>" ;
   
   echo "<td width=10% align=center>"  .number_format($qtysale6) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($qtypur6) . "</td>" ;
   echo "<td width=10% align=center>"  .number_format($netqty6) . "</td>" ;
  
  
   echo "</tr>";

  $tnetqty=$tnetqty + $netqty;
   $tnetqty1=$tnetqty1 + $netqty1;
    $tnetqty2=$tnetqty2 + $netqty2;
	 $tnetqty3=$tnetqty3 + $netqty3;
	  $tnetqty4=$tnetqty4 + $netqty4;
	   $tnetqty5=$tnetqty5 + $netqty5;
	    $tnetqty6=$tnetqty6 + $netqty6;
		
		$tqtysale=$tqtysale + $qtysale;
   $tqtysale1=$tqtysale1 + $qtysale1;
    $tqtysale2=$tqtysale2 + $qtysale2;
	 $tqtysale3=$tqtysale3 + $qtysale3;
	  $tqtysale4=$tqtysale4 + $qtysale4;
	   $tqtysale5=$tqtysale5 + $qtysale5;
	    $tqtysale6=$tqtysale6 + $qtysale6;
		
		$tqtypur=$tqtypur + $qtypur;
   $tqtypur1=$tqtypur1 + $qtypur1;
    $tqtypur2=$tqtypur2 + $qtypur2;
	 $tqtypur3=$tqtypur3 + $qtypur3;
	  $tqtypur4=$tqtypur4 + $qtypur4;
	   $tqtypur5=$tqtypur5 + $qtypur5;
	    $tqtypur6=$tqtypur6 + $qtypur6;
    }
	echo "<tr>";
   echo "<td width=20% colspan=7>Total</td>" ;
    echo "<td width=25% align=center><h5>"  .number_format($tqtysale) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur) . "</td>" ;
    echo "<td width=25% align=center><h5>"  .number_format($tnetqty) . "</td>" ;
   
	echo "<td width=25% align=center><h5>"  .number_format($tqtysale1) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur1) . "</td>" ;
    echo "<td width=25% align=center><h5>"  .number_format($tnetqty1) . "</td>" ;
	
	 echo "<td width=25% align=center><h5>"  .number_format($tqtysale2) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur2) . "</td>" ;
    echo "<td width=25% align=center><h5>"  .number_format($tnetqty2) . "</td>" ;
	  
	  echo "<td width=25% align=center><h5>"  .number_format($tqtysale3) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur3) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tnetqty3) . "</td>" ;
	   
	   echo "<td width=25% align=center><h5>"  .number_format($tqtysale4) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur4) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tnetqty4) . "</td>" ;
	   
		echo "<td width=25% align=center><h5>"  .number_format($tqtysale5) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur5) . "</td>" ;
    echo "<td width=25% align=center><h5>"  .number_format($tnetqty5) . "</td>" ;
		
   echo "<td width=25% align=center><h5>"  .number_format($tqtysale6) . "</td>" ;
   echo "<td width=25% align=center><h5>"  .number_format($tqtypur6) . "</td>" ;
    echo "<td width=25% align=center><h5>"  .number_format($tnetqty6) . "</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
}
?>