<?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">
						 <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 Finance Summary Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$month=$_POST["month"];
 $sql5 = "SELECT * FROM rec_fee where month_period='$month' and  user_id='$userid'";
$result5=$conn->query($sql5);
while($row5 = $result5->fetch_assoc())
 
  {
  $tfee25=$tfee25 + $row5['feerec'];
 
$trecord2=$trecord2 + 1;
  }
$sql11 = "SELECT * FROM addclass where user_id = '$userid'";
$result11=$conn->query($sql11);
    $row11 = $result11->fetch_assoc();
$feedisc1=$row11['feedisc1'] ;
$feedisc2=$row11['feedisc2'] ;
$feedisc3=$row11['feedisc3'] ;
$feedisc4=$row11['feedisc4'] ;
$feedisc5=$row11['feedisc5'] ;
$feedisc6=$row11['feedisc6'] ;


?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";

echo "<th bgcolor=#0099FF><center> Class Name </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>  </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>";

$sql21 = "SELECT * FROM addclass where  user_id='$userid'";
$result21=$conn->query($sql21);
  while($row21 = $result21->fetch_assoc())
   {
   $cname=$row21["cname"];
   
   $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 class_name='$cname' 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"];  
 } 
  
$sql31 = "select * from rec_fee where class_name='$cname' and month_period='$month' and user_id='$userid'";
$result31=$conn->query($sql31);
while($ppp31 = $result31->fetch_assoc())
{
  $qtypur= $qtypur + $ppp31["feerec"];
 $qtypur1= $qtypur1 + $ppp31["fee1rec"];
  $qtypur2= $qtypur2 + $ppp31["fee2rec"];
  $qtypur3= $qtypur3 + $ppp31["fee3rec"];
  $qtypur4= $qtypur4 + $ppp31["fee4rec"];
  $qtypur5= $qtypur5 + $ppp31["fee5rec"];
  $qtypur6= $qtypur6 + $ppp31["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=25%>"  .$cname . "</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($netqty2) . "</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%>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
}
?>